* [PATCH v2 1/1] i3c: master: Drop duplicate check before calling OF APIs
@ 2025-03-21 19:30 Andy Shevchenko
2025-03-24 19:39 ` Frank Li
2025-03-31 9:42 ` Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2025-03-21 19:30 UTC (permalink / raw)
To: Alexandre Belloni, linux-i3c, linux-kernel; +Cc: Frank Li, Andy Shevchenko
OF APIs are usually NULL-aware and returns an error in case when
device node is not present or supported. We already have a check
for the returned value, no need to check for the parameter.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: added missed updates (hit 'send' too early in v1)
drivers/i3c/master.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index d5dc4180afbc..fd26c4bb8b34 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2276,7 +2276,7 @@ static int of_i3c_master_add_dev(struct i3c_master_controller *master,
u32 reg[3];
int ret;
- if (!master || !node)
+ if (!master)
return -EINVAL;
ret = of_property_read_u32_array(node, "reg", reg, ARRAY_SIZE(reg));
@@ -2369,14 +2369,10 @@ static u8 i3c_master_i2c_get_lvr(struct i2c_client *client)
{
/* Fall back to no spike filters and FM bus mode. */
u8 lvr = I3C_LVR_I2C_INDEX(2) | I3C_LVR_I2C_FM_MODE;
+ u32 reg[3];
- if (client->dev.of_node) {
- u32 reg[3];
-
- if (!of_property_read_u32_array(client->dev.of_node, "reg",
- reg, ARRAY_SIZE(reg)))
- lvr = reg[2];
- }
+ if (!of_property_read_u32_array(client->dev.of_node, "reg", reg, ARRAY_SIZE(reg)))
+ lvr = reg[2];
return lvr;
}
@@ -2486,7 +2482,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
struct i2c_adapter *adap = i3c_master_to_i2c_adapter(master);
struct i2c_dev_desc *i2cdev;
struct i2c_dev_boardinfo *i2cboardinfo;
- int ret, id = -ENODEV;
+ int ret, id;
adap->dev.parent = master->dev.parent;
adap->owner = master->dev.parent->driver->owner;
@@ -2497,9 +2493,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
adap->timeout = 1000;
adap->retries = 3;
- if (master->dev.of_node)
- id = of_alias_get_id(master->dev.of_node, "i2c");
-
+ id = of_alias_get_id(master->dev.of_node, "i2c");
if (id >= 0) {
adap->nr = id;
ret = i2c_add_numbered_adapter(adap);
--
2.47.2
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] i3c: master: Drop duplicate check before calling OF APIs
2025-03-21 19:30 [PATCH v2 1/1] i3c: master: Drop duplicate check before calling OF APIs Andy Shevchenko
@ 2025-03-24 19:39 ` Frank Li
2025-03-31 9:42 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2025-03-24 19:39 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Alexandre Belloni, linux-i3c, linux-kernel
On Fri, Mar 21, 2025 at 09:30:06PM +0200, Andy Shevchenko wrote:
> OF APIs are usually NULL-aware and returns an error in case when
> device node is not present or supported. We already have a check
> for the returned value, no need to check for the parameter.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
>
> v2: added missed updates (hit 'send' too early in v1)
>
> drivers/i3c/master.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index d5dc4180afbc..fd26c4bb8b34 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -2276,7 +2276,7 @@ static int of_i3c_master_add_dev(struct i3c_master_controller *master,
> u32 reg[3];
> int ret;
>
> - if (!master || !node)
> + if (!master)
> return -EINVAL;
>
> ret = of_property_read_u32_array(node, "reg", reg, ARRAY_SIZE(reg));
> @@ -2369,14 +2369,10 @@ static u8 i3c_master_i2c_get_lvr(struct i2c_client *client)
> {
> /* Fall back to no spike filters and FM bus mode. */
> u8 lvr = I3C_LVR_I2C_INDEX(2) | I3C_LVR_I2C_FM_MODE;
> + u32 reg[3];
>
> - if (client->dev.of_node) {
> - u32 reg[3];
> -
> - if (!of_property_read_u32_array(client->dev.of_node, "reg",
> - reg, ARRAY_SIZE(reg)))
> - lvr = reg[2];
> - }
> + if (!of_property_read_u32_array(client->dev.of_node, "reg", reg, ARRAY_SIZE(reg)))
> + lvr = reg[2];
>
> return lvr;
> }
> @@ -2486,7 +2482,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
> struct i2c_adapter *adap = i3c_master_to_i2c_adapter(master);
> struct i2c_dev_desc *i2cdev;
> struct i2c_dev_boardinfo *i2cboardinfo;
> - int ret, id = -ENODEV;
> + int ret, id;
>
> adap->dev.parent = master->dev.parent;
> adap->owner = master->dev.parent->driver->owner;
> @@ -2497,9 +2493,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
> adap->timeout = 1000;
> adap->retries = 3;
>
> - if (master->dev.of_node)
> - id = of_alias_get_id(master->dev.of_node, "i2c");
> -
> + id = of_alias_get_id(master->dev.of_node, "i2c");
> if (id >= 0) {
> adap->nr = id;
> ret = i2c_add_numbered_adapter(adap);
> --
> 2.47.2
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] i3c: master: Drop duplicate check before calling OF APIs
2025-03-21 19:30 [PATCH v2 1/1] i3c: master: Drop duplicate check before calling OF APIs Andy Shevchenko
2025-03-24 19:39 ` Frank Li
@ 2025-03-31 9:42 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2025-03-31 9:42 UTC (permalink / raw)
To: linux-i3c, linux-kernel, Andy Shevchenko; +Cc: Frank Li
On Fri, 21 Mar 2025 21:30:06 +0200, Andy Shevchenko wrote:
> OF APIs are usually NULL-aware and returns an error in case when
> device node is not present or supported. We already have a check
> for the returned value, no need to check for the parameter.
>
>
Applied, thanks!
[1/1] i3c: master: Drop duplicate check before calling OF APIs
https://git.kernel.org/abelloni/c/465e5486aa5e
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-31 9:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 19:30 [PATCH v2 1/1] i3c: master: Drop duplicate check before calling OF APIs Andy Shevchenko
2025-03-24 19:39 ` Frank Li
2025-03-31 9:42 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox