Skip to contentSkip to conversation

ACPI, ASoC, gpio: Add and use acpi_dev_get_first_match_name()

PATCH In review Andy Shevchenko 7 participants 22 messages Jan 5, 2018 – Jan 12, 2018

Subsystems (8)
Sound ACPI ASoC GPIO +4 more subsystems
lore
Share & tools
lore
#0 lore raw

v3 cover ACPI, ASoC, gpio: Add and use acpi_dev_get_first_match_name()

It appears that at least one current user (patch 3) and upcoming one (patch 2) need to get device name by ACPI HID.

Here we introduce acpi_dev_get_first_match_name() based on code done for acpi_dev_present() and reuse it where appropriate.

The series has been tested on Intel Edison with non-ACPI and ACPI enabled versions of U-Boot, while patches 1 and 3 were tested by Pierre.

Since patch 1 and cross subsystem nature of the series I think the best way is to push this (patches 1 and 2) via Rafael's linux-pm tree.

Taking into consideration that patch 3 requires not-yet-applied work from Pierre, I left it for reference, in particular to show the LOC statistics.

Changelog v3:
- add Pierre's tag (I dared to do this for both patches 1 and 3)
- address comment about function name (patch 1)
- add a reference to the first user (patch 1)
- consolidate pin control device possible names in one place (patch 2)
- rebase ASoC patch on not-yet-applied series from Pierre (patch 3), and
- thus reordered to make it last in the series (patch 3)

Andy Shevchenko (3):
ACPI / utils: Introduce acpi_dev_get_first_match_name()
gpio: merrifield: Add support of ACPI enabled platforms
ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

 drivers/acpi/utils.c                    | 41 +++++++++++++++++++++++++++------
 drivers/gpio/gpio-merrifield.c          | 11 ++++++++-
 include/acpi/acpi_bus.h                 |  3 +++
 include/linux/acpi.h                    |  6 +++++
 include/sound/soc-acpi.h                |  7 ------
 sound/soc/intel/boards/bytcht_da7213.c  |  2 +-
 sound/soc/intel/boards/bytcht_es8316.c  |  2 +-
 sound/soc/intel/boards/bytcr_rt5640.c   |  2 +-
 sound/soc/intel/boards/bytcr_rt5651.c   |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5645.c |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5672.c |  2 +-
 sound/soc/soc-acpi.c                    | 33 --------------------------
 12 files changed, 59 insertions(+), 54 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH v3 1/3 ACPI / utils: Introduce acpi_dev_get_first_match_name()

Sometimes the user wants to have device name of the match rather than just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present().

For example, GPIO driver for Intel Merrifield needs to know the device name of pin control to be able to apply GPIO mapping table to the proper device.

To be more consistent with the purpose rename

struct acpi_dev_present_info -> struct acpi_dev_match_info
acpi_dev_present_cb() -> acpi_dev_match_cb()

in the utils.c file.

---
 drivers/acpi/utils.c    | 41 ++++++++++++++++++++++++++++++++++-------
 include/acpi/acpi_bus.h |  3 +++
 include/linux/acpi.h    |  6 ++++++
 3 files changed, 43 insertions(+), 7 deletions(-)
drivers/acpi/utils.c +34 -7
index 9d49a1acebe3..78db97687f26 100644
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid)
 }
 EXPORT_SYMBOL(acpi_dev_found);
 
-struct acpi_dev_present_info {
+struct acpi_dev_match_info {
+	const char *dev_name;
 	struct acpi_device_id hid[2];
 	const char *uid;
 	s64 hrv;
 };
 
-static int acpi_dev_present_cb(struct device *dev, void *data)
+static int acpi_dev_match_cb(struct device *dev, void *data)
 {
 	struct acpi_device *adev = to_acpi_device(dev);
-	struct acpi_dev_present_info *match = data;
+	struct acpi_dev_match_info *match = data;
 	unsigned long long hrv;
 	acpi_status status;
 
@@ -757,6 +758,8 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
 	    strcmp(adev->pnp.unique_id, match->uid)))
 		return 0;
 
+	match->dev_name = acpi_dev_name(adev);
+
 	if (match->hrv == -1)
 		return 1;
 
@@ -789,20 +792,44 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
  */
 bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 {
-	struct acpi_dev_present_info match = {};
+	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_present_cb);
-
+	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
 	return !!dev;
 }
 EXPORT_SYMBOL(acpi_dev_present);
 
+/**
+ * acpi_dev_get_first_match_name - Return name of 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
+ * at the moment of invocation, or NULL otherwise.
+ *
+ * See additional information in acpi_dev_present() as well.
+ */
+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.
include/acpi/acpi_bus.h +3 -0
index 79287629c888..c9608b0b80c6 100644
@@ -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);
 
