[v1,7/9] i2c: desingware: Unify firmware type checks
Commit Message
Instead of asymmetrical checks for the firmware use is_*_node()
calls. With that, drop now local wrappers against
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 23 +++++++---------------
1 file changed, 7 insertions(+), 16 deletions(-)
Comments
Hi Andy,
On Tue, Jul 25, 2023 at 05:30:21PM +0300, Andy Shevchenko wrote:
> Instead of asymmetrical checks for the firmware use is_*_node()
> calls. With that, drop now local wrappers against
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/i2c/busses/i2c-designware-common.c | 23 +++++++---------------
> 1 file changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
> index 443426474cfc..e6df6a484955 100644
> --- a/drivers/i2c/busses/i2c-designware-common.c
> +++ b/drivers/i2c/busses/i2c-designware-common.c
> @@ -241,15 +241,9 @@ static void i2c_dw_of_do_configure(struct dw_i2c_dev *dev, struct device *device
> }
> }
>
> -static void i2c_dw_of_configure(struct dw_i2c_dev *dev)
> -{
> - if (dev_of_node(dev->dev))
> - i2c_dw_of_do_configure(dev, dev->dev);
> -}
> -
I have to partially agree with Jarkko here, the patch splitting
of this series is a bit too exotic. Series need to be understood
by reading them forward, not backward.
Oversplitting sometimes might even reduce readability and
"reviewability" (can I say so?). And this function, in seven
patches, has been added, moved and removed, and I had to read the
series twice :)
Anyway, I won't ask you to refactor the whole series, I
understand your logic.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Andi
@@ -241,15 +241,9 @@ static void i2c_dw_of_do_configure(struct dw_i2c_dev *dev, struct device *device
}
}
-static void i2c_dw_of_configure(struct dw_i2c_dev *dev)
-{
- if (dev_of_node(dev->dev))
- i2c_dw_of_do_configure(dev, dev->dev);
-}
-
#else /* CONFIG_OF */
-static inline void i2c_dw_of_configure(struct dw_i2c_dev *dev) { }
+static inline void i2c_dw_of_do_configure(struct dw_i2c_dev *dev, struct device *device) { }
#endif /* CONFIG_OF */
@@ -329,12 +323,6 @@ static void i2c_dw_acpi_do_configure(struct dw_i2c_dev *dev, struct device *devi
}
}
-static void i2c_dw_acpi_configure(struct dw_i2c_dev *dev)
-{
- if (has_acpi_companion(dev->dev))
- i2c_dw_acpi_do_configure(dev, dev->dev);
-}
-
static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
{
u32 acpi_speed;
@@ -355,7 +343,7 @@ static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
#else /* CONFIG_ACPI */
-static inline void i2c_dw_acpi_configure(struct dw_i2c_dev *dev) { }
+static inline void i2c_dw_acpi_do_configure(struct dw_i2c_dev *dev, struct device *device) { }
static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; }
@@ -380,14 +368,17 @@ static void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)
{
+ struct fwnode_handle *fwnode = dev_fwnode(dev->dev);
struct i2c_timings *t = &dev->timings;
i2c_parse_fw_timings(dev->dev, t, false);
i2c_dw_adjust_bus_speed(dev);
- i2c_dw_of_configure(dev);
- i2c_dw_acpi_configure(dev);
+ if (is_of_node(fwnode))
+ i2c_dw_of_do_configure(dev, dev->dev);
+ else if (is_acpi_node(fwnode))
+ i2c_dw_acpi_do_configure(dev, dev->dev);
return i2c_dw_validate_speed(dev);
}