diff mbox series

[v1,3/4] pinctrl: intel: Convert revision conditional to switch-case

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

Commit Message

Andy Shevchenko Jan. 7, 2021, 7:01 p.m. UTC
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(-)

Comments

Mika Westerberg Jan. 8, 2021, 7:05 a.m. UTC | #1
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 mbox series

Patch

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 */