]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: ac97: Convert to GPIO descriptors
authorPeng Fan <peng.fan@nxp.com>
Thu, 22 Jan 2026 12:45:00 +0000 (20:45 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 27 Jan 2026 12:45:57 +0000 (12:45 +0000)
of_gpio.h is deprecated, update the driver to use GPIO descriptors.
 - Use devm_gpiod_get to get GPIO descriptor, and set consumer
   name.

Since the driver still pass the reset_gpio to pxa27x_configure_ac97reset,
so use desc_to_gpio() to get it gpio id.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20260122-sound-cleanup-v1-4-0a91901609b8@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/arm/pxa2xx-ac97-lib.c

index 0a28e44118c5253054370b6d8117d8b61fa257fd..1e114dbcf93c94ef30b7b81c40ef9aa30d1271ff 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/io.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
 #include <linux/soc/pxa/cpu.h>
 
 #include <sound/pxa2xx-lib.h>
@@ -31,6 +30,7 @@ static volatile long gsr_bits;
 static struct clk *ac97_clk;
 static struct clk *ac97conf_clk;
 static int reset_gpio;
+struct gpio_desc *rst_gpio;
 static void __iomem *ac97_reg_base;
 
 /*
@@ -329,11 +329,14 @@ int pxa2xx_ac97_hw_probe(struct platform_device *dev)
        }
 
        if (dev->dev.of_node) {
-               reset_gpio = of_get_named_gpio(dev->dev.of_node, "reset-gpios", 0);
-               if (reset_gpio == -ENOENT)
+               /* Assert reset using GPIOD_OUT_HIGH, because reset is GPIO_ACTIVE_LOW */
+               rst_gpio = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH);
+               ret = PTR_ERR(rst_gpio);
+               if (ret == -ENOENT)
                        reset_gpio = -1;
-               else if (reset_gpio < 0)
-                       return reset_gpio;
+               else if (ret)
+                       return ret;
+               reset_gpio = desc_to_gpio(rst_gpio);
        } else {
                if (cpu_is_pxa27x())
                        reset_gpio = 113;
@@ -346,13 +349,7 @@ int pxa2xx_ac97_hw_probe(struct platform_device *dev)
                 * here so that it is an output driven high when switching from
                 * AC97_nRESET alt function to generic gpio.
                 */
-               ret = gpio_request_one(reset_gpio, GPIOF_OUT_INIT_HIGH,
-                                      "pxa27x ac97 reset");
-               if (ret < 0) {
-                       pr_err("%s: gpio_request_one() failed: %d\n",
-                              __func__, ret);
-                       goto err_conf;
-               }
+               gpiod_set_consumer_name(rst_gpio, "pxa27x ac97 reset");
                pxa27x_configure_ac97reset(reset_gpio, false);
 
                ac97conf_clk = clk_get(&dev->dev, "AC97CONFCLK");
@@ -403,8 +400,6 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_probe);
 
 void pxa2xx_ac97_hw_remove(struct platform_device *dev)
 {
-       if (cpu_is_pxa27x())
-               gpio_free(reset_gpio);
        writel(readl(ac97_reg_base + GCR) | (GCR_ACLINK_OFF), ac97_reg_base + GCR);
        free_irq(platform_get_irq(dev, 0), NULL);
        if (ac97conf_clk) {