* [PATCH v3 0/5] i2c: xiic: use generic device property accessors
@ 2026-01-23 8:02 Abdurrahman Hussain via B4 Relay
2026-01-23 8:02 ` [PATCH v3 1/5] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
` (5 more replies)
0 siblings, 6 replies; 19+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-23 8:02 UTC (permalink / raw)
To: Michal Simek, Andi Shyti
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
Abdurrahman Hussain
Switch to generic device property accessors and make minor code
refactoring.
Make the clock optional since the driver is designed to operate without
explicit configuration in firmware thus making it useful on platforms
where clock is not or cannot be provided.
Changed in v2:
* Split the patch into two independent changes.
* Added struct device *dev at the top of probe() and remove() to re-use.
* Switched to device_set_node(...)
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
Changes in v3:
- Reorder the "optional clock" patch to be the first in the series.
- Add a patch to switch to devm_mutex_init().
- Remove dup message in error path.
- Cosmetic: use temporary dev variable.
- Link to v2: https://lore.kernel.org/r/20260122-i2c-xiic-v2-0-134f5d743e8b@nexthop.ai
---
Abdurrahman Hussain (5):
i2c: xiic: make the clock optional
i2c: xiic: switch to managed version of mutex_init
i2c: xiic: remove duplicate error message
i2c: xiic: switch to generic device property accessors
i2c: xiic: minor cosmetic cleanup
drivers/i2c/busses/i2c-xiic.c | 74 ++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 39 deletions(-)
---
base-commit: 944aacb68baf7624ab8d277d0ebf07f025ca137c
change-id: 20260122-i2c-xiic-3ba89ff5ea93
Best regards,
--
Abdurrahman Hussain <abdurrahman@nexthop.ai>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 1/5] i2c: xiic: make the clock optional
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:02 ` Abdurrahman Hussain via B4 Relay
2026-01-23 8:29 ` Andy Shevchenko
2026-01-23 19:20 ` Andrew Lunn
2026-01-23 8:02 ` [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init Abdurrahman Hussain via B4 Relay
` (4 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-23 8:02 UTC (permalink / raw)
To: Michal Simek, Andi Shyti
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
The xiic driver is designed to operate without explicit clock configuration
when clocks are not specified in the firmware. This functionality is
already implemented in xiic_setclk(), which performs an early return when
either i2c_clk or input_clk are zero:
This condition is satisfied when clocks are missing, as clk_get_rate(NULL)
returns zero, allowing the driver to rely on hardware-configured timing.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 28015d77599d..603a246a1445 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1464,7 +1464,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
mutex_init(&i2c->lock);
spin_lock_init(&i2c->atomic_lock);
- i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
"failed to enable input clock.\n");
--
2.52.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
2026-01-23 8:02 ` [PATCH v3 1/5] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:02 ` Abdurrahman Hussain via B4 Relay
2026-01-23 8:30 ` Andy Shevchenko
2026-01-23 19:22 ` Andrew Lunn
2026-01-23 8:02 ` [PATCH v3 3/5] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
` (3 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-23 8:02 UTC (permalink / raw)
To: Michal Simek, Andi Shyti
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Simplify the error path by switching to a managed version of mutex_init.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 603a246a1445..79643c27e75d 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1461,7 +1461,10 @@ static int xiic_i2c_probe(struct platform_device *pdev)
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
DRIVER_NAME " %s", pdev->name);
- mutex_init(&i2c->lock);
+ ret = devm_mutex_init(&pdev->dev, &i2c->lock);
+ if (ret < 0)
+ return ret;
+
spin_lock_init(&i2c->atomic_lock);
i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
--
2.52.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 3/5] i2c: xiic: remove duplicate error message
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
2026-01-23 8:02 ` [PATCH v3 1/5] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
2026-01-23 8:02 ` [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:02 ` Abdurrahman Hussain via B4 Relay
2026-01-23 19:23 ` Andrew Lunn
2026-01-23 8:02 ` [PATCH v3 4/5] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
` (2 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-23 8:02 UTC (permalink / raw)
To: Michal Simek, Andi Shyti
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
The devm_request_threaded_irq() already prints an error message. Remove
the duplicate.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 79643c27e75d..52d5c0c5c5c8 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1491,7 +1491,6 @@ static int xiic_i2c_probe(struct platform_device *pdev)
pdev->name, i2c);
if (ret < 0) {
- dev_err_probe(&pdev->dev, ret, "Cannot claim IRQ\n");
goto err_pm_disable;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 4/5] i2c: xiic: switch to generic device property accessors
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (2 preceding siblings ...)
2026-01-23 8:02 ` [PATCH v3 3/5] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:02 ` Abdurrahman Hussain via B4 Relay
2026-01-23 8:33 ` Andy Shevchenko
2026-01-23 8:02 ` [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup Abdurrahman Hussain via B4 Relay
2026-01-23 8:31 ` [PATCH v3 0/5] i2c: xiic: use generic device property accessors Andy Shevchenko
5 siblings, 1 reply; 19+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-23 8:02 UTC (permalink / raw)
To: Michal Simek, Andi Shyti
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Use generic device property accessors.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 52d5c0c5c5c8..3af2d60d3e32 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -27,7 +27,6 @@
#include <linux/platform_data/i2c-xiic.h>
#include <linux/io.h>
#include <linux/slab.h>
-#include <linux/of.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <linux/iopoll.h>
@@ -1408,7 +1407,6 @@ static const struct i2c_adapter xiic_adapter = {
.algo = &xiic_algorithm,
};
-#if defined(CONFIG_OF)
static const struct xiic_version_data xiic_2_00 = {
.quirks = DYNAMIC_MODE_READ_BROKEN_BIT,
};
@@ -1419,13 +1417,12 @@ static const struct of_device_id xiic_of_match[] = {
{},
};
MODULE_DEVICE_TABLE(of, xiic_of_match);
-#endif
static int xiic_i2c_probe(struct platform_device *pdev)
{
struct xiic_i2c *i2c;
struct xiic_i2c_platform_data *pdata;
- const struct of_device_id *match;
+ const struct xiic_version_data *data;
struct resource *res;
int ret, irq;
u8 i;
@@ -1435,12 +1432,9 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (!i2c)
return -ENOMEM;
- match = of_match_node(xiic_of_match, pdev->dev.of_node);
- if (match && match->data) {
- const struct xiic_version_data *data = match->data;
-
+ data = device_get_match_data(&pdev->dev);
+ if (data)
i2c->quirks = data->quirks;
- }
i2c->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(i2c->base))
@@ -1457,7 +1451,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
i2c->adap = xiic_adapter;
i2c_set_adapdata(&i2c->adap, i2c);
i2c->adap.dev.parent = &pdev->dev;
- i2c->adap.dev.of_node = pdev->dev.of_node;
+ device_set_node(&i2c->adap.dev, dev_fwnode(&pdev->dev));
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
DRIVER_NAME " %s", pdev->name);
@@ -1480,8 +1474,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
/* SCL frequency configuration */
i2c->input_clk = clk_get_rate(i2c->clk);
- ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &i2c->i2c_clk);
+ ret = device_property_read_u32(&pdev->dev, "clock-frequency",
+ &i2c->i2c_clk);
/* If clock-frequency not specified in DT, do not configure in SW */
if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
i2c->i2c_clk = 0;
@@ -1495,7 +1489,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
}
i2c->singlemaster =
- of_property_read_bool(pdev->dev.of_node, "single-master");
+ device_property_read_bool(&pdev->dev, "single-master");
/*
* Detect endianness
--
2.52.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (3 preceding siblings ...)
2026-01-23 8:02 ` [PATCH v3 4/5] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:02 ` Abdurrahman Hussain via B4 Relay
2026-01-23 8:28 ` Andy Shevchenko
2026-01-23 8:37 ` Andy Shevchenko
2026-01-23 8:31 ` [PATCH v3 0/5] i2c: xiic: use generic device property accessors Andy Shevchenko
5 siblings, 2 replies; 19+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-23 8:02 UTC (permalink / raw)
To: Michal Simek, Andi Shyti
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Add a temporary dev variable and reuse it instead of referencing pdev->dev
everywhere.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 60 +++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 3af2d60d3e32..3c0ec33aefd4 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1420,6 +1420,7 @@ MODULE_DEVICE_TABLE(of, xiic_of_match);
static int xiic_i2c_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct xiic_i2c *i2c;
struct xiic_i2c_platform_data *pdata;
const struct xiic_version_data *data;
@@ -1428,11 +1429,11 @@ static int xiic_i2c_probe(struct platform_device *pdev)
u8 i;
u32 sr;
- i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
+ i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
- data = device_get_match_data(&pdev->dev);
+ data = device_get_match_data(dev);
if (data)
i2c->quirks = data->quirks;
@@ -1444,52 +1445,50 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- pdata = dev_get_platdata(&pdev->dev);
+ pdata = dev_get_platdata(dev);
/* hook up driver to tree */
platform_set_drvdata(pdev, i2c);
i2c->adap = xiic_adapter;
i2c_set_adapdata(&i2c->adap, i2c);
- i2c->adap.dev.parent = &pdev->dev;
- device_set_node(&i2c->adap.dev, dev_fwnode(&pdev->dev));
+ i2c->adap.dev.parent = dev;
+ device_set_node(&i2c->adap.dev, dev_fwnode(dev));
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
DRIVER_NAME " %s", pdev->name);
- ret = devm_mutex_init(&pdev->dev, &i2c->lock);
+ ret = devm_mutex_init(dev, &i2c->lock);
if (ret < 0)
return ret;
spin_lock_init(&i2c->atomic_lock);
- i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
+ i2c->clk = devm_clk_get_optional_enabled(dev, NULL);
if (IS_ERR(i2c->clk))
- return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
+ return dev_err_probe(dev, PTR_ERR(i2c->clk),
"failed to enable input clock.\n");
- i2c->dev = &pdev->dev;
- pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT);
- pm_runtime_use_autosuspend(i2c->dev);
- pm_runtime_set_active(i2c->dev);
- pm_runtime_enable(i2c->dev);
+ i2c->dev = dev;
+ pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
+ pm_runtime_use_autosuspend(dev);
+ pm_runtime_set_active(dev);
+ pm_runtime_enable(dev);
/* SCL frequency configuration */
i2c->input_clk = clk_get_rate(i2c->clk);
- ret = device_property_read_u32(&pdev->dev, "clock-frequency",
- &i2c->i2c_clk);
+ ret = device_property_read_u32(dev, "clock-frequency", &i2c->i2c_clk);
+
/* If clock-frequency not specified in DT, do not configure in SW */
if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
i2c->i2c_clk = 0;
- ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- xiic_process, IRQF_ONESHOT,
- pdev->name, i2c);
+ ret = devm_request_threaded_irq(dev, irq, NULL, xiic_process,
+ IRQF_ONESHOT, pdev->name, i2c);
if (ret < 0) {
goto err_pm_disable;
}
- i2c->singlemaster =
- device_property_read_bool(&pdev->dev, "single-master");
+ i2c->singlemaster = device_property_read_bool(dev, "single-master");
/*
* Detect endianness
@@ -1505,7 +1504,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
ret = xiic_reinit(i2c);
if (ret < 0) {
- dev_err_probe(&pdev->dev, ret, "Cannot xiic_reinit\n");
+ dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
goto err_pm_disable;
}
@@ -1522,38 +1521,39 @@ static int xiic_i2c_probe(struct platform_device *pdev)
i2c_new_client_device(&i2c->adap, pdata->devices + i);
}
- dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n",
+ dev_dbg(dev, "mmio %08lx irq %d scl clock frequency %d\n",
(unsigned long)res->start, irq, i2c->i2c_clk);
return 0;
err_pm_disable:
- pm_runtime_disable(&pdev->dev);
- pm_runtime_set_suspended(&pdev->dev);
+ pm_runtime_disable(dev);
+ pm_runtime_set_suspended(dev);
return ret;
}
static void xiic_i2c_remove(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct xiic_i2c *i2c = platform_get_drvdata(pdev);
int ret;
/* remove adapter & data */
i2c_del_adapter(&i2c->adap);
- ret = pm_runtime_get_sync(i2c->dev);
+ ret = pm_runtime_get_sync(dev);
if (ret < 0)
- dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
+ dev_warn(dev, "Failed to activate device for removal (%pe)\n",
ERR_PTR(ret));
else
xiic_deinit(i2c);
- pm_runtime_put_sync(i2c->dev);
- pm_runtime_disable(&pdev->dev);
- pm_runtime_set_suspended(&pdev->dev);
- pm_runtime_dont_use_autosuspend(&pdev->dev);
+ pm_runtime_put_sync(dev);
+ pm_runtime_disable(dev);
+ pm_runtime_set_suspended(dev);
+ pm_runtime_dont_use_autosuspend(dev);
}
static const struct dev_pm_ops xiic_dev_pm_ops = {
--
2.52.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup
2026-01-23 8:02 ` [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:28 ` Andy Shevchenko
2026-01-23 8:37 ` Andy Shevchenko
1 sibling, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-01-23 8:28 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, linux-arm-kernel, linux-i2c,
linux-kernel
On Fri, Jan 23, 2026 at 08:02:48AM +0000, Abdurrahman Hussain via B4 Relay wrote:
>
> Add a temporary dev variable and reuse it instead of referencing pdev->dev
> everywhere.
...
> + struct device *dev = &pdev->dev;
No, this part should go earlier because of other patches that use it.
devm_clk_get*()
device_get_match_data()
Without this you add an unneeded churn.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] i2c: xiic: make the clock optional
2026-01-23 8:02 ` [PATCH v3 1/5] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:29 ` Andy Shevchenko
2026-01-23 19:20 ` Andrew Lunn
1 sibling, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-01-23 8:29 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, linux-arm-kernel, linux-i2c,
linux-kernel
On Fri, Jan 23, 2026 at 08:02:44AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> The xiic driver is designed to operate without explicit clock configuration
> when clocks are not specified in the firmware. This functionality is
> already implemented in xiic_setclk(), which performs an early return when
> either i2c_clk or input_clk are zero:
>
> This condition is satisfied when clocks are missing, as clk_get_rate(NULL)
> returns zero, allowing the driver to rely on hardware-configured timing.
...
> mutex_init(&i2c->lock);
> spin_lock_init(&i2c->atomic_lock);
>
> - i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> + i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
You also need to have
struct device *dev = &pdev->dev;
in *this* patch.
> if (IS_ERR(i2c->clk))
> return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
> "failed to enable input clock.\n");
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init
2026-01-23 8:02 ` [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:30 ` Andy Shevchenko
2026-01-23 19:22 ` Andrew Lunn
1 sibling, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-01-23 8:30 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, linux-arm-kernel, linux-i2c,
linux-kernel
On Fri, Jan 23, 2026 at 08:02:45AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Simplify the error path by switching to a managed version of mutex_init.
...
> - mutex_init(&i2c->lock);
> + ret = devm_mutex_init(&pdev->dev, &i2c->lock);
> + if (ret < 0)
> + return ret;
Should use 'dev' instead (see comment on the patches 1 and 5).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 0/5] i2c: xiic: use generic device property accessors
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (4 preceding siblings ...)
2026-01-23 8:02 ` [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:31 ` Andy Shevchenko
5 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-01-23 8:31 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, linux-arm-kernel, linux-i2c,
linux-kernel
On Fri, Jan 23, 2026 at 08:02:43AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Switch to generic device property accessors and make minor code
> refactoring.
>
> Make the clock optional since the driver is designed to operate without
> explicit configuration in firmware thus making it useful on platforms
> where clock is not or cannot be provided.
Everything looks fine in the result, but one nuance ruins the series.
See my other comments. After fixing it and rebasing I will give you a tag.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/5] i2c: xiic: switch to generic device property accessors
2026-01-23 8:02 ` [PATCH v3 4/5] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
@ 2026-01-23 8:33 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-01-23 8:33 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, linux-arm-kernel, linux-i2c,
linux-kernel
On Fri, Jan 23, 2026 at 08:02:47AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Use generic device property accessors.
...
> + data = device_get_match_data(&pdev->dev);
Should use 'dev'.
> + if (data)
> i2c->quirks = data->quirks;
...
> + device_set_node(&i2c->adap.dev, dev_fwnode(&pdev->dev));
Ditto.
> + ret = device_property_read_u32(&pdev->dev, "clock-frequency",
> + &i2c->i2c_clk);
Ditto and it will be a single line, I think.
ret = device_property_read_u32(dev, "clock-frequency", &i2c->i2c_clk);
(yep, only 78 characters).
...
> - of_property_read_bool(pdev->dev.of_node, "single-master");
> + device_property_read_bool(&pdev->dev, "single-master");
Use 'dev'.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup
2026-01-23 8:02 ` [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup Abdurrahman Hussain via B4 Relay
2026-01-23 8:28 ` Andy Shevchenko
@ 2026-01-23 8:37 ` Andy Shevchenko
1 sibling, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-01-23 8:37 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, linux-arm-kernel, linux-i2c,
linux-kernel
On Fri, Jan 23, 2026 at 08:02:48AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Add a temporary dev variable and reuse it instead of referencing pdev->dev
> everywhere.
...
> - pm_runtime_enable(i2c->dev);
> + pm_runtime_enable(dev);
Ah, please also move this to devm_pm_...* in a separate patch or combine it
with mutex and explain that this fixes the cleanup ordering and simplifies
error handling.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] i2c: xiic: make the clock optional
2026-01-23 8:02 ` [PATCH v3 1/5] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
2026-01-23 8:29 ` Andy Shevchenko
@ 2026-01-23 19:20 ` Andrew Lunn
2026-01-23 19:56 ` Abdurrahman Hussain
1 sibling, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2026-01-23 19:20 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri, Jan 23, 2026 at 08:02:44AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>
> The xiic driver is designed to operate without explicit clock configuration
> when clocks are not specified in the firmware. This functionality is
> already implemented in xiic_setclk(), which performs an early return when
> either i2c_clk or input_clk are zero:
>
> This condition is satisfied when clocks are missing, as clk_get_rate(NULL)
> returns zero, allowing the driver to rely on hardware-configured timing.
https://elixir.bootlin.com/linux/v6.18.6/source/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml#L42
The binding indicates the clock is required. You need to update the
binding to match the code.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init
2026-01-23 8:02 ` [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init Abdurrahman Hussain via B4 Relay
2026-01-23 8:30 ` Andy Shevchenko
@ 2026-01-23 19:22 ` Andrew Lunn
2026-01-23 20:20 ` Abdurrahman Hussain
1 sibling, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2026-01-23 19:22 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri, Jan 23, 2026 at 08:02:45AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>
> Simplify the error path by switching to a managed version of mutex_init.
How does this simplify the error path? You don't remove anything from
the error path.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/5] i2c: xiic: remove duplicate error message
2026-01-23 8:02 ` [PATCH v3 3/5] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
@ 2026-01-23 19:23 ` Andrew Lunn
0 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2026-01-23 19:23 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri, Jan 23, 2026 at 08:02:46AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>
> The devm_request_threaded_irq() already prints an error message. Remove
> the duplicate.
>
> Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] i2c: xiic: make the clock optional
2026-01-23 19:20 ` Andrew Lunn
@ 2026-01-23 19:56 ` Abdurrahman Hussain
0 siblings, 0 replies; 19+ messages in thread
From: Abdurrahman Hussain @ 2026-01-23 19:56 UTC (permalink / raw)
To: Andrew Lunn, abdurrahman
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri Jan 23, 2026 at 7:20 PM UTC, Andrew Lunn wrote:
> On Fri, Jan 23, 2026 at 08:02:44AM +0000, Abdurrahman Hussain via B4 Relay wrote:
>> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>>
>> The xiic driver is designed to operate without explicit clock configuration
>> when clocks are not specified in the firmware. This functionality is
>> already implemented in xiic_setclk(), which performs an early return when
>> either i2c_clk or input_clk are zero:
>>
>> This condition is satisfied when clocks are missing, as clk_get_rate(NULL)
>> returns zero, allowing the driver to rely on hardware-configured timing.
>
> https://elixir.bootlin.com/linux/v6.18.6/source/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml#L42
>
> The binding indicates the clock is required. You need to update the
> binding to match the code.
>
> Andrew
Absolutely! Let me take care of it in v5. Will add the doc change before the
code changes.
Abdurrahman
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init
2026-01-23 19:22 ` Andrew Lunn
@ 2026-01-23 20:20 ` Abdurrahman Hussain
2026-01-23 21:36 ` Andrew Lunn
0 siblings, 1 reply; 19+ messages in thread
From: Abdurrahman Hussain @ 2026-01-23 20:20 UTC (permalink / raw)
To: Andrew Lunn, abdurrahman
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri Jan 23, 2026 at 7:22 PM UTC, Andrew Lunn wrote:
> On Fri, Jan 23, 2026 at 08:02:45AM +0000, Abdurrahman Hussain via B4 Relay wrote:
>> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>>
>> Simplify the error path by switching to a managed version of mutex_init.
>
> How does this simplify the error path? You don't remove anything from
> the error path.
>
> Andrew
Thank you for the feedback. In v4, as suggested by Andy, I introduced managed
versions of the pm_runtime_ functions which do simplify the error handling.
I apologize for submitting v4 prematurely before allowing sufficient time for
review of v3.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init
2026-01-23 20:20 ` Abdurrahman Hussain
@ 2026-01-23 21:36 ` Andrew Lunn
2026-01-23 22:25 ` Abdurrahman Hussain
0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2026-01-23 21:36 UTC (permalink / raw)
To: Abdurrahman Hussain
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri, Jan 23, 2026 at 12:20:54PM -0800, Abdurrahman Hussain wrote:
> On Fri Jan 23, 2026 at 7:22 PM UTC, Andrew Lunn wrote:
> > On Fri, Jan 23, 2026 at 08:02:45AM +0000, Abdurrahman Hussain via B4 Relay wrote:
> >> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
> >>
> >> Simplify the error path by switching to a managed version of mutex_init.
> >
> > How does this simplify the error path? You don't remove anything from
> > the error path.
> >
> > Andrew
>
>
> Thank you for the feedback. In v4, as suggested by Andy, I introduced managed
> versions of the pm_runtime_ functions which do simplify the error handling.
But this patch is not about pm_runtime_, it is about a mutex. How does
this patch make the error path simpler? Please make sure your commit
messages are accurate.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init
2026-01-23 21:36 ` Andrew Lunn
@ 2026-01-23 22:25 ` Abdurrahman Hussain
0 siblings, 0 replies; 19+ messages in thread
From: Abdurrahman Hussain @ 2026-01-23 22:25 UTC (permalink / raw)
To: Andrew Lunn, Abdurrahman Hussain
Cc: Michal Simek, Andi Shyti, Andy Shevchenko, linux-arm-kernel,
linux-i2c, linux-kernel
On Fri Jan 23, 2026 at 9:36 PM UTC, Andrew Lunn wrote:
> On Fri, Jan 23, 2026 at 12:20:54PM -0800, Abdurrahman Hussain wrote:
>> On Fri Jan 23, 2026 at 7:22 PM UTC, Andrew Lunn wrote:
>> > On Fri, Jan 23, 2026 at 08:02:45AM +0000, Abdurrahman Hussain via B4 Relay wrote:
>> >> From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>> >>
>> >> Simplify the error path by switching to a managed version of mutex_init.
>> >
>> > How does this simplify the error path? You don't remove anything from
>> > the error path.
>> >
>> > Andrew
>>
>>
>> Thank you for the feedback. In v4, as suggested by Andy, I introduced managed
>> versions of the pm_runtime_ functions which do simplify the error handling.
>
> But this patch is not about pm_runtime_, it is about a mutex. How does
> this patch make the error path simpler? Please make sure your commit
> messages are accurate.
>
You are right. In the case of mutex there was no error path. I should have
worded it differently. In v4 pm_runtime changes were added to the same
patch, so the wording might actually be correct now.
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-01-23 22:25 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 8:02 [PATCH v3 0/5] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
2026-01-23 8:02 ` [PATCH v3 1/5] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
2026-01-23 8:29 ` Andy Shevchenko
2026-01-23 19:20 ` Andrew Lunn
2026-01-23 19:56 ` Abdurrahman Hussain
2026-01-23 8:02 ` [PATCH v3 2/5] i2c: xiic: switch to managed version of mutex_init Abdurrahman Hussain via B4 Relay
2026-01-23 8:30 ` Andy Shevchenko
2026-01-23 19:22 ` Andrew Lunn
2026-01-23 20:20 ` Abdurrahman Hussain
2026-01-23 21:36 ` Andrew Lunn
2026-01-23 22:25 ` Abdurrahman Hussain
2026-01-23 8:02 ` [PATCH v3 3/5] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
2026-01-23 19:23 ` Andrew Lunn
2026-01-23 8:02 ` [PATCH v3 4/5] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
2026-01-23 8:33 ` Andy Shevchenko
2026-01-23 8:02 ` [PATCH v3 5/5] i2c: xiic: minor cosmetic cleanup Abdurrahman Hussain via B4 Relay
2026-01-23 8:28 ` Andy Shevchenko
2026-01-23 8:37 ` Andy Shevchenko
2026-01-23 8:31 ` [PATCH v3 0/5] i2c: xiic: use generic device property accessors Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox