All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix pinctrl-single pcs_pin_dbg_show()
@ 2021-03-15 14:59 ` Hanna Hawa
  0 siblings, 0 replies; 7+ messages in thread
From: Hanna Hawa @ 2021-03-15 14:59 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.

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

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

-- 
2.17.1


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

* [PATCH 0/2] Fix pinctrl-single pcs_pin_dbg_show()
@ 2021-03-15 14:59 ` Hanna Hawa
  0 siblings, 0 replies; 7+ messages in thread
From: Hanna Hawa @ 2021-03-15 14:59 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.

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

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

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/2] pinctrl: pinctrl-single: remove unused parameter
  2021-03-15 14:59 ` Hanna Hawa
@ 2021-03-15 14:59   ` Hanna Hawa
  -1 siblings, 0 replies; 7+ messages in thread
From: Hanna Hawa @ 2021-03-15 14:59 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 7771316dfffa..8a7922459896 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;
@@ -729,16 +727,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 related	[flat|nested] 7+ messages in thread

* [PATCH 1/2] pinctrl: pinctrl-single: remove unused parameter
@ 2021-03-15 14:59   ` Hanna Hawa
  0 siblings, 0 replies; 7+ messages in thread
From: Hanna Hawa @ 2021-03-15 14:59 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 7771316dfffa..8a7922459896 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;
@@ -729,16 +727,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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0
  2021-03-15 14:59 ` Hanna Hawa
@ 2021-03-15 14:59   ` Hanna Hawa
  -1 siblings, 0 replies; 7+ messages in thread
From: Hanna Hawa @ 2021-03-15 14:59 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 8a7922459896..0288bf430916 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;
 	}
@@ -726,14 +756,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 related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0
@ 2021-03-15 14:59   ` Hanna Hawa
  0 siblings, 0 replies; 7+ messages in thread
From: Hanna Hawa @ 2021-03-15 14:59 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 8a7922459896..0288bf430916 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;
 	}
@@ -726,14 +756,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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] pinctrl: pinctrl-single: remove unused parameter
  2021-03-15 14:59   ` Hanna Hawa
  (?)
@ 2021-03-15 20:39   ` kernel test robot
  -1 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-03-15 20:39 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7128 bytes --]

Hi Hanna,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pinctrl/devel]
[also build test WARNING on v5.12-rc3 next-20210315]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hanna-Hawa/Fix-pinctrl-single-pcs_pin_dbg_show/20210315-230418
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: ia64-randconfig-r011-20210315 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/518757b3bf7378b1c46be74640d0754e47e83624
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hanna-Hawa/Fix-pinctrl-single-pcs_pin_dbg_show/20210315-230418
        git checkout 518757b3bf7378b1c46be74640d0754e47e83624
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from arch/ia64/include/asm/pgtable.h:154,
                    from include/linux/pgtable.h:6,
                    from arch/ia64/include/asm/uaccess.h:40,
                    from include/linux/uaccess.h:11,
                    from arch/ia64/include/asm/sections.h:11,
                    from include/linux/interrupt.h:20,
                    from drivers/pinctrl/pinctrl-single.c:18:
   arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
   arch/ia64/include/asm/mmu_context.h:127:41: warning: variable 'old_rr4' set but not used [-Wunused-but-set-variable]
     127 |  unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
         |                                         ^~~~~~~
   drivers/pinctrl/pinctrl-single.c: In function 'pcs_allocate_pin_table':
>> drivers/pinctrl/pinctrl-single.c:704:6: warning: variable 'num_pins_in_register' set but not used [-Wunused-but-set-variable]
     704 |  int num_pins_in_register = 0;
         |      ^~~~~~~~~~~~~~~~~~~~


vim +/num_pins_in_register +704 drivers/pinctrl/pinctrl-single.c

