Skip to content

Commit 0c2c7e1

Browse files
committed
gpio: exar: use a helper variable for &pdev->dev
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>
1 parent 8e27c2a commit 0c2c7e1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/gpio/gpio-exar.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ static int exar_direction_input(struct gpio_chip *chip, unsigned int offset)
120120

121121
static int gpio_exar_probe(struct platform_device *pdev)
122122
{
123-
struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent);
123+
struct device *dev = &pdev->dev;
124+
struct pci_dev *pcidev = to_pci_dev(dev->parent);
124125
struct exar_gpio_chip *exar_gpio;
125126
u32 first_pin, ngpios;
126127
void __iomem *p;
@@ -134,16 +135,15 @@ static int gpio_exar_probe(struct platform_device *pdev)
134135
if (!p)
135136
return -ENOMEM;
136137

137-
ret = device_property_read_u32(&pdev->dev, "exar,first-pin",
138-
&first_pin);
138+
ret = device_property_read_u32(dev, "exar,first-pin", &first_pin);
139139
if (ret)
140140
return ret;
141141

142-
ret = device_property_read_u32(&pdev->dev, "ngpios", &ngpios);
142+
ret = device_property_read_u32(dev, "ngpios", &ngpios);
143143
if (ret)
144144
return ret;
145145

146-
exar_gpio = devm_kzalloc(&pdev->dev, sizeof(*exar_gpio), GFP_KERNEL);
146+
exar_gpio = devm_kzalloc(dev, sizeof(*exar_gpio), GFP_KERNEL);
147147
if (!exar_gpio)
148148
return -ENOMEM;
149149

@@ -157,7 +157,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
157157

158158
sprintf(exar_gpio->name, "exar_gpio%d", index);
159159
exar_gpio->gpio_chip.label = exar_gpio->name;
160-
exar_gpio->gpio_chip.parent = &pdev->dev;
160+
exar_gpio->gpio_chip.parent = dev;
161161
exar_gpio->gpio_chip.direction_output = exar_direction_output;
162162
exar_gpio->gpio_chip.direction_input = exar_direction_input;
163163
exar_gpio->gpio_chip.get_direction = exar_get_direction;
@@ -169,8 +169,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
169169
exar_gpio->index = index;
170170
exar_gpio->first_pin = first_pin;
171171

172-
ret = devm_gpiochip_add_data(&pdev->dev,
173-
&exar_gpio->gpio_chip, exar_gpio);
172+
ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio);
174173
if (ret)
175174
goto err_destroy;
176175

0 commit comments

Comments
 (0)