diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2018-01-17 21:31:49 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2018-02-13 13:48:24 +0100 |
commit | 416a1ae673db0918fbe6707c7d6f4459598e2c65 (patch) | |
tree | 284adeb945d6456e37129b404649fcde0e8ead97 /drivers/power | |
parent | power: supply: gpio-charger: Drop driver remove function (diff) | |
download | linux-416a1ae673db0918fbe6707c7d6f4459598e2c65.tar.xz linux-416a1ae673db0918fbe6707c7d6f4459598e2c65.zip |
power: supply: gpio-charger: use helper variable to access device info
Using explicit struct device variable makes code a bit more readable.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/gpio-charger.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c index 666abc23e2ee..f0d8cc19ad1e 100644 --- a/drivers/power/supply/gpio-charger.c +++ b/drivers/power/supply/gpio-charger.c @@ -118,7 +118,8 @@ struct gpio_charger_platform_data *gpio_charger_parse_dt(struct device *dev) static int gpio_charger_probe(struct platform_device *pdev) { - const struct gpio_charger_platform_data *pdata = pdev->dev.platform_data; + struct device *dev = &pdev->dev; + const struct gpio_charger_platform_data *pdata = dev->platform_data; struct power_supply_config psy_cfg = {}; struct gpio_charger *gpio_charger; struct power_supply_desc *charger_desc; @@ -126,19 +127,18 @@ static int gpio_charger_probe(struct platform_device *pdev) int irq; if (!pdata) { - pdata = gpio_charger_parse_dt(&pdev->dev); + pdata = gpio_charger_parse_dt(dev); if (IS_ERR(pdata)) { ret = PTR_ERR(pdata); if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "No platform data\n"); + dev_err(dev, "No platform data\n"); return ret; } } - gpio_charger = devm_kzalloc(&pdev->dev, sizeof(*gpio_charger), - GFP_KERNEL); + gpio_charger = devm_kzalloc(dev, sizeof(*gpio_charger), GFP_KERNEL); if (!gpio_charger) { - dev_err(&pdev->dev, "Failed to alloc driver structure\n"); + dev_err(dev, "Failed to alloc driver structure\n"); return -ENOMEM; } @@ -146,20 +146,20 @@ static int gpio_charger_probe(struct platform_device *pdev) * This will fetch a GPIO descriptor from device tree, ACPI or * boardfile descriptor tables. It's good to try this first. */ - gpio_charger->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN); + gpio_charger->gpiod = devm_gpiod_get(dev, NULL, GPIOD_IN); /* * If this fails and we're not using device tree, try the * legacy platform data method. */ - if (IS_ERR(gpio_charger->gpiod) && !pdev->dev.of_node) { + if (IS_ERR(gpio_charger->gpiod) && !dev->of_node) { /* Non-DT: use legacy GPIO numbers */ if (!gpio_is_valid(pdata->gpio)) { - dev_err(&pdev->dev, "Invalid gpio pin in pdata\n"); + dev_err(dev, "Invalid gpio pin in pdata\n"); return -EINVAL; } - ret = devm_gpio_request_one(&pdev->dev, pdata->gpio, GPIOF_IN, - dev_name(&pdev->dev)); + ret = devm_gpio_request_one(dev, pdata->gpio, GPIOF_IN, + dev_name(dev)); if (ret) { dev_err(&pdev->dev, "Failed to request gpio pin: %d\n", ret); @@ -171,7 +171,7 @@ static int gpio_charger_probe(struct platform_device *pdev) /* Just try again if this happens */ if (PTR_ERR(gpio_charger->gpiod) == -EPROBE_DEFER) return -EPROBE_DEFER; - dev_err(&pdev->dev, "error getting GPIO descriptor\n"); + dev_err(dev, "error getting GPIO descriptor\n"); return PTR_ERR(gpio_charger->gpiod); } @@ -185,33 +185,31 @@ static int gpio_charger_probe(struct platform_device *pdev) psy_cfg.supplied_to = pdata->supplied_to; psy_cfg.num_supplicants = pdata->num_supplicants; - psy_cfg.of_node = pdev->dev.of_node; + psy_cfg.of_node = dev->of_node; psy_cfg.drv_data = gpio_charger; - gpio_charger->charger = devm_power_supply_register(&pdev->dev, - charger_desc, &psy_cfg); + gpio_charger->charger = devm_power_supply_register(dev, charger_desc, + &psy_cfg); if (IS_ERR(gpio_charger->charger)) { ret = PTR_ERR(gpio_charger->charger); - dev_err(&pdev->dev, "Failed to register power supply: %d\n", - ret); + dev_err(dev, "Failed to register power supply: %d\n", ret); return ret; } irq = gpiod_to_irq(gpio_charger->gpiod); if (irq > 0) { - ret = devm_request_any_context_irq(&pdev->dev, irq, - gpio_charger_irq, + ret = devm_request_any_context_irq(dev, irq, gpio_charger_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - dev_name(&pdev->dev), gpio_charger->charger); + dev_name(dev), gpio_charger->charger); if (ret < 0) - dev_warn(&pdev->dev, "Failed to request irq: %d\n", ret); + dev_warn(dev, "Failed to request irq: %d\n", ret); else gpio_charger->irq = irq; } platform_set_drvdata(pdev, gpio_charger); - device_init_wakeup(&pdev->dev, 1); + device_init_wakeup(dev, 1); return 0; } |