+const char *
+acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
+
 #ifdef CONFIG_ACPI
 
 #include <linux/proc_fs.h>
include/linux/acpi.h +6 -0
index 60f0d3248125..493ac6451773 100644
@@ -642,6 +642,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 	return false;
 }
 
+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;
Signature · 1 line
2.15.1
#9 lore raw

PATCH v3 2/3 gpio: merrifield: Add support of ACPI enabled platforms

In reply to Andy Shevchenko

The driver needs the pin control device name for ACPI.

We are looking through ACPI namespace and return first found device based on ACPI HID for Intel Merrifield FLIS (pin control device).

---
 drivers/gpio/gpio-merrifield.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpio/gpio-merrifield.c +10 -1
index dd67a31ac337..c38624ea0251 100644
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/bitops.h>
 #include <linux/gpio/driver.h>
 #include <linux/init.h>
@@ -380,9 +381,16 @@ static void mrfld_irq_init_hw(struct mrfld_gpio *priv)
 	}
 }
 
+static const char *mrfld_gpio_get_pinctrl_dev_name(void)
+{
+	const char *dev_name = acpi_dev_get_first_match_name("INTC1002", NULL, -1);
+	return dev_name ? dev_name : "pinctrl-merrifield";
+}
+
 static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	const struct mrfld_gpio_pinrange *range;
+	const char *pinctrl_dev_name;
 	struct mrfld_gpio *priv;
 	u32 gpio_base, irq_base;
 	void __iomem *base;
@@ -439,10 +447,11 @@ 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();
 	for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
 		range = &mrfld_gpio_ranges[i];
 		retval = gpiochip_add_pin_range(&priv->chip,
-						"pinctrl-merrifield",
+						pinctrl_dev_name,
 						range->gpio_base,
 						range->pin_base,
 						range->npins);
Signature · 1 line
2.15.1
#13 lore raw

PATCH v3 3/3 ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

In reply to Andy Shevchenko

Instead of home grown snd_soc_acpi_find_name_from_hid() use acpi_dev_get_first_match_name().

---
 include/sound/soc-acpi.h                |  7 -------
 sound/soc/intel/boards/bytcht_da7213.c  |  2 +-
 sound/soc/intel/boards/bytcht_es8316.c  |  2 +-
 sound/soc/intel/boards/bytcr_rt5640.c   |  2 +-
 sound/soc/intel/boards/bytcr_rt5651.c   |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5645.c |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5672.c |  2 +-
 sound/soc/soc-acpi.c                    | 33 ---------------------------------
 8 files changed, 6 insertions(+), 46 deletions(-)
include/sound/soc-acpi.h +0 -7
index 703c78483113..5ab6b2069f6b 100644
@@ -31,16 +31,9 @@ struct snd_soc_acpi_package_context {
 #define SND_SOC_ACPI_I2C_DEVICE_NAME_LEN (4 + ACPI_ID_LEN + 3 + 1)
 
 #if IS_ENABLED(CONFIG_ACPI)
-/* translation fron HID to I2C name, needed for DAI codec_name */
-const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
 bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 				    struct snd_soc_acpi_package_context *ctx);
 #else
-static inline const char *
-snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
-{
-	return NULL;
-}
 static inline bool
 snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 				   struct snd_soc_acpi_package_context *ctx)
sound/soc/intel/boards/bytcht_da7213.c +1 -1
index e78d9e860522..bf6217c3de94 100644
@@ -244,7 +244,7 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
 	if (i2c_name) {
 		snprintf(codec_name, sizeof(codec_name),
 			"%s%s", "i2c-", i2c_name);
sound/soc/intel/boards/bytcht_es8316.c +1 -1
index a1cc9590747e..4f6af9f43df8 100644
@@ -259,7 +259,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
 	if (i2c_name) {
 		snprintf(codec_name, sizeof(codec_name),
 			"%s%s", "i2c-", i2c_name);
sound/soc/intel/boards/bytcr_rt5640.c +1 -1
index 4bfd11968f77..a45180ad5882 100644
@@ -763,7 +763,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
 	if (i2c_name) {
 		snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
 			"%s%s", "i2c-", i2c_name);
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
index 86baa6906e92..794d984e420b 100644
@@ -500,7 +500,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
 	}
 
 	/* fixup codec name based on HID */
-	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
 	if (i2c_name) {
 		snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name),
 			"%s%s", "i2c-", i2c_name);
sound/soc/intel/boards/cht_bsw_rt5645.c +1 -1
index b2a69aae257e..cd3febbffcfe 100644
@@ -568,7 +568,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 		}
 
 	/* fixup codec name based on HID */
-	i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
 	if (i2c_name) {
 		snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name),
 			"%s%s", "i2c-", i2c_name);
