All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] ACPI: platform: Fix SMB0001 enumeration on Kontron devices
@ 2023-06-26 11:00 ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Rafael J. Wysocki, Len Brown, Andi Shyti, Robert Moore, Michael Walle

After switching i2c-scmi driver to be a plaform one, it stopped
being enumerated on number of Kontron platforms, because it's
listed in the forbidden_id_list.

To resolve the situation, add a flag and count the resources of the
forbiden device. If the count is non-zero, the device must be skipped.

Changelog v3:
- provided completely rewritten solution (Rafael)
- due to above, added two new patches
- due to above, dropped tags from patch 3

Andy Shevchenko (4):
  ACPI: bus: Constify acpi_companion_match() returned value
  ACPI: bus: Introduce acpi_match_acpi_device() helper
  ACPI: platform: Ignore SMB0001 only when it has resources
  ACPI: platform: Move SMB0001 HID to the header and reuse

 drivers/acpi/acpi_platform.c  | 31 +++++++++++++++++++++++++++----
 drivers/acpi/bus.c            | 21 ++++++++++++++-------
 drivers/acpi/device_sysfs.c   |  2 +-
 drivers/acpi/internal.h       |  2 +-
 drivers/i2c/busses/i2c-scmi.c |  3 ---
 include/acpi/acpi_drivers.h   |  2 ++
 include/linux/acpi.h          |  9 +++++++++
 7 files changed, 54 insertions(+), 16 deletions(-)

-- 
2.40.0.1.gaa8946217a0b


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

* [Acpica-devel] [PATCH v3 2/4] ACPI: bus: Introduce acpi_match_acpi_device() helper
  2023-06-26 11:00 ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-26 11:00   ` Andy Shevchenko
  -1 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Robert Moore, Michael Walle, Len Brown, Andi Shyti

In some cases we can't have a physical node associated with
the ACPI device. Yet we want to match it against ID table and
get respective driver data. Introduce the helper for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/bus.c   | 15 +++++++++++----
 include/linux/acpi.h |  9 +++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 20cdfb37da79..ee88bfb60ac2 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -850,6 +850,16 @@ static bool __acpi_match_device(const struct acpi_device *device,
 	return true;
 }
 
+const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
+						    const struct acpi_device *adev)
+{
+	const struct acpi_device_id *id = NULL;
+
+	__acpi_match_device(adev, ids, NULL, &id, NULL);
+	return id;
+}
+EXPORT_SYMBOL_GPL(acpi_match_acpi_device);
+
 /**
  * acpi_match_device - Match a struct device against a given list of ACPI IDs
  * @ids: Array of struct acpi_device_id object to match against.
@@ -864,10 +874,7 @@ static bool __acpi_match_device(const struct acpi_device *device,
 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
 					       const struct device *dev)
 {
-	const struct acpi_device_id *id = NULL;
-
-	__acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL);
-	return id;
+	return acpi_match_acpi_device(ids, acpi_companion_match(dev));
 }
 EXPORT_SYMBOL_GPL(acpi_match_device);
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 640f1c07c894..641dc4843987 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -707,6 +707,9 @@ extern int acpi_nvs_register(__u64 start, __u64 size);
 extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
 				    void *data);
 
+const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
+						    const struct acpi_device *adev);
+
 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
 					       const struct device *dev);
 
@@ -922,6 +925,12 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
 
 struct acpi_device_id;
 
+static inline const struct acpi_device_id *acpi_match_acpi_device(
+	const struct acpi_device_id *ids, const struct acpi_device *adev)
+{
+	return NULL;
+}
+
 static inline const struct acpi_device_id *acpi_match_device(
 	const struct acpi_device_id *ids, const struct device *dev)
 {
-- 
2.40.0.1.gaa8946217a0b


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

* [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
  2023-06-26 11:00 ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-26 11:00   ` Andy Shevchenko
  -1 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Rafael J. Wysocki, Len Brown, Andi Shyti, Robert Moore, Michael Walle

