Linux-OMAP Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/3] Fix pinctrl-single pcs_pin_dbg_show()
@ 2021-03-16 20:24 Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 1/3] pinctrl: pinctrl-single: remove unused variable Hanna Hawa
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hanna Hawa @ 2021-03-16 20:24 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, tgershi,
	linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, hhhawa

These patches fix the pcs_pin_dbg_show() function for the scenario where
a single register controls multiple pins (i.e. bits_per_mux != 0).
Additionally, the common formula is moved to a separate function to
allow reuse.

Changes since v1:
-----------------
- remove unused variable in In function 'pcs_allocate_pin_table'
  (Reported-by: kernel test robot <lkp@intel.com>)

Hanna Hawa (3):
  pinctrl: pinctrl-single: remove unused variable
  pinctrl: pinctrl-single: remove unused parameter
  pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0

 drivers/pinctrl/pinctrl-single.c | 76 ++++++++++++++++++++------------
 1 file changed, 47 insertions(+), 29 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] pinctrl: pinctrl-single: remove unused variable
  2021-03-16 20:24 [PATCH v2 0/3] Fix pinctrl-single pcs_pin_dbg_show() Hanna Hawa
@ 2021-03-16 20:24 ` Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 2/3] pinctrl: pinctrl-single: remove unused parameter Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0 Hanna Hawa
  2 siblings, 0 replies; 6+ messages in thread
From: Hanna Hawa @ 2021-03-16 20:24 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, tgershi,
	linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, hhhawa

Remove unused parameter 'num_pins_in_register' from
pcs_allocate_pin_table().

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
---
 drivers/pinctrl/pinctrl-single.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 7771316dfffa..91c638b85d2c 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -703,14 +703,12 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
 static int pcs_allocate_pin_table(struct pcs_device *pcs)
 {
 	int mux_bytes, nr_pins, i;
-	int num_pins_in_register = 0;
 
 	mux_bytes = pcs->width / BITS_PER_BYTE;
 
 	if (pcs->bits_per_mux) {
 		pcs->bits_per_pin = fls(pcs->fmask);
 		nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin;
-		num_pins_in_register = pcs->width / pcs->bits_per_pin;
 	} else {
 		nr_pins = pcs->size / mux_bytes;
 	}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] pinctrl: pinctrl-single: remove unused parameter
  2021-03-16 20:24 [PATCH v2 0/3] Fix pinctrl-single pcs_pin_dbg_show() Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 1/3] pinctrl: pinctrl-single: remove unused variable Hanna Hawa
@ 2021-03-16 20:24 ` Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0 Hanna Hawa
  2 siblings, 0 replies; 6+ messages in thread
From: Hanna Hawa @ 2021-03-16 20:24 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, tgershi,
	linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, hhhawa