sound/soc/intel/boards/cht_bsw_rt5672.c +1 -1
index c488dca55570..d1d0617bdf15 100644
@@ -397,7 +397,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 
 	/* fixup codec name based on HID */
 	if (mach) {
-		i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
+		i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
 		if (i2c_name) {
 			snprintf(drv->codec_name, sizeof(drv->codec_name),
 				 "i2c-%s", i2c_name);
sound/soc/soc-acpi.c +0 -33
index 7f43c9bf3d09..3d7e1ff79139 100644
@@ -16,39 +16,6 @@
 
 #include <sound/soc-acpi.h>
 
-static acpi_status snd_soc_acpi_find_name(acpi_handle handle, u32 level,
-				      void *context, void **ret)
-{
-	struct acpi_device *adev;
-	const char *name = NULL;
-
-	if (acpi_bus_get_device(handle, &adev))
-		return AE_OK;
-
-	if (adev->status.present && adev->status.functional) {
-		name = acpi_dev_name(adev);
-		*(const char **)ret = name;
-		return AE_CTRL_TERMINATE;
-	}
-
-	return AE_OK;
-}
-
-const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
-{
-	const char *name = NULL;
-	acpi_status status;
-
-	status = acpi_get_devices(hid, snd_soc_acpi_find_name, NULL,
-				  (void **)&name);
-
-	if (ACPI_FAILURE(status) || name[0] == '\0')
-		return NULL;
-
-	return name;
-}
-EXPORT_SYMBOL_GPL(snd_soc_acpi_find_name_from_hid);
-
 struct snd_soc_acpi_mach *
 snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
 {
Signature · 1 line
2.15.1
#18 lore raw
In reply to Andy Shevchenko
Quoted 13 lines · Andy Shevchenko

It appears that at least one current user (patch 3) and upcoming one (patch 2) need to get device name by ACPI HID.

Here we introduce acpi_dev_get_first_match_name() based on code done for acpi_dev_present() and reuse it where appropriate.

The series has been tested on Intel Edison with non-ACPI and ACPI enabled versions of U-Boot, while patches 1 and 3 were tested by Pierre.

Since patch 1 and cross subsystem nature of the series I think the best way is to push this (patches 1 and 2) via Rafael's linux-pm tree.

Quoted 6 lines

Taking into consideration that patch 3 requires not-yet-applied work from Pierre, I left it for reference, in particular to show the LOC statistics.

Changelog v3:
- add Pierre's tag (I dared to do this for both patches 1 and 3)

I tested a modified version of patch 3 (conflict resolution + addition of ES8316 support).

Quoted 25 lines

- address comment about function name (patch 1)
- add a reference to the first user (patch 1)
- consolidate pin control device possible names in one place (patch 2)
- rebase ASoC patch on not-yet-applied series from Pierre (patch 3), and
- thus reordered to make it last in the series (patch 3)

Andy Shevchenko (3):
ACPI / utils: Introduce acpi_dev_get_first_match_name()
gpio: merrifield: Add support of ACPI enabled platforms
ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

  drivers/acpi/utils.c                    | 41 +++++++++++++++++++++++++++------
  drivers/gpio/gpio-merrifield.c          | 11 ++++++++-
  include/acpi/acpi_bus.h                 |  3 +++
  include/linux/acpi.h                    |  6 +++++
  include/sound/soc-acpi.h                |  7 ------
  sound/soc/intel/boards/bytcht_da7213.c  |  2 +-
  sound/soc/intel/boards/bytcht_es8316.c  |  2 +-
  sound/soc/intel/boards/bytcr_rt5640.c   |  2 +-
  sound/soc/intel/boards/bytcr_rt5651.c   |  2 +-
  sound/soc/intel/boards/cht_bsw_rt5645.c |  2 +-
  sound/soc/intel/boards/cht_bsw_rt5672.c |  2 +-
  sound/soc/soc-acpi.c                    | 33 --------------------------
  12 files changed, 59 insertions(+), 54 deletions(-)
#19 lore raw
Quoted 19 lines · Pierre-Louis Bossart
Quoted 18 lines · Andy Shevchenko

It appears that at least one current user (patch 3) and upcoming one (patch 2) need to get device name by ACPI HID.

Here we introduce acpi_dev_get_first_match_name() based on code done for acpi_dev_present() and reuse it where appropriate.

The series has been tested on Intel Edison with non-ACPI and ACPI enabled versions of U-Boot, while patches 1 and 3 were tested by Pierre.

Since patch 1 and cross subsystem nature of the series I think the best way is to push this (patches 1 and 2) via Rafael's linux-pm tree.

Taking into consideration that patch 3 requires not-yet-applied work from Pierre, I left it for reference, in particular to show the LOC statistics.

Quoted 6 lines
Quoted 2 lines

Changelog v3:
- add Pierre's tag (I dared to do this for both patches 1 and 3)

I tested a modified version of patch 3 (conflict resolution + addition
of ES8316 support).

In v3 these have been addressed as I put above as "requires non-yet- applied work".

Quoted 32 lines
Quoted 30 lines

- address comment about function name (patch 1)
- add a reference to the first user (patch 1)
- consolidate pin control device possible names in one place (patch
2)
- rebase ASoC patch on not-yet-applied series from Pierre (patch 3), and
- thus reordered to make it last in the series (patch 3)

Andy Shevchenko (3):
ACPI / utils: Introduce acpi_dev_get_first_match_name()
gpio: merrifield: Add support of ACPI enabled platforms
ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

  drivers/acpi/utils.c                    | 41
+++++++++++++++++++++++++++------
  drivers/gpio/gpio-merrifield.c          | 11 ++++++++-
  include/acpi/acpi_bus.h                 |  3 +++
  include/linux/acpi.h                    |  6 +++++
  include/sound/soc-acpi.h                |  7 ------
  sound/soc/intel/boards/bytcht_da7213.c  |  2 +-
  sound/soc/intel/boards/bytcht_es8316.c  |  2 +-
  sound/soc/intel/boards/bytcr_rt5640.c   |  2 +-
  sound/soc/intel/boards/bytcr_rt5651.c   |  2 +-
  sound/soc/intel/boards/cht_bsw_rt5645.c |  2 +-
  sound/soc/intel/boards/cht_bsw_rt5672.c |  2 +-
  sound/soc/soc-acpi.c                    | 33 -------------------
-------
  12 files changed, 59 insertions(+), 54 deletions(-)
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw

Re: [PATCH v3 1/3] ACPI / utils: Introduce acpi_dev_get_first_match_name()

In reply to Andy Shevchenko
Quoted 11 lines · Andy Shevchenko

Sometimes the user wants to have device name of the match rather than just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present().

For example, GPIO driver for Intel Merrifield needs to know the device name of pin control to be able to apply GPIO mapping table to the proper device.

To be more consistent with the purpose rename

Quoted 7 lines

struct acpi_dev_present_info -> struct acpi_dev_match_info
acpi_dev_present_cb() -> acpi_dev_match_cb()

in the utils.c file.

OK, so which way do you want this to go in?

Quoted 127 lines
---
 drivers/acpi/utils.c    | 41 ++++++++++++++++++++++++++++++++++-------
 include/acpi/acpi_bus.h |  3 +++
 include/linux/acpi.h    |  6 ++++++
 3 files changed, 43 insertions(+), 7 deletions(-)
drivers/acpi/utils.c +34 -7
index 9d49a1acebe3..78db97687f26 100644
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid)
 }
 EXPORT_SYMBOL(acpi_dev_found);
 
-struct acpi_dev_present_info {
+struct acpi_dev_match_info {
+       const char *dev_name;
        struct acpi_device_id hid[2];
        const char *uid;
        s64 hrv;
 };
 
-static int acpi_dev_present_cb(struct device *dev, void *data)
+static int acpi_dev_match_cb(struct device *dev, void *data)
 {
        struct acpi_device *adev = to_acpi_device(dev);
-       struct acpi_dev_present_info *match = data;
+       struct acpi_dev_match_info *match = data;
        unsigned long long hrv;
        acpi_status status;
 
@@ -757,6 +758,8 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
            strcmp(adev->pnp.unique_id, match->uid)))
                return 0;
 
+       match->dev_name = acpi_dev_name(adev);
+
        if (match->hrv == -1)
                return 1;
 
@@ -789,20 +792,44 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
  */
 bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 {
-       struct acpi_dev_present_info match = {};
+       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_present_cb);
-
+       dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
        return !!dev;
 }
 EXPORT_SYMBOL(acpi_dev_present);
 