8b8b091bf07fa7 Tony Lindgren          2012-07-10  691  
8b8b091bf07fa7 Tony Lindgren          2012-07-10  692  /**
8b8b091bf07fa7 Tony Lindgren          2012-07-10  693   * pcs_allocate_pin_table() - adds all the pins for the pinctrl driver
8b8b091bf07fa7 Tony Lindgren          2012-07-10  694   * @pcs: pcs driver instance
8b8b091bf07fa7 Tony Lindgren          2012-07-10  695   *
8b8b091bf07fa7 Tony Lindgren          2012-07-10  696   * In case of errors, resources are freed in pcs_free_resources.
8b8b091bf07fa7 Tony Lindgren          2012-07-10  697   *
8b8b091bf07fa7 Tony Lindgren          2012-07-10  698   * If your hardware needs holes in the address space, then just set
8b8b091bf07fa7 Tony Lindgren          2012-07-10  699   * up multiple driver instances.
8b8b091bf07fa7 Tony Lindgren          2012-07-10  700   */
150632b09aadf1 Greg Kroah-Hartman     2012-12-21  701  static int pcs_allocate_pin_table(struct pcs_device *pcs)
8b8b091bf07fa7 Tony Lindgren          2012-07-10  702  {
8b8b091bf07fa7 Tony Lindgren          2012-07-10  703  	int mux_bytes, nr_pins, i;
6f924b0b7cbe2a Manjunathappa, Prakash 2013-05-21 @704  	int num_pins_in_register = 0;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  705  
8b8b091bf07fa7 Tony Lindgren          2012-07-10  706  	mux_bytes = pcs->width / BITS_PER_BYTE;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  707  
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  708  	if (pcs->bits_per_mux) {
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  709  		pcs->bits_per_pin = fls(pcs->fmask);
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  710  		nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin;
6f924b0b7cbe2a Manjunathappa, Prakash 2013-05-21  711  		num_pins_in_register = pcs->width / pcs->bits_per_pin;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  712  	} else {
8b8b091bf07fa7 Tony Lindgren          2012-07-10  713  		nr_pins = pcs->size / mux_bytes;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  714  	}
8b8b091bf07fa7 Tony Lindgren          2012-07-10  715  
8b8b091bf07fa7 Tony Lindgren          2012-07-10  716  	dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins);
a86854d0c599b3 Kees Cook              2018-06-12  717  	pcs->pins.pa = devm_kcalloc(pcs->dev,
a86854d0c599b3 Kees Cook              2018-06-12  718  				nr_pins, sizeof(*pcs->pins.pa),
8b8b091bf07fa7 Tony Lindgren          2012-07-10  719  				GFP_KERNEL);
8b8b091bf07fa7 Tony Lindgren          2012-07-10  720  	if (!pcs->pins.pa)
8b8b091bf07fa7 Tony Lindgren          2012-07-10  721  		return -ENOMEM;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  722  
8b8b091bf07fa7 Tony Lindgren          2012-07-10  723  	pcs->desc.pins = pcs->pins.pa;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  724  	pcs->desc.npins = nr_pins;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  725  
8b8b091bf07fa7 Tony Lindgren          2012-07-10  726  	for (i = 0; i < pcs->desc.npins; i++) {
8b8b091bf07fa7 Tony Lindgren          2012-07-10  727  		unsigned offset;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  728  		int res;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  729  		int byte_num;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  730  
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  731  		if (pcs->bits_per_mux) {
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  732  			byte_num = (pcs->bits_per_pin * i) / BITS_PER_BYTE;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  733  			offset = (byte_num / mux_bytes) * mux_bytes;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  734  		} else {
8b8b091bf07fa7 Tony Lindgren          2012-07-10  735  			offset = i * mux_bytes;
4e7e8017a80e18 Manjunathappa, Prakash 2013-05-21  736  		}
518757b3bf7378 Hanna Hawa             2021-03-15  737  		res = pcs_add_pin(pcs, offset);
8b8b091bf07fa7 Tony Lindgren          2012-07-10  738  		if (res < 0) {
8b8b091bf07fa7 Tony Lindgren          2012-07-10  739  			dev_err(pcs->dev, "error adding pins: %i\n", res);
8b8b091bf07fa7 Tony Lindgren          2012-07-10  740  			return res;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  741  		}
8b8b091bf07fa7 Tony Lindgren          2012-07-10  742  	}
8b8b091bf07fa7 Tony Lindgren          2012-07-10  743  
8b8b091bf07fa7 Tony Lindgren          2012-07-10  744  	return 0;
8b8b091bf07fa7 Tony Lindgren          2012-07-10  745  }
8b8b091bf07fa7 Tony Lindgren          2012-07-10  746  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 23280 bytes --]

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

end of thread, other threads:[~2021-03-15 20:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 14:59 [PATCH 0/2] Fix pinctrl-single pcs_pin_dbg_show() Hanna Hawa
2021-03-15 14:59 ` Hanna Hawa
2021-03-15 14:59 ` [PATCH 1/2] pinctrl: pinctrl-single: remove unused parameter Hanna Hawa
2021-03-15 14:59   ` Hanna Hawa
2021-03-15 20:39   ` kernel test robot
2021-03-15 14:59 ` [PATCH 2/2] pinctrl: pinctrl-single: fix pcs_pin_dbg_show() when bits_per_mux != 0 Hanna Hawa
2021-03-15 14:59   ` Hanna Hawa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.