Hello Laurent, On Sun, 14 Jun 2020 at 21:01, Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> wrote: > > To prepare for the split of the camerarx code to a separate file, move > the CAL I/O accessors to cal.h. This requires renaming the accessors > with a cal_prefix, as the current names are too generic and prone to > namespace clashes. > > The reg_read() and read_write() macros, that cover both CAL and CAMERARX > register access, are split in two groups of inline functions, one for > CAL access and one for CAMERARX access. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > --- > drivers/media/platform/ti-vpe/cal-video.c | 1 - > drivers/media/platform/ti-vpe/cal.c | 280 ++++++++++------------ > drivers/media/platform/ti-vpe/cal.h | 36 +++ > 3 files changed, 168 insertions(+), 149 deletions(-) > > diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c > index 82b32a2f9db5..df472a175e83 100644 > --- a/drivers/media/platform/ti-vpe/cal-video.c > +++ b/drivers/media/platform/ti-vpe/cal-video.c > @@ -9,7 +9,6 @@ > * Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > */ > > -#include <linux/bitfield.h> > #include <linux/delay.h> > #include <linux/ioctl.h> > #include <linux/pm_runtime.h> > diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c > index 0bc02ba52b59..abeded3b5e6c 100644 > --- a/drivers/media/platform/ti-vpe/cal.c > +++ b/drivers/media/platform/ti-vpe/cal.c > @@ -9,11 +9,9 @@ > * Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > */ > > -#include <linux/bitfield.h> > #include <linux/clk.h> > #include <linux/delay.h> > #include <linux/interrupt.h> > -#include <linux/io.h> > #include <linux/mfd/syscon.h> > #include <linux/module.h> > #include <linux/of_device.h> > @@ -133,33 +131,6 @@ static const struct cal_data am654_cal_data = { > * ------------------------------------------------------------------ > */ > > -#define reg_read(dev, offset) ioread32(dev->base + offset) > -#define reg_write(dev, offset, val) iowrite32(val, dev->base + offset) > - > -static inline u32 reg_read_field(struct cal_dev *cal, u32 offset, u32 mask) > -{ > - return FIELD_GET(mask, reg_read(cal, offset)); > -} > - > -static inline void reg_write_field(struct cal_dev *cal, u32 offset, u32 value, > - u32 mask) > -{ > - u32 val = reg_read(cal, offset); > - > - val &= ~mask; > - val |= FIELD_PREP(mask, value); > - reg_write(cal, offset, val); > -} > - > -static inline void set_field(u32 *valp, u32 field, u32 mask) > -{ > - u32 val = *valp; > - > - val &= ~mask; > - val |= (field << __ffs(mask)) & mask; > - *valp = val; > -} > - Slightly unrelated, have you considered moving all of these to regmap? Perhaps it will make the code more maintainable. Regards, Ezequiel