+/**
+ * acpi_dev_get_first_match_name - Return name of 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
+ * at the moment of invocation, or NULL otherwise.
+ *
+ * See additional information in acpi_dev_present() as well.
+ */
+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.
include/acpi/acpi_bus.h +3 -0
index 79287629c888..c9608b0b80c6 100644
@@ -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);
 
+const char *
+acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
+
 #ifdef CONFIG_ACPI
 
 #include <linux/proc_fs.h>
include/linux/acpi.h +6 -1
index 60f0d3248125..493ac6451773 100644
@@ -642,6 +642,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
        return false;
 }
 
+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.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Re: [PATCH v3 1/3] ACPI / utils: Introduce acpi_dev_get_first_match_name()

In reply to Rafael J. Wysocki
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · Andy Shevchenko

Sometimes the user wants to have device name of the match rather than
just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present().

For example, GPIO driver for Intel Merrifield needs to know the device
name of pin control to be able to apply GPIO mapping table to the proper
device.

To be more consistent with the purpose rename

struct acpi_dev_present_info -> struct acpi_dev_match_info
acpi_dev_present_cb() -> acpi_dev_match_cb()

Quoted 7 lines
Quoted 5 lines

in the utils.c file.

m>

OK, so which way do you want this to go in?

If you have no objections, patch 1 may go straight forward to linux-pm tree as far as you are okay with the contents.