acpi_companion_match() doesn't alter the contents of the passed
parameter, so we don't expect that returned value can be altered
either. So constify it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/bus.c          | 6 +++---
 drivers/acpi/device_sysfs.c | 2 +-
 drivers/acpi/internal.h     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e3e0bd0c5a50..20cdfb37da79 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -682,7 +682,7 @@ bool acpi_device_is_first_physical_node(struct acpi_device *adev,
  * resources available from it but they will be matched normally using functions
  * provided by their bus types (and analogously for their modalias).
  */
-struct acpi_device *acpi_companion_match(const struct device *dev)
+const struct acpi_device *acpi_companion_match(const struct device *dev)
 {
 	struct acpi_device *adev;
 
@@ -706,7 +706,7 @@ struct acpi_device *acpi_companion_match(const struct device *dev)
  * identifiers and a _DSD object with the "compatible" property, use that
  * property to match against the given list of identifiers.
  */
-static bool acpi_of_match_device(struct acpi_device *adev,
+static bool acpi_of_match_device(const struct acpi_device *adev,
 				 const struct of_device_id *of_match_table,
 				 const struct of_device_id **of_id)
 {
@@ -808,7 +808,7 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id,
 	return true;
 }
 
-static bool __acpi_match_device(struct acpi_device *device,
+static bool __acpi_match_device(const struct acpi_device *device,
 				const struct acpi_device_id *acpi_ids,
 				const struct of_device_id *of_ids,
 				const struct acpi_device_id **acpi_id,
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 0fbfbaa8d8e3..b9bbf0746199 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -283,7 +283,7 @@ int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
 }
 EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
 
-static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
+static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
 {
 	int len, count;
 
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 50dcb35c9965..f4148dc50b9c 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -121,7 +121,7 @@ int acpi_bus_register_early_device(int type);
 /* --------------------------------------------------------------------------
                      Device Matching and Notification
    -------------------------------------------------------------------------- */
-struct acpi_device *acpi_companion_match(const struct device *dev);
+const struct acpi_device *acpi_companion_match(const struct device *dev);
 int __acpi_device_uevent_modalias(const struct acpi_device *adev,
 				  struct kobj_uevent_env *env);
 
-- 
2.40.0.1.gaa8946217a0b


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

* [Acpica-devel] [PATCH v3 3/4] ACPI: platform: Ignore SMB0001 only when it has resources
  2023-06-26 11:00 ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-26 11:00   ` Andy Shevchenko
  -1 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Robert Moore, Michael Walle, Len Brown, Andi Shyti

After switching i2c-scmi driver to be a platform one, it stopped
being enumerated on number of Kontron platforms, because it's
listed in the forbidden_id_list.

To resolve the situation, add a flag to driver data to allow devices
with no resources in _CRS to be enumerated via platform bus.

Fixes: 03d4287add6e ("i2c: scmi: Convert to be a platform driver")
Closes: https://lore.kernel.org/r/60c1756765b9a3f1eab0dcbd84f59f00fe1caf48.camel@kontron.com
Link: https://lore.kernel.org/r/20230621151652.79579-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index fe00a5783f53..ee6ea1ee8396 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/bits.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
@@ -19,13 +20,16 @@
 
 #include "internal.h"
 
+/* Exclude devices that have no _CRS resources provided */
+#define ACPI_ALLOW_WO_RESOURCES		BIT(0)
+
 static const struct acpi_device_id forbidden_id_list[] = {
 	{"ACPI0009", 0},	/* IOxAPIC */
 	{"ACPI000A", 0},	/* IOAPIC */
 	{"PNP0000",  0},	/* PIC */
 	{"PNP0100",  0},	/* Timer */
 	{"PNP0200",  0},	/* AT DMA Controller */
-	{"SMB0001",  0},	/* ACPI SMBUS virtual device */
+	{"SMB0001",  ACPI_ALLOW_WO_RESOURCES},	/* ACPI SMBUS virtual device */
 	{ }
 };
 
@@ -83,6 +87,15 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
 		dest->parent = pci_find_resource(to_pci_dev(parent), dest);
 }
 
+static unsigned int acpi_platform_resource_count(struct acpi_resource *ares, void *data)
+{
+	int *count = data;
+
+	(*count)++;
+
+	return AE_OK;
+}
+
 /**
  * acpi_create_platform_device - Create platform device for ACPI device node
  * @adev: ACPI device node to create a platform device for.
@@ -100,17 +113,27 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
 	struct acpi_device *parent = acpi_dev_parent(adev);
 	struct platform_device *pdev = NULL;
 	struct platform_device_info pdevinfo;
+	const struct acpi_device_id *match;
 	struct resource_entry *rentry;
 	struct list_head resource_list;
 	struct resource *resources = NULL;
-	int count;
+	int count = 0;
 
 	/* If the ACPI node already has a physical device attached, skip it. */
 	if (adev->physical_node_count)
 		return NULL;
 
-	if (!acpi_match_device_ids(adev, forbidden_id_list))
-		return ERR_PTR(-EINVAL);
+	match = acpi_match_acpi_device(forbidden_id_list, adev);
+	if (match) {
+		if (match->driver_data & ACPI_ALLOW_WO_RESOURCES) {
+			acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
+					    acpi_platform_resource_count, &count);
+			if (count > 0)
+				return ERR_PTR(-EINVAL);
+		} else {
+			return ERR_PTR(-EINVAL);
+		}
+	}
 
 	INIT_LIST_HEAD(&resource_list);
 	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
-- 
2.40.0.1.gaa8946217a0b


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

* [Acpica-devel] [PATCH v3 4/4] ACPI: platform: Move SMB0001 HID to the header and reuse
  2023-06-26 11:00 ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-26 11:00   ` Andy Shevchenko
  -1 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Andi Shyti, Robert Moore, Wolfram Sang, Michael Walle, Len Brown

There are at least two places in the kernel that are using
the SMB0001 HID. Make it to be available via acpi_drivers.h
header file. While at it, replace hard coded one with a
definition.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Wolfram Sang <wsa@kernel.org> # for I2C
Link: https://lore.kernel.org/r/20230621151652.79579-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c  | 2 +-
 drivers/i2c/busses/i2c-scmi.c | 3 ---
 include/acpi/acpi_drivers.h   | 2 ++
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index ee6ea1ee8396..b5e32257fa3e 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -29,7 +29,7 @@ static const struct acpi_device_id forbidden_id_list[] = {
 	{"PNP0000",  0},	/* PIC */
 	{"PNP0100",  0},	/* Timer */
 	{"PNP0200",  0},	/* AT DMA Controller */
-	{"SMB0001",  ACPI_ALLOW_WO_RESOURCES},	/* ACPI SMBUS virtual device */
+	{ACPI_SMBUS_MS_HID,  ACPI_ALLOW_WO_RESOURCES},	/* ACPI SMBUS virtual device */
 	{ }
 };
 
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
index 104570292241..421735acfa14 100644
--- a/drivers/i2c/busses/i2c-scmi.c
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -13,9 +13,6 @@
 #include <linux/i2c.h>
 #include <linux/acpi.h>
 
-/* SMBUS HID definition as supported by Microsoft Windows */
-#define ACPI_SMBUS_MS_HID		"SMB0001"
-
 struct smbus_methods_t {
 	char *mt_info;
 	char *mt_sbr;
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 8372b0e7fd15..b14d165632e7 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -27,6 +27,8 @@
 #define ACPI_BAY_HID			"LNXIOBAY"
 #define ACPI_DOCK_HID			"LNXDOCK"
 #define ACPI_ECDT_HID			"LNXEC"
+/* SMBUS HID definition as supported by Microsoft Windows */
+#define ACPI_SMBUS_MS_HID		"SMB0001"
 /* Quirk for broken IBM BIOSes */
 #define ACPI_SMBUS_IBM_HID		"SMBUSIBM"
 
-- 
2.40.0.1.gaa8946217a0b


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

* [PATCH v3 2/4] ACPI: bus: Introduce acpi_match_acpi_device() helper
@ 2023-06-26 11:00   ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Rafael J. Wysocki, Len Brown, Andi Shyti, Robert Moore, Michael Walle

In some cases we can't have a physical node associated with
the ACPI device. Yet we want to match it against ID table and
get respective driver data. Introduce the helper for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/bus.c   | 15 +++++++++++----
 include/linux/acpi.h |  9 +++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 20cdfb37da79..ee88bfb60ac2 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -850,6 +850,16 @@ static bool __acpi_match_device(const struct acpi_device *device,
 	return true;
 }
 
+const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
+						    const struct acpi_device *adev)
+{
+	const struct acpi_device_id *id = NULL;
+
+	__acpi_match_device(adev, ids, NULL, &id, NULL);
+	return id;
+}
+EXPORT_SYMBOL_GPL(acpi_match_acpi_device);
+
 /**
  * acpi_match_device - Match a struct device against a given list of ACPI IDs
  * @ids: Array of struct acpi_device_id object to match against.
@@ -864,10 +874,7 @@ static bool __acpi_match_device(const struct acpi_device *device,
 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
 					       const struct device *dev)
 {
-	const struct acpi_device_id *id = NULL;
-
-	__acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL);
-	return id;
+	return acpi_match_acpi_device(ids, acpi_companion_match(dev));
 }
 EXPORT_SYMBOL_GPL(acpi_match_device);
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 640f1c07c894..641dc4843987 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -707,6 +707,9 @@ extern int acpi_nvs_register(__u64 start, __u64 size);
 extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
 				    void *data);
 
+const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
+						    const struct acpi_device *adev);
+
 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
 					       const struct device *dev);
 
@@ -922,6 +925,12 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
 
 struct acpi_device_id;
 
+static inline const struct acpi_device_id *acpi_match_acpi_device(
+	const struct acpi_device_id *ids, const struct acpi_device *adev)
+{
+	return NULL;
+}
+
 static inline const struct acpi_device_id *acpi_match_device(
 	const struct acpi_device_id *ids, const struct device *dev)
 {
-- 
2.40.0.1.gaa8946217a0b


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

* [Acpica-devel] [PATCH v3 0/4] ACPI: platform: Fix SMB0001 enumeration on Kontron devices
@ 2023-06-26 11:00 ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Robert Moore, Michael Walle, Len Brown, Andi Shyti

After switching i2c-scmi driver to be a plaform one, it stopped
being enumerated on number of Kontron platforms, because it's
listed in the forbidden_id_list.

To resolve the situation, add a flag and count the resources of the
forbiden device. If the count is non-zero, the device must be skipped.

Changelog v3:
- provided completely rewritten solution (Rafael)
- due to above, added two new patches
- due to above, dropped tags from patch 3

Andy Shevchenko (4):
  ACPI: bus: Constify acpi_companion_match() returned value
  ACPI: bus: Introduce acpi_match_acpi_device() helper
  ACPI: platform: Ignore SMB0001 only when it has resources
  ACPI: platform: Move SMB0001 HID to the header and reuse

 drivers/acpi/acpi_platform.c  | 31 +++++++++++++++++++++++++++----
 drivers/acpi/bus.c            | 21 ++++++++++++++-------
 drivers/acpi/device_sysfs.c   |  2 +-
 drivers/acpi/internal.h       |  2 +-
 drivers/i2c/busses/i2c-scmi.c |  3 ---
 include/acpi/acpi_drivers.h   |  2 ++
 include/linux/acpi.h          |  9 +++++++++
 7 files changed, 54 insertions(+), 16 deletions(-)

-- 
2.40.0.1.gaa8946217a0b


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

* [PATCH v3 3/4] ACPI: platform: Ignore SMB0001 only when it has resources
@ 2023-06-26 11:00   ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Rafael J. Wysocki, Len Brown, Andi Shyti, Robert Moore, Michael Walle

After switching i2c-scmi driver to be a platform one, it stopped
being enumerated on number of Kontron platforms, because it's
listed in the forbidden_id_list.

To resolve the situation, add a flag to driver data to allow devices
with no resources in _CRS to be enumerated via platform bus.

Fixes: 03d4287add6e ("i2c: scmi: Convert to be a platform driver")
Closes: https://lore.kernel.org/r/60c1756765b9a3f1eab0dcbd84f59f00fe1caf48.camel@kontron.com
Link: https://lore.kernel.org/r/20230621151652.79579-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index fe00a5783f53..ee6ea1ee8396 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/bits.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
@@ -19,13 +20,16 @@
 
 #include "internal.h"
 
+/* Exclude devices that have no _CRS resources provided */
+#define ACPI_ALLOW_WO_RESOURCES		BIT(0)
+
 static const struct acpi_device_id forbidden_id_list[] = {
 	{"ACPI0009", 0},	/* IOxAPIC */
 	{"ACPI000A", 0},	/* IOAPIC */
 	{"PNP0000",  0},	/* PIC */
 	{"PNP0100",  0},	/* Timer */
 	{"PNP0200",  0},	/* AT DMA Controller */
-	{"SMB0001",  0},	/* ACPI SMBUS virtual device */
+	{"SMB0001",  ACPI_ALLOW_WO_RESOURCES},	/* ACPI SMBUS virtual device */
 	{ }
 };
 
@@ -83,6 +87,15 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
 		dest->parent = pci_find_resource(to_pci_dev(parent), dest);
 }
 
+static unsigned int acpi_platform_resource_count(struct acpi_resource *ares, void *data)
+{
+	int *count = data;
+
+	(*count)++;
+
+	return AE_OK;
+}
+
 /**
  * acpi_create_platform_device - Create platform device for ACPI device node
  * @adev: ACPI device node to create a platform device for.
@@ -100,17 +113,27 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
 	struct acpi_device *parent = acpi_dev_parent(adev);
 	struct platform_device *pdev = NULL;
 	struct platform_device_info pdevinfo;
+	const struct acpi_device_id *match;
 	struct resource_entry *rentry;
 	struct list_head resource_list;
 	struct resource *resources = NULL;
-	int count;
+	int count = 0;
 
 	/* If the ACPI node already has a physical device attached, skip it. */
 	if (adev->physical_node_count)
 		return NULL;
 
-	if (!acpi_match_device_ids(adev, forbidden_id_list))
-		return ERR_PTR(-EINVAL);
+	match = acpi_match_acpi_device(forbidden_id_list, adev);
+	if (match) {
+		if (match->driver_data & ACPI_ALLOW_WO_RESOURCES) {
+			acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
+					    acpi_platform_resource_count, &count);
+			if (count > 0)
+				return ERR_PTR(-EINVAL);
+		} else {
+			return ERR_PTR(-EINVAL);
+		}
+	}
 
 	INIT_LIST_HEAD(&resource_list);
 	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
-- 
2.40.0.1.gaa8946217a0b


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

* [Acpica-devel] [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
@ 2023-06-26 11:00   ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Robert Moore, Michael Walle, Len Brown, Andi Shyti

acpi_companion_match() doesn't alter the contents of the passed
parameter, so we don't expect that returned value can be altered
either. So constify it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/bus.c          | 6 +++---
 drivers/acpi/device_sysfs.c | 2 +-
 drivers/acpi/internal.h     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e3e0bd0c5a50..20cdfb37da79 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -682,7 +682,7 @@ bool acpi_device_is_first_physical_node(struct acpi_device *adev,
  * resources available from it but they will be matched normally using functions
  * provided by their bus types (and analogously for their modalias).
  */
-struct acpi_device *acpi_companion_match(const struct device *dev)
+const struct acpi_device *acpi_companion_match(const struct device *dev)
 {
 	struct acpi_device *adev;
 
@@ -706,7 +706,7 @@ struct acpi_device *acpi_companion_match(const struct device *dev)
  * identifiers and a _DSD object with the "compatible" property, use that
  * property to match against the given list of identifiers.
  */
-static bool acpi_of_match_device(struct acpi_device *adev,
+static bool acpi_of_match_device(const struct acpi_device *adev,
 				 const struct of_device_id *of_match_table,
 				 const struct of_device_id **of_id)
 {
@@ -808,7 +808,7 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id,
 	return true;
 }
 
-static bool __acpi_match_device(struct acpi_device *device,
+static bool __acpi_match_device(const struct acpi_device *device,
 				const struct acpi_device_id *acpi_ids,
 				const struct of_device_id *of_ids,
 				const struct acpi_device_id **acpi_id,
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 0fbfbaa8d8e3..b9bbf0746199 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -283,7 +283,7 @@ int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
 }
 EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
 
-static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
+static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
 {
 	int len, count;
 
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 50dcb35c9965..f4148dc50b9c 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -121,7 +121,7 @@ int acpi_bus_register_early_device(int type);
 /* --------------------------------------------------------------------------
                      Device Matching and Notification
    -------------------------------------------------------------------------- */
-struct acpi_device *acpi_companion_match(const struct device *dev);
+const struct acpi_device *acpi_companion_match(const struct device *dev);
 int __acpi_device_uevent_modalias(const struct acpi_device *adev,
 				  struct kobj_uevent_env *env);
 
-- 
2.40.0.1.gaa8946217a0b


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

* [PATCH v3 4/4] ACPI: platform: Move SMB0001 HID to the header and reuse
@ 2023-06-26 11:00   ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-26 11:00 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel
  Cc: Rafael J. Wysocki, Len Brown, Andi Shyti, Robert Moore,
	Michael Walle, Wolfram Sang

There are at least two places in the kernel that are using
the SMB0001 HID. Make it to be available via acpi_drivers.h
header file. While at it, replace hard coded one with a
definition.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Wolfram Sang <wsa@kernel.org> # for I2C
Link: https://lore.kernel.org/r/20230621151652.79579-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c  | 2 +-
 drivers/i2c/busses/i2c-scmi.c | 3 ---
 include/acpi/acpi_drivers.h   | 2 ++
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index ee6ea1ee8396..b5e32257fa3e 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -29,7 +29,7 @@ static const struct acpi_device_id forbidden_id_list[] = {
 	{"PNP0000",  0},	/* PIC */
 	{"PNP0100",  0},	/* Timer */
 	{"PNP0200",  0},	/* AT DMA Controller */
-	{"SMB0001",  ACPI_ALLOW_WO_RESOURCES},	/* ACPI SMBUS virtual device */
+	{ACPI_SMBUS_MS_HID,  ACPI_ALLOW_WO_RESOURCES},	/* ACPI SMBUS virtual device */
 	{ }
 };
 
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
index 104570292241..421735acfa14 100644
--- a/drivers/i2c/busses/i2c-scmi.c
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -13,9 +13,6 @@
 #include <linux/i2c.h>
 #include <linux/acpi.h>
 
-/* SMBUS HID definition as supported by Microsoft Windows */
-#define ACPI_SMBUS_MS_HID		"SMB0001"
-
 struct smbus_methods_t {
 	char *mt_info;
 	char *mt_sbr;
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 8372b0e7fd15..b14d165632e7 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -27,6 +27,8 @@
 #define ACPI_BAY_HID			"LNXIOBAY"
 #define ACPI_DOCK_HID			"LNXDOCK"
 #define ACPI_ECDT_HID			"LNXEC"
+/* SMBUS HID definition as supported by Microsoft Windows */
+#define ACPI_SMBUS_MS_HID		"SMB0001"
 /* Quirk for broken IBM BIOSes */
 #define ACPI_SMBUS_IBM_HID		"SMBUSIBM"
 
-- 
2.40.0.1.gaa8946217a0b


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

* Re: [PATCH v3 2/4] ACPI: bus: Introduce acpi_match_acpi_device() helper
  2023-06-26 11:00   ` Andy Shevchenko
@ 2023-06-29  8:45     ` Rafael J. Wysocki
  -1 siblings, 0 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29  8:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, linux-acpi, linux-kernel, linux-i2c,
	acpica-devel, Rafael J. Wysocki, Len Brown, Andi Shyti,
	Robert Moore, Michael Walle

On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> In some cases we can't have a physical node associated with
> the ACPI device. Yet we want to match it against ID table and
> get respective driver data. Introduce the helper for that.

I think that the problem is really to find a struct acpi_device_id in
a given list matching a given struct acpi_device.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/acpi/bus.c   | 15 +++++++++++----
>  include/linux/acpi.h |  9 +++++++++
>  2 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 20cdfb37da79..ee88bfb60ac2 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -850,6 +850,16 @@ static bool __acpi_match_device(const struct acpi_device *device,
>         return true;
>  }
>
> +const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
> +                                                   const struct acpi_device *adev)
> +{
> +       const struct acpi_device_id *id = NULL;
> +
> +       __acpi_match_device(adev, ids, NULL, &id, NULL);
> +       return id;
> +}
> +EXPORT_SYMBOL_GPL(acpi_match_acpi_device);

This is fine, but it requires a kerneldoc comment (as an exported function).

Of course, the code in scan.c can use it even if it is not exported.

> +
>  /**
>   * acpi_match_device - Match a struct device against a given list of ACPI IDs
>   * @ids: Array of struct acpi_device_id object to match against.
> @@ -864,10 +874,7 @@ static bool __acpi_match_device(const struct acpi_device *device,
>  const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
>                                                const struct device *dev)
>  {
> -       const struct acpi_device_id *id = NULL;
> -
> -       __acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL);
> -       return id;
> +       return acpi_match_acpi_device(ids, acpi_companion_match(dev));
>  }
>  EXPORT_SYMBOL_GPL(acpi_match_device);
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 640f1c07c894..641dc4843987 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -707,6 +707,9 @@ extern int acpi_nvs_register(__u64 start, __u64 size);
>  extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
>                                     void *data);
>
> +const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
> +                                                   const struct acpi_device *adev);
> +
>  const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
>                                                const struct device *dev);
>
> @@ -922,6 +925,12 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
>
>  struct acpi_device_id;
>
> +static inline const struct acpi_device_id *acpi_match_acpi_device(
> +       const struct acpi_device_id *ids, const struct acpi_device *adev)
> +{
> +       return NULL;
> +}
> +
>  static inline const struct acpi_device_id *acpi_match_device(
>         const struct acpi_device_id *ids, const struct device *dev)
>  {
> --
> 2.40.0.1.gaa8946217a0b
>

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

* Re: [Acpica-devel] [PATCH v3 2/4] ACPI: bus: Introduce acpi_match_acpi_device() helper
@ 2023-06-29  8:45     ` Rafael J. Wysocki
  0 siblings, 0 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29  8:45 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Rafael J. Wysocki, linux-kernel, Robert Moore,
	linux-acpi, Michael Walle, linux-i2c, acpica-devel, Len Brown

On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> In some cases we can't have a physical node associated with
> the ACPI device. Yet we want to match it against ID table and
> get respective driver data. Introduce the helper for that.

I think that the problem is really to find a struct acpi_device_id in
a given list matching a given struct acpi_device.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/acpi/bus.c   | 15 +++++++++++----
>  include/linux/acpi.h |  9 +++++++++
>  2 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 20cdfb37da79..ee88bfb60ac2 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -850,6 +850,16 @@ static bool __acpi_match_device(const struct acpi_device *device,
>         return true;
>  }
>
> +const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
> +                                                   const struct acpi_device *adev)
> +{
> +       const struct acpi_device_id *id = NULL;
> +
> +       __acpi_match_device(adev, ids, NULL, &id, NULL);
> +       return id;
> +}
> +EXPORT_SYMBOL_GPL(acpi_match_acpi_device);

This is fine, but it requires a kerneldoc comment (as an exported function).

Of course, the code in scan.c can use it even if it is not exported.

> +
>  /**
>   * acpi_match_device - Match a struct device against a given list of ACPI IDs
>   * @ids: Array of struct acpi_device_id object to match against.
> @@ -864,10 +874,7 @@ static bool __acpi_match_device(const struct acpi_device *device,
>  const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
>                                                const struct device *dev)
>  {
> -       const struct acpi_device_id *id = NULL;
> -
> -       __acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL);
> -       return id;
> +       return acpi_match_acpi_device(ids, acpi_companion_match(dev));
>  }
>  EXPORT_SYMBOL_GPL(acpi_match_device);
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 640f1c07c894..641dc4843987 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -707,6 +707,9 @@ extern int acpi_nvs_register(__u64 start, __u64 size);
>  extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
>                                     void *data);
>
> +const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
> +                                                   const struct acpi_device *adev);
> +
>  const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
>                                                const struct device *dev);
>
> @@ -922,6 +925,12 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
>
>  struct acpi_device_id;
>
> +static inline const struct acpi_device_id *acpi_match_acpi_device(
> +       const struct acpi_device_id *ids, const struct acpi_device *adev)
> +{
> +       return NULL;
> +}
> +
>  static inline const struct acpi_device_id *acpi_match_device(
>         const struct acpi_device_id *ids, const struct device *dev)
>  {
> --
> 2.40.0.1.gaa8946217a0b
>

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

* Re: [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
  2023-06-26 11:00   ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-29  8:49     ` Rafael J. Wysocki
  -1 siblings, 0 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29  8:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, linux-acpi, linux-kernel, linux-i2c,
	acpica-devel, Rafael J. Wysocki, Len Brown, Andi Shyti,
	Robert Moore, Michael Walle

On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> acpi_companion_match() doesn't alter the contents of the passed
> parameter, so we don't expect that returned value can be altered
> either. So constify it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

This makes sense even without the rest of the series, so I can queue
it up right away if you want me to do that.

> ---
>  drivers/acpi/bus.c          | 6 +++---
>  drivers/acpi/device_sysfs.c | 2 +-
>  drivers/acpi/internal.h     | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index e3e0bd0c5a50..20cdfb37da79 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -682,7 +682,7 @@ bool acpi_device_is_first_physical_node(struct acpi_device *adev,
>   * resources available from it but they will be matched normally using functions
>   * provided by their bus types (and analogously for their modalias).
>   */
> -struct acpi_device *acpi_companion_match(const struct device *dev)
> +const struct acpi_device *acpi_companion_match(const struct device *dev)
>  {
>         struct acpi_device *adev;
>
> @@ -706,7 +706,7 @@ struct acpi_device *acpi_companion_match(const struct device *dev)
>   * identifiers and a _DSD object with the "compatible" property, use that
>   * property to match against the given list of identifiers.
>   */
> -static bool acpi_of_match_device(struct acpi_device *adev,
> +static bool acpi_of_match_device(const struct acpi_device *adev,
>                                  const struct of_device_id *of_match_table,
>                                  const struct of_device_id **of_id)
>  {
> @@ -808,7 +808,7 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id,
>         return true;
>  }
>
> -static bool __acpi_match_device(struct acpi_device *device,
> +static bool __acpi_match_device(const struct acpi_device *device,
>                                 const struct acpi_device_id *acpi_ids,
>                                 const struct of_device_id *of_ids,
>                                 const struct acpi_device_id **acpi_id,
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 0fbfbaa8d8e3..b9bbf0746199 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -283,7 +283,7 @@ int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
>  }
>  EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
>
> -static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
> +static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
>  {
>         int len, count;
>
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 50dcb35c9965..f4148dc50b9c 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -121,7 +121,7 @@ int acpi_bus_register_early_device(int type);
>  /* --------------------------------------------------------------------------
>                       Device Matching and Notification
>     -------------------------------------------------------------------------- */
> -struct acpi_device *acpi_companion_match(const struct device *dev);
> +const struct acpi_device *acpi_companion_match(const struct device *dev);
>  int __acpi_device_uevent_modalias(const struct acpi_device *adev,
>                                   struct kobj_uevent_env *env);
>
> --
> 2.40.0.1.gaa8946217a0b
>

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

* Re: [Acpica-devel] [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
@ 2023-06-29  8:49     ` Rafael J. Wysocki
  0 siblings, 0 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29  8:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Rafael J. Wysocki, linux-kernel, Robert Moore,
	linux-acpi, Michael Walle, linux-i2c, acpica-devel, Len Brown

On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> acpi_companion_match() doesn't alter the contents of the passed
> parameter, so we don't expect that returned value can be altered
> either. So constify it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

This makes sense even without the rest of the series, so I can queue
it up right away if you want me to do that.

> ---
>  drivers/acpi/bus.c          | 6 +++---
>  drivers/acpi/device_sysfs.c | 2 +-
>  drivers/acpi/internal.h     | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index e3e0bd0c5a50..20cdfb37da79 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -682,7 +682,7 @@ bool acpi_device_is_first_physical_node(struct acpi_device *adev,
>   * resources available from it but they will be matched normally using functions
>   * provided by their bus types (and analogously for their modalias).
>   */
> -struct acpi_device *acpi_companion_match(const struct device *dev)
> +const struct acpi_device *acpi_companion_match(const struct device *dev)
>  {
>         struct acpi_device *adev;
>
> @@ -706,7 +706,7 @@ struct acpi_device *acpi_companion_match(const struct device *dev)
>   * identifiers and a _DSD object with the "compatible" property, use that
>   * property to match against the given list of identifiers.
>   */
> -static bool acpi_of_match_device(struct acpi_device *adev,
> +static bool acpi_of_match_device(const struct acpi_device *adev,
>                                  const struct of_device_id *of_match_table,
>                                  const struct of_device_id **of_id)
>  {
> @@ -808,7 +808,7 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id,
>         return true;
>  }
>
> -static bool __acpi_match_device(struct acpi_device *device,
> +static bool __acpi_match_device(const struct acpi_device *device,
>                                 const struct acpi_device_id *acpi_ids,
>                                 const struct of_device_id *of_ids,
>                                 const struct acpi_device_id **acpi_id,
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 0fbfbaa8d8e3..b9bbf0746199 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -283,7 +283,7 @@ int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
>  }
>  EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
>
> -static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
> +static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
>  {
>         int len, count;
>
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 50dcb35c9965..f4148dc50b9c 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -121,7 +121,7 @@ int acpi_bus_register_early_device(int type);
>  /* --------------------------------------------------------------------------
>                       Device Matching and Notification
>     -------------------------------------------------------------------------- */
> -struct acpi_device *acpi_companion_match(const struct device *dev);
> +const struct acpi_device *acpi_companion_match(const struct device *dev);
>  int __acpi_device_uevent_modalias(const struct acpi_device *adev,
>                                   struct kobj_uevent_env *env);
>
> --
> 2.40.0.1.gaa8946217a0b
>

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

* Re: [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
  2023-06-29  8:49     ` [Acpica-devel] " Rafael J. Wysocki
@ 2023-06-29  9:08       ` Andy Shevchenko
  -1 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-29  9:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J. Wysocki, linux-acpi, linux-kernel, linux-i2c,
	acpica-devel, Len Brown, Andi Shyti, Robert Moore, Michael Walle

On Thu, Jun 29, 2023 at 10:49:17AM +0200, Rafael J. Wysocki wrote:
> On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > acpi_companion_match() doesn't alter the contents of the passed
> > parameter, so we don't expect that returned value can be altered
> > either. So constify it.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> This makes sense even without the rest of the series, so I can queue
> it up right away if you want me to do that.

Please, go ahead and thank you!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [Acpica-devel] [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
@ 2023-06-29  9:08       ` Andy Shevchenko
  0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2023-06-29  9:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andi Shyti, Rafael J. Wysocki, linux-kernel, Robert Moore,
	linux-acpi, Michael Walle, linux-i2c, acpica-devel, Len Brown

On Thu, Jun 29, 2023 at 10:49:17AM +0200, Rafael J. Wysocki wrote:
> On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > acpi_companion_match() doesn't alter the contents of the passed
> > parameter, so we don't expect that returned value can be altered
> > either. So constify it.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> This makes sense even without the rest of the series, so I can queue
> it up right away if you want me to do that.

Please, go ahead and thank you!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
  2023-06-29  9:08       ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-29  9:43         ` Rafael J. Wysocki
  -1 siblings, 0 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29  9:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, Rafael J. Wysocki, linux-acpi, linux-kernel,
	linux-i2c, acpica-devel, Len Brown, Andi Shyti, Robert Moore,
	Michael Walle

On Thu, Jun 29, 2023 at 11:08 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Jun 29, 2023 at 10:49:17AM +0200, Rafael J. Wysocki wrote:
> > On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > acpi_companion_match() doesn't alter the contents of the passed
> > > parameter, so we don't expect that returned value can be altered
> > > either. So constify it.
> > >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > This makes sense even without the rest of the series, so I can queue
> > it up right away if you want me to do that.
>
> Please, go ahead and thank you!

Done, thanks!

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

* Re: [Acpica-devel] [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
@ 2023-06-29  9:43         ` Rafael J. Wysocki
  0 siblings, 0 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29  9:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Rafael J. Wysocki, linux-kernel, Robert Moore,
	linux-acpi, Michael Walle, linux-i2c, acpica-devel, Len Brown

On Thu, Jun 29, 2023 at 11:08 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Jun 29, 2023 at 10:49:17AM +0200, Rafael J. Wysocki wrote:
> > On Mon, Jun 26, 2023 at 1:00 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > acpi_companion_match() doesn't alter the contents of the passed
> > > parameter, so we don't expect that returned value can be altered
> > > either. So constify it.
> > >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > This makes sense even without the rest of the series, so I can queue
> > it up right away if you want me to do that.
>
> Please, go ahead and thank you!

Done, thanks!

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

* Re: [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
  2023-06-26 11:00   ` [Acpica-devel] " Andy Shevchenko
@ 2023-06-29 15:52     ` Andi Shyti
  -1 siblings, 0 replies; 22+ messages in thread
From: Andi Shyti @ 2023-06-29 15:52 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, linux-acpi, linux-kernel, linux-i2c,
	acpica-devel, Rafael J. Wysocki, Len Brown, Robert Moore,
	Michael Walle

Hi Andy,

On Mon, Jun 26, 2023 at 02:00:23PM +0300, Andy Shevchenko wrote:
> acpi_companion_match() doesn't alter the contents of the passed
> parameter, so we don't expect that returned value can be altered
> either. So constify it.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I guess I'm late for adding my

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

here.

Andi

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

* Re: [Acpica-devel] [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value
@ 2023-06-29 15:52     ` Andi Shyti
  0 siblings, 0 replies; 22+ messages in thread
From: Andi Shyti @ 2023-06-29 15:52 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, linux-kernel, Robert Moore, linux-acpi,
	Michael Walle, linux-i2c, acpica-devel, Len Brown

Hi Andy,

On Mon, Jun 26, 2023 at 02:00:23PM +0300, Andy Shevchenko wrote:
> acpi_companion_match() doesn't alter the contents of the passed
> parameter, so we don't expect that returned value can be altered
> either. So constify it.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I guess I'm late for adding my

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

here.

Andi

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

* Re: [PATCH v3 3/4] ACPI: platform: Ignore SMB0001 only when it has resources
  2023-06-26 11:00   ` Andy Shevchenko
@ 2023-06-29 16:00     ` Andi Shyti
  -1 siblings, 0 replies; 22+ messages in thread
From: Andi Shyti @ 2023-06-29 15:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, linux-acpi, linux-kernel, linux-i2c,
	acpica-devel, Rafael J. Wysocki, Len Brown, Robert Moore,
	Michael Walle

Hi Andy,

On Mon, Jun 26, 2023 at 02:00:25PM +0300, Andy Shevchenko wrote:
> After switching i2c-scmi driver to be a platform one, it stopped
> being enumerated on number of Kontron platforms, because it's
> listed in the forbidden_id_list.
> 
> To resolve the situation, add a flag to driver data to allow devices
> with no resources in _CRS to be enumerated via platform bus.
> 
> Fixes: 03d4287add6e ("i2c: scmi: Convert to be a platform driver")
> Closes: https://lore.kernel.org/r/60c1756765b9a3f1eab0dcbd84f59f00fe1caf48.camel@kontron.com
> Link: https://lore.kernel.org/r/20230621151652.79579-1-andriy.shevchenko@linux.intel.com
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi

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

* Re: [Acpica-devel] [PATCH v3 3/4] ACPI: platform: Ignore SMB0001 only when it has resources
@ 2023-06-29 16:00     ` Andi Shyti
  0 siblings, 0 replies; 22+ messages in thread
From: Andi Shyti @ 2023-06-29 16:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, linux-kernel, Robert Moore, linux-acpi,
	Michael Walle, linux-i2c, acpica-devel, Len Brown

Hi Andy,

On Mon, Jun 26, 2023 at 02:00:25PM +0300, Andy Shevchenko wrote:
> After switching i2c-scmi driver to be a platform one, it stopped
> being enumerated on number of Kontron platforms, because it's
> listed in the forbidden_id_list.
> 
> To resolve the situation, add a flag to driver data to allow devices
> with no resources in _CRS to be enumerated via platform bus.
> 
> Fixes: 03d4287add6e ("i2c: scmi: Convert to be a platform driver")
> Closes: https://lore.kernel.org/r/60c1756765b9a3f1eab0dcbd84f59f00fe1caf48.camel@kontron.com
> Link: https://lore.kernel.org/r/20230621151652.79579-1-andriy.shevchenko@linux.intel.com
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi

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

end of thread, other threads:[~2023-06-29 16:00 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 11:00 [PATCH v3 0/4] ACPI: platform: Fix SMB0001 enumeration on Kontron devices Andy Shevchenko
2023-06-26 11:00 ` [Acpica-devel] " Andy Shevchenko
2023-06-26 11:00 ` [Acpica-devel] [PATCH v3 2/4] ACPI: bus: Introduce acpi_match_acpi_device() helper Andy Shevchenko
2023-06-26 11:00   ` Andy Shevchenko
2023-06-29  8:44   ` Rafael J. Wysocki
2023-06-29  8:45     ` [Acpica-devel] " Rafael J. Wysocki
2023-06-26 11:00 ` [Acpica-devel] [PATCH v3 4/4] ACPI: platform: Move SMB0001 HID to the header and reuse Andy Shevchenko
2023-06-26 11:00   ` Andy Shevchenko
2023-06-26 11:00 ` [Acpica-devel] [PATCH v3 3/4] ACPI: platform: Ignore SMB0001 only when it has resources Andy Shevchenko
2023-06-26 11:00   ` Andy Shevchenko
2023-06-29 15:59   ` Andi Shyti
2023-06-29 16:00     ` [Acpica-devel] " Andi Shyti
2023-06-26 11:00 ` [PATCH v3 1/4] ACPI: bus: Constify acpi_companion_match() returned value Andy Shevchenko
2023-06-26 11:00   ` [Acpica-devel] " Andy Shevchenko
2023-06-29  8:49   ` Rafael J. Wysocki
2023-06-29  8:49     ` [Acpica-devel] " Rafael J. Wysocki
2023-06-29  9:08     ` Andy Shevchenko
2023-06-29  9:08       ` [Acpica-devel] " Andy Shevchenko
2023-06-29  9:43       ` Rafael J. Wysocki
2023-06-29  9:43         ` [Acpica-devel] " Rafael J. Wysocki
2023-06-29 15:52   ` Andi Shyti
2023-06-29 15:52     ` [Acpica-devel] " Andi Shyti

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.