Remove unused parameter 'pin_pos' from pcs_add_pin().

Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
---
 drivers/pinctrl/pinctrl-single.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 91c638b85d2c..f3394517cb2e 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -656,10 +656,8 @@ static const struct pinconf_ops pcs_pinconf_ops = {
  * pcs_add_pin() - add a pin to the static per controller pin array
  * @pcs: pcs driver instance
  * @offset: register offset from base
- * @pin_pos: unused
  */
-static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
-		unsigned pin_pos)
+static int pcs_add_pin(struct pcs_device *pcs, unsigned int offset)
 {
 	struct pcs_soc_data *pcs_soc = &pcs->socdata;
 	struct pinctrl_pin_desc *pin;
@@ -727,16 +725,14 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
 		unsigned offset;
 		int res;
 		int byte_num;
-		int pin_pos = 0;
 
 		if (pcs->bits_per_mux) {
 			byte_num = (pcs->bits_per_pin * i) / BITS_PER_BYTE;
 			offset = (byte_num / mux_bytes) * mux_bytes;
-			pin_pos = i % num_pins_in_register;
 		} else {
 			offset = i * mux_bytes;
 		}
-		res = pcs_add_pin(pcs, offset, pin_pos);
+		res = pcs_add_pin(pcs, offset);
 		if (res < 0) {
 			dev_err(pcs->dev, "error adding pins: %i\n", res);
 			return res;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0
  2021-03-16 20:24 [PATCH v2 0/3] Fix pinctrl-single pcs_pin_dbg_show() Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 1/3] pinctrl: pinctrl-single: remove unused variable Hanna Hawa
  2021-03-16 20:24 ` [PATCH v2 2/3] pinctrl: pinctrl-single: remove unused parameter Hanna Hawa
@ 2021-03-16 20:24 ` Hanna Hawa
  2021-03-17 12:27   ` Andy Shevchenko
  2 siblings, 1 reply; 6+ messages in thread
From: Hanna Hawa @ 2021-03-16 20:24 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, tgershi,
	linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, hhhawa

An SError was detected when trying to print the supported pins in a
pinctrl device which supports multiple pins per register. This change
fixes the pcs_pin_dbg_show() in pinctrl-single driver when
bits_per_mux != 0. In addition move offset calculation and pin offset in
register to common function.

Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
---
 drivers/pinctrl/pinctrl-single.c | 66 ++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 21 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index f3394517cb2e..434f90c8b1b3 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -270,20 +270,53 @@ static void __maybe_unused pcs_writel(unsigned val, void __iomem *reg)
 	writel(val, reg);
 }
 
+static unsigned int pcs_pin_reg_offset_get(struct pcs_device *pcs,
+					   unsigned int pin)
+{
+	unsigned int offset, mux_bytes;
+
+	mux_bytes = pcs->width / BITS_PER_BYTE;
+
+	if (pcs->bits_per_mux) {
+		unsigned int pin_offset_bytes;
+
+		pin_offset_bytes = (pcs->bits_per_pin * pin) / BITS_PER_BYTE;
+		offset = (pin_offset_bytes / mux_bytes) * mux_bytes;
+	} else {
+		offset = pin * mux_bytes;
+	}
+
+	return offset;
+}
+
+static unsigned int pcs_pin_shift_reg_get(struct pcs_device *pcs,
+					  unsigned int pin)
+{
+	return ((pin % (pcs->width / pcs->bits_per_pin)) * pcs->bits_per_pin);
+}
+
 static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
 					struct seq_file *s,
 					unsigned pin)
 {
 	struct pcs_device *pcs;
-	unsigned val, mux_bytes;
+	unsigned int val;
 	unsigned long offset;
 	size_t pa;
 
 	pcs = pinctrl_dev_get_drvdata(pctldev);
 
-	mux_bytes = pcs->width / BITS_PER_BYTE;
-	offset = pin * mux_bytes;
-	val = pcs->read(pcs->base + offset);
+	offset = pcs_pin_reg_offset_get(pcs, pin);
+
+	if (pcs->bits_per_mux) {
+		unsigned int pin_shift_in_reg = pcs_pin_shift_reg_get(pcs, pin);
+
+		val = pcs->read(pcs->base + offset)
+			& (pcs->fmask << pin_shift_in_reg);
+	} else {
+		val = pcs->read(pcs->base + offset);
+	}
+
 	pa = pcs->res->start + offset;
 
 	seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
@@ -384,7 +417,6 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev,
 	struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
 	struct pcs_gpiofunc_range *frange = NULL;
 	struct list_head *pos, *tmp;
-	int mux_bytes = 0;
 	unsigned data;
 
 	/* If function mask is null, return directly. */
@@ -392,29 +424,27 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev,
 		return -ENOTSUPP;
 
 	list_for_each_safe(pos, tmp, &pcs->gpiofuncs) {
+		u32 offset;
+
 		frange = list_entry(pos, struct pcs_gpiofunc_range, node);
 		if (pin >= frange->offset + frange->npins
 			|| pin < frange->offset)
 			continue;
-		mux_bytes = pcs->width / BITS_PER_BYTE;
 
-		if (pcs->bits_per_mux) {
-			int byte_num, offset, pin_shift;
+		offset = pcs_pin_reg_offset_get(pcs, pin);
 
-			byte_num = (pcs->bits_per_pin * pin) / BITS_PER_BYTE;
-			offset = (byte_num / mux_bytes) * mux_bytes;
-			pin_shift = pin % (pcs->width / pcs->bits_per_pin) *
-				    pcs->bits_per_pin;
+		if (pcs->bits_per_mux) {
+			int pin_shift = pcs_pin_shift_reg_get(pcs, pin);
 
 			data = pcs->read(pcs->base + offset);
 			data &= ~(pcs->fmask << pin_shift);
 			data |= frange->gpiofunc << pin_shift;
 			pcs->write(data, pcs->base + offset);
 		} else {
-			data = pcs->read(pcs->base + pin * mux_bytes);
+			data = pcs->read(pcs->base + offset);
 			data &= ~pcs->fmask;
 			data |= frange->gpiofunc;
-			pcs->write(data, pcs->base + pin * mux_bytes);
+			pcs->write(data, pcs->base + offset);
 		}
 		break;
 	}
@@ -724,14 +754,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
 	for (i = 0; i < pcs->desc.npins; i++) {
 		unsigned offset;
 		int res;
-		int byte_num;
 
-		if (pcs->bits_per_mux) {
-			byte_num = (pcs->bits_per_pin * i) / BITS_PER_BYTE;
-			offset = (byte_num / mux_bytes) * mux_bytes;
-		} else {
-			offset = i * mux_bytes;
-		}
+		offset = pcs_pin_reg_offset_get(pcs, i);
 		res = pcs_add_pin(pcs, offset);
 		if (res < 0) {
 			dev_err(pcs->dev, "error adding pins: %i\n", res);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0
  2021-03-16 20:24 ` [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0 Hanna Hawa
@ 2021-03-17 12:27   ` Andy Shevchenko
  2021-03-17 19:35     ` Hawa, Hanna
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-03-17 12:27 UTC (permalink / raw)
  To: Hanna Hawa
  Cc: Tony Lindgren, Haojian Zhuang, Linus Walleij, David Woodhouse,
	benh, ronenk, talel, jonnyc, hanochu, tgershi,
	linux-arm Mailing List, Linux OMAP Mailing List,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Tue, Mar 16, 2021 at 11:24 PM Hanna Hawa <hhhawa@amazon.com> wrote:
>
> An SError was detected when trying to print the supported pins in a

What SError is?

> pinctrl device which supports multiple pins per register. This change
> fixes the pcs_pin_dbg_show() in pinctrl-single driver when
> bits_per_mux != 0. In addition move offset calculation and pin offset in

'!= 0' -> 'is not zero'

> register to common function.

Fixes tag?

> Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
> ---
>  drivers/pinctrl/pinctrl-single.c | 66 ++++++++++++++++++++++----------
>  1 file changed, 45 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index f3394517cb2e..434f90c8b1b3 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -270,20 +270,53 @@ static void __maybe_unused pcs_writel(unsigned val, void __iomem *reg)
>         writel(val, reg);
>  }
>
> +static unsigned int pcs_pin_reg_offset_get(struct pcs_device *pcs,
> +                                          unsigned int pin)
> +{
> +       unsigned int offset, mux_bytes;

Offset can be replaced by direct return statements.

> +       mux_bytes = pcs->width / BITS_PER_BYTE;
> +
> +       if (pcs->bits_per_mux) {
> +               unsigned int pin_offset_bytes;
> +
> +               pin_offset_bytes = (pcs->bits_per_pin * pin) / BITS_PER_BYTE;
> +               offset = (pin_offset_bytes / mux_bytes) * mux_bytes;
> +       } else {
> +               offset = pin * mux_bytes;
> +       }
> +
> +       return offset;
> +}
> +
> +static unsigned int pcs_pin_shift_reg_get(struct pcs_device *pcs,
> +                                         unsigned int pin)
> +{
> +       return ((pin % (pcs->width / pcs->bits_per_pin)) * pcs->bits_per_pin);

Too many parentheses.

> +}
> +
>  static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
>                                         struct seq_file *s,
>                                         unsigned pin)
>  {
>         struct pcs_device *pcs;
> -       unsigned val, mux_bytes;
> +       unsigned int val;
>         unsigned long offset;
>         size_t pa;
>
>         pcs = pinctrl_dev_get_drvdata(pctldev);
>
> -       mux_bytes = pcs->width / BITS_PER_BYTE;
> -       offset = pin * mux_bytes;
> -       val = pcs->read(pcs->base + offset);
> +       offset = pcs_pin_reg_offset_get(pcs, pin);
> +
> +       if (pcs->bits_per_mux) {
> +               unsigned int pin_shift_in_reg = pcs_pin_shift_reg_get(pcs, pin);

> +               val = pcs->read(pcs->base + offset)
> +                       & (pcs->fmask << pin_shift_in_reg);

One line?
At least move & to the upper line.

> +       } else {
> +               val = pcs->read(pcs->base + offset);

It's the same as in above branch, why not

val = read();
if ()
 val &= fmask << _reg_get(...);

?

> +       }
> +
>         pa = pcs->res->start + offset;
>
>         seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
> @@ -384,7 +417,6 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev,
>         struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
>         struct pcs_gpiofunc_range *frange = NULL;
>         struct list_head *pos, *tmp;
> -       int mux_bytes = 0;
>         unsigned data;
>
>         /* If function mask is null, return directly. */
> @@ -392,29 +424,27 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev,
>                 return -ENOTSUPP;
>
>         list_for_each_safe(pos, tmp, &pcs->gpiofuncs) {
> +               u32 offset;
> +
>                 frange = list_entry(pos, struct pcs_gpiofunc_range, node);
>                 if (pin >= frange->offset + frange->npins
>                         || pin < frange->offset)
>                         continue;
> -               mux_bytes = pcs->width / BITS_PER_BYTE;
>
> -               if (pcs->bits_per_mux) {
> -                       int byte_num, offset, pin_shift;
> +               offset = pcs_pin_reg_offset_get(pcs, pin);
>
> -                       byte_num = (pcs->bits_per_pin * pin) / BITS_PER_BYTE;
> -                       offset = (byte_num / mux_bytes) * mux_bytes;
> -                       pin_shift = pin % (pcs->width / pcs->bits_per_pin) *
> -                                   pcs->bits_per_pin;
> +               if (pcs->bits_per_mux) {
> +                       int pin_shift = pcs_pin_shift_reg_get(pcs, pin);
>
>                         data = pcs->read(pcs->base + offset);
>                         data &= ~(pcs->fmask << pin_shift);
>                         data |= frange->gpiofunc << pin_shift;
>                         pcs->write(data, pcs->base + offset);
>                 } else {
> -                       data = pcs->read(pcs->base + pin * mux_bytes);
> +                       data = pcs->read(pcs->base + offset);
>                         data &= ~pcs->fmask;
>                         data |= frange->gpiofunc;
> -                       pcs->write(data, pcs->base + pin * mux_bytes);
> +                       pcs->write(data, pcs->base + offset);
>                 }
>                 break;
>         }
> @@ -724,14 +754,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
>         for (i = 0; i < pcs->desc.npins; i++) {
>                 unsigned offset;
>                 int res;
> -               int byte_num;
>
> -               if (pcs->bits_per_mux) {
> -                       byte_num = (pcs->bits_per_pin * i) / BITS_PER_BYTE;
> -                       offset = (byte_num / mux_bytes) * mux_bytes;
> -               } else {
> -                       offset = i * mux_bytes;
> -               }
> +               offset = pcs_pin_reg_offset_get(pcs, i);
>                 res = pcs_add_pin(pcs, offset);
>                 if (res < 0) {
>                         dev_err(pcs->dev, "error adding pins: %i\n", res);
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0
  2021-03-17 12:27   ` Andy Shevchenko
@ 2021-03-17 19:35     ` Hawa, Hanna
  0 siblings, 0 replies; 6+ messages in thread
From: Hawa, Hanna @ 2021-03-17 19:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tony Lindgren, Haojian Zhuang, Linus Walleij, David Woodhouse,
	benh, ronenk, talel, jonnyc, hanochu, tgershi,
	linux-arm Mailing List, Linux OMAP Mailing List,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List



On 3/17/2021 2:27 PM, Andy Shevchenko wrote:
> 
> On Tue, Mar 16, 2021 at 11:24 PM Hanna Hawa <hhhawa@amazon.com> wrote:
>>
>> An SError was detected when trying to print the supported pins in a
> 
> What SError is?

System error:
[   24.257831] SError Interrupt on CPU0, code 0xbf000002 -- SError
...
[   24.257855] Kernel panic - not syncing: Asynchronous SError Interrupt

> 
>> pinctrl device which supports multiple pins per register. This change
>> fixes the pcs_pin_dbg_show() in pinctrl-single driver when
>> bits_per_mux != 0. In addition move offset calculation and pin offset in
> 
> '!= 0' -> 'is not zero'

Will be fixed.

> 
>> register to common function.
> 
> Fixes tag?

Sure, will be added.

> 
>> Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
>> ---
>>   drivers/pinctrl/pinctrl-single.c | 66 ++++++++++++++++++++++----------
>>   1 file changed, 45 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
>> index f3394517cb2e..434f90c8b1b3 100644
>> --- a/drivers/pinctrl/pinctrl-single.c
>> +++ b/drivers/pinctrl/pinctrl-single.c
>> @@ -270,20 +270,53 @@ static void __maybe_unused pcs_writel(unsigned val, void __iomem *reg)
>>          writel(val, reg);
>>   }
>>
>> +static unsigned int pcs_pin_reg_offset_get(struct pcs_device *pcs,
>> +                                          unsigned int pin)
>> +{
>> +       unsigned int offset, mux_bytes;
> 
> Offset can be replaced by direct return statements.

Ack.

> 
>> +       mux_bytes = pcs->width / BITS_PER_BYTE;
>> +
>> +       if (pcs->bits_per_mux) {
>> +               unsigned int pin_offset_bytes;
>> +
>> +               pin_offset_bytes = (pcs->bits_per_pin * pin) / BITS_PER_BYTE;
>> +               offset = (pin_offset_bytes / mux_bytes) * mux_bytes;
>> +       } else {
>> +               offset = pin * mux_bytes;
>> +       }
>> +
>> +       return offset;
>> +}
>> +
>> +static unsigned int pcs_pin_shift_reg_get(struct pcs_device *pcs,
>> +                                         unsigned int pin)
>> +{
>> +       return ((pin % (pcs->width / pcs->bits_per_pin)) * pcs->bits_per_pin);
> 
> Too many parentheses.

Will remove the extra parentheses.

> 
>> +}
>> +
>>   static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
>>                                          struct seq_file *s,
>>                                          unsigned pin)
>>   {
>>          struct pcs_device *pcs;
>> -       unsigned val, mux_bytes;
>> +       unsigned int val;
>>          unsigned long offset;
>>          size_t pa;
>>
>>          pcs = pinctrl_dev_get_drvdata(pctldev);
>>
>> -       mux_bytes = pcs->width / BITS_PER_BYTE;
>> -       offset = pin * mux_bytes;
>> -       val = pcs->read(pcs->base + offset);
>> +       offset = pcs_pin_reg_offset_get(pcs, pin);
>> +
>> +       if (pcs->bits_per_mux) {
>> +               unsigned int pin_shift_in_reg = pcs_pin_shift_reg_get(pcs, pin);
> 
>> +               val = pcs->read(pcs->base + offset)
>> +                       & (pcs->fmask << pin_shift_in_reg);
> 
> One line?
> At least move & to the upper line.
> 
>> +       } else {
>> +               val = pcs->read(pcs->base + offset);
> 
> It's the same as in above branch, why not
> 
> val = read();
> if ()
>   val &= fmask << _reg_get(...);
> 
> ?

Agree, looks better

Thanks Andy, will send new patchset soon.

Thanks,
Hanna

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 20:24 [PATCH v2 0/3] Fix pinctrl-single pcs_pin_dbg_show() Hanna Hawa
2021-03-16 20:24 ` [PATCH v2 1/3] pinctrl: pinctrl-single: remove unused variable Hanna Hawa
2021-03-16 20:24 ` [PATCH v2 2/3] pinctrl: pinctrl-single: remove unused parameter Hanna Hawa
2021-03-16 20:24 ` [PATCH v2 3/3] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0 Hanna Hawa
2021-03-17 12:27   ` Andy Shevchenko
2021-03-17 19:35     ` Hawa, Hanna

Linux-OMAP Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-omap/0 linux-omap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-omap linux-omap/ https://lore.kernel.org/linux-omap \
		linux-omap@vger.kernel.org
	public-inbox-index linux-omap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-omap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git