From: Bartosz Golaszewski <bgolaszew...@baylibre.com>

It's more elegant to use a helper local variable to store the address
of the underlying struct device than to dereference pdev everywhere. It
also has the benefit of avoiding unnecessary line breaks.

Signed-off-by: Bartosz Golaszewski <bgolaszew...@baylibre.com>
---
 drivers/gpio/gpio-exar.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index 752e8437ff80..db366d85b6b4 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -120,7 +120,8 @@ static int exar_direction_input(struct gpio_chip *chip, 
unsigned int offset)
 
 static int gpio_exar_probe(struct platform_device *pdev)
 {
-       struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent);
+       struct device *dev = &pdev->dev;
+       struct pci_dev *pcidev = to_pci_dev(dev->parent);
        struct exar_gpio_chip *exar_gpio;
        u32 first_pin, ngpios;
        void __iomem *p;
@@ -134,16 +135,15 @@ static int gpio_exar_probe(struct platform_device *pdev)
        if (!p)
                return -ENOMEM;
 
-       ret = device_property_read_u32(&pdev->dev, "exar,first-pin",
-                                      &first_pin);
+       ret = device_property_read_u32(dev, "exar,first-pin", &first_pin);
        if (ret)
                return ret;
 
-       ret = device_property_read_u32(&pdev->dev, "ngpios", &ngpios);
+       ret = device_property_read_u32(dev, "ngpios", &ngpios);
        if (ret)
                return ret;
 
-       exar_gpio = devm_kzalloc(&pdev->dev, sizeof(*exar_gpio), GFP_KERNEL);
+       exar_gpio = devm_kzalloc(dev, sizeof(*exar_gpio), GFP_KERNEL);
        if (!exar_gpio)
                return -ENOMEM;
 
@@ -157,7 +157,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
 
        sprintf(exar_gpio->name, "exar_gpio%d", index);
        exar_gpio->gpio_chip.label = exar_gpio->name;
-       exar_gpio->gpio_chip.parent = &pdev->dev;
+       exar_gpio->gpio_chip.parent = dev;
        exar_gpio->gpio_chip.direction_output = exar_direction_output;
        exar_gpio->gpio_chip.direction_input = exar_direction_input;
        exar_gpio->gpio_chip.get_direction = exar_get_direction;
@@ -169,8 +169,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
        exar_gpio->index = index;
        exar_gpio->first_pin = first_pin;
 
-       ret = devm_gpiochip_add_data(&pdev->dev,
-                                    &exar_gpio->gpio_chip, exar_gpio);
+       ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio);
        if (ret)
                goto err_destroy;
 
-- 
2.29.1

Reply via email to