Skip to content

Commit b621a96

Browse files
abdurrahman-nexthopAndi Shyti
authored andcommitted
i2c: xiic: switch to generic device property accessors
Use generic device property accessors making them work for ACPI platforms. Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260223-i2c-xiic-v12-3-b6c9ce4e4f3c@nexthop.ai
1 parent e1d98e4 commit b621a96

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

drivers/i2c/busses/i2c-xiic.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/platform_data/i2c-xiic.h>
2828
#include <linux/io.h>
2929
#include <linux/slab.h>
30-
#include <linux/of.h>
3130
#include <linux/clk.h>
3231
#include <linux/pm_runtime.h>
3332
#include <linux/iopoll.h>
@@ -1408,7 +1407,6 @@ static const struct i2c_adapter xiic_adapter = {
14081407
.algo = &xiic_algorithm,
14091408
};
14101409

1411-
#if defined(CONFIG_OF)
14121410
static const struct xiic_version_data xiic_2_00 = {
14131411
.quirks = DYNAMIC_MODE_READ_BROKEN_BIT,
14141412
};
@@ -1419,14 +1417,14 @@ static const struct of_device_id xiic_of_match[] = {
14191417
{},
14201418
};
14211419
MODULE_DEVICE_TABLE(of, xiic_of_match);
1422-
#endif
14231420

14241421
static int xiic_i2c_probe(struct platform_device *pdev)
14251422
{
14261423
struct device *dev = &pdev->dev;
1424+
struct fwnode_handle *fwnode = dev_fwnode(dev);
14271425
struct xiic_i2c *i2c;
14281426
struct xiic_i2c_platform_data *pdata;
1429-
const struct of_device_id *match;
1427+
const struct xiic_version_data *data;
14301428
struct resource *res;
14311429
int ret, irq;
14321430
u8 i;
@@ -1436,12 +1434,9 @@ static int xiic_i2c_probe(struct platform_device *pdev)
14361434
if (!i2c)
14371435
return -ENOMEM;
14381436

1439-
match = of_match_node(xiic_of_match, pdev->dev.of_node);
1440-
if (match && match->data) {
1441-
const struct xiic_version_data *data = match->data;
1442-
1437+
data = device_get_match_data(dev);
1438+
if (data)
14431439
i2c->quirks = data->quirks;
1444-
}
14451440

14461441
i2c->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
14471442
if (IS_ERR(i2c->base))
@@ -1458,7 +1453,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
14581453
i2c->adap = xiic_adapter;
14591454
i2c_set_adapdata(&i2c->adap, i2c);
14601455
i2c->adap.dev.parent = &pdev->dev;
1461-
i2c->adap.dev.of_node = pdev->dev.of_node;
1456+
device_set_node(&i2c->adap.dev, fwnode);
14621457
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
14631458
DRIVER_NAME " %s", pdev->name);
14641459

@@ -1482,8 +1477,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
14821477

14831478
/* SCL frequency configuration */
14841479
i2c->input_clk = clk_get_rate(i2c->clk);
1485-
ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
1486-
&i2c->i2c_clk);
1480+
ret = device_property_read_u32(dev, "clock-frequency", &i2c->i2c_clk);
14871481
/* If clock-frequency not specified in DT, do not configure in SW */
14881482
if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
14891483
i2c->i2c_clk = 0;
@@ -1494,8 +1488,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
14941488
if (ret)
14951489
return ret;
14961490

1497-
i2c->singlemaster =
1498-
of_property_read_bool(pdev->dev.of_node, "single-master");
1491+
i2c->singlemaster = device_property_read_bool(dev, "single-master");
14991492

15001493
/*
15011494
* Detect endianness

0 commit comments

Comments
 (0)