Message ID | 20230531100600.13543-6-Jonathan.Cameron@huawei.com |
---|---|
State | New |
Headers | show |
Series | i2c: Enabling use of aspeed-i2c with ACPI | expand |
On Wed, May 31, 2023 at 1:08 PM Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote: > > Moving over to generic firmware properties allows this driver to > get closer to working out of the box with both device tree and > other firmware options, such as ACPI via PRP0001. > > Tested only via QEMU emulation. ... > static int aspeed_i2c_probe_bus(struct platform_device *pdev) > { > - const struct of_device_id *match; With struct device *dev = &pdev->dev; ... > + device_property_read_u32(&pdev->dev, > + "bus-frequency", &bus->bus_frequency); This can take one or both parameters on one line. ... > + bus->get_clk_reg_val = > + (aspeed_get_clk_reg_val_cb)device_get_match_data(&pdev->dev); This one as well I believe. Also others, but it can be done in a separate patch.
On Wed, 31 May 2023 20:45:08 +0300 Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Wed, May 31, 2023 at 1:08 PM Jonathan Cameron > <Jonathan.Cameron@huawei.com> wrote: > > > > Moving over to generic firmware properties allows this driver to > > get closer to working out of the box with both device tree and > > other firmware options, such as ACPI via PRP0001. > > > > Tested only via QEMU emulation. > > ... > > > static int aspeed_i2c_probe_bus(struct platform_device *pdev) > > { > > - const struct of_device_id *match; > > With > > struct device *dev = &pdev->dev; > > ... > > > + device_property_read_u32(&pdev->dev, > > + "bus-frequency", &bus->bus_frequency); > > This can take one or both parameters on one line. > > ... > > > + bus->get_clk_reg_val = > > + (aspeed_get_clk_reg_val_cb)device_get_match_data(&pdev->dev); > > This one as well I believe. > > Also others, but it can be done in a separate patch. > I thought about it, but decided out of scope for this set. I'm not aiming for too much general tidying! Jonathan
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index be93de56f7e4..992d64acd38d 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -18,9 +18,8 @@ #include <linux/irq.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/of_address.h> -#include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/reset.h> #include <linux/slab.h> @@ -976,7 +975,6 @@ MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table); static int aspeed_i2c_probe_bus(struct platform_device *pdev) { - const struct of_device_id *match; struct aspeed_i2c_bus *bus; struct clk *parent_clk; int irq, ret; @@ -1005,14 +1003,13 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev) reset_control_deassert(bus->rst); bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ; - of_property_read_u32(pdev->dev.of_node, - "bus-frequency", &bus->bus_frequency); + device_property_read_u32(&pdev->dev, + "bus-frequency", &bus->bus_frequency); - match = of_match_node(aspeed_i2c_bus_of_table, pdev->dev.of_node); - if (!match) + bus->get_clk_reg_val = + (aspeed_get_clk_reg_val_cb)device_get_match_data(&pdev->dev); + if (!bus->get_clk_reg_val) bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; - else - bus->get_clk_reg_val = (aspeed_get_clk_reg_val_cb)(match->data); /* Initialize the I2C adapter */ spin_lock_init(&bus->lock);
Moving over to generic firmware properties allows this driver to get closer to working out of the box with both device tree and other firmware options, such as ACPI via PRP0001. Tested only via QEMU emulation. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> --- v3: - Use a typedef for the function pointer type as introduced in precusor patch --- drivers/i2c/busses/i2c-aspeed.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)