]> www.infradead.org Git - linux.git/commitdiff
gpio: twl4030: use gpiochip_get_data
authorRosen Penev <rosenp@gmail.com>
Tue, 3 Dec 2024 23:33:54 +0000 (15:33 -0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 5 Dec 2024 12:14:44 +0000 (13:14 +0100)
We can pass the pointer in probe to gpiochip_add_data instead of using
dev_get_drvdata.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://lore.kernel.org/r/20241203233354.184404-1-rosenp@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-twl6040.c

index 6c3fbf382dba831881fcd9f052e3f6c4e4e20fb5..b9171bf66168f054e9eddef8417bef6d8f197f3c 100644 (file)
@@ -22,7 +22,7 @@
 
 static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
 {
-       struct twl6040 *twl6040 = dev_get_drvdata(chip->parent->parent);
+       struct twl6040 *twl6040 = gpiochip_get_data(chip);
        int ret = 0;
 
        ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL);
@@ -46,7 +46,7 @@ static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
 
 static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value)
 {
-       struct twl6040 *twl6040 = dev_get_drvdata(chip->parent->parent);
+       struct twl6040 *twl6040 = gpiochip_get_data(chip);
        int ret;
        u8 gpoctl;
 
@@ -91,7 +91,7 @@ static int gpo_twl6040_probe(struct platform_device *pdev)
 
        twl6040gpo_chip.parent = &pdev->dev;
 
-       ret = devm_gpiochip_add_data(&pdev->dev, &twl6040gpo_chip, NULL);
+       ret = devm_gpiochip_add_data(&pdev->dev, &twl6040gpo_chip, twl6040);
        if (ret < 0) {
                dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
                twl6040gpo_chip.ngpio = 0;