Re: [PATCH v1 2/2] gpio: merrifield: Convert to use acpi_dev_get_first_match()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 12-07-18 19:23, Andy Shevchenko wrote:
acpi_dev_get_first_match_name() is deprecated because it leaks
a reference count.

Convert the driver to use acpi_dev_get_first_match() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
  drivers/gpio/gpio-merrifield.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index 97421bd4a60f..c618073b1d01 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -381,10 +381,18 @@ static void mrfld_irq_init_hw(struct mrfld_gpio *priv)
  	}
  }
-static const char *mrfld_gpio_get_pinctrl_dev_name(void)
+static const char *mrfld_gpio_get_pinctrl_dev_name(struct mrfld_gpio *priv)
  {
-	const char *dev_name = acpi_dev_get_first_match_name("INTC1002", NULL, -1);
-	return dev_name ? dev_name : "pinctrl-merrifield";
+	struct acpi_device *adev;
+	const char *dev_name;
+
+	adev = acpi_dev_get_first_match("INTC1002", NULL, -1);
+	if (!adev)
+		return "pinctrl-merrifield";
+
+	dev_name = devm_kstrdup(priv->dev, acpi_dev_name(adev), GFP_KERNEL);
+	put_device(&adev->dev);
+	return dev_name;
  }

Hmm, this looks complicated(ish) maybe add a new
devm_acpi_dev_get_first_match_name() which takes a dev for the
devm_kstrdup and do all this inside there. There are
quite a few users of acpi_dev_get_first_match_name() under
sound/soc/intel/boards and converting them all like this will
be cumbersome. IMHO we need a better API then the acpi_dev_get_first_match()
you are proposing.

Regards,

Hans



static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -445,7 +453,7 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id
  		return retval;
  	}
- pinctrl_dev_name = mrfld_gpio_get_pinctrl_dev_name();
+	pinctrl_dev_name = mrfld_gpio_get_pinctrl_dev_name(priv);
  	for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
  		range = &mrfld_gpio_ranges[i];
  		retval = gpiochip_add_pin_range(&priv->chip,

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux