Message ID | 20211115154201.46579-2-andriy.shevchenko@linux.intel.com |
---|---|
State | Accepted |
Headers | show |
Series | [v1,1/3] i2c: mux: gpio: Replace custom acpi_get_local_address() | expand |
On Mon, Nov 15, 2021 at 7:42 AM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > We have a special helper to get fwnode out of struct device. > Moreover, dereferencing it directly prevents the fwnode > modifications in the future. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Evan Green <evgreen@chromium.org>
Hi! On 2021-11-15 16:42, Andy Shevchenko wrote: > We have a special helper to get fwnode out of struct device. > Moreover, dereferencing it directly prevents the fwnode > modifications in the future. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/i2c/muxes/i2c-mux-gpio.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c > index 31e6eb1591bb..b09c10f36ddb 100644 > --- a/drivers/i2c/muxes/i2c-mux-gpio.c > +++ b/drivers/i2c/muxes/i2c-mux-gpio.c > @@ -53,6 +53,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, > struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > + struct fwnode_handle *fwnode = dev_fwnode(dev); > struct device_node *np = dev->of_node; It feels like there is opportunity to get rid of np, but I suppose that can be done later... Acked-by: Peter Rosin <peda@axentia.se> Cheers, Peter > struct device_node *adapter_np; > struct i2c_adapter *adapter = NULL; > @@ -60,7 +61,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, > unsigned *values; > int rc, i = 0; > > - if (is_of_node(dev->fwnode)) { > + if (is_of_node(fwnode)) { > if (!np) > return -ENODEV; > > @@ -72,7 +73,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, > adapter = of_find_i2c_adapter_by_node(adapter_np); > of_node_put(adapter_np); > > - } else if (is_acpi_node(dev->fwnode)) { > + } else if (is_acpi_node(fwnode)) { > /* > * In ACPI land the mux should be a direct child of the i2c > * bus it muxes. > @@ -111,7 +112,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, > } > mux->data.values = values; > > - if (fwnode_property_read_u32(dev->fwnode, "idle-state", &mux->data.idle)) > + if (device_property_read_u32(dev, "idle-state", &mux->data.idle)) > mux->data.idle = I2C_MUX_GPIO_NO_IDLE; > > return 0; >
On Mon, Nov 15, 2021 at 05:42:00PM +0200, Andy Shevchenko wrote: > We have a special helper to get fwnode out of struct device. > Moreover, dereferencing it directly prevents the fwnode > modifications in the future. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Applied to for-next, thanks!
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 31e6eb1591bb..b09c10f36ddb 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -53,6 +53,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct device_node *np = dev->of_node; struct device_node *adapter_np; struct i2c_adapter *adapter = NULL; @@ -60,7 +61,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, unsigned *values; int rc, i = 0; - if (is_of_node(dev->fwnode)) { + if (is_of_node(fwnode)) { if (!np) return -ENODEV; @@ -72,7 +73,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, adapter = of_find_i2c_adapter_by_node(adapter_np); of_node_put(adapter_np); - } else if (is_acpi_node(dev->fwnode)) { + } else if (is_acpi_node(fwnode)) { /* * In ACPI land the mux should be a direct child of the i2c * bus it muxes. @@ -111,7 +112,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, } mux->data.values = values; - if (fwnode_property_read_u32(dev->fwnode, "idle-state", &mux->data.idle)) + if (device_property_read_u32(dev, "idle-state", &mux->data.idle)) mux->data.idle = I2C_MUX_GPIO_NO_IDLE; return 0;
We have a special helper to get fwnode out of struct device. Moreover, dereferencing it directly prevents the fwnode modifications in the future. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/i2c/muxes/i2c-mux-gpio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)