I dunno, if Mika's ACK is enough to you to get the second one (patch 2) together, otherwise Linus' ACK would be needed or leave it for next cycle.

According to what Mark and Pierre told previously I guess we just postpone patch 3 for next cycle.

Quoted 141 lines
Quoted 141 lines
---
 drivers/acpi/utils.c    | 41 ++++++++++++++++++++++++++++++++++--
-----
 include/acpi/acpi_bus.h |  3 +++
 include/linux/acpi.h    |  6 ++++++
 3 files changed, 43 insertions(+), 7 deletions(-)
drivers/acpi/utils.c +10 -7
index 9d49a1acebe3..78db97687f26 100644
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid)
 }
 EXPORT_SYMBOL(acpi_dev_found);
 
-struct acpi_dev_present_info {
+struct acpi_dev_match_info {
+       const char *dev_name;
        struct acpi_device_id hid[2];
        const char *uid;
        s64 hrv;
 };
 
-static int acpi_dev_present_cb(struct device *dev, void *data)
+static int acpi_dev_match_cb(struct device *dev, void *data)
 {
        struct acpi_device *adev = to_acpi_device(dev);
-       struct acpi_dev_present_info *match = data;
+       struct acpi_dev_match_info *match = data;
        unsigned long long hrv;
        acpi_status status;
 
@@ -757,6 +758,8 @@ static int acpi_dev_present_cb(struct device
 *dev, void *data)
            strcmp(adev->pnp.unique_id, match->uid)))
                return 0;
 
+       match->dev_name = acpi_dev_name(adev);
+
        if (match->hrv == -1)
                return 1;
@@ -789,20 +792,44 @@ static int acpi_dev_present_cb(struct device
 *dev, void *data)
  */
 bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 {
-       struct acpi_dev_present_info match = {};
+       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_present_cb);
-
+       dev = bus_find_device(&acpi_bus_type, NULL, &match,
 acpi_dev_match_cb);
        return !!dev;
 }
 EXPORT_SYMBOL(acpi_dev_present);
 
+/**
+ * acpi_dev_get_first_match_name - Return name of 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
+ * at the moment of invocation, or NULL otherwise.
+ *
+ * See additional information in acpi_dev_present() as well.
+ */

drivers/acpi/utils.c +2 -0
+const char *
+acpi_dev_get_first_match_name(const char *hid, const char *uid, s64

hrv)

drivers/acpi/utils.c +9 -0
+{
+       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);

drivers/acpi/utils.c +4 -0
+       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.

include/acpi/acpi_bus.h +3 -0
index 79287629c888..c9608b0b80c6 100644
@@ -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);
 
+const char *
+acpi_dev_get_first_match_name(const char *hid, const char *uid, s64
 hrv);
+
 #ifdef CONFIG_ACPI

#include <linux/proc_fs.h>

include/linux/acpi.h +6 -0
index 60f0d3248125..493ac6451773 100644
@@ -642,6 +642,12 @@ static inline bool acpi_dev_present(const char
 *hid, const char *uid, s64 hrv)
        return false;
 }
 
+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.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux- acpi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#4 lore raw

Re: [PATCH v3 1/3] ACPI / utils: Introduce acpi_dev_get_first_match_name()

Quoted 31 lines · CET Andy Shevchenko
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · Andy Shevchenko

Sometimes the user wants to have device name of the match rather than
just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present().

For example, GPIO driver for Intel Merrifield needs to know the device
name of pin control to be able to apply GPIO mapping table to the proper
device.

To be more consistent with the purpose rename

struct acpi_dev_present_info -> struct acpi_dev_match_info
acpi_dev_present_cb() -> acpi_dev_match_cb()

Quoted 7 lines
Quoted 5 lines

in the utils.c file.

m>

OK, so which way do you want this to go in?

If you have no objections, patch 1 may go straight forward to linux-pm tree as far as you are okay with the contents.

Quoted 6 lines

I dunno, if Mika's ACK is enough to you to get the second one (patch 2) together, otherwise Linus' ACK would be needed or leave it for next cycle.

According to what Mark and Pierre told previously I guess we just postpone patch 3 for next cycle.

OK

Linus, can you please have a look at the [2/3] from this lot and let me know whether or not I can take it?

Thanks,
Rafael

#5 lore raw

Re: [PATCH v3 1/3] ACPI / utils: Introduce acpi_dev_get_first_match_name()

Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · CET Andy Shevchenko
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · Andy Shevchenko

