ACPI enumeration support for i2c mux clients
Subsystems (3)
cover ACPI enumeration support for i2c mux clients
Added ACPI enumeration support for i2c mux clients.
Please let me know your review comments.
Kuppuswamy Sathyanarayanan (1):
i2c: Add acpi support to enumerate i2c mux clients
drivers/i2c/i2c-core.c | 3 ++- drivers/i2c/i2c-mux.c | 26 ++++++++++++++++++++++++++ include/linux/i2c.h | 5 +++++ 3 files changed, 33 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): cover.1428546834.git.sathyanarayanan.kuppuswamy-VuQAYsv1563Yd54FQh9/[email protected]
PATCH 1/1 i2c: Add acpi support to enumerate i2c mux clients
Added support to enumerate i2c mux clients via ACPI.
Currently we don't have any fixed way for enumerating mux clients via acpi. This patch adds support to scan for all client i2c devices under the mux device in DSDT table and enumerate them in order.
--- drivers/i2c/i2c-core.c | 3 ++- drivers/i2c/i2c-mux.c | 26 ++++++++++++++++++++++++++ include/linux/i2c.h | 5 +++++ 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core.c +2 -1
@@ -118,7 +118,7 @@ static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)return 1 ; } -static acpi_status acpi_i2c_add_device (acpi_handle handle,u32 level, +acpi_status acpi_i2c_add_device (acpi_handle handle,u32 level,void *data,void **return_value) {struct i2c_adapter *adapter = data;
@@ -155,6 +155,7 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,return AE_OK ; } +EXPORT_SYMBOL_GPL (acpi_i2c_add_device);/** * acpi_i2c_register_devices - enumerate I2C slave devices behind adapter
drivers/i2c/i2c-mux.c +26 -0
@@ -100,6 +100,29 @@ static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent)return class; } +#ifdef CONFIG_ACPI +static void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) +{ +acpi_handle handle; +acpi_status status; + + handle =ACPI_HANDLE (mux_dev); +if (!handle) +return ; + + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + acpi_i2c_add_device,NULL , + adap,NULL ); + +if (ACPI_FAILURE (status)) +dev_warn (mux_dev,"mux adapter slave enumeration fails\n" ); +} +#else /* !CONFIG_ACPI */ +static inline void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) { } +#endif /* CONFIG_ACPI */ + struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, struct device *mux_dev, void *mux_priv, u32 force_nr, u32 chan_id,
@@ -193,6 +216,9 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,dev_info (&parent->dev,"Added multiplexed i2c bus %d\n" ,i2c_adapter_id (&priv->adap)); +/* scan for mux clients */ +acpi_i2c_mux_register_devices (&priv->adap, mux_dev); +return &priv->adap; }EXPORT_SYMBOL_GPL (i2c_add_mux_adapter);
include/linux/i2c.h +5 -0
@@ -33,6 +33,7 @@#include <linux/of.h> /* for struct device_node */ #include <linux/swab.h> /* for swab16 */ #include <uapi/linux/i2c.h> +#include <linux/acpi.h> extern struct bus_type i2c_bus_type;extern struct device_type i2c_adapter_type;
@@ -608,4 +609,8 @@ static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node }#endif /* CONFIG_OF */ +#ifdef CONFIG_ACPI +extern acpi_status acpi_i2c_add_device (acpi_handle handle,u32 level, +void *data,void **return_value); +#endif /* CONFIG_ACPI */ #endif /* _LINUX_I2C_H */
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): b57c66fc1b7e790bd8c3e525faf65ce46cd91f23.1428546834.git.sathyanarayanan.kuppuswamy-VuQAYsv1563Yd54FQh9/[email protected]
Mika Westerberg
Reviewed-byRe: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
Quoted 10 lines · Kuppuswamy Sathyanarayanan
Added support to enumerate i2c mux clients via ACPI.
Currently we don't have any fixed way for enumerating mux clients via acpi. This patch adds support to scan for all client i2c devices under the mux device in DSDT table and enumerate them in order.
From ACPI standpoint I don't see problems with this code.
A message that is not in the archive (sent off-list or not yet received): 20150410084208.GR1734-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org
Re: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
Thanks Mika.
Quoted 13 lines · Mika Westerberg
Quoted 9 lines · Kuppuswamy Sathyanarayanan
Added support to enumerate i2c mux clients via ACPI.
Currently we don't have any fixed way for enumerating mux clients via acpi. This patch adds support to scan for all client i2c devices under the mux device in DSDT table and enumerate them in order.
From ACPI standpoint I don't see problems with this code.
Signature · 3 lines
-- Sathyanarayanan KN Android Kernel Developer
Re: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
In reply to a message not in the archiveping.
Quoted 13 lines · Mika Westerberg
Quoted 9 lines · Kuppuswamy Sathyanarayanan
Added support to enumerate i2c mux clients via ACPI.
Currently we don't have any fixed way for enumerating mux clients via acpi. This patch adds support to scan for all client i2c devices under the mux device in DSDT table and enumerate them in order.
From ACPI standpoint I don't see problems with this code.
Signature · 2 lines
Sathyanarayanan Kuppuswamy Android kernel developer
Re: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
In reply to a message not in the archivegentle ping.
Quoted 13 lines · Mika Westerberg
Quoted 9 lines · Kuppuswamy Sathyanarayanan
Added support to enumerate i2c mux clients via ACPI.
Currently we don't have any fixed way for enumerating mux clients via acpi. This patch adds support to scan for all client i2c devices under the mux device in DSDT table and enumerate them in order.
From ACPI standpoint I don't see problems with this code.
Signature · 2 lines
Sathyanarayanan Kuppuswamy Android kernel developer
Re: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
In reply to a message not in the archiveQuoted 12 lines
drivers/i2c/i2c-mux.c +12
-0+#ifdef CONFIG_ACPI +static void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) +{ +acpi_handle handle; +acpi_status status; + + handle =ACPI_HANDLE (mux_dev); +if (!handle) +return ; + + status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
drivers/i2c/i2c-mux.c static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent) · line 124
Quoted 10 lines
drivers/i2c/i2c-mux.c +10
-0+ acpi_i2c_add_device,NULL , + adap, NULL); + +if (ACPI_FAILURE (status)) + dev_warn(mux_dev, "mux adapter slave enumeration fails\n"); +} +#else /* !CONFIG_ACPI */ +static inline void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) { } +#endif /* CONFIG_ACPI */
IMO, this shares too much code with acpi_i2c_register_devices(). And it pulls in ACPI into mux.c which is not really needed.
What about naming the above function acpi_i2c_register_devices_from_dev() and let acpi_i2c_register_devices() then call it as a helper function, all this in i2c-core.c?
Thanks for your patience BTW...
Re: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
Hi Sang
Thanks for your comments. Please find my reply inline.
Quoted 16 lines · Wolfram Sang
Quoted 16 lines
drivers/i2c/i2c-mux.c +16
-0+#ifdef CONFIG_ACPI +static void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) +{ +acpi_handle handle; +acpi_status status; + + handle =ACPI_HANDLE (mux_dev); +if (!handle) +return ; + + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + acpi_i2c_add_device,NULL , + adap,NULL ); + +if (ACPI_FAILURE (status))
Quoted 8 lines
drivers/i2c/i2c-mux.c static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent) · line 124
Quoted 6 lines
drivers/i2c/i2c-mux.c +6
-0+ dev_warn(mux_dev, "mux adapter slave enumeration fails\n"); +} +#else /* !CONFIG_ACPI */ +static inline void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) { } +#endif /* CONFIG_ACPI */ IMO, this shares too much code with
acpi_i2c_register_devices(). And it pulls in ACPI intomux.cwhich is not really needed.
Even though mux is a just a virtual adapter without any ACPI ID, Its slaves are a still actual devices and needs to be enumerated by ACPI. So think its accptable to include ACPI in mux code. Don't you agree ?
Also ACPI handle code in this function is slightly different from acpi_i2c_register_devices() code.
Quoted 3 lines
What about naming the above function
acpi_i2c_register_devices_from_dev()and letacpi_i2c_register_devices()
If you call this function from i2c-core register device function, then how will you maintain the hierarchy ? We need some way to indicate that these devices are under mux adapter right ?
Quoted 4 lines
then call it as a helper function, all this in
i2c-core.c?Thanks for your patience BTW...
Signature · 2 lines
Sathyanarayanan Kuppuswamy Android kernel developer
A message that is not in the archive (sent off-list or not yet received): 556E4C7C.8050009-VuQAYsv1563Yd54FQh9/[email protected]
Re: [PATCH v1 1/1] i2c: Add acpi support to enumerate i2c mux clients
Quoted 29 lines · sathyanarayanan kuppuswamy
Hi Sang
Thanks for your comments. Please find my reply inline.
Quoted 16 lines · Wolfram Sang
Quoted 16 lines
drivers/i2c/i2c-mux.c +16
-0+#ifdef CONFIG_ACPI +static void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) +{ +acpi_handle handle; +acpi_status status; + + handle =ACPI_HANDLE (mux_dev); +if (!handle) +return ; + + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + acpi_i2c_add_device,NULL , + adap,NULL ); + +if (ACPI_FAILURE (status))Quoted 8 lines
drivers/i2c/i2c-mux.c static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent) · line 124
Quoted 6 lines
drivers/i2c/i2c-mux.c +6
-0+ dev_warn(mux_dev, "mux adapter slave enumeration fails\n"); +} +#else /* !CONFIG_ACPI */ +static inline void acpi_i2c_mux_register_devices (struct i2c_adapter *adap, +struct device *mux_dev) { } +#endif /* CONFIG_ACPI */ IMO, this shares too much code with
acpi_i2c_register_devices(). And it pulls in ACPI intomux.cwhich is not really needed.
Quoted 3 lines
Even though mux is a just a virtual adapter without any ACPI ID, Its slaves are a still actual devices and needs to be enumerated by ACPI. So think its accptable to include ACPI in mux code. Don't you agree ?
The resulting function should be called from mux code. But the function itself should be in the core.
Quoted 2 lines
Also ACPI handle code in this function is slightly different from
acpi_i2c_register_devices()code.
The only difference I see is that one takes a device as parameter, the other an adapter. So, you can read out the device from the adapter in acpi_i2c_register_devices() and then call acpi_i2c_register_devices_from_dev().