diff mbox series

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

Message ID 20230531100600.13543-5-Jonathan.Cameron@huawei.com
State New, archived
Headers show
Series i2c: Enabling use of aspeed-i2c with ACPI | expand

Commit Message

Jonathan Cameron May 31, 2023, 10:05 a.m. UTC
Rather than having to define the parameter types of this function
in multiple places, use a single typedef.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

---
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(-)

Comments

Andy Shevchenko May 31, 2023, 5:42 p.m. UTC | #1
On Wed, May 31, 2023 at 1:08 PM Jonathan Cameron
<Jonathan.Cameron@huawei.com> 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@gmail.com>

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> ---
> 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
>
Jonathan Cameron June 1, 2023, 9:07 a.m. UTC | #2
On Wed, 31 May 2023 20:42:15 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, May 31, 2023 at 1:08 PM Jonathan Cameron
> <Jonathan.Cameron@huawei.com> wrote:
> >
> > Rather than having to define the parameter types of this function
> > in multiple places, use a single typedef.  
> 
> Suggested-by then?
> 
Good point.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Hopefully Wolfram uses b4 and that will get picked up automatically.

> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > ---
> > 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
> >  
> 
>
diff mbox series

Patch

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);