lkml.org 
[lkml]   [2018]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 3/9] pinctrl: actions: Add Actions S900 pinctrl driver
Hi Andy,

On Sat, Mar 31, 2018 at 12:16:49AM +0300, Andy Shevchenko wrote:
> On Wed, Mar 28, 2018 at 8:46 PM, Manivannan Sadhasivam
> <manivannan.sadhasivam@linaro.org> wrote:
> > Add pinctrl driver for Actions Semi S900 SoC. The driver supports
> > pinctrl, pinmux and pinconf functionalities through a range of registers
> > common to both gpio driver and pinctrl driver.
> >
> > Pinmux functionality is available only for the pin groups while the
> > pinconf functionality is available for both pin groups and individual
> > pins.
>
> > +static void owl_update_bits(void __iomem *base, u32 mask, u32 val)
> > +{
> > + u32 reg_val;
> > +
> > + reg_val = readl_relaxed(base);
> > +
> > + reg_val &= ~mask;
> > + reg_val |= val;
>
> Usual pattern here is
>
> reg_val = (reg_val & ~mask) | (val & mask);
>
> This will allow to avoid possible overflow.
>

Ack.

> > +
> > + writel_relaxed(reg_val, base);
> > +}
>
> > + tmp = readl_relaxed(pctrl->base + reg);
> > + mask = (1 << width) - 1;
> > + arg = (tmp >> bit) & mask;
>
> This looks like a candidate for a helper function. You have at least
> one more same code.
>
> Something like
>
> ..._read_field(reg, mask, shift)
>
>

Okay. Will add owl_read_field helper function.

> > + mask = (1 << width) - 1;
> > + mask = mask << bit;
> > +
> > + owl_update_bits(pctrl->base + reg, mask, (arg << bit));
>
> Similar here,
>
> ..._write_field(regm mask, shift, arg)
>

Will add owl_write_field helper function.

> > + tmp = readl_relaxed(pctrl->base + reg);
> > + mask = (1 << width) - 1;
> > + arg = (tmp >> bit) & mask;
>
> > + mask = (1 << width) - 1;
> > + mask = mask << bit;
> > +
> > + owl_update_bits(pctrl->base + reg, mask, (arg << bit));
>
> > +static const struct pinconf_ops owl_pinconf_ops = {
> > + .is_generic = true,
> > + .pin_config_get = owl_pin_config_get,
> > + .pin_config_set = owl_pin_config_set,
> > + .pin_config_group_get = owl_group_config_get,
> > + .pin_config_group_set = owl_group_config_set
>
> It's still good idea to leave comma here...
>

I'm confused. What is the criteria for removing/keeping comma for last member
of struct? I followed your gpio driver suggestion.

Thanks,
Mani

> > +};
> > +
> > +static struct pinctrl_desc owl_pinctrl_desc = {
> > + .pctlops = &owl_pinctrl_ops,
> > + .pmxops = &owl_pinmux_ops,
> > + .confops = &owl_pinconf_ops,
> > + .owner = THIS_MODULE
>
> ...and here, and in all similar places.
>
> > +};
> > +
>
> --
> With Best Regards,
> Andy Shevchenko

\
 
 \ /
  Last update: 2018-04-03 19:01    [W:0.111 / U:3.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site