Sometimes the user wants to have device name of the match rather than
just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present().

For example, GPIO driver for Intel Merrifield needs to know the device
name of pin control to be able to apply GPIO mapping table to the proper
device.

To be more consistent with the purpose rename

struct acpi_dev_present_info -> struct acpi_dev_match_info
acpi_dev_present_cb() -> acpi_dev_match_cb()

Quoted 7 lines
Quoted 5 lines

in the utils.c file.

m>

OK, so which way do you want this to go in?

If you have no objections, patch 1 may go straight forward to linux-pm tree as far as you are okay with the contents.

I dunno, if Mika's ACK is enough to you to get the second one (patch 2) together, otherwise Linus' ACK would be needed or leave it for next cycle.

Quoted 7 lines
Quoted 2 lines

According to what Mark and Pierre told previously I guess we just postpone patch 3 for next cycle.

OK

Linus, can you please have a look at the [2/3] from this lot and let me know whether or not I can take it?

OK looking...

Yours,
Linus Walleij

Acked-by on v3 2/3
#11 lore raw

Re: [PATCH v3 2/3] gpio: merrifield: Add support of ACPI enabled platforms

In reply to Andy Shevchenko
Quoted 7 lines · Andy Shevchenko

The driver needs the pin control device name for ACPI.

We are looking through ACPI namespace and return first found device based on ACPI HID for Intel Merrifield FLIS (pin control device).

Looks neat and clean.

Rafael: feel free to pick this up with the series.

Yours,
Linus Walleij

maintainer
#6 lore raw

Re: [PATCH v3 1/3] ACPI / utils: Introduce acpi_dev_get_first_match_name()

In reply to Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

According to what Mark and Pierre told previously I guess we just postpone patch 3 for next cycle.

Well, if someone can send me a pull request I could look at merging it... I had thought we might get a new release this week and be in the merge window by now TBH.

#7 lore raw

Re: [PATCH v3 1/3] ACPI / utils: Introduce acpi_dev_get_first_match_name()

Quoted 5 lines · CET Mark Brown

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Quoted 8 lines
Quoted 2 lines · Andy Shevchenko

According to what Mark and Pierre told previously I guess we just postpone patch 3 for next cycle.

Well, if someone can send me a pull request I could look at merging it... I had thought we might get a new release this week and be in the merge window by now TBH.

Patches [1-2/3] from this series are available for pulling in the git branch at

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

with top-most commit dd1dbf94d2826a045fbbe2649d84b27d48620d56

gpio: merrifield: Add support of ACPI enabled platforms

on top of commit b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d

    Linux 4.15-rc7

Thanks!

#20 lore raw
In reply to Andy Shevchenko
Quoted 30 lines · CET Andy Shevchenko

It appears that at least one current user (patch 3) and upcoming one (patch 2) need to get device name by ACPI HID.

Here we introduce acpi_dev_get_first_match_name() based on code done for acpi_dev_present() and reuse it where appropriate.

The series has been tested on Intel Edison with non-ACPI and ACPI enabled versions of U-Boot, while patches 1 and 3 were tested by Pierre.

Since patch 1 and cross subsystem nature of the series I think the best way is to push this (patches 1 and 2) via Rafael's linux-pm tree.

Taking into consideration that patch 3 requires not-yet-applied work from Pierre, I left it for reference, in particular to show the LOC statistics.

Changelog v3:
- add Pierre's tag (I dared to do this for both patches 1 and 3)
- address comment about function name (patch 1)
- add a reference to the first user (patch 1)
- consolidate pin control device possible names in one place (patch 2)
- rebase ASoC patch on not-yet-applied series from Pierre (patch 3), and
- thus reordered to make it last in the series (patch 3)

Andy Shevchenko (3):
ACPI / utils: Introduce acpi_dev_get_first_match_name()
gpio: merrifield: Add support of ACPI enabled platforms
ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

Quoted 13 lines
 drivers/acpi/utils.c                    | 41 +++++++++++++++++++++++++++------
 drivers/gpio/gpio-merrifield.c          | 11 ++++++++-
 include/acpi/acpi_bus.h                 |  3 +++
 include/linux/acpi.h                    |  6 +++++
 include/sound/soc-acpi.h                |  7 ------
 sound/soc/intel/boards/bytcht_da7213.c  |  2 +-
 sound/soc/intel/boards/bytcht_es8316.c  |  2 +-
 sound/soc/intel/boards/bytcr_rt5640.c   |  2 +-
 sound/soc/intel/boards/bytcr_rt5651.c   |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5645.c |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5672.c |  2 +-
 sound/soc/soc-acpi.c                    | 33 --------------------------
 12 files changed, 59 insertions(+), 54 deletions(-)

[1-2/3] applied and I set up a git branch with them to pull from for Mark.

Thanks,
Rafael

