Introduce acpi_match_device_id().
RFC PATCH 1/6 Introduce acpi_match_device_id().
Quoted 1 line
From
72df5d1f51fb27a4ba7f70a3b07df759d32b8288Mon Sep 17 00:00:00 2001
From: Zhang Rui <[email protected]>
Date: Thu, 27 Sep 2012 15:11:55 +0800
Subject: [RFC PATCH 1/6] Introduce acpi_match_device_id().
This API is used to check if a device id string is compatible with an ACPI device,
either PNP id exported via _HID or compatible ids exported via _CID control method.
--- drivers/acpi/scan.c | 22 ++++++++++++++++++++++ include/acpi/acpi_bus.h | 6 ++++++ 2 files changed, 28 insertions(+), 0 deletions(-)
drivers/acpi/scan.c +22 -0
@@ -312,6 +312,28 @@ int acpi_match_device_ids(struct acpi_device *device, }EXPORT_SYMBOL (acpi_match_device_ids); +int acpi_match_device_id (const struct device *dev,const char *id) +{ +acpi_handle handle =DEVICE_ACPI_HANDLE (dev); +struct acpi_device *device; +struct acpi_hardware_id *hwid; +acpi_status status; + +if (!handle || !id) +return -ENODEV ; + + status =acpi_bus_get_device (handle, &device); +if (ACPI_FAILURE (status)) +return -ENODEV ; + +list_for_each_entry (hwid, &device->pnp.ids, list) +if (!strcmp (id, hwid->id)) +return 0 ; + +return -ENODEV ; +} +EXPORT_SYMBOL (acpi_match_device_id); +static void acpi_free_ids (struct acpi_device *device) {struct acpi_hardware_id *id, *tmp;
include/acpi/acpi_bus.h +6 -0
@@ -378,6 +378,7 @@ int acpi_bus_start(struct acpi_device *device);acpi_status acpi_bus_get_ejd (acpi_handle handle,acpi_handle * ejd);int acpi_match_device_ids (struct acpi_device *device,const struct acpi_device_id *ids); +int acpi_match_device_id (const struct device *,const char *);int acpi_create_dir (struct acpi_device *);void acpi_remove_dir (struct acpi_device *);
@@ -448,6 +449,11 @@ static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable)static inline int register_acpi_bus_type (void *bus) {return 0 ; }static inline int unregister_acpi_bus_type (void *bus) {return 0 ; } +static inline int acpi_match_device_id (const struct device *device, +const char *name) +{ +return -ENODEV ; +}#endif /* CONFIG_ACPI */
Signature · 1 line
1.7.7.6
Quoted 21 lines · Zhang Rui
Quoted 1 line
From
72df5d1f51fb27a4ba7f70a3b07df759d32b8288Mon Sep 17 00:00:00 2001From: Zhang Rui <[email protected]>
Date: Thu, 27 Sep 2012 15:11:55 +0800
Subject: [RFC PATCH 1/6] Introduceacpi_match_device_id().This API is used to check if a device id string is compatible with an ACPI device,
either PNP id exported via_HIDor compatible ids exported via_CIDcontrol method.Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/scan.c | 22 ++++++++++++++++++++++ include/acpi/acpi_bus.h | 6 ++++++ 2 files changed, 28 insertions(+), 0 deletions(-)drivers/acpi/scan.c +0
-0
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 315
Quoted 4 lines
drivers/acpi/scan.c +1
-0@@ -312,6 +312,28 @@ int acpi_match_device_ids(struct acpi_device *device, }EXPORT_SYMBOL (acpi_match_device_ids); +int acpi_match_device_id (const struct device *dev,const char *id)
Would be good idea to implement this in terms of of_match_device() so that it returns pointer to the matched id. This way drivers can get the ->driver_data pretty easily if needed.
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 317
Quoted 2 lines
drivers/acpi/scan.c +2
-0+{ +acpi_handle handle =DEVICE_ACPI_HANDLE (dev);
If the device is not bound to an ACPI handle this will return NULL. And I don't see you doing that in this series meaning that..
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 323
Quoted 6 lines
drivers/acpi/scan.c +6
-0+struct acpi_device *device; +struct acpi_hardware_id *hwid; +acpi_status status; + +if (!handle || !id) +return -ENODEV ;
..you always return -ENODEV here, right?
Quoted 12 lines
drivers/acpi/scan.c +12
-0+ + status =acpi_bus_get_device (handle, &device); +if (ACPI_FAILURE (status)) +return -ENODEV ; + +list_for_each_entry (hwid, &device->pnp.ids, list) +if (!strcmp (id, hwid->id)) +return 0 ; + +return -ENODEV ; +} +EXPORT_SYMBOL (acpi_match_device_id);
Quoted 35 lines
-----Original Message-----
From: Mika Westerberg [mailto:mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]]
Sent: Friday, September 28, 2012 10:14 PM
To: Zhang, Rui
Cc: LKML; linux-pm; linux-i2c; [email protected]; Len, Brown; Rafael J. Wysocki; Grant Likely; Dirk Brandewie
Subject: Re: [RFC PATCH 1/6] Introduceacpi_match_device_id().
Importance: HighQuoted 23 lines · Zhang Rui
Quoted 2 lines
From
72df5d1f51fb27a4ba7f70a3b07df759d32b8288Mon Sep 17 00:00:00 2001From: Zhang Rui <[email protected]>
Date: Thu, 27 Sep 2012 15:11:55 +0800
Subject: [RFC PATCH 1/6] Introduceacpi_match_device_id().This API is used to check if a device id string is compatible with an ACPI device, either PNP id exported via
_HIDor compatible ids exported via_CIDcontrol method.Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/scan.c | 22 ++++++++++++++++++++++ include/acpi/acpi_bus.h | 6 ++++++ 2 files changed, 28 insertions(+), 0 deletions(-)drivers/acpi/scan.c index renamed from drivers/acpi/scan.c +0
-0d1ecca2..936a7c9 100644
drivers/acpi/scan.c +0
-0@@ -312,6 +312,28 @@ int acpi_match_device_ids(struct acpi_device *device, } EXPORT_SYMBOL(acpi_match_device_ids);
Quoted 6 lines
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 315
Quoted 1 line
drivers/acpi/scan.c +1
-0+int acpi_match_device_id (const struct device *dev,const char *id)Would be good idea to implement this in terms of
of_match_device()so that it returns pointer to the matched id. This way drivers can get the ->driver_data pretty easily if needed.
Good idea.
Will do that in v2.
Quoted 6 lines
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 317
Quoted 2 lines
drivers/acpi/scan.c +2
-0+{ +acpi_handle handle =DEVICE_ACPI_HANDLE (dev);If the device is not bound to an ACPI handle this will return NULL. And I don't see you doing that in this series meaning that..
You're right, I should set pdev->archdata.acpi_handle to the I2C controller in i2c_root.c.
Thanks,
rui
Quoted 11 lines · Rui
Quoted 7 lines
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 317
Quoted 3 lines
drivers/acpi/scan.c +2
-0+{ +acpi_handle handle =DEVICE_ACPI_HANDLE (dev);If the device is not bound to an ACPI handle this will return NULL. And I don't see you doing that in this series meaning that..
You're right, I should set
pdev->archdata.acpi_handleto the I2C controller ini2c_root.c.
There already is an API for that - check drivers/acpi/glue.c.
Quoted 21 lines
-----Original Message-----
From: Mika Westerberg [mailto:mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]]
Sent: Monday, October 01, 2012 2:38 PM
To: Zhang, Rui
Cc: LKML; linux-pm; linux-i2c; [email protected]; Len, Brown; Rafael J. Wysocki; Grant Likely; Dirk Brandewie
Subject: Re: [RFC PATCH 1/6] Introduceacpi_match_device_id().
Importance: HighQuoted 9 lines · Rui
Quoted 7 lines
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 317
Quoted 3 lines
drivers/acpi/scan.c +2
-0+{ +acpi_handle handle =DEVICE_ACPI_HANDLE (dev);If the device is not bound to an ACPI handle this will return NULL. And I don't see you doing that in this series meaning that..
Quoted 4 lines
Quoted 2 lines
You're right, I should set
pdev->archdata.acpi_handleto the I2C controller ini2c_root.c.There already is an API for that - check
drivers/acpi/glue.c.
Do you mean acpi_bind?acpi_bind_one will bind the physical device node to the ACPI device, But for the i2c controller ACPI device, the physical node is the I2C adapter in the I2C bus.
If we introduce I2C bus ACPI binding, which is what we're doing now, the i2c_adapter->dev.archdata.acpi_handle will be set to the ACPI i2c controller handle by acpi_bind_one.
Thanks,
rui
Quoted 21 lines · Rui
Quoted 21 lines
-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]
Sent: Monday, October 01, 2012 2:38 PM
To: Zhang, Rui
Cc: LKML; linux-pm; linux-i2c; [email protected]; Len, Brown; Rafael J. Wysocki; Grant Likely; Dirk Brandewie
Subject: Re: [RFC PATCH 1/6] Introduceacpi_match_device_id().
Importance: HighQuoted 9 lines · Rui
Quoted 7 lines
drivers/acpi/scan.c int acpi_match_device_ids(struct acpi_device *device, · line 317
Quoted 3 lines
drivers/acpi/scan.c +2
-0+{ +acpi_handle handle =DEVICE_ACPI_HANDLE (dev);If the device is not bound to an ACPI handle this will return NULL. And I don't see you doing that in this series meaning that..
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
You're right, I should set
pdev->archdata.acpi_handleto the I2C controller ini2c_root.c.There already is an API for that - check
drivers/acpi/glue.c.Do you mean
acpi_bind?
No, I mean register_acpi_bus_type(). You can see an example of this looking PCI, USB, .., drivers.