Skip to content

Commit a263a84

Browse files
Akhil Rwsakernel
authored andcommitted
i2c: smbus: Use device_*() functions instead of of_*()
Change of_*() functions to device_*() for firmware agnostic usage. This allows to have the smbus_alert interrupt without any changes in the controller drivers using the ACPI table. Signed-off-by: Akhil R <akhilrajeev@nvidia.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 20e8ef5 commit a263a84

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
14791479
goto out_list;
14801480
}
14811481

1482-
res = of_i2c_setup_smbus_alert(adap);
1482+
res = i2c_setup_smbus_alert(adap);
14831483
if (res)
14841484
goto out_reg;
14851485

drivers/i2c/i2c-core-smbus.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/err.h>
1515
#include <linux/i2c.h>
1616
#include <linux/i2c-smbus.h>
17+
#include <linux/property.h>
1718
#include <linux/slab.h>
1819

1920
#include "i2c-core.h"
@@ -701,19 +702,19 @@ struct i2c_client *i2c_new_smbus_alert_device(struct i2c_adapter *adapter,
701702
}
702703
EXPORT_SYMBOL_GPL(i2c_new_smbus_alert_device);
703704

704-
#if IS_ENABLED(CONFIG_I2C_SMBUS) && IS_ENABLED(CONFIG_OF)
705-
int of_i2c_setup_smbus_alert(struct i2c_adapter *adapter)
705+
#if IS_ENABLED(CONFIG_I2C_SMBUS)
706+
int i2c_setup_smbus_alert(struct i2c_adapter *adapter)
706707
{
707708
int irq;
708709

709-
irq = of_property_match_string(adapter->dev.of_node, "interrupt-names",
710-
"smbus_alert");
710+
irq = device_property_match_string(adapter->dev.parent, "interrupt-names",
711+
"smbus_alert");
711712
if (irq == -EINVAL || irq == -ENODATA)
712713
return 0;
713714
else if (irq < 0)
714715
return irq;
715716

716717
return PTR_ERR_OR_ZERO(i2c_new_smbus_alert_device(adapter, NULL));
717718
}
718-
EXPORT_SYMBOL_GPL(of_i2c_setup_smbus_alert);
719+
EXPORT_SYMBOL_GPL(i2c_setup_smbus_alert);
719720
#endif

drivers/i2c/i2c-smbus.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/interrupt.h>
1414
#include <linux/kernel.h>
1515
#include <linux/module.h>
16-
#include <linux/of_irq.h>
16+
#include <linux/property.h>
1717
#include <linux/slab.h>
1818
#include <linux/workqueue.h>
1919

@@ -128,7 +128,8 @@ static int smbalert_probe(struct i2c_client *ara,
128128
if (setup) {
129129
irq = setup->irq;
130130
} else {
131-
irq = of_irq_get_byname(adapter->dev.of_node, "smbus_alert");
131+
irq = fwnode_irq_get_byname(dev_fwnode(adapter->dev.parent),
132+
"smbus_alert");
132133
if (irq <= 0)
133134
return irq;
134135
}

include/linux/i2c-smbus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ struct i2c_client *i2c_new_smbus_alert_device(struct i2c_adapter *adapter,
3030
struct i2c_smbus_alert_setup *setup);
3131
int i2c_handle_smbus_alert(struct i2c_client *ara);
3232

33-
#if IS_ENABLED(CONFIG_I2C_SMBUS) && IS_ENABLED(CONFIG_OF)
34-
int of_i2c_setup_smbus_alert(struct i2c_adapter *adap);
33+
#if IS_ENABLED(CONFIG_I2C_SMBUS)
34+
int i2c_setup_smbus_alert(struct i2c_adapter *adap);
3535
#else
36-
static inline int of_i2c_setup_smbus_alert(struct i2c_adapter *adap)
36+
static inline int i2c_setup_smbus_alert(struct i2c_adapter *adap)
3737
{
3838
return 0;
3939
}

0 commit comments

Comments
 (0)