Skip to content

Commit 4ef339b

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
gpiolib: Unify access to the device properties
Some of the functions are using struct fwnode_handle, some struct device pointer. In the GPIO library the firmware node of the GPIO device is the same as GPIO node of the GPIO chip. Due to this fact we may use former to access properties everywhere in the code. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Brian Masney <[email protected]> Tested-by: Marijn Suijten <[email protected]> [Bartosz: stick to the 80-char limit where it's not hurting readability] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 923d011 commit 4ef339b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/gpio/gpiolib.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,12 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
367367
static int devprop_gpiochip_set_names(struct gpio_chip *chip)
368368
{
369369
struct gpio_device *gdev = chip->gpiodev;
370-
const struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev);
370+
struct device *dev = &gdev->dev;
371371
const char **names;
372372
int ret, i;
373373
int count;
374374

375-
count = fwnode_property_string_array_count(fwnode, "gpio-line-names");
375+
count = device_property_string_array_count(dev, "gpio-line-names");
376376
if (count < 0)
377377
return 0;
378378

@@ -385,7 +385,7 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
385385
* gpiochips.
386386
*/
387387
if (count <= chip->offset) {
388-
dev_warn(&gdev->dev, "gpio-line-names too short (length %d), cannot map names for the gpiochip at offset %u\n",
388+
dev_warn(dev, "gpio-line-names too short (length %d), cannot map names for the gpiochip at offset %u\n",
389389
count, chip->offset);
390390
return 0;
391391
}
@@ -394,10 +394,10 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
394394
if (!names)
395395
return -ENOMEM;
396396

397-
ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
397+
ret = device_property_read_string_array(dev, "gpio-line-names",
398398
names, count);
399399
if (ret < 0) {
400-
dev_warn(&gdev->dev, "failed to read GPIO line names\n");
400+
dev_warn(dev, "failed to read GPIO line names\n");
401401
kfree(names);
402402
return ret;
403403
}
@@ -448,10 +448,11 @@ static unsigned long *gpiochip_allocate_mask(struct gpio_chip *gc)
448448

449449
static unsigned int gpiochip_count_reserved_ranges(struct gpio_chip *gc)
450450
{
451+
struct device *dev = &gc->gpiodev->dev;
451452
int size;
452453

453454
/* Format is "start, count, ..." */
454-
size = fwnode_property_count_u32(gc->fwnode, "gpio-reserved-ranges");
455+
size = device_property_count_u32(dev, "gpio-reserved-ranges");
455456
if (size > 0 && size % 2 == 0)
456457
return size;
457458

@@ -472,6 +473,7 @@ static int gpiochip_alloc_valid_mask(struct gpio_chip *gc)
472473

473474
static int gpiochip_apply_reserved_ranges(struct gpio_chip *gc)
474475
{
476+
struct device *dev = &gc->gpiodev->dev;
475477
unsigned int size;
476478
u32 *ranges;
477479
int ret;
@@ -484,7 +486,8 @@ static int gpiochip_apply_reserved_ranges(struct gpio_chip *gc)
484486
if (!ranges)
485487
return -ENOMEM;
486488

487-
ret = fwnode_property_read_u32_array(gc->fwnode, "gpio-reserved-ranges", ranges, size);
489+
ret = device_property_read_u32_array(dev, "gpio-reserved-ranges",
490+
ranges, size);
488491
if (ret) {
489492
kfree(ranges);
490493
return ret;

0 commit comments

Comments
 (0)