Skip to content

Commit

Permalink
gpio: exar: use a helper variable for &pdev->dev
Browse files Browse the repository at this point in the history
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 <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
Bartosz Golaszewski committed Nov 25, 2020
1 parent 8e27c2a commit 0c2c7e1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions drivers/gpio/gpio-exar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit 0c2c7e1

Please sign in to comment.