#21 lore raw
Quoted 50 lines · Rafael J. Wysocki
Quoted 33 lines · CET Andy Shevchenko

It appears that at least one current user (patch 3) and upcoming one (patch 2) need to get device name by ACPI HID.

Here we introduce acpi_dev_get_first_match_name() based on code done for acpi_dev_present() and reuse it where appropriate.

The series has been tested on Intel Edison with non-ACPI and ACPI enabled versions of U-Boot, while patches 1 and 3 were tested by Pierre.

Since patch 1 and cross subsystem nature of the series I think the best way is to push this (patches 1 and 2) via Rafael's linux-pm tree.

Taking into consideration that patch 3 requires not-yet-applied work from Pierre, I left it for reference, in particular to show the LOC statistics.

Changelog v3:
- add Pierre's tag (I dared to do this for both patches 1 and 3)
- address comment about function name (patch 1)
- add a reference to the first user (patch 1)
- consolidate pin control device possible names in one place (patch
2)
- rebase ASoC patch on not-yet-applied series from Pierre (patch 3), and
- thus reordered to make it last in the series (patch 3)

Andy Shevchenko (3):
ACPI / utils: Introduce acpi_dev_get_first_match_name()
gpio: merrifield: Add support of ACPI enabled platforms
ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

Quoted 15 lines
 drivers/acpi/utils.c                    | 41
+++++++++++++++++++++++++++------
 drivers/gpio/gpio-merrifield.c          | 11 ++++++++-
 include/acpi/acpi_bus.h                 |  3 +++
 include/linux/acpi.h                    |  6 +++++
 include/sound/soc-acpi.h                |  7 ------
 sound/soc/intel/boards/bytcht_da7213.c  |  2 +-
 sound/soc/intel/boards/bytcht_es8316.c  |  2 +-
 sound/soc/intel/boards/bytcr_rt5640.c   |  2 +-
 sound/soc/intel/boards/bytcr_rt5651.c   |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5645.c |  2 +-
 sound/soc/intel/boards/cht_bsw_rt5672.c |  2 +-
 sound/soc/soc-acpi.c                    | 33 ----------------------
----
 12 files changed, 59 insertions(+), 54 deletions(-)
Quoted 2 lines

[1-2/3] applied and I set up a git branch with them to pull from for Mark.

Thanks, Rafael!

So, the roadmap is as I see the following:
1) Mark applies (if no objection) latest version of the second patch series from Pierre...
2) ...followed by PR from Rafael...
3) ...followed by the patch 3 from this series.

Mark, does it sound like a plan to you?

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer
#14 lore raw

Re: [PATCH v3 3/3] ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

In reply to Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

Instead of home grown snd_soc_acpi_find_name_from_hid() use acpi_dev_get_first_match_name().

This doesn't apply against current code (even after pulling Raphael's pull request) - can you please check and resend?

maintainer
#12 lore raw

Applied "gpio: merrifield: Add support of ACPI enabled platforms" to the asoc tree

In reply to Andy Shevchenko

The patch

gpio: merrifield: Add support of ACPI enabled platforms

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From dd1dbf94d2826a045fbbe2649d84b27d48620d56 Mon Sep 17 00:00:00 2001

From: Andy Shevchenko <[email protected]>
Date: Fri, 5 Jan 2018 18:09:34 +0200
Subject: [PATCH] gpio: merrifield: Add support of ACPI enabled platforms

The driver needs the pin control device name for ACPI.

We are looking through ACPI namespace and return first found device based on ACPI HID for Intel Merrifield FLIS (pin control device).

---
 drivers/gpio/gpio-merrifield.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpio/gpio-merrifield.c +10 -1
index dd67a31ac337..c38624ea0251 100644
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/bitops.h>
 #include <linux/gpio/driver.h>
 #include <linux/init.h>
@@ -380,9 +381,16 @@ static void mrfld_irq_init_hw(struct mrfld_gpio *priv)
 	}
 }
 
+static const char *mrfld_gpio_get_pinctrl_dev_name(void)
+{
+	const char *dev_name = acpi_dev_get_first_match_name("INTC1002", NULL, -1);
+	return dev_name ? dev_name : "pinctrl-merrifield";
+}
+
 static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	const struct mrfld_gpio_pinrange *range;
+	const char *pinctrl_dev_name;
 	struct mrfld_gpio *priv;
 	u32 gpio_base, irq_base;
 	void __iomem *base;
@@ -439,10 +447,11 @@ 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();
 	for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
 		range = &mrfld_gpio_ranges[i];
 		retval = gpiochip_add_pin_range(&priv->chip,
-						"pinctrl-merrifield",
+						pinctrl_dev_name,
 						range->gpio_base,
 						range->pin_base,
 						range->npins);
Signature · 1 line
2.15.1
maintainer
#8 lore raw

