Re: [PATCH v4 08/11] i2c: designware: Convert driver to using regmap API

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

 



On Wed, May 27, 2020 at 03:01:08PM +0300, Serge Semin wrote:
> Seeing the DW I2C driver is using flags-based accessors with two
> conditional clauses it would be better to replace them with the regmap
> API IO methods and to initialize the regmap object with read/write
> callbacks specific to the controller registers map implementation. This
> will be also handy for the drivers with non-standard registers mapping
> (like an embedded into the Baikal-T1 System Controller DW I2C block, which
> glue-driver is a part of this series).
> 
> As before the driver tries to detect the mapping setup at probe stage and
> creates a regmap object accordingly, which will be used by the rest of the
> code to correctly access the controller registers. In two places it was
> appropriate to convert the hand-written read-modify-write and
> read-poll-loop design patterns to the corresponding regmap API
> ready-to-use methods.
> 
> Note the regmap IO methods return value is checked only at the probe
> stage. The rest of the code won't do this because basically we have
> MMIO-based regmap so non of the read/write methods can fail (this also
> won't be needed for the Baikal-T1-specific I2C controller).

Thanks! My comments below.

...

>  #include <linux/export.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/regmap.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>

Please, keep ordered.

...

> +static int dw_reg_write_word(void *context, unsigned int reg, unsigned int val)
> +{
> +	struct dw_i2c_dev *dev = context;
> +

> +	writew_relaxed((u16)val, dev->base + reg);
> +	writew_relaxed((u16)(val >> 16), dev->base + reg + 2);

What does explicit casting here help to?
I think you may drop it.

> +	return 0;
>  }

...

>  #include <linux/errno.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/regmap.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/pm_runtime.h>

Order?

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux