All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/10] ACPI / utils: Replace leaky function
@ 2019-03-28 17:17 Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper Andy Shevchenko
                   ` (13 more replies)
  0 siblings, 14 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Bartosz Golaszewski, Linus Walleij, Chanwoo Choi, Chen-Yu Tsai,
	MyungJoo Ham, Andy Shevchenko

The acpi_dev_get_first_match_name() is missing put_device() call
and thus keeping reference counting unbalanced.

In order to fix the issue introduce a new helper to convert existing users
one-by-one to a better API.

Since v3:
- convert all existing users and drop old API (Mika)
- add Hans' tag

Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Andy Shevchenko (10):
  ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
  extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
  gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
  ASoC: Intel: bytcht_da7213: Convert to use
    acpi_dev_get_first_match_dev()
  ASoC: Intel: bytcht_es8316: Convert to use
    acpi_dev_get_first_match_dev()
  ASoC: Intel: bytcr_rt5640: Convert to use
    acpi_dev_get_first_match_dev()
  ASoC: Intel: bytcr_rt5651: Convert to use
    acpi_dev_get_first_match_dev()
  ASoC: Intel: cht_bsw_rt5645: Convert to use
    acpi_dev_get_first_match_dev()
  ASoC: Intel: cht_bsw_rt5672: Convert to use
    acpi_dev_get_first_match_dev()
  ACPI / utils: Remove deprecated function since no user left

 drivers/acpi/utils.c                    | 16 ++++++++++------
 drivers/extcon/extcon-axp288.c          |  9 +++++----
 drivers/gpio/gpio-merrifield.c          | 18 ++++++++++++++----
 include/acpi/acpi_bus.h                 |  4 ++--
 include/linux/acpi.h                    |  4 ++--
 sound/soc/intel/boards/bytcht_da7213.c  |  9 +++++----
 sound/soc/intel/boards/bytcht_es8316.c  |  9 +++++----
 sound/soc/intel/boards/bytcr_rt5640.c   | 10 +++++-----
 sound/soc/intel/boards/bytcr_rt5651.c   | 14 ++++++++------
 sound/soc/intel/boards/cht_bsw_rt5645.c |  9 +++++----
 sound/soc/intel/boards/cht_bsw_rt5672.c |  9 +++++----
 11 files changed, 66 insertions(+), 45 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 20:12   ` Rafael J. Wysocki
  2019-04-01  7:23   ` Mark Brown
  2019-03-28 17:17 ` [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev() Andy Shevchenko
                   ` (12 subsequent siblings)
  13 siblings, 2 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

The acpi_dev_get_first_match_name() is missing put_device() call
and thus keeping reference counting unbalanced.

In order to fix the issue introduce a new helper to convert existing users
one-by-one to a better API. And then remove the old one.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/utils.c    | 24 ++++++++++++++++++++++--
 include/acpi/acpi_bus.h |  3 +++
 include/linux/acpi.h    |  6 ++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index c4b06cc075f9..5a2bae2b6c3a 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -739,6 +739,7 @@ EXPORT_SYMBOL(acpi_dev_found);
 
 struct acpi_dev_match_info {
 	const char *dev_name;
+	struct acpi_device *adev;
 	struct acpi_device_id hid[2];
 	const char *uid;
 	s64 hrv;
@@ -759,6 +760,7 @@ static int acpi_dev_match_cb(struct device *dev, void *data)
 		return 0;
 
 	match->dev_name = acpi_dev_name(adev);
+	match->adev = adev;
 
 	if (match->hrv == -1)
 		return 1;
@@ -806,16 +808,34 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 EXPORT_SYMBOL(acpi_dev_present);
 
 /**
- * acpi_dev_get_first_match_name - Return name of first match of ACPI device
+ * acpi_dev_get_first_match_dev - Return the first match of ACPI device
  * @hid: Hardware ID of the device.
  * @uid: Unique ID of the device, pass NULL to not check _UID
  * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
  *
- * Return device name if a matching device was present
+ * Return the first match of ACPI device if a matching device was present
  * at the moment of invocation, or NULL otherwise.
  *
+ * The caller is responsible to call put_device() on the returned device.
+ *
  * See additional information in acpi_dev_present() as well.
  */
+struct acpi_device *
+acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
+{
+	struct acpi_dev_match_info match = {};
+	struct device *dev;
+
+	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
+	match.uid = uid;
+	match.hrv = hrv;
+
+	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
+	return dev ? match.adev : NULL;
+}
+EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
+
+/* DEPRECATED, use acpi_dev_get_first_match_dev() instead */
 const char *
 acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
 {
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 0300374101cd..2063e9e2f384 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -91,6 +91,9 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
 bool acpi_dev_found(const char *hid);
 bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
 
+struct acpi_device *
+acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
+
 const char *
 acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index d5dcebd7aad3..3e1d16b00513 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -669,6 +669,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 	return false;
 }
 
+static inline struct acpi_device *
+acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
+{
+	return NULL;
+}
+
 static inline const char *
 acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
 {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-29  0:53   ` Chanwoo Choi
  2019-03-28 17:17 ` [PATCH v3 03/10] gpio: merrifield: " Andy Shevchenko
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Chanwoo Choi, Chen-Yu Tsai, Andy Shevchenko, MyungJoo Ham

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-axp288.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index a983708b77a6..50f9402fb325 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -333,7 +333,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
 	struct axp288_extcon_info *info;
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct device *dev = &pdev->dev;
-	const char *name;
+	struct acpi_device *adev;
 	int ret, i, pirq;
 
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
@@ -357,9 +357,10 @@ static int axp288_extcon_probe(struct platform_device *pdev)
 		if (ret)
 			return ret;
 
-		name = acpi_dev_get_first_match_name("INT3496", NULL, -1);
-		if (name) {
-			info->id_extcon = extcon_get_extcon_dev(name);
+		adev = acpi_dev_get_first_match_dev("INT3496", NULL, -1);
+		if (adev) {
+			info->id_extcon = extcon_get_extcon_dev(acpi_dev_name(adev));
+			put_device(&adev->dev);
 			if (!info->id_extcon)
 				return -EPROBE_DEFER;
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 03/10] gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev() Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 04/10] ASoC: Intel: bytcht_da7213: " Andy Shevchenko
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Bartosz Golaszewski, Linus Walleij, Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpio/gpio-merrifield.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index 7c659fdaa6d5..2383dc78b123 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -377,10 +377,20 @@ 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 *name;
+
+	adev = acpi_dev_get_first_match_dev("INTC1002", NULL, -1);
+	if (adev) {
+		name = devm_kstrdup(priv->dev, acpi_dev_name(adev), GFP_KERNEL);
+		put_device(&adev->dev);
+	} else {
+		name = "pinctrl-merrifield";
+	}
+
+	return name;
 }
 
 static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -441,7 +451,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,
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 04/10] ASoC: Intel: bytcht_da7213: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (2 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 03/10] gpio: merrifield: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 05/10] ASoC: Intel: bytcht_es8316: " Andy Shevchenko
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/boards/bytcht_da7213.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/boards/bytcht_da7213.c b/sound/soc/intel/boards/bytcht_da7213.c
index b8e884803777..4decba338156 100644
--- a/sound/soc/intel/boards/bytcht_da7213.c
+++ b/sound/soc/intel/boards/bytcht_da7213.c
@@ -226,7 +226,7 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
 	struct snd_soc_card *card;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
-	const char *i2c_name = NULL;
+	struct acpi_device *adev;
 	int dai_index = 0;
 	int ret_val = 0;
 	int i;
@@ -244,10 +244,11 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
-	if (i2c_name) {
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
 		snprintf(codec_name, sizeof(codec_name),
-			"%s%s", "i2c-", i2c_name);
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
 		dailink[dai_index].codec_name = codec_name;
 	}
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 05/10] ASoC: Intel: bytcht_es8316: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (3 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 04/10] ASoC: Intel: bytcht_da7213: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 06/10] ASoC: Intel: bytcr_rt5640: " Andy Shevchenko
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/boards/bytcht_es8316.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index d2a7e6ba11ae..6937c00cf63d 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -442,7 +442,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
-	const char *i2c_name = NULL;
+	struct acpi_device *adev;
 	struct device *codec_dev;
 	int dai_index = 0;
 	int i;
@@ -463,10 +463,11 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
-	if (i2c_name) {
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
 		snprintf(codec_name, sizeof(codec_name),
-			"%s%s", "i2c-", i2c_name);
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
 		byt_cht_es8316_dais[dai_index].codec_name = codec_name;
 	}
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 06/10] ASoC: Intel: bytcr_rt5640: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (4 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 05/10] ASoC: Intel: bytcht_es8316: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 07/10] ASoC: Intel: bytcr_rt5651: " Andy Shevchenko
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/boards/bytcr_rt5640.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 940eb27158da..f9175cf6747e 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -1154,7 +1154,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
 	struct byt_rt5640_private *priv;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
-	const char *i2c_name = NULL;
+	struct acpi_device *adev;
 	int ret_val = 0;
 	int dai_index = 0;
 	int i;
@@ -1178,11 +1178,11 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
-	if (i2c_name) {
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
 		snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
-			"%s%s", "i2c-", i2c_name);
-
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
 		byt_rt5640_dais[dai_index].codec_name = byt_rt5640_codec_name;
 	}
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 07/10] ASoC: Intel: bytcr_rt5651: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (5 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 06/10] ASoC: Intel: bytcr_rt5640: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 08/10] ASoC: Intel: cht_bsw_rt5645: " Andy Shevchenko
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/boards/bytcr_rt5651.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
index b0a4d297176e..b744add01d12 100644
--- a/sound/soc/intel/boards/bytcr_rt5651.c
+++ b/sound/soc/intel/boards/bytcr_rt5651.c
@@ -867,8 +867,8 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
 	struct byt_rt5651_private *priv;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
+	struct acpi_device *adev;
 	struct device *codec_dev;
-	const char *i2c_name = NULL;
 	const char *hp_swapped;
 	bool is_bytcr = false;
 	int ret_val = 0;
@@ -894,14 +894,16 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
-	if (!i2c_name) {
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
+		snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name),
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
+		byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name;
+	} else {
 		dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
 		return -ENODEV;
 	}
-	snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name),
-		"%s%s", "i2c-", i2c_name);
-	byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name;
 
 	codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
 					    byt_rt5651_codec_name);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 08/10] ASoC: Intel: cht_bsw_rt5645: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (6 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 07/10] ASoC: Intel: bytcr_rt5651: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 09/10] ASoC: Intel: cht_bsw_rt5672: " Andy Shevchenko
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/boards/cht_bsw_rt5645.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index cbc2d458483f..32dbeaf1ab94 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -532,7 +532,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
 	struct cht_mc_private *drv;
-	const char *i2c_name = NULL;
+	struct acpi_device *adev;
 	bool found = false;
 	bool is_bytcr = false;
 	int dai_index = 0;
@@ -573,10 +573,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 		}
 
 	/* fixup codec name based on HID */
-	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
-	if (i2c_name) {
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
 		snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name),
-			"%s%s", "i2c-", i2c_name);
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
 		cht_dailink[dai_index].codec_name = cht_rt5645_codec_name;
 	}
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 09/10] ASoC: Intel: cht_bsw_rt5672: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (7 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 08/10] ASoC: Intel: cht_bsw_rt5645: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 17:17 ` [PATCH v3 10/10] ACPI / utils: Remove deprecated function since no user left Andy Shevchenko
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/boards/cht_bsw_rt5672.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c
index 3d5a2b3a06f0..0f7770822388 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5672.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5672.c
@@ -401,7 +401,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	struct cht_mc_private *drv;
 	struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
 	const char *platform_name;
-	const char *i2c_name;
+	struct acpi_device *adev;
 	int i;
 
 	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
@@ -411,10 +411,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	strcpy(drv->codec_name, RT5672_I2C_DEFAULT);
 
 	/* fixup codec name based on HID */
-	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
-	if (i2c_name) {
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
 		snprintf(drv->codec_name, sizeof(drv->codec_name),
-			 "i2c-%s", i2c_name);
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
 		for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) {
 			if (!strcmp(cht_dailink[i].codec_name,
 				RT5672_I2C_DEFAULT)) {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 10/10] ACPI / utils: Remove deprecated function since no user left
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (8 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 09/10] ASoC: Intel: cht_bsw_rt5672: " Andy Shevchenko
@ 2019-03-28 17:17 ` Andy Shevchenko
  2019-03-28 18:31 ` [PATCH v3 00/10] ACPI / utils: Replace leaky function Pierre-Louis Bossart
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 17:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel, Hans de Goede,
	Mika Westerberg
  Cc: Andy Shevchenko

There is no more user of acpi_dev_get_first_match_name(),
which is deprecated and has no user left, so, remove it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/utils.c    | 16 ----------------
 include/acpi/acpi_bus.h |  3 ---
 include/linux/acpi.h    |  6 ------
 3 files changed, 25 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 5a2bae2b6c3a..89363b245489 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -835,22 +835,6 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
 }
 EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
 
-/* DEPRECATED, use acpi_dev_get_first_match_dev() instead */
-const char *
-acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
-{
-	struct acpi_dev_match_info match = {};
-	struct device *dev;
-
-	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
-	match.uid = uid;
-	match.hrv = hrv;
-
-	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
-	return dev ? match.dev_name : NULL;
-}
-EXPORT_SYMBOL(acpi_dev_get_first_match_name);
-
 /*
  * acpi_backlight= handling, this is done here rather then in video_detect.c
  * because __setup cannot be used in modules.
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 2063e9e2f384..f7981751ac77 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -94,9 +94,6 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
 struct acpi_device *
 acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
 
-const char *
-acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
-
 #ifdef CONFIG_ACPI
 
 #include <linux/proc_fs.h>
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3e1d16b00513..392413075cc0 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -675,12 +675,6 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
 	return NULL;
 }
 
-static inline const char *
-acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
-{
-	return NULL;
-}
-
 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 {
 	return false;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (9 preceding siblings ...)
  2019-03-28 17:17 ` [PATCH v3 10/10] ACPI / utils: Remove deprecated function since no user left Andy Shevchenko
@ 2019-03-28 18:31 ` Pierre-Louis Bossart
  2019-03-28 21:40   ` Andy Shevchenko
  2019-03-28 22:29 ` Hans de Goede
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Pierre-Louis Bossart @ 2019-03-28 18:31 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, Liam Girdwood,
	Jie Yang, Mark Brown, alsa-devel, Hans de Goede, Mika Westerberg
  Cc: Bartosz Golaszewski, Linus Walleij, MyungJoo Ham, Chen-Yu Tsai,
	Chanwoo Choi

On 3/28/19 1:17 PM, Andy Shevchenko wrote:
> The acpi_dev_get_first_match_name() is missing put_device() call
> and thus keeping reference counting unbalanced.
> 
> In order to fix the issue introduce a new helper to convert existing users
> one-by-one to a better API.
> 
> Since v3:
> - convert all existing users and drop old API (Mika)
> - add Hans' tag
> 
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> Cc: Chanwoo Choi <cw00.choi@samsung.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patches 4..9 for the Intel machine drivers:

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Is this going to be merged through the ACPI or ASoC tree? The changes 
will conflict with cleanups I started to use the 'modern' dailinks 
(codec_name -> codecs[0].name), so some level of coordination is needed.

> 
> Andy Shevchenko (10):
>    ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
>    extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
>    gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcht_da7213: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcht_es8316: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcr_rt5640: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcr_rt5651: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: cht_bsw_rt5645: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: cht_bsw_rt5672: Convert to use
>      acpi_dev_get_first_match_dev()
>    ACPI / utils: Remove deprecated function since no user left
> 
>   drivers/acpi/utils.c                    | 16 ++++++++++------
>   drivers/extcon/extcon-axp288.c          |  9 +++++----
>   drivers/gpio/gpio-merrifield.c          | 18 ++++++++++++++----
>   include/acpi/acpi_bus.h                 |  4 ++--
>   include/linux/acpi.h                    |  4 ++--
>   sound/soc/intel/boards/bytcht_da7213.c  |  9 +++++----
>   sound/soc/intel/boards/bytcht_es8316.c  |  9 +++++----
>   sound/soc/intel/boards/bytcr_rt5640.c   | 10 +++++-----
>   sound/soc/intel/boards/bytcr_rt5651.c   | 14 ++++++++------
>   sound/soc/intel/boards/cht_bsw_rt5645.c |  9 +++++----
>   sound/soc/intel/boards/cht_bsw_rt5672.c |  9 +++++----
>   11 files changed, 66 insertions(+), 45 deletions(-)
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
  2019-03-28 17:17 ` [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper Andy Shevchenko
@ 2019-03-28 20:12   ` Rafael J. Wysocki
  2019-03-28 21:38     ` Andy Shevchenko
  2019-04-01  7:23   ` Mark Brown
  1 sibling, 1 reply; 27+ messages in thread
From: Rafael J. Wysocki @ 2019-03-28 20:12 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Hans de Goede, Rafael J. Wysocki, Jie Yang, Pierre-Louis Bossart,
	Liam Girdwood, ACPI Devel Maling List, Mark Brown,
	Mika Westerberg

On Thu, Mar 28, 2019 at 6:17 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> The acpi_dev_get_first_match_name() is missing put_device() call
> and thus keeping reference counting unbalanced.
>
> In order to fix the issue introduce a new helper to convert existing users
> one-by-one to a better API. And then remove the old one.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Any differences between this and the previous one?  I've queued up
that one already.

> ---
>  drivers/acpi/utils.c    | 24 ++++++++++++++++++++++--
>  include/acpi/acpi_bus.h |  3 +++
>  include/linux/acpi.h    |  6 ++++++
>  3 files changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index c4b06cc075f9..5a2bae2b6c3a 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -739,6 +739,7 @@ EXPORT_SYMBOL(acpi_dev_found);
>
>  struct acpi_dev_match_info {
>         const char *dev_name;
> +       struct acpi_device *adev;
>         struct acpi_device_id hid[2];
>         const char *uid;
>         s64 hrv;
> @@ -759,6 +760,7 @@ static int acpi_dev_match_cb(struct device *dev, void *data)
>                 return 0;
>
>         match->dev_name = acpi_dev_name(adev);
> +       match->adev = adev;
>
>         if (match->hrv == -1)
>                 return 1;
> @@ -806,16 +808,34 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
>  EXPORT_SYMBOL(acpi_dev_present);
>
>  /**
> - * acpi_dev_get_first_match_name - Return name of first match of ACPI device
> + * acpi_dev_get_first_match_dev - Return the first match of ACPI device
>   * @hid: Hardware ID of the device.
>   * @uid: Unique ID of the device, pass NULL to not check _UID
>   * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
>   *
> - * Return device name if a matching device was present
> + * Return the first match of ACPI device if a matching device was present
>   * at the moment of invocation, or NULL otherwise.
>   *
> + * The caller is responsible to call put_device() on the returned device.
> + *
>   * See additional information in acpi_dev_present() as well.
>   */
> +struct acpi_device *
> +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> +{
> +       struct acpi_dev_match_info match = {};
> +       struct device *dev;
> +
> +       strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
> +       match.uid = uid;
> +       match.hrv = hrv;
> +
> +       dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
> +       return dev ? match.adev : NULL;
> +}
> +EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
> +
> +/* DEPRECATED, use acpi_dev_get_first_match_dev() instead */
>  const char *
>  acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
>  {
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 0300374101cd..2063e9e2f384 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -91,6 +91,9 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
>  bool acpi_dev_found(const char *hid);
>  bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
>
> +struct acpi_device *
> +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
> +
>  const char *
>  acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index d5dcebd7aad3..3e1d16b00513 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -669,6 +669,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
>         return false;
>  }
>
> +static inline struct acpi_device *
> +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> +{
> +       return NULL;
> +}
> +
>  static inline const char *
>  acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
>  {
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
  2019-03-28 20:12   ` Rafael J. Wysocki
@ 2019-03-28 21:38     ` Andy Shevchenko
  0 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 21:38 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Hans de Goede, Rafael J. Wysocki, Jie Yang, Pierre-Louis Bossart,
	Liam Girdwood, ACPI Devel Maling List, Mark Brown,
	Mika Westerberg

On Thu, Mar 28, 2019 at 09:12:49PM +0100, Rafael J. Wysocki wrote:
> On Thu, Mar 28, 2019 at 6:17 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > The acpi_dev_get_first_match_name() is missing put_device() call
> > and thus keeping reference counting unbalanced.
> >
> > In order to fix the issue introduce a new helper to convert existing users
> > one-by-one to a better API. And then remove the old one.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> 
> Any differences between this and the previous one?  I've queued up
> that one already.

Not a single bit. Just Hans' tag is added.

> 
> > ---
> >  drivers/acpi/utils.c    | 24 ++++++++++++++++++++++--
> >  include/acpi/acpi_bus.h |  3 +++
> >  include/linux/acpi.h    |  6 ++++++
> >  3 files changed, 31 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> > index c4b06cc075f9..5a2bae2b6c3a 100644
> > --- a/drivers/acpi/utils.c
> > +++ b/drivers/acpi/utils.c
> > @@ -739,6 +739,7 @@ EXPORT_SYMBOL(acpi_dev_found);
> >
> >  struct acpi_dev_match_info {
> >         const char *dev_name;
> > +       struct acpi_device *adev;
> >         struct acpi_device_id hid[2];
> >         const char *uid;
> >         s64 hrv;
> > @@ -759,6 +760,7 @@ static int acpi_dev_match_cb(struct device *dev, void *data)
> >                 return 0;
> >
> >         match->dev_name = acpi_dev_name(adev);
> > +       match->adev = adev;
> >
> >         if (match->hrv == -1)
> >                 return 1;
> > @@ -806,16 +808,34 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
> >  EXPORT_SYMBOL(acpi_dev_present);
> >
> >  /**
> > - * acpi_dev_get_first_match_name - Return name of first match of ACPI device
> > + * acpi_dev_get_first_match_dev - Return the first match of ACPI device
> >   * @hid: Hardware ID of the device.
> >   * @uid: Unique ID of the device, pass NULL to not check _UID
> >   * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
> >   *
> > - * Return device name if a matching device was present
> > + * Return the first match of ACPI device if a matching device was present
> >   * at the moment of invocation, or NULL otherwise.
> >   *
> > + * The caller is responsible to call put_device() on the returned device.
> > + *
> >   * See additional information in acpi_dev_present() as well.
> >   */
> > +struct acpi_device *
> > +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> > +{
> > +       struct acpi_dev_match_info match = {};
> > +       struct device *dev;
> > +
> > +       strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
> > +       match.uid = uid;
> > +       match.hrv = hrv;
> > +
> > +       dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
> > +       return dev ? match.adev : NULL;
> > +}
> > +EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
> > +
> > +/* DEPRECATED, use acpi_dev_get_first_match_dev() instead */
> >  const char *
> >  acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
> >  {
> > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> > index 0300374101cd..2063e9e2f384 100644
> > --- a/include/acpi/acpi_bus.h
> > +++ b/include/acpi/acpi_bus.h
> > @@ -91,6 +91,9 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
> >  bool acpi_dev_found(const char *hid);
> >  bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
> >
> > +struct acpi_device *
> > +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
> > +
> >  const char *
> >  acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
> >
> > diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> > index d5dcebd7aad3..3e1d16b00513 100644
> > --- a/include/linux/acpi.h
> > +++ b/include/linux/acpi.h
> > @@ -669,6 +669,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
> >         return false;
> >  }
> >
> > +static inline struct acpi_device *
> > +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> > +{
> > +       return NULL;
> > +}
> > +
> >  static inline const char *
> >  acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
> >  {
> > --
> > 2.20.1
> >

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 18:31 ` [PATCH v3 00/10] ACPI / utils: Replace leaky function Pierre-Louis Bossart
@ 2019-03-28 21:40   ` Andy Shevchenko
  2019-03-28 23:33     ` Rafael J. Wysocki
  0 siblings, 1 reply; 27+ messages in thread
From: Andy Shevchenko @ 2019-03-28 21:40 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, Chanwoo Choi, Hans de Goede, Rafael J. Wysocki,
	Linus Walleij, Jie Yang, Liam Girdwood, linux-acpi, Chen-Yu Tsai,
	Mark Brown, MyungJoo Ham, Bartosz Golaszewski, Mika Westerberg

On Thu, Mar 28, 2019 at 02:31:28PM -0400, Pierre-Louis Bossart wrote:
> On 3/28/19 1:17 PM, Andy Shevchenko wrote:
> > The acpi_dev_get_first_match_name() is missing put_device() call
> > and thus keeping reference counting unbalanced.
> > 
> > In order to fix the issue introduce a new helper to convert existing users
> > one-by-one to a better API.
> > 
> > Since v3:
> > - convert all existing users and drop old API (Mika)
> > - add Hans' tag
> > 
> > Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> > Cc: Chanwoo Choi <cw00.choi@samsung.com>
> > Cc: Chen-Yu Tsai <wens@csie.org>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Patches 4..9 for the Intel machine drivers:
> 
> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Thank you!

> Is this going to be merged through the ACPI or ASoC tree? The changes will
> conflict with cleanups I started to use the 'modern' dailinks (codec_name ->
> codecs[0].name), so some level of coordination is needed.

I suppose via ACPI.

> 
> > 
> > Andy Shevchenko (10):
> >    ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
> >    extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
> >    gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
> >    ASoC: Intel: bytcht_da7213: Convert to use
> >      acpi_dev_get_first_match_dev()
> >    ASoC: Intel: bytcht_es8316: Convert to use
> >      acpi_dev_get_first_match_dev()
> >    ASoC: Intel: bytcr_rt5640: Convert to use
> >      acpi_dev_get_first_match_dev()
> >    ASoC: Intel: bytcr_rt5651: Convert to use
> >      acpi_dev_get_first_match_dev()
> >    ASoC: Intel: cht_bsw_rt5645: Convert to use
> >      acpi_dev_get_first_match_dev()
> >    ASoC: Intel: cht_bsw_rt5672: Convert to use
> >      acpi_dev_get_first_match_dev()
> >    ACPI / utils: Remove deprecated function since no user left
> > 
> >   drivers/acpi/utils.c                    | 16 ++++++++++------
> >   drivers/extcon/extcon-axp288.c          |  9 +++++----
> >   drivers/gpio/gpio-merrifield.c          | 18 ++++++++++++++----
> >   include/acpi/acpi_bus.h                 |  4 ++--
> >   include/linux/acpi.h                    |  4 ++--
> >   sound/soc/intel/boards/bytcht_da7213.c  |  9 +++++----
> >   sound/soc/intel/boards/bytcht_es8316.c  |  9 +++++----
> >   sound/soc/intel/boards/bytcr_rt5640.c   | 10 +++++-----
> >   sound/soc/intel/boards/bytcr_rt5651.c   | 14 ++++++++------
> >   sound/soc/intel/boards/cht_bsw_rt5645.c |  9 +++++----
> >   sound/soc/intel/boards/cht_bsw_rt5672.c |  9 +++++----
> >   11 files changed, 66 insertions(+), 45 deletions(-)
> > 
> 

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (10 preceding siblings ...)
  2019-03-28 18:31 ` [PATCH v3 00/10] ACPI / utils: Replace leaky function Pierre-Louis Bossart
@ 2019-03-28 22:29 ` Hans de Goede
  2019-03-29  9:29 ` Mika Westerberg
  2019-04-02  8:57 ` Rafael J. Wysocki
  13 siblings, 0 replies; 27+ messages in thread
From: Hans de Goede @ 2019-03-28 22:29 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi,
	Pierre-Louis Bossart, Liam Girdwood, Jie Yang, Mark Brown,
	alsa-devel, Mika Westerberg
  Cc: Chanwoo Choi, Chen-Yu Tsai, MyungJoo Ham, Linus Walleij,
	Bartosz Golaszewski

Hi,

On 28-03-19 18:17, Andy Shevchenko wrote:
> The acpi_dev_get_first_match_name() is missing put_device() call
> and thus keeping reference counting unbalanced.
> 
> In order to fix the issue introduce a new helper to convert existing users
> one-by-one to a better API.
> 
> Since v3:
> - convert all existing users and drop old API (Mika)
> - add Hans' tag
> 
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> Cc: Chanwoo Choi <cw00.choi@samsung.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>

> Andy Shevchenko (10):
>    ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
>    extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
>    gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcht_da7213: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcht_es8316: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcr_rt5640: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: bytcr_rt5651: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: cht_bsw_rt5645: Convert to use
>      acpi_dev_get_first_match_dev()
>    ASoC: Intel: cht_bsw_rt5672: Convert to use
>      acpi_dev_get_first_match_dev()
>    ACPI / utils: Remove deprecated function since no user left

The entire series looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

For the entire series.

Regards,

Hans



> 
>   drivers/acpi/utils.c                    | 16 ++++++++++------
>   drivers/extcon/extcon-axp288.c          |  9 +++++----
>   drivers/gpio/gpio-merrifield.c          | 18 ++++++++++++++----
>   include/acpi/acpi_bus.h                 |  4 ++--
>   include/linux/acpi.h                    |  4 ++--
>   sound/soc/intel/boards/bytcht_da7213.c  |  9 +++++----
>   sound/soc/intel/boards/bytcht_es8316.c  |  9 +++++----
>   sound/soc/intel/boards/bytcr_rt5640.c   | 10 +++++-----
>   sound/soc/intel/boards/bytcr_rt5651.c   | 14 ++++++++------
>   sound/soc/intel/boards/cht_bsw_rt5645.c |  9 +++++----
>   sound/soc/intel/boards/cht_bsw_rt5672.c |  9 +++++----
>   11 files changed, 66 insertions(+), 45 deletions(-)
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 21:40   ` Andy Shevchenko
@ 2019-03-28 23:33     ` Rafael J. Wysocki
  2019-04-01  7:24       ` Mark Brown
  0 siblings, 1 reply; 27+ messages in thread
From: Rafael J. Wysocki @ 2019-03-28 23:33 UTC (permalink / raw)
  To: Andy Shevchenko, Pierre-Louis Bossart
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Chanwoo Choi, Hans de Goede, Rafael J. Wysocki, Linus Walleij,
	Jie Yang, Liam Girdwood, ACPI Devel Maling List, Chen-Yu Tsai,
	Mark Brown, MyungJoo Ham, Bartosz Golaszewski, Mika Westerberg

On Thu, Mar 28, 2019 at 10:40 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Mar 28, 2019 at 02:31:28PM -0400, Pierre-Louis Bossart wrote:
> > On 3/28/19 1:17 PM, Andy Shevchenko wrote:
> > > The acpi_dev_get_first_match_name() is missing put_device() call
> > > and thus keeping reference counting unbalanced.
> > >
> > > In order to fix the issue introduce a new helper to convert existing users
> > > one-by-one to a better API.
> > >
> > > Since v3:
> > > - convert all existing users and drop old API (Mika)
> > > - add Hans' tag
> > >
> > > Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> > > Cc: Chanwoo Choi <cw00.choi@samsung.com>
> > > Cc: Chen-Yu Tsai <wens@csie.org>
> > > Cc: Linus Walleij <linus.walleij@linaro.org>
> > > Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Patches 4..9 for the Intel machine drivers:
> >
> > Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>
> Thank you!
>
> > Is this going to be merged through the ACPI or ASoC tree? The changes will
> > conflict with cleanups I started to use the 'modern' dailinks (codec_name ->
> > codecs[0].name), so some level of coordination is needed.
>
> I suppose via ACPI.

I can expose a non-volatile branch with this material, would that work?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
  2019-03-28 17:17 ` [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev() Andy Shevchenko
@ 2019-03-29  0:53   ` Chanwoo Choi
  2019-03-29 22:58     ` Rafael J. Wysocki
  0 siblings, 1 reply; 27+ messages in thread
From: Chanwoo Choi @ 2019-03-29  0:53 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi,
	Pierre-Louis Bossart, Liam Girdwood, Jie Yang, Mark Brown,
	alsa-devel, Hans de Goede, Mika Westerberg
  Cc: Chen-Yu Tsai, MyungJoo Ham

Hi Andy,

On 19. 3. 29. 오전 2:17, Andy Shevchenko wrote:
> acpi_dev_get_first_match_name() is deprecated and going to be removed
> because it leaks a reference.
> 
> Convert the driver to use acpi_dev_get_first_match_dev() instead.
> 
> Cc: Chanwoo Choi <cw00.choi@samsung.com>
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/extcon/extcon-axp288.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
> index a983708b77a6..50f9402fb325 100644
> --- a/drivers/extcon/extcon-axp288.c
> +++ b/drivers/extcon/extcon-axp288.c
> @@ -333,7 +333,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
>  	struct axp288_extcon_info *info;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
>  	struct device *dev = &pdev->dev;
> -	const char *name;
> +	struct acpi_device *adev;
>  	int ret, i, pirq;
>  
>  	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> @@ -357,9 +357,10 @@ static int axp288_extcon_probe(struct platform_device *pdev)
>  		if (ret)
>  			return ret;
>  
> -		name = acpi_dev_get_first_match_name("INT3496", NULL, -1);
> -		if (name) {
> -			info->id_extcon = extcon_get_extcon_dev(name);
> +		adev = acpi_dev_get_first_match_dev("INT3496", NULL, -1);
> +		if (adev) {
> +			info->id_extcon = extcon_get_extcon_dev(acpi_dev_name(adev));
> +			put_device(&adev->dev);
>  			if (!info->id_extcon)
>  				return -EPROBE_DEFER;
>  
> 

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (11 preceding siblings ...)
  2019-03-28 22:29 ` Hans de Goede
@ 2019-03-29  9:29 ` Mika Westerberg
  2019-04-02  8:57 ` Rafael J. Wysocki
  13 siblings, 0 replies; 27+ messages in thread
From: Mika Westerberg @ 2019-03-29  9:29 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, Chanwoo Choi, Hans de Goede, Rafael J. Wysocki,
	Linus Walleij, Jie Yang, Pierre-Louis Bossart, Liam Girdwood,
	linux-acpi, Chen-Yu Tsai, Mark Brown, MyungJoo Ham,
	Bartosz Golaszewski

On Thu, Mar 28, 2019 at 07:17:19PM +0200, Andy Shevchenko wrote:
> The acpi_dev_get_first_match_name() is missing put_device() call
> and thus keeping reference counting unbalanced.
> 
> In order to fix the issue introduce a new helper to convert existing users
> one-by-one to a better API.

For the entire series,

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
  2019-03-29  0:53   ` Chanwoo Choi
@ 2019-03-29 22:58     ` Rafael J. Wysocki
  2019-04-01  1:25       ` Chanwoo Choi
  0 siblings, 1 reply; 27+ messages in thread
From: Rafael J. Wysocki @ 2019-03-29 22:58 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: alsa-devel, Hans de Goede, Jie Yang, Pierre-Louis Bossart,
	Liam Girdwood, linux-acpi, Chen-Yu Tsai, Mark Brown,
	MyungJoo Ham, Andy Shevchenko, Mika Westerberg

On Friday, March 29, 2019 1:53:09 AM CET Chanwoo Choi wrote:
> Hi Andy,
> 
> On 19. 3. 29. 오전 2:17, Andy Shevchenko wrote:
> > acpi_dev_get_first_match_name() is deprecated and going to be removed
> > because it leaks a reference.
> > 
> > Convert the driver to use acpi_dev_get_first_match_dev() instead.
> > 
> > Cc: Chanwoo Choi <cw00.choi@samsung.com>
> > Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> > Cc: Chen-Yu Tsai <wens@csie.org>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/extcon/extcon-axp288.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
> > index a983708b77a6..50f9402fb325 100644
> > --- a/drivers/extcon/extcon-axp288.c
> > +++ b/drivers/extcon/extcon-axp288.c
> > @@ -333,7 +333,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
> >  	struct axp288_extcon_info *info;
> >  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> >  	struct device *dev = &pdev->dev;
> > -	const char *name;
> > +	struct acpi_device *adev;
> >  	int ret, i, pirq;
> >  
> >  	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> > @@ -357,9 +357,10 @@ static int axp288_extcon_probe(struct platform_device *pdev)
> >  		if (ret)
> >  			return ret;
> >  
> > -		name = acpi_dev_get_first_match_name("INT3496", NULL, -1);
> > -		if (name) {
> > -			info->id_extcon = extcon_get_extcon_dev(name);
> > +		adev = acpi_dev_get_first_match_dev("INT3496", NULL, -1);
> > +		if (adev) {
> > +			info->id_extcon = extcon_get_extcon_dev(acpi_dev_name(adev));
> > +			put_device(&adev->dev);
> >  			if (!info->id_extcon)
> >  				return -EPROBE_DEFER;
> >  
> > 
> 
> Applied it. Thanks.
> 
> 

But it won't build without the first patch I suppose?

ACK, please?


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
  2019-03-29 22:58     ` Rafael J. Wysocki
@ 2019-04-01  1:25       ` Chanwoo Choi
  0 siblings, 0 replies; 27+ messages in thread
From: Chanwoo Choi @ 2019-04-01  1:25 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: alsa-devel, Hans de Goede, Jie Yang, Pierre-Louis Bossart,
	Liam Girdwood, linux-acpi, Chen-Yu Tsai, Mark Brown,
	MyungJoo Ham, Andy Shevchenko, Mika Westerberg

Hi Rafael,

On 19. 3. 30. 오전 7:58, Rafael J. Wysocki wrote:
> On Friday, March 29, 2019 1:53:09 AM CET Chanwoo Choi wrote:
>> Hi Andy,
>>
>> On 19. 3. 29. 오전 2:17, Andy Shevchenko wrote:
>>> acpi_dev_get_first_match_name() is deprecated and going to be removed
>>> because it leaks a reference.
>>>
>>> Convert the driver to use acpi_dev_get_first_match_dev() instead.
>>>
>>> Cc: Chanwoo Choi <cw00.choi@samsung.com>
>>> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
>>> Cc: Chen-Yu Tsai <wens@csie.org>
>>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>> ---
>>>  drivers/extcon/extcon-axp288.c | 9 +++++----
>>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
>>> index a983708b77a6..50f9402fb325 100644
>>> --- a/drivers/extcon/extcon-axp288.c
>>> +++ b/drivers/extcon/extcon-axp288.c
>>> @@ -333,7 +333,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
>>>  	struct axp288_extcon_info *info;
>>>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
>>>  	struct device *dev = &pdev->dev;
>>> -	const char *name;
>>> +	struct acpi_device *adev;
>>>  	int ret, i, pirq;
>>>  
>>>  	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
>>> @@ -357,9 +357,10 @@ static int axp288_extcon_probe(struct platform_device *pdev)
>>>  		if (ret)
>>>  			return ret;
>>>  
>>> -		name = acpi_dev_get_first_match_name("INT3496", NULL, -1);
>>> -		if (name) {
>>> -			info->id_extcon = extcon_get_extcon_dev(name);
>>> +		adev = acpi_dev_get_first_match_dev("INT3496", NULL, -1);
>>> +		if (adev) {
>>> +			info->id_extcon = extcon_get_extcon_dev(acpi_dev_name(adev));
>>> +			put_device(&adev->dev);
>>>  			if (!info->id_extcon)
>>>  				return -EPROBE_DEFER;
>>>  
>>>
>>
>> Applied it. Thanks.
>>
>>
> 
> But it won't build without the first patch I suppose?
> 
> ACK, please?

It is my fault. I'll drop it from extcon.git.

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

> 
> 
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
  2019-03-28 17:17 ` [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper Andy Shevchenko
  2019-03-28 20:12   ` Rafael J. Wysocki
@ 2019-04-01  7:23   ` Mark Brown
  1 sibling, 0 replies; 27+ messages in thread
From: Mark Brown @ 2019-04-01  7:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, Hans de Goede, Rafael J. Wysocki, Jie Yang,
	Pierre-Louis Bossart, Liam Girdwood, linux-acpi, Mika Westerberg


[-- Attachment #1.1: Type: text/plain, Size: 372 bytes --]

On Thu, Mar 28, 2019 at 07:17:20PM +0200, Andy Shevchenko wrote:
> The acpi_dev_get_first_match_name() is missing put_device() call
> and thus keeping reference counting unbalanced.
> 
> In order to fix the issue introduce a new helper to convert existing users
> one-by-one to a better API. And then remove the old one.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 23:33     ` Rafael J. Wysocki
@ 2019-04-01  7:24       ` Mark Brown
  2019-04-02  9:02         ` Rafael J. Wysocki
  0 siblings, 1 reply; 27+ messages in thread
From: Mark Brown @ 2019-04-01  7:24 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Chanwoo Choi, Hans de Goede, Rafael J. Wysocki, Linus Walleij,
	Jie Yang, Pierre-Louis Bossart, Liam Girdwood,
	ACPI Devel Maling List, Chen-Yu Tsai, MyungJoo Ham,
	Bartosz Golaszewski, Andy Shevchenko, Mika Westerberg


[-- Attachment #1.1: Type: text/plain, Size: 619 bytes --]

On Fri, Mar 29, 2019 at 12:33:33AM +0100, Rafael J. Wysocki wrote:
> On Thu, Mar 28, 2019 at 10:40 PM Andy Shevchenko

> > > Is this going to be merged through the ACPI or ASoC tree? The changes will
> > > conflict with cleanups I started to use the 'modern' dailinks (codec_name ->
> > > codecs[0].name), so some level of coordination is needed.

> > I suppose via ACPI.

> I can expose a non-volatile branch with this material, would that work?

That would be very helpful, please - there's a lot of work going on with
the ASoC Intel drivers in order to add SoF support so there's likely to
be some kind of overlaps.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
                   ` (12 preceding siblings ...)
  2019-03-29  9:29 ` Mika Westerberg
@ 2019-04-02  8:57 ` Rafael J. Wysocki
  2019-04-02  9:17   ` Rafael J. Wysocki
  13 siblings, 1 reply; 27+ messages in thread
From: Rafael J. Wysocki @ 2019-04-02  8:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, Chanwoo Choi, Hans de Goede, Linus Walleij, Jie Yang,
	Pierre-Louis Bossart, Liam Girdwood, linux-acpi, Chen-Yu Tsai,
	Mark Brown, MyungJoo Ham, Bartosz Golaszewski, Mika Westerberg

On Thursday, March 28, 2019 6:17:19 PM CEST Andy Shevchenko wrote:
> The acpi_dev_get_first_match_name() is missing put_device() call
> and thus keeping reference counting unbalanced.
> 
> In order to fix the issue introduce a new helper to convert existing users
> one-by-one to a better API.
> 
> Since v3:
> - convert all existing users and drop old API (Mika)
> - add Hans' tag
> 
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> Cc: Chanwoo Choi <cw00.choi@samsung.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Andy Shevchenko (10):
>   ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
>   extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
>   gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
>   ASoC: Intel: bytcht_da7213: Convert to use
>     acpi_dev_get_first_match_dev()
>   ASoC: Intel: bytcht_es8316: Convert to use
>     acpi_dev_get_first_match_dev()
>   ASoC: Intel: bytcr_rt5640: Convert to use
>     acpi_dev_get_first_match_dev()
>   ASoC: Intel: bytcr_rt5651: Convert to use
>     acpi_dev_get_first_match_dev()
>   ASoC: Intel: cht_bsw_rt5645: Convert to use
>     acpi_dev_get_first_match_dev()
>   ASoC: Intel: cht_bsw_rt5672: Convert to use
>     acpi_dev_get_first_match_dev()
>   ACPI / utils: Remove deprecated function since no user left
> 
>  drivers/acpi/utils.c                    | 16 ++++++++++------
>  drivers/extcon/extcon-axp288.c          |  9 +++++----
>  drivers/gpio/gpio-merrifield.c          | 18 ++++++++++++++----
>  include/acpi/acpi_bus.h                 |  4 ++--
>  include/linux/acpi.h                    |  4 ++--
>  sound/soc/intel/boards/bytcht_da7213.c  |  9 +++++----
>  sound/soc/intel/boards/bytcht_es8316.c  |  9 +++++----
>  sound/soc/intel/boards/bytcr_rt5640.c   | 10 +++++-----
>  sound/soc/intel/boards/bytcr_rt5651.c   | 14 ++++++++------
>  sound/soc/intel/boards/cht_bsw_rt5645.c |  9 +++++----
>  sound/soc/intel/boards/cht_bsw_rt5672.c |  9 +++++----
>  11 files changed, 66 insertions(+), 45 deletions(-)
> 
> 

All applied (with the tags selected so far), thanks!

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-04-01  7:24       ` Mark Brown
@ 2019-04-02  9:02         ` Rafael J. Wysocki
  0 siblings, 0 replies; 27+ messages in thread
From: Rafael J. Wysocki @ 2019-04-02  9:02 UTC (permalink / raw)
  To: Mark Brown
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Chanwoo Choi, Rafael J. Wysocki, Linus Walleij, Jie Yang,
	Pierre-Louis Bossart, Liam Girdwood, ACPI Devel Maling List,
	Chen-Yu Tsai, MyungJoo Ham, Hans de Goede, Bartosz Golaszewski,
	Andy Shevchenko, Mika Westerberg

On Monday, April 1, 2019 9:24:35 AM CEST Mark Brown wrote:
> 
> --cYtjc4pxslFTELvY
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> 
> On Fri, Mar 29, 2019 at 12:33:33AM +0100, Rafael J. Wysocki wrote:
> > On Thu, Mar 28, 2019 at 10:40 PM Andy Shevchenko
> 
> > > > Is this going to be merged through the ACPI or ASoC tree? The changes will
> > > > conflict with cleanups I started to use the 'modern' dailinks (codec_name ->
> > > > codecs[0].name), so some level of coordination is needed.
> 
> > > I suppose via ACPI.
> 
> > I can expose a non-volatile branch with this material, would that work?
> 
> That would be very helpful, please - there's a lot of work going on with
> the ASoC Intel drivers in order to add SoF support so there's likely to
> be some kind of overlaps.

The series is available for pulling in the git branch at

 git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
 acpi-utils

on top of 5.1-rc3 with top-most commit 257f9053c0204ea47491aa236004fd1226f75fa8

 ACPI / utils: Remove deprecated function since no user left

Thanks!

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-04-02  8:57 ` Rafael J. Wysocki
@ 2019-04-02  9:17   ` Rafael J. Wysocki
  2019-04-02 10:37     ` Andy Shevchenko
  0 siblings, 1 reply; 27+ messages in thread
From: Rafael J. Wysocki @ 2019-04-02  9:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Chanwoo Choi, Hans de Goede, Linus Walleij, Jie Yang,
	Pierre-Louis Bossart, Liam Girdwood, ACPI Devel Maling List,
	Chen-Yu Tsai, Mark Brown, MyungJoo Ham, Bartosz Golaszewski,
	Mika Westerberg

On Tue, Apr 2, 2019 at 10:59 AM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> On Thursday, March 28, 2019 6:17:19 PM CEST Andy Shevchenko wrote:
> > The acpi_dev_get_first_match_name() is missing put_device() call
> > and thus keeping reference counting unbalanced.
> >
> > In order to fix the issue introduce a new helper to convert existing users
> > one-by-one to a better API.
> >
> > Since v3:
> > - convert all existing users and drop old API (Mika)
> > - add Hans' tag
> >
> > Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> > Cc: Chanwoo Choi <cw00.choi@samsung.com>
> > Cc: Chen-Yu Tsai <wens@csie.org>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Andy Shevchenko (10):
> >   ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper
> >   extcon: axp288: Convert to use acpi_dev_get_first_match_dev()
> >   gpio: merrifield: Convert to use acpi_dev_get_first_match_dev()
> >   ASoC: Intel: bytcht_da7213: Convert to use
> >     acpi_dev_get_first_match_dev()
> >   ASoC: Intel: bytcht_es8316: Convert to use
> >     acpi_dev_get_first_match_dev()
> >   ASoC: Intel: bytcr_rt5640: Convert to use
> >     acpi_dev_get_first_match_dev()
> >   ASoC: Intel: bytcr_rt5651: Convert to use
> >     acpi_dev_get_first_match_dev()
> >   ASoC: Intel: cht_bsw_rt5645: Convert to use
> >     acpi_dev_get_first_match_dev()
> >   ASoC: Intel: cht_bsw_rt5672: Convert to use
> >     acpi_dev_get_first_match_dev()
> >   ACPI / utils: Remove deprecated function since no user left
> >
> >  drivers/acpi/utils.c                    | 16 ++++++++++------
> >  drivers/extcon/extcon-axp288.c          |  9 +++++----
> >  drivers/gpio/gpio-merrifield.c          | 18 ++++++++++++++----
> >  include/acpi/acpi_bus.h                 |  4 ++--
> >  include/linux/acpi.h                    |  4 ++--
> >  sound/soc/intel/boards/bytcht_da7213.c  |  9 +++++----
> >  sound/soc/intel/boards/bytcht_es8316.c  |  9 +++++----
> >  sound/soc/intel/boards/bytcr_rt5640.c   | 10 +++++-----
> >  sound/soc/intel/boards/bytcr_rt5651.c   | 14 ++++++++------
> >  sound/soc/intel/boards/cht_bsw_rt5645.c |  9 +++++----
> >  sound/soc/intel/boards/cht_bsw_rt5672.c |  9 +++++----
> >  11 files changed, 66 insertions(+), 45 deletions(-)
> >
> >
>
> All applied (with the tags selected so far), thanks!

s/selected/collected/

Strange ...

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 00/10] ACPI / utils: Replace leaky function
  2019-04-02  9:17   ` Rafael J. Wysocki
@ 2019-04-02 10:37     ` Andy Shevchenko
  0 siblings, 0 replies; 27+ messages in thread
From: Andy Shevchenko @ 2019-04-02 10:37 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Chanwoo Choi, Hans de Goede, Linus Walleij, Jie Yang,
	Pierre-Louis Bossart, Liam Girdwood, ACPI Devel Maling List,
	Chen-Yu Tsai, Mark Brown, MyungJoo Ham, Bartosz Golaszewski,
	Mika Westerberg

On Tue, Apr 02, 2019 at 11:17:06AM +0200, Rafael J. Wysocki wrote:
> On Tue, Apr 2, 2019 at 10:59 AM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> >
> > On Thursday, March 28, 2019 6:17:19 PM CEST Andy Shevchenko wrote:
> > > The acpi_dev_get_first_match_name() is missing put_device() call
> > > and thus keeping reference counting unbalanced.
> > >
> > > In order to fix the issue introduce a new helper to convert existing users
> > > one-by-one to a better API.
> > >
> > > Since v3:
> > > - convert all existing users and drop old API (Mika)
> > > - add Hans' tag

> > All applied (with the tags selected so far), thanks!
> 
> s/selected/collected/
> 
> Strange ...

Thank you, Rafael!


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-04-02 10:37 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 17:17 [PATCH v3 00/10] ACPI / utils: Replace leaky function Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 01/10] ACPI / utils: Introduce acpi_dev_get_first_match_dev() helper Andy Shevchenko
2019-03-28 20:12   ` Rafael J. Wysocki
2019-03-28 21:38     ` Andy Shevchenko
2019-04-01  7:23   ` Mark Brown
2019-03-28 17:17 ` [PATCH v3 02/10] extcon: axp288: Convert to use acpi_dev_get_first_match_dev() Andy Shevchenko
2019-03-29  0:53   ` Chanwoo Choi
2019-03-29 22:58     ` Rafael J. Wysocki
2019-04-01  1:25       ` Chanwoo Choi
2019-03-28 17:17 ` [PATCH v3 03/10] gpio: merrifield: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 04/10] ASoC: Intel: bytcht_da7213: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 05/10] ASoC: Intel: bytcht_es8316: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 06/10] ASoC: Intel: bytcr_rt5640: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 07/10] ASoC: Intel: bytcr_rt5651: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 08/10] ASoC: Intel: cht_bsw_rt5645: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 09/10] ASoC: Intel: cht_bsw_rt5672: " Andy Shevchenko
2019-03-28 17:17 ` [PATCH v3 10/10] ACPI / utils: Remove deprecated function since no user left Andy Shevchenko
2019-03-28 18:31 ` [PATCH v3 00/10] ACPI / utils: Replace leaky function Pierre-Louis Bossart
2019-03-28 21:40   ` Andy Shevchenko
2019-03-28 23:33     ` Rafael J. Wysocki
2019-04-01  7:24       ` Mark Brown
2019-04-02  9:02         ` Rafael J. Wysocki
2019-03-28 22:29 ` Hans de Goede
2019-03-29  9:29 ` Mika Westerberg
2019-04-02  8:57 ` Rafael J. Wysocki
2019-04-02  9:17   ` Rafael J. Wysocki
2019-04-02 10:37     ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.