Re: [RFC PATCH v3 4/7] i2c: aspeed: use a function pointer type def for clk_reg_val callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 31, 2023 at 1:08 PM Jonathan Cameron
<Jonathan.Cameron@xxxxxxxxxx> wrote:
>
> Rather than having to define the parameter types of this function
> in multiple places, use a single typedef.

Suggested-by then?

Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>
> ---
> v3: New patch to switch to a function pointer as suggested by Andy.
> ---
>  drivers/i2c/busses/i2c-aspeed.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index 4363bfe06f9b..be93de56f7e4 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -137,6 +137,8 @@ enum aspeed_i2c_slave_state {
>         ASPEED_I2C_SLAVE_STOP,
>  };
>
> +typedef u32 (*aspeed_get_clk_reg_val_cb)(struct device *dev, u32 divisor);
> +
>  struct aspeed_i2c_bus {
>         struct i2c_adapter              adap;
>         struct device                   *dev;
> @@ -145,8 +147,7 @@ struct aspeed_i2c_bus {
>         /* Synchronizes I/O mem access to base. */
>         spinlock_t                      lock;
>         struct completion               cmd_complete;
> -       u32                             (*get_clk_reg_val)(struct device *dev,
> -                                                          u32 divisor);
> +       aspeed_get_clk_reg_val_cb       get_clk_reg_val;
>         unsigned long                   parent_clk_frequency;
>         u32                             bus_frequency;
>         /* Transaction state. */
> @@ -1011,8 +1012,7 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
>         if (!match)
>                 bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val;
>         else
> -               bus->get_clk_reg_val = (u32 (*)(struct device *, u32))
> -                               match->data;
> +               bus->get_clk_reg_val = (aspeed_get_clk_reg_val_cb)(match->data);
>
>         /* Initialize the I2C adapter */
>         spin_lock_init(&bus->lock);
> --
> 2.39.2
>


-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux