* [PATCH v5 1/6] dt-bindings: i2c: xiic: make clocks optional
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
@ 2026-01-26 17:08 ` Abdurrahman Hussain via B4 Relay
2026-01-26 17:08 ` [PATCH v5 2/6] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-26 17:08 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree, 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.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml | 1 -
1 file changed, 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml b/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml
index 658ae92fa86d..cc500130f41f 100644
--- a/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml
+++ b/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml
@@ -43,7 +43,6 @@ required:
- compatible
- reg
- interrupts
- - clocks
unevaluatedProperties: false
--
2.52.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v5 2/6] i2c: xiic: make the clock optional
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
2026-01-26 17:08 ` [PATCH v5 1/6] dt-bindings: i2c: xiic: make clocks optional Abdurrahman Hussain via B4 Relay
@ 2026-01-26 17:08 ` Abdurrahman Hussain via B4 Relay
2026-01-27 9:36 ` Andy Shevchenko
2026-01-26 17:08 ` [PATCH v5 3/6] i2c: xiic: switch to devres managed APIs Abdurrahman Hussain via B4 Relay
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-26 17:08 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree, 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 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 28015d77599d..16202fb89271 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1423,6 +1423,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 of_device_id *match;
@@ -1464,7 +1465,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(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] 14+ messages in thread* Re: [PATCH v5 2/6] i2c: xiic: make the clock optional
2026-01-26 17:08 ` [PATCH v5 2/6] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
@ 2026-01-27 9:36 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:36 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Mon, Jan 26, 2026 at 05:08:17PM +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.
Bingo!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 3/6] i2c: xiic: switch to devres managed APIs
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
2026-01-26 17:08 ` [PATCH v5 1/6] dt-bindings: i2c: xiic: make clocks optional Abdurrahman Hussain via B4 Relay
2026-01-26 17:08 ` [PATCH v5 2/6] i2c: xiic: make the clock optional Abdurrahman Hussain via B4 Relay
@ 2026-01-26 17:08 ` Abdurrahman Hussain via B4 Relay
2026-01-27 9:35 ` Andy Shevchenko
2026-01-26 17:08 ` [PATCH v5 4/6] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-26 17:08 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree, Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Simplify the error code paths by switching to devres managed helper
functions.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 16202fb89271..a4a8087c1407 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1462,7 +1462,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(dev, &i2c->lock);
+ if (ret < 0)
+ return ret;
+
spin_lock_init(&i2c->atomic_lock);
i2c->clk = devm_clk_get_optional_enabled(dev, NULL);
@@ -1473,8 +1476,9 @@ static int xiic_i2c_probe(struct platform_device *pdev)
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);
+ ret = devm_pm_runtime_set_active_enabled(dev);
+ if (ret < 0)
+ return ret;
/* SCL frequency configuration */
i2c->input_clk = clk_get_rate(i2c->clk);
@@ -1490,7 +1494,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err_probe(&pdev->dev, ret, "Cannot claim IRQ\n");
- goto err_pm_disable;
+ return ret;
}
i2c->singlemaster =
@@ -1511,14 +1515,14 @@ 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");
- goto err_pm_disable;
+ return ret;
}
/* add i2c adapter to i2c tree */
ret = i2c_add_adapter(&i2c->adap);
if (ret) {
xiic_deinit(i2c);
- goto err_pm_disable;
+ return ret;
}
if (pdata) {
@@ -1530,12 +1534,6 @@ static int xiic_i2c_probe(struct platform_device *pdev)
dev_dbg(&pdev->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);
-
return ret;
}
@@ -1556,8 +1554,6 @@ static void xiic_i2c_remove(struct platform_device *pdev)
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);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v5 3/6] i2c: xiic: switch to devres managed APIs
2026-01-26 17:08 ` [PATCH v5 3/6] i2c: xiic: switch to devres managed APIs Abdurrahman Hussain via B4 Relay
@ 2026-01-27 9:35 ` Andy Shevchenko
2026-01-27 9:39 ` Andy Shevchenko
0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:35 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Mon, Jan 26, 2026 at 05:08:18PM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Simplify the error code paths by switching to devres managed helper
> functions.
Thanks for the update, my comments below.
...
> + ret = devm_mutex_init(dev, &i2c->lock);
> + if (ret < 0)
Why ' < 0'?
> + return ret;
...
> + ret = devm_pm_runtime_set_active_enabled(dev);
> + if (ret < 0)
Ditto.
> + return ret;
...
> if (ret < 0) {
> dev_err_probe(&pdev->dev, ret, "Cannot claim IRQ\n");
> - goto err_pm_disable;
> + return ret;
return dev_err_probe(...);
> }
...
> ret = xiic_reinit(i2c);
> if (ret < 0) {
> dev_err_probe(&pdev->dev, ret, "Cannot xiic_reinit\n");
Ditto.
> - goto err_pm_disable;
> + return ret;
> }
...
> dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n",
> (unsigned long)res->start, irq, i2c->i2c_clk);
Side note, consider using %pR instead of ugly casting for resources.
(separate change).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v5 3/6] i2c: xiic: switch to devres managed APIs
2026-01-27 9:35 ` Andy Shevchenko
@ 2026-01-27 9:39 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:39 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Tue, Jan 27, 2026 at 11:35:38AM +0200, Andy Shevchenko wrote:
> On Mon, Jan 26, 2026 at 05:08:18PM +0000, Abdurrahman Hussain via B4 Relay wrote:
...
> > if (ret < 0) {
> > dev_err_probe(&pdev->dev, ret, "Cannot claim IRQ\n");
> > - goto err_pm_disable;
> > + return ret;
>
> return dev_err_probe(...);
Actually you are right as here we remove the message in the next patch,
so discard my previous comment.
> > }
...
> > ret = xiic_reinit(i2c);
> > if (ret < 0) {
> > dev_err_probe(&pdev->dev, ret, "Cannot xiic_reinit\n");
>
> Ditto.
>
> > - goto err_pm_disable;
> > + return ret;
But here it will stay, so
return dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
> > }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 4/6] i2c: xiic: remove duplicate error message
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (2 preceding siblings ...)
2026-01-26 17:08 ` [PATCH v5 3/6] i2c: xiic: switch to devres managed APIs Abdurrahman Hussain via B4 Relay
@ 2026-01-26 17:08 ` Abdurrahman Hussain via B4 Relay
2026-01-27 9:37 ` Andy Shevchenko
2026-01-26 17:08 ` [PATCH v5 5/6] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-26 17:08 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree, 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 | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index a4a8087c1407..a06597bbf6fc 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1492,10 +1492,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
xiic_process, IRQF_ONESHOT,
pdev->name, i2c);
- if (ret < 0) {
- dev_err_probe(&pdev->dev, ret, "Cannot claim IRQ\n");
+ if (ret < 0)
return ret;
- }
i2c->singlemaster =
of_property_read_bool(pdev->dev.of_node, "single-master");
--
2.52.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v5 4/6] i2c: xiic: remove duplicate error message
2026-01-26 17:08 ` [PATCH v5 4/6] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
@ 2026-01-27 9:37 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:37 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Mon, Jan 26, 2026 at 05:08:19PM +0000, Abdurrahman Hussain via B4 Relay wrote:
> The devm_request_threaded_irq() already prints an error message. Remove
> the duplicate.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 5/6] i2c: xiic: switch to generic device property accessors
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (3 preceding siblings ...)
2026-01-26 17:08 ` [PATCH v5 4/6] i2c: xiic: remove duplicate error message Abdurrahman Hussain via B4 Relay
@ 2026-01-26 17:08 ` Abdurrahman Hussain via B4 Relay
2026-01-27 9:41 ` Andy Shevchenko
2026-01-26 17:08 ` [PATCH v5 6/6] i2c: xiic: cosmetic cleanup Abdurrahman Hussain via B4 Relay
2026-01-27 9:45 ` [PATCH v5 0/6] i2c: xiic: use generic device property accessors Andy Shevchenko
6 siblings, 1 reply; 14+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-26 17:08 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree, 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 | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index a06597bbf6fc..09a4b532d55d 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,14 +1417,13 @@ 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 device *dev = &pdev->dev;
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;
@@ -1436,12 +1433,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(dev);
+ if (data)
i2c->quirks = data->quirks;
- }
i2c->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(i2c->base))
@@ -1458,7 +1452,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(dev));
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
DRIVER_NAME " %s", pdev->name);
@@ -1482,21 +1476,18 @@ 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(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)
return ret;
- i2c->singlemaster =
- of_property_read_bool(pdev->dev.of_node, "single-master");
+ i2c->singlemaster = device_property_read_bool(dev, "single-master");
/*
* Detect endianness
--
2.52.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v5 5/6] i2c: xiic: switch to generic device property accessors
2026-01-26 17:08 ` [PATCH v5 5/6] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
@ 2026-01-27 9:41 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:41 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Mon, Jan 26, 2026 at 05:08:20PM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Use generic device property accessors.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
One nit-pick below.
...
> - 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);
>
Also drop this blank line.
> if (ret < 0)
> return ret;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 6/6] i2c: xiic: cosmetic cleanup
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (4 preceding siblings ...)
2026-01-26 17:08 ` [PATCH v5 5/6] i2c: xiic: switch to generic device property accessors Abdurrahman Hussain via B4 Relay
@ 2026-01-26 17:08 ` Abdurrahman Hussain via B4 Relay
2026-01-27 9:44 ` Andy Shevchenko
2026-01-27 9:45 ` [PATCH v5 0/6] i2c: xiic: use generic device property accessors Andy Shevchenko
6 siblings, 1 reply; 14+ messages in thread
From: Abdurrahman Hussain via B4 Relay @ 2026-01-26 17:08 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info
Cc: Andy Shevchenko, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree, Abdurrahman Hussain
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Re-use dev pointer instead of referencing &pdev->dev everywhere.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 09a4b532d55d..3537c97e307a 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1429,7 +1429,7 @@ 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;
@@ -1445,13 +1445,13 @@ 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;
+ 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);
@@ -1464,12 +1464,12 @@ static int xiic_i2c_probe(struct platform_device *pdev)
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);
+ i2c->dev = dev;
+ pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
+ pm_runtime_use_autosuspend(dev);
ret = devm_pm_runtime_set_active_enabled(dev);
if (ret < 0)
return ret;
@@ -1503,7 +1503,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");
return ret;
}
@@ -1528,22 +1528,23 @@ static int xiic_i2c_probe(struct platform_device *pdev)
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_dont_use_autosuspend(&pdev->dev);
+ pm_runtime_put_sync(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] 14+ messages in thread* Re: [PATCH v5 6/6] i2c: xiic: cosmetic cleanup
2026-01-26 17:08 ` [PATCH v5 6/6] i2c: xiic: cosmetic cleanup Abdurrahman Hussain via B4 Relay
@ 2026-01-27 9:44 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:44 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Mon, Jan 26, 2026 at 05:08:21PM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Re-use dev pointer instead of referencing &pdev->dev everywhere.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
A couple of nit-picks to be addressed though.
...
> - i2c->dev = &pdev->dev;
> - pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT);
> - pm_runtime_use_autosuspend(i2c->dev);
> + i2c->dev = dev;
+ blank line here.
> + pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
> + pm_runtime_use_autosuspend(dev);
> ret = devm_pm_runtime_set_active_enabled(dev);
> if (ret < 0)
> return ret;
...
> 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");
> return ret;
> }
It should be integrated in the second patch or so, I have already commented on
that.
...
> - ret = pm_runtime_get_sync(i2c->dev);
> + ret = pm_runtime_get_sync(dev);
>
Drop this blank line as well.
> 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);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/6] i2c: xiic: use generic device property accessors
2026-01-26 17:08 [PATCH v5 0/6] i2c: xiic: use generic device property accessors Abdurrahman Hussain via B4 Relay
` (5 preceding siblings ...)
2026-01-26 17:08 ` [PATCH v5 6/6] i2c: xiic: cosmetic cleanup Abdurrahman Hussain via B4 Relay
@ 2026-01-27 9:45 ` Andy Shevchenko
6 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-01-27 9:45 UTC (permalink / raw)
To: abdurrahman
Cc: Michal Simek, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, info, linux-arm-kernel, linux-i2c, linux-kernel,
devicetree
On Mon, Jan 26, 2026 at 05:08:15PM +0000, Abdurrahman Hussain via B4 Relay wrote:
> Switch to generic device property accessors.
>
> Switch to managed devm_ functions to simplify error handling.
>
> 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.
Overall looks good, needs some nit-picks to be addressed.
I hope v6 will manage to go in soon.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread