Enable named interrupt smbus-alert for ACPI
Subsystems (6)
v2 cover Enable named interrupt smbus-alert for ACPI
I2C - SMBus core drivers use named interrupts to support smbus_alert. As named interrupts are not available for ACPI based systems, it was required to change the i2c bus controller driver if to use smbus alert. These patches provide option for named interrupts in ACPI and make the implementation similar to DT. This will enable use of interrupt named 'smbus-alert' in ACPI as well which will be taken during i2c adapter register.
v1->v2:
* Added firmware guide documentation for ACPI named interrupts
* Updates in function description comments
Akhil R (3):
device property: Add device_irq_get_byname
docs: firmware-guide: ACPI: Add named interrupt doc
i2c: smbus: Use device_*() functions instead of of_*()
Documentation/firmware-guide/acpi/enumeration.rst | 38 +++++++++++++++++++++++ drivers/base/property.c | 35 +++++++++++++++++++++ drivers/i2c/i2c-core-base.c | 2 +- drivers/i2c/i2c-core-smbus.c | 10 +++--- drivers/i2c/i2c-smbus.c | 2 +- include/linux/i2c-smbus.h | 6 ++-- include/linux/property.h | 3 ++ 7 files changed, 86 insertions(+), 10 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/3 device property: Add device_irq_get_byname
Get interrupt by name from ACPI table as well.
Add option to use 'interrupt-names' in _DSD which can map to interrupt by index. The implementation is similar to 'interrupt-names' in devicetree. Also add a common routine to get irq by name from devicetree and ACPI table.
--- drivers/base/property.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/property.h | 3 +++ 2 files changed, 38 insertions(+)
drivers/base/property.c +35 -0
@@ -920,6 +920,41 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)EXPORT_SYMBOL (fwnode_irq_get);/** +* fwnode_irq_get_byname - Get IRQ from a fwnode using its name +* @fwnode: Pointer to the firmware node +* @name: IRQ name in interrupt-names property in fwnode +* +* Returns Linux IRQ number on success, errno otherwise. +*/ +int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name) +{ +int index; + +if (unlikely (!name)) +return -EINVAL ; + + index =fwnode_property_match_string (fwnode,"interrupt-names" , name); +if (index <0 ) +return index; + +return fwnode_irq_get (fwnode, index); +} +EXPORT_SYMBOL (fwnode_irq_get_byname); + +/** +* device_irq_get_byname - Get IRQ of a device using interrupt name +* @dev: Device to get the interrupt +* @name: IRQ name in interrupt-names property in fwnode +* +* Returns Linux IRQ number on success, errno otherwise. +*/ +int device_irq_get_byname (struct device *dev,const char *name) +{ +return fwnode_irq_get_byname (dev_fwnode (dev), name); +} +EXPORT_SYMBOL_GPL (device_irq_get_byname); + +/** * fwnode_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node * @prev: Previous endpoint node or %NULL to get the first
include/linux/property.h +3 -0
@@ -121,6 +121,9 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);void fwnode_handle_put (struct fwnode_handle *fwnode);int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index); +int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name); + +int device_irq_get_byname (struct device *dev,const char *name);unsigned int device_get_child_node_count (struct device *dev);
Signature · 1 line
2.7.4
Re: [PATCH v2 1/3] device property: Add device_irq_get_byname
On Wed, Jan 12, 2022 at 4:14 PM Akhil R <[email protected]> wrote:
In the subject line: device_irq_get_byname()
Quoted 1 line
Get interrupt by name from ACPI table as well.
an interrupt
the ACPI
Quoted 1 line
Add option to use 'interrupt-names' in
_DSDwhich can map to interrupt by
can be mappedInterrupt() resource
(The last one is very important to point out this is only about Interrupt() resources for now).
Quoted 1 line
index. The implementation is similar to 'interrupt-names' in devicetree.
the Device Tree
Quoted 1 line
Also add a common routine to get irq by name from devicetree and ACPI
IRQ
Device Tree
Quoted 1 line
table.
...
Quoted 6 lines
/**
+ *fwnode_irq_get_byname- Get IRQ from a fwnode using its name
+ * @fwnode: Pointer to the firmware node
+ * @name: IRQ name in interrupt-names property in fwnode
+ *
+ * Returns Linux IRQ number on success, errno otherwise.
negative errno
drivers/base/property.c int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) · line 933
Quoted 6 lines
+ */
drivers/base/property.c +4
-0+int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name) +{ +int index; +if (unlikely (!name))
Don't use unlikely() here.
Quoted 8 lines
drivers/base/property.c +8
-0+return -EINVAL ; + + index =fwnode_property_match_string (fwnode,"interrupt-names" , name); +if (index <0 ) +return index; + +return fwnode_irq_get (fwnode, index); +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerRe: [PATCH v2 1/3] device property: Add device_irq_get_byname
In reply to Akhil RQuoted 37 lines · Akhil R
Get interrupt by name from ACPI table as well.
Add option to use 'interrupt-names' in
_DSDwhich can map to interrupt by index. The implementation is similar to 'interrupt-names' in devicetree. Also add a common routine to get irq by name from devicetree and ACPI table.Signed-off-by Akhil R <[email protected]>--- drivers/base/property.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/property.h | 3 +++ 2 files changed, 38 insertions(+)drivers/base/property.c +15
-0@@ -920,6 +920,41 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)EXPORT_SYMBOL (fwnode_irq_get);/** +* fwnode_irq_get_byname - Get IRQ from a fwnode using its name +* @fwnode: Pointer to the firmware node +* @name: IRQ name in interrupt-names property in fwnode +* +* Returns Linux IRQ number on success, errno otherwise. +*/ +int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name) +{ +int index; + +if (unlikely (!name)) +return -EINVAL ; + + index =fwnode_property_match_string (fwnode,"interrupt-names" , name); +if (index <0 )
drivers/base/property.c int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) · line 947
Quoted 10 lines
drivers/base/property.c +10
-0+return index; + +return fwnode_irq_get (fwnode, index); +} +EXPORT_SYMBOL (fwnode_irq_get_byname); + +/** +* device_irq_get_byname - Get IRQ of a device using interrupt name +* @dev: Device to get the interrupt +* @name: IRQ name in interrupt-names property in fwnode
Which fwnode?
drivers/base/property.c int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) · line 955
Quoted 8 lines
drivers/base/property.c +8
-0+* +* Returns Linux IRQ number on success, errno otherwise. +*/ +int device_irq_get_byname (struct device *dev,const char *name) +{ +return fwnode_irq_get_byname (dev_fwnode (dev), name); +} +EXPORT_SYMBOL_GPL (device_irq_get_byname);
This can be confusing, because it pretends to be super-generic and in fact it depends on an fwnode to be there.
I guess I'd rather not have it at all, or use a more precise name for it.
Quoted 22 lines
drivers/base/property.c +2
-0+ +/** * fwnode_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node * @prev: Previous endpoint node or %NULL to get the first include/linux/property.h +3
-1@@ -121,6 +121,9 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);void fwnode_handle_put (struct fwnode_handle *fwnode);int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index); +int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name); + +int device_irq_get_byname (struct device *dev,const char *name);unsigned int device_get_child_node_count (struct device *dev); --2.7.4
RE: [PATCH v2 1/3] device property: Add device_irq_get_byname
Quoted 61 lines · Akhil R
Quoted 26 lines
Get interrupt by name from ACPI table as well.
Add option to use 'interrupt-names' in
_DSDwhich can map to interrupt by index. The implementation is similar to 'interrupt-names' in devicetree. Also add a common routine to get irq by name from devicetree and ACPI table.Signed-off-by Akhil R <[email protected]>--- drivers/base/property.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/property.h | 3 +++ 2 files changed, 38 insertions(+)drivers/base/property.c index renamed from drivers/base/property.c +0
-0cbe4fa2..414c316 100644
drivers/base/property.c +4
-0@@ -920,6 +920,41 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) EXPORT_SYMBOL(fwnode_irq_get);/** +* fwnode_irq_get_byname - Get IRQ from a fwnode using its name +* @fwnode: Pointer to the firmware node +* @name: IRQ name in interrupt-names property in fwnode +* drivers/base/property.c int fwnode_irq_get(const struct fwnode_handle · line 936
Quoted 10 lines
drivers/base/property.c +10
-0+* Returns Linux IRQ number on success, errno otherwise. +*/ +int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const +char *name) { +int index; + +if (unlikely (!name)) +return -EINVAL ; + + index = fwnode_property_match_string(fwnode, "interrupt-names",name);
drivers/base/property.c int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) · line 947
Quoted 10 lines
drivers/base/property.c +10
-0+if (index <0 ) +return index; + +return fwnode_irq_get (fwnode, index); } +EXPORT_SYMBOL (fwnode_irq_get_byname); + +/** +* device_irq_get_byname - Get IRQ of a device using interrupt name +* @dev: Device to get the interrupt +* @name: IRQ name in interrupt-names property in fwnode Which fwnode?
drivers/base/property.c int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) · line 955
Quoted 6 lines
drivers/base/property.c +6
-0+* +* Returns Linux IRQ number on success, errno otherwise. +*/ +int device_irq_get_byname (struct device *dev,const char *name) { +return fwnode_irq_get_byname (dev_fwnode (dev), name); } +EXPORT_SYMBOL_GPL (device_irq_get_byname);This can be confusing, because it pretends to be super-generic and in fact it depends on an fwnode to be there.
Quoted 1 line
I guess I'd rather not have it at all, or use a more precise name for it.
But, I suppose, the other device_*() functions also depend on the fwnode. Wouldn't it make the naming inconsistent if we add a different one here? Would it be better if I add more details in the description comment?
PATCH v2 2/3 docs: firmware-guide: ACPI: Add named interrupt doc
In reply to Akhil RAdded details and example for named interrupts in the ACPI Table
--- Documentation/firmware-guide/acpi/enumeration.rst | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Documentation/firmware-guide/acpi/enumeration.rst +38 -0
@@ -143,6 +143,44 @@ In robust cases the client unfortunately needs to call acpi_dma_request_slave_chan_by_index() directly and therefore choose the specific FixedDMA resource by its index. +Named Interrupts +================ + +Drivers with ACPI node can have names to interrupts in ACPI table which +can be used to get the irq number in the driver. + +The interrupt name can be listed in _DSD as 'interrupt-names'. The names +should be listed as an array of strings which will map to the Interrupt +property in ACPI table corresponding to its index. + +The table below shows an example of its usage:: + + Device (DEV0) { + ... + Name (_CRS, ResourceTemplate() { + ... + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { + 0x20, + 0x24 + } + }) + + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"interrupt-names", + Package (2) {"default", "alert"}}, + } + ... + }) + } + +The interrupt name 'default' will correspond to 0x20 in Interrupt property +and 'alert' to 0x24. + +The driver can call the function - device_irq_get_byname with the device +and interrupt name as arguments to get the corresponding irq number. + SPI serial bus support ======================
Signature · 1 line
2.7.4
Re: [PATCH v2 2/3] docs: firmware-guide: ACPI: Add named interrupt doc
On Wed, Jan 12, 2022 at 4:15 PM Akhil R <[email protected]> wrote:
Thanks for doing this, very helpful! My comments below.
Quoted 1 line
Added details and example for named interrupts in the ACPI Table
Table.
...
Documentation/firmware-guide/acpi/enumeration.rst In robust cases the client unfortunately needs to call · line 150
Quoted 5 lines
Documentation/firmware-guide/acpi/enumeration.rst +5
-0+Named Interrupts +================ + +Drivers with ACPI node can have names to interrupts in ACPI table which +can be used to get the irq number in the driver.
IRQ
Documentation/firmware-guide/acpi/enumeration.rst In robust cases the client unfortunately needs to call · line 154
Quoted 3 lines
Documentation/firmware-guide/acpi/enumeration.rst +3
-0+The interrupt name can be listed in _DSD as 'interrupt-names'. The names +should be listed as an array of strings which will map to the Interrupt +property in ACPI table corresponding to its index.
'Interrupt property' --> 'Interrupt() resource'
the ACPI
Quoted 8 lines
Documentation/firmware-guide/acpi/enumeration.rst +8
-0+The table below shows an example of its usage:: + + Device (DEV0) { + ... + Name (_CRS, ResourceTemplate() { + ... + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { + 0x20,
Documentation/firmware-guide/acpi/enumeration.rst In robust cases the client unfortunately needs to call · line 173
Quoted 10 lines
Documentation/firmware-guide/acpi/enumeration.rst +10
-0+ 0x24 + } + }) + + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"interrupt-names", + Package (2) {"default", "alert"}}, + }
Package () {
Package () {
"interrupt-names", Package ()
{"default", "alert"}
},
}Documentation/firmware-guide/acpi/enumeration.rst In robust cases the client unfortunately needs to call · line 173
Quoted 3 lines
Documentation/firmware-guide/acpi/enumeration.rst +3
-0+ ... + }) + }
Please, drop the indentation to just 4 spaces.
Quoted 1 line
+The interrupt name 'default' will correspond to
0x20in Interrupt property
Interrupt() resource
Documentation/firmware-guide/acpi/enumeration.rst In robust cases the client unfortunately needs to call · line 181
Quoted 3 lines
Documentation/firmware-guide/acpi/enumeration.rst +3
-0+and 'alert' to 0x24. + +The driver can call the function - device_irq_get_byname with the device
device_irq_get_byname()
Quoted 1 line
+and interrupt name as arguments to get the corresponding irq number.
IRQ
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 3/3 i2c: smbus: Use device_*() functions instead of of_*()
In reply to Akhil RChange of_*() functions to device_*() for firmware agnostic usage. This allows to have smbus_alert interrupt without any changes in the controller drivers using ACPI table.
--- drivers/i2c/i2c-core-base.c | 2 +- drivers/i2c/i2c-core-smbus.c | 10 +++++----- drivers/i2c/i2c-smbus.c | 2 +- include/linux/i2c-smbus.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/i2c/i2c-core-base.c +1 -1
@@ -1574,7 +1574,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) goto out_list; } - res =of_i2c_setup_smbus_alert (adap); + res =i2c_setup_smbus_alert (adap);if (res) goto out_reg;
drivers/i2c/i2c-core-smbus.c +5 -5
@@ -701,13 +701,13 @@ struct i2c_client *i2c_new_smbus_alert_device(struct i2c_adapter *adapter, }EXPORT_SYMBOL_GPL (i2c_new_smbus_alert_device); -#if IS_ENABLED (CONFIG_I2C_SMBUS ) &&IS_ENABLED (CONFIG_OF ) -int of_i2c_setup_smbus_alert (struct i2c_adapter *adapter) +#if IS_ENABLED (CONFIG_I2C_SMBUS ) +int i2c_setup_smbus_alert (struct i2c_adapter *adapter) {int irq; - irq =of_property_match_string (adapter->dev.of_node,"interrupt-names" , -"smbus_alert" ); + irq =device_property_match_string (adapter->dev.parent,"interrupt-names" , +"smbus_alert" );if (irq == -EINVAL || irq == -ENODATA )return 0 ;else if (irq <0 )
@@ -715,5 +715,5 @@ int of_i2c_setup_smbus_alert(struct i2c_adapter *adapter) return PTR_ERR_OR_ZERO(i2c_new_smbus_alert_device(adapter, NULL)); } -EXPORT_SYMBOL_GPL (of_i2c_setup_smbus_alert); +EXPORT_SYMBOL_GPL (i2c_setup_smbus_alert);#endif
drivers/i2c/i2c-smbus.c +1 -1
@@ -128,7 +128,7 @@ static int smbalert_probe(struct i2c_client *ara,if (setup) { irq = setup->irq; }else { - irq =of_irq_get_byname (adapter->dev.of_node,"smbus_alert" ); + irq =device_irq_get_byname (adapter->dev.parent,"smbus_alert" );if (irq <=0 )return irq; }
include/linux/i2c-smbus.h +3 -3
@@ -30,10 +30,10 @@ struct i2c_client *i2c_new_smbus_alert_device(struct i2c_adapter *adapter, struct i2c_smbus_alert_setup *setup);int i2c_handle_smbus_alert (struct i2c_client *ara); -#if IS_ENABLED (CONFIG_I2C_SMBUS ) &&IS_ENABLED (CONFIG_OF ) -int of_i2c_setup_smbus_alert (struct i2c_adapter *adap); +#if IS_ENABLED (CONFIG_I2C_SMBUS ) +int i2c_setup_smbus_alert (struct i2c_adapter *adap);#else -static inline int of_i2c_setup_smbus_alert (struct i2c_adapter *adap) +static inline int i2c_setup_smbus_alert (struct i2c_adapter *adap) {return 0 ; }
Signature · 1 line
2.7.4
Re: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
Quoted 3 lines · Akhil R
Change of_*() functions to device_*() for firmware agnostic usage. This allows to have
smbus_alertinterrupt without any changes
the smbus_alert
Quoted 1 line
in the controller drivers using ACPI table.
the ACPI
...
This change reveals potential issue:
drivers/i2c/i2c-smbus.c static int smbalert_probe(struct i2c_client *ara, · line 132
Quoted 4 lines
drivers/i2c/i2c-smbus.c +1
-1- irq =of_irq_get_byname (adapter->dev.of_node,"smbus_alert" ); + irq =device_irq_get_byname (adapter->dev.parent,"smbus_alert" );if (irq <=0 )
I guess this '= 0' part should be fixed first.
Quoted 1 line
return irq;
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
Quoted 13 lines · Akhil R
Quoted 3 lines
Change of_*() functions to device_*() for firmware agnostic usage. This allows to have
smbus_alertinterrupt without any changesthe
smbus_alertQuoted 1 line
in the controller drivers using ACPI table.
the ACPI
...
Quoted 8 lines
This change reveals potential issue:
drivers/i2c/i2c-smbus.c static int smbalert_probe(struct i2c_client *ara, · line 132
Quoted 4 lines
drivers/i2c/i2c-smbus.c +1
-1- irq =of_irq_get_byname (adapter->dev.of_node,"smbus_alert" ); + irq =device_irq_get_byname (adapter->dev.parent,"smbus_alert" );if (irq <=0 )I guess this '= 0' part should be fixed first.
'0' is a failure as per the documentation of of_irq_get_byname() as well as of_irq_get(). The case is different for acpi_irq_get(), but it is handled in fwnode_irq_get(). If I understood it right, a return value of '0' should be considered a failure here.
Thanks,
Akhil
Re: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
Quoted 1 line · Akhil R
Quoted 1 line · Akhil R
...
Quoted 5 lines
Quoted 5 lines
This change reveals potential issue:
Quoted 2 lines
drivers/i2c/i2c-smbus.c +1
-1- irq =of_irq_get_byname (adapter->dev.of_node,"smbus_alert" ); + irq =device_irq_get_byname (adapter->dev.parent,"smbus_alert" );
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
if (irq <= 0)I guess this '= 0' part should be fixed first.
'0' is a failure as per the documentation of
of_irq_get_byname()as well asof_irq_get(). The case is different foracpi_irq_get(), but it is handled infwnode_irq_get(). If I understood it right, a return value of '0' should be considered a failure here.
Depends. I have no idea what the original code does here. But returning an error or 0 from this function seems confusing to me.
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
Quoted 12 lines
...
Quoted 4 lines
Quoted 4 lines
This change reveals potential issue:
Quoted 2 lines
(quoted diff) +1
-1- irq = of_irq_get_byname(adapter->dev.of_node, "smbus_alert"); + irq = device_irq_get_byname(adapter->dev.parent,"
smbus_alert");Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
if (irq <= 0)I guess this '= 0' part should be fixed first.
Quoted 8 lines
Quoted 4 lines
'0' is a failure as per the documentation of
of_irq_get_byname()as well asof_irq_get(). The case is different foracpi_irq_get(), but it is handled infwnode_irq_get(). If I understood it right, a return value of '0' should be considered a failure here.Depends. I have no idea what the original code does here. But returning an error or 0 from this function seems confusing to me.
The description in of_irq_get*() says -
/* Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or
* -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
* of any other failure.
*/
As I see from the code of fwnode_irq_get(), which is used in this case, returns either the return value of of_irq_get() or error code from acpi_irq_get() when it fails, or res.start if it didn't fail. I guess, any of these would not be 0 unless there is an error.
Thanks,
Akhil
Re: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
Quoted 21 lines · Akhil R
Quoted 13 lines
...
Quoted 4 lines
Quoted 4 lines
This change reveals potential issue:
Quoted 2 lines
(quoted diff) +1
-1- irq = of_irq_get_byname(adapter->dev.of_node, "smbus_alert"); + irq = device_irq_get_byname(adapter->dev.parent,"
smbus_alert");Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
if (irq <= 0)I guess this '= 0' part should be fixed first.
Quoted 8 lines
Quoted 4 lines
'0' is a failure as per the documentation of
of_irq_get_byname()as well asof_irq_get(). The case is different foracpi_irq_get(), but it is handled infwnode_irq_get(). If I understood it right, a return value of '0' should be considered a failure here.Depends. I have no idea what the original code does here. But returning an error or 0 from this function seems confusing to me.
Quoted 9 lines
The description in of_irq_get*() says -
/* Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or
* -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
* of any other failure.
*/
As I see from the code offwnode_irq_get(), which is used in this case, returns either the return value ofof_irq_get()or error code fromacpi_irq_get()when it fails, or res.start if it didn't fail. I guess, any of these would not be 0 unless there is an error.
of_irq_get*() seems inconsistent...
Uwe, what do you think?
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
Quoted 34 lines
Quoted 5 lines
Quoted 5 lines
...
Quoted 3 lines
Quoted 3 lines
This change reveals potential issue:
Quoted 1 line
- irq = of_irq_get_byname(adapter->dev.of_node,
"
smbus_alert");Quoted 16 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ irq =
+ device_irq_get_byname(adapter->dev.parent,"
smbus_alert");Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
if (irq <= 0)I guess this '= 0' part should be fixed first.
Quoted 8 lines
Quoted 4 lines
'0' is a failure as per the documentation of
of_irq_get_byname()as well asof_irq_get(). The case is different foracpi_irq_get(), but it is handled infwnode_irq_get(). If I understood it right, a return value of '0' should be considered a failure here.Depends. I have no idea what the original code does here. But returning an error or 0 from this function seems confusing to me.
Quoted 11 lines
The description in of_irq_get*() says -
/* Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or
* -EPROBE_DEFER if the IRQ domain is not yet created, or error code
in case
* of any other failure.
*/
As I see from the code offwnode_irq_get(), which is used in this case, returns either the return value ofof_irq_get()or error code fromacpi_irq_get()when it fails, or res.start if it didn't fail. I guess, any of these would not be 0 unless there is an error.
Quoted 4 lines
of_irq_get*() seems inconsistent...
Uwe, what do you think?
A bit tricky. You are right, as we don't often see a return value of '0' as an error in Linux. But here since it is a number which is expected, it might be reasonable to allot 0 to an error as well. Not sure of the exact rationale in those functions though.
Thanks,
Akhil
Re: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()
In reply to Andy ShevchenkoQuoted 32 lines · Andy Shevchenko
Quoted 21 lines · Akhil R
Quoted 13 lines
...
Quoted 4 lines
Quoted 4 lines
This change reveals potential issue:
Quoted 2 lines
(quoted diff) +1
-1- irq = of_irq_get_byname(adapter->dev.of_node, "smbus_alert"); + irq = device_irq_get_byname(adapter->dev.parent,"
smbus_alert");Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
if (irq <= 0)I guess this '= 0' part should be fixed first.
Quoted 8 lines
Quoted 4 lines
'0' is a failure as per the documentation of
of_irq_get_byname()as well asof_irq_get(). The case is different foracpi_irq_get(), but it is handled infwnode_irq_get(). If I understood it right, a return value of '0' should be considered a failure here.Depends. I have no idea what the original code does here. But returning an error or 0 from this function seems confusing to me.
Quoted 9 lines
The description in of_irq_get*() says -
/* Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or
* -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
* of any other failure.
*/
As I see from the code offwnode_irq_get(), which is used in this case, returns either the return value ofof_irq_get()or error code fromacpi_irq_get()when it fails, or res.start if it didn't fail. I guess, any of these would not be 0 unless there is an error.
Quoted 3 lines
of_irq_get*() seems inconsistent...
Uwe, what do you think?
Yeah, this is something I stumbled over during the platform_get_irq*() discussion. But I don't feel like investing any more energy there.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 8 lines · Akhil R
I2C - SMBus core drivers use named interrupts to support
smbus_alert. As named interrupts are not available for ACPI based systems, it was required to change the i2c bus controller driver if to use smbus alert. These patches provide option for named interrupts in ACPI and make the implementation similar to DT. This will enable use of interrupt named 'smbus-alert' in ACPI as well which will be taken during i2c adapter register.
Most of my comments are regarding spelling and documentation. The code looks almost good enough. That said, if maintainers will be okay, I'm sure the next version will be upstream-ready.
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko