Message ID | 20210107190200.41221-3-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | [v1,1/4] pinctrl: intel: Split intel_pinctrl_add_padgroups() for better maintenance | expand |
On Thu, Jan 07, 2021 at 09:01:59PM +0200, Andy Shevchenko wrote: > switch-case is slightly better to maintain in case some new features will come > in new revisions of the hardware. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/pinctrl/intel/pinctrl-intel.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c > index 1a479112ed85..00979acb0203 100644 > --- a/drivers/pinctrl/intel/pinctrl-intel.c > +++ b/drivers/pinctrl/intel/pinctrl-intel.c > @@ -1483,9 +1483,13 @@ static int intel_pinctrl_probe(struct platform_device *pdev, > > /* Determine community features based on the revision */ > value = readl(regs + REVID); > - if (((value & REVID_MASK) >> REVID_SHIFT) >= 0x94) { > + switch ((value & REVID_MASK) >> REVID_SHIFT) { > + case 0x0094 ... 0xffff: > community->features |= PINCTRL_FEATURE_DEBOUNCE; > community->features |= PINCTRL_FEATURE_1K_PD; > + break; > + default: > + break; This adds 4 new lines and I don't think it improves anything so I suggest we leave it as is for now. Once we have hardware that actually implements some new features we can reconsider something like this.
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 1a479112ed85..00979acb0203 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1483,9 +1483,13 @@ static int intel_pinctrl_probe(struct platform_device *pdev, /* Determine community features based on the revision */ value = readl(regs + REVID); - if (((value & REVID_MASK) >> REVID_SHIFT) >= 0x94) { + switch ((value & REVID_MASK) >> REVID_SHIFT) { + case 0x0094 ... 0xffff: community->features |= PINCTRL_FEATURE_DEBOUNCE; community->features |= PINCTRL_FEATURE_1K_PD; + break; + default: + break; } /* Read offset of the pad configuration registers */
switch-case is slightly better to maintain in case some new features will come in new revisions of the hardware. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pinctrl/intel/pinctrl-intel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)