[PATCH 1/1] i2c: lpi2c: Avoid calling clk_get_rate during transfer

Andi Shyti andi.shyti at kernel.org
Thu Jan 18 16:08:37 PST 2024


Hi,

> > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > index 678b30e90492a..6cbcb27a3b280 100644
> > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > @@ -99,6 +99,7 @@ struct lpi2c_imx_struct {
> >  	__u8			*rx_buf;
> >  	__u8			*tx_buf;
> >  	struct completion	complete;
> > +	unsigned long		rate_per;
> >  	unsigned int		msglen;
> >  	unsigned int		delivered;
> >  	unsigned int		block_data;
> > @@ -207,7 +208,7 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
> >  
> >  	lpi2c_imx_set_mode(lpi2c_imx);
> >  
> > -	clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk);
> > +	clk_rate = lpi2c_imx->rate_per;
> >  	if (!clk_rate)
> >  		return -EINVAL;
> 
> After the things you did in lpi2c_imx_probe() you can assume that
> clk_rate is not zero, so you could drop the if here.
> 
> Otherwise looks good to me (if you want even if you keep the if which is
> only a minor optimisation).
> 
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>

you're finding users already... :-)

Looks better than the original version.

Reviewed-by: Andi Shyti <andi.shyti at kernel.org>

Thanks,
Andi



More information about the linux-arm-kernel mailing list