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>
This commit is contained in:
parent
8e27c2aef8
commit
0c2c7e1323
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user