Applied "ACPI: utils: Introduce acpi_dev_get_first_match_name()" to the asoc tree

In reply to Andy Shevchenko

The patch

ACPI: utils: Introduce acpi_dev_get_first_match_name()

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 67dcf8a3e06582cb6b02952335b5612beb97889f Mon Sep 17 00:00:00 2001

From: Andy Shevchenko <[email protected]>
Date: Fri, 5 Jan 2018 18:09:33 +0200
Subject: [PATCH] ACPI: utils: Introduce acpi_dev_get_first_match_name()

Sometimes the user wants to have device name of the match rather than just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present().

For example, GPIO driver for Intel Merrifield needs to know the device name of pin control to be able to apply GPIO mapping table to the proper device.

To be more consistent with the purpose rename

struct acpi_dev_present_info -> struct acpi_dev_match_info
acpi_dev_present_cb() -> acpi_dev_match_cb()

in the utils.c file.

---
 drivers/acpi/utils.c    | 41 ++++++++++++++++++++++++++++++++++-------
 include/acpi/acpi_bus.h |  3 +++
 include/linux/acpi.h    |  6 ++++++
 3 files changed, 43 insertions(+), 7 deletions(-)
drivers/acpi/utils.c +34 -7
index 9d49a1acebe3..78db97687f26 100644
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid)
 }
 EXPORT_SYMBOL(acpi_dev_found);
 
-struct acpi_dev_present_info {
+struct acpi_dev_match_info {
+	const char *dev_name;
 	struct acpi_device_id hid[2];
 	const char *uid;
 	s64 hrv;
 };
 
-static int acpi_dev_present_cb(struct device *dev, void *data)
+static int acpi_dev_match_cb(struct device *dev, void *data)
 {
 	struct acpi_device *adev = to_acpi_device(dev);
-	struct acpi_dev_present_info *match = data;
+	struct acpi_dev_match_info *match = data;
 	unsigned long long hrv;
 	acpi_status status;
 
@@ -757,6 +758,8 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
 	    strcmp(adev->pnp.unique_id, match->uid)))
 		return 0;
 
+	match->dev_name = acpi_dev_name(adev);
+
 	if (match->hrv == -1)
 		return 1;
 
@@ -789,20 +792,44 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
  */
 bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 {
-	struct acpi_dev_present_info match = {};
+	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_present_cb);
-
+	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
 	return !!dev;
 }
 EXPORT_SYMBOL(acpi_dev_present);
 
+/**
+ * acpi_dev_get_first_match_name - Return name of 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
+ * at the moment of invocation, or NULL otherwise.
+ *
+ * See additional information in acpi_dev_present() as well.
+ */
+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.
include/acpi/acpi_bus.h +3 -0
index 79287629c888..c9608b0b80c6 100644
@@ -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);
 
+const char *
+acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
+
 #ifdef CONFIG_ACPI
 
 #include <linux/proc_fs.h>
include/linux/acpi.h +6 -0
index dc1ebfeeb5ec..d918f1ea84e6 100644
@@ -640,6 +640,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 	return false;
 }
 
+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;
Signature · 1 line
2.15.1
#15 lore raw

Re: [PATCH v3 3/3] ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

In reply to Mark Brown
Quoted 6 lines · Mark Brown
Quoted 2 lines · Andy Shevchenko

Instead of home grown snd_soc_acpi_find_name_from_hid() use acpi_dev_get_first_match_name().

This doesn't apply against current code (even after pulling Raphael's pull request) - can you please check and resend?

It requires Pierre's series #2 [1] to be applied first.

[1]: https://www.spinics.net/lists/alsa-devel/msg72463.html

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer
#16 lore raw

Re: [PATCH v3 3/3] ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Mark Brown

This doesn't apply against current code (even after pulling Raphael's pull request) - can you please check and resend?

It requires Pierre's series #2 [1] to be applied first.

Ugh, I see. I'm surprised I was getting pushed about applying this when it had unreviewed dependencies...

Quoted 1 line

[1]: https://www.spinics.net/lists/alsa-devel/msg72463.html

Please include human readable descriptions of things like commits and issues being discussed in e-mail in your mails, this makes them much easier for humans to read especially when they have no internet access. I do frequently catch up on my mail on flights or while otherwise travelling so this is even more pressing for me than just being about making things a bit easier to read.

maintainer
#17 lore raw

Re: [PATCH v3 3/3] ASoC: Intel - Convert to use acpi_dev_get_first_match_name()

In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Mark Brown

This doesn't apply against current code (even after pulling Raphael's pull request) - can you please check and resend?

It requires Pierre's series #2 [1] to be applied first.

Oh, and please note that the "and resend" part there is important, if I've replied like that it means the patch is gone from my review queue so I'll need to go and try to find a copy to do something with it which can be error prone.