Skip to content

Commit 243cfa6

Browse files
andy-shevbrgl
authored andcommitted
gpiolib: Use list_first_entry()/list_last_entry()
Use list_first_entry()/list_last_entry() instead of open coded variants. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent 37db988 commit 243cfa6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ static int gpiodev_add_to_list(struct gpio_device *gdev)
262262
return 0;
263263
}
264264

265-
next = list_entry(gpio_devices.next, struct gpio_device, list);
265+
next = list_first_entry(&gpio_devices, struct gpio_device, list);
266266
if (gdev->base + gdev->ngpio <= next->base) {
267267
/* add before first entry */
268268
list_add(&gdev->list, &gpio_devices);
269269
return 0;
270270
}
271271

272-
prev = list_entry(gpio_devices.prev, struct gpio_device, list);
272+
prev = list_last_entry(&gpio_devices, struct gpio_device, list);
273273
if (prev->base + prev->ngpio <= gdev->base) {
274274
/* add behind last entry */
275275
list_add_tail(&gdev->list, &gpio_devices);
@@ -4423,7 +4423,7 @@ static void *gpiolib_seq_next(struct seq_file *s, void *v, loff_t *pos)
44234423
if (list_is_last(&gdev->list, &gpio_devices))
44244424
ret = NULL;
44254425
else
4426-
ret = list_entry(gdev->list.next, struct gpio_device, list);
4426+
ret = list_first_entry(&gdev->list, struct gpio_device, list);
44274427
spin_unlock_irqrestore(&gpio_lock, flags);
44284428

44294429
s->private = "\n";

0 commit comments

Comments
 (0)