summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2024-02-05 20:28:48 +0100
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2024-02-12 10:51:13 +0100
commit5694f274a060ebd0e7128c11501281197fb7a5ce (patch)
treeb7faaa485c1230c1b2824f46969d17262ef7baca
parentgpio: cdev: don't access gdev->chip if it's not needed (diff)
downloadlinux-5694f274a060ebd0e7128c11501281197fb7a5ce.tar.xz
linux-5694f274a060ebd0e7128c11501281197fb7a5ce.zip
gpio: sysfs: don't access gdev->chip if it's not needed
Don't dereference gdev->chip if the same information can be obtained from struct gpio_device. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-rw-r--r--drivers/gpio/gpiolib-sysfs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 84b8a7555791..c1f96a14fe7d 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -403,7 +403,7 @@ static ssize_t base_show(struct device *dev,
{
const struct gpio_device *gdev = dev_get_drvdata(dev);
- return sysfs_emit(buf, "%d\n", gdev->chip->base);
+ return sysfs_emit(buf, "%d\n", gdev->base);
}
static DEVICE_ATTR_RO(base);
@@ -412,7 +412,7 @@ static ssize_t label_show(struct device *dev,
{
const struct gpio_device *gdev = dev_get_drvdata(dev);
- return sysfs_emit(buf, "%s\n", gdev->chip->label ?: "");
+ return sysfs_emit(buf, "%s\n", gdev->label);
}
static DEVICE_ATTR_RO(label);
@@ -421,7 +421,7 @@ static ssize_t ngpio_show(struct device *dev,
{
const struct gpio_device *gdev = dev_get_drvdata(dev);
- return sysfs_emit(buf, "%u\n", gdev->chip->ngpio);
+ return sysfs_emit(buf, "%u\n", gdev->ngpio);
}
static DEVICE_ATTR_RO(ngpio);