Skip to contentSkip to conversation

Few pinctrl-single clean-ups

PATCH In review Tony Lindgren 2 participants 12 messages Oct 25, 2016 – Oct 28, 2016

Subsystems (3)
lore
Share & tools
lore

Tony Lindgren

author maintainer
#0 lore raw

cover Few pinctrl-single clean-ups

Hi,

In preparation for some more generic pinctrl changes, here are two clean-up patches for pinctrl-single.

Regards,

Tony

Tony Lindgren (2):
pinctrl: single: Drop custom names
pinctrl: single: Drop pointless macro

 drivers/pinctrl/pinctrl-single.c | 53 +++++++++-------------------------------
 1 file changed, 12 insertions(+), 41 deletions(-)
Signature · 1 line
2.9.3
author maintainer
#1 lore raw

PATCH 1/2 pinctrl: single: Drop custom names

We no longer need to allocate custom names as those are dynamically generated in pinctrl_register_one_pin() if no name is passed to pinctrl_register_pins().

---
 drivers/pinctrl/pinctrl-single.c | 35 +++++------------------------------
 1 file changed, 5 insertions(+), 30 deletions(-)
drivers/pinctrl/pinctrl-single.c +5 -30
@@ -36,7 +36,6 @@
 #define DRIVER_NAME			"pinctrl-single"
 #define PCS_MUX_PINS_NAME		"pinctrl-single,pins"
 #define PCS_MUX_BITS_NAME		"pinctrl-single,bits"
-#define PCS_REG_NAME_LEN		((sizeof(unsigned long) * 2) + 3)
 #define PCS_OFF_DISABLED		~0U
 
 /**
@@ -142,20 +141,6 @@ struct pcs_data {
 };
 
 /**
- * struct pcs_name - register name for a pin
- * @name:	name of the pinctrl register
- *
- * REVISIT: We may want to make names optional in the pinctrl
- * framework as some drivers may not care about pin names to
- * avoid kernel bloat. The pin names can be deciphered by user
- * space tools using debugfs based on the register address and
- * SoC packaging information.
- */
-struct pcs_name {
-	char name[PCS_REG_NAME_LEN];
-};
-
-/**
  * struct pcs_soc_data - SoC specific settings
  * @flags:	initial SoC specific PCS_FEAT_xxx values
  * @irq:	optional interrupt for the controller
@@ -187,7 +172,6 @@ struct pcs_soc_data {
  * @foff:	value to turn mux off
  * @fmax:	max number of functions in fmask
  * @bits_per_pin:number of bits per pin
- * @names:	array of register names for pins
  * @pins:	physical pins on the SoC
  * @pgtree:	pingroup index radix tree
  * @ftree:	function index radix tree
@@ -223,7 +207,6 @@ struct pcs_device {
 	unsigned fmax;
 	bool bits_per_mux;
 	unsigned bits_per_pin;
-	struct pcs_name *names;
 	struct pcs_data pins;
 	struct radix_tree_root pgtree;
 	struct radix_tree_root ftree;
@@ -354,13 +337,16 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
 {
 	struct pcs_device *pcs;
 	unsigned val, mux_bytes;
+	unsigned long offset;
 
 	pcs = pinctrl_dev_get_drvdata(pctldev);
 
 	mux_bytes = pcs->width / BITS_PER_BYTE;
-	val = pcs->read(pcs->base + pin * mux_bytes);
+	offset = pin * mux_bytes;
+	val = pcs->read(pcs->base + offset);
 
-	seq_printf(s, "%08x %s " , val, DRIVER_NAME);
+	seq_printf(s, "%lx %08x %s ", pcs->res->start + offset, val,
+		   DRIVER_NAME);
 }
 
 static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
@@ -763,7 +749,6 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
 {
 	struct pcs_soc_data *pcs_soc = &pcs->socdata;
 	struct pinctrl_pin_desc *pin;
-	struct pcs_name *pn;
 	int i;
 
 	i = pcs->pins.cur;
@@ -786,10 +771,6 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
 	}
 
 	pin = &pcs->pins.pa[i];
-	pn = &pcs->names[i];
-	sprintf(pn->name, "%lx.%u",
-		(unsigned long)pcs->res->start + offset, pin_pos);
-	pin->name = pn->name;
 	pin->number = i;
 	pcs->pins.cur++;
 
@@ -827,12 +808,6 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
 	if (!pcs->pins.pa)
 		return -ENOMEM;
 
-	pcs->names = devm_kzalloc(pcs->dev,
-				sizeof(struct pcs_name) * nr_pins,
-				GFP_KERNEL);
-	if (!pcs->names)
-		return -ENOMEM;
-
 	pcs->desc.pins = pcs->pins.pa;
 	pcs->desc.npins = nr_pins;
 
Signature · 1 line
2.9.3
author maintainer
#4 lore raw

PATCH 2/2 pinctrl: single: Drop pointless macro

In reply to Tony Lindgren

This is left over from initial experiments with more properties. It's only used in one place, so let's just get rid of it to make the code more readable.

---
 drivers/pinctrl/pinctrl-single.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/pinctrl/pinctrl-single.c +7 -11
@@ -1471,15 +1471,6 @@ static void pcs_free_resources(struct pcs_device *pcs)
 	pcs_free_pingroups(pcs);
 }
 
-#define PCS_GET_PROP_U32(name, reg, err)				\
-	do {								\
-		ret = of_property_read_u32(np, name, reg);		\
-		if (ret) {						\
-			dev_err(pcs->dev, err);				\
-			return ret;					\
-		}							\
-	} while (0);
-
 static const struct of_device_id pcs_of_match[];
 
 static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs)
@@ -1824,8 +1815,13 @@ static int pcs_probe(struct platform_device *pdev)
 	pcs->flags = soc->flags;
 	memcpy(&pcs->socdata, soc, sizeof(*soc));
 
-	PCS_GET_PROP_U32("pinctrl-single,register-width", &pcs->width,
-			 "register width not specified\n");
+	ret = of_property_read_u32(np, "pinctrl-single,register-width",
+				   &pcs->width);
+	if (ret) {
+		dev_err(pcs->dev, "register width not specified\n");
+
+		return ret;
+	}
 
 	ret = of_property_read_u32(np, "pinctrl-single,function-mask",
 				   &pcs->fmask);
Signature · 1 line
2.9.3
author maintainer
#2 lore raw

Re: [PATCH 1/2] pinctrl: single: Drop custom names

In reply to Tony Lindgren
Quoted 3 lines · Tony Lindgren

We no longer need to allocate custom names as those are dynamically generated in pinctrl_register_one_pin() if no name is passed to pinctrl_register_pins().

...

Quoted 7 lines
drivers/pinctrl/pinctrl-single.c +1 -0
@@ -354,13 +337,16 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
 {
 	struct pcs_device *pcs;
 	unsigned val, mux_bytes;
+	unsigned long offset;
 
 	pcs = pinctrl_dev_get_drvdata(pctldev);

drivers/pinctrl/pinctrl-single.c static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev, · line 350

Quoted 10 lines
drivers/pinctrl/pinctrl-single.c +4 -2
 
 	mux_bytes = pcs->width / BITS_PER_BYTE;
-	val = pcs->read(pcs->base + pin * mux_bytes);
+	offset = pin * mux_bytes;
+	val = pcs->read(pcs->base + offset);
 
-	seq_printf(s, "%08x %s " , val, DRIVER_NAME);
+	seq_printf(s, "%lx %08x %s ", pcs->res->start + offset, val,
+		   DRIVER_NAME);
 }

This should use %zx instead of %lx to avoid build warnings on 64-bit systems as reported by kbuild test robot.

Regards,

Tony

#6 lore raw
In reply to Tony Lindgren
Quoted 2 lines · Tony Lindgren

In preparation for some more generic pinctrl changes, here are two clean-up patches for pinctrl-single.

Can you respin the first patch so I can merge these two?

Linus

author maintainer
#3 lore raw

Re: [PATCH 1/2] pinctrl: single: Drop custom names

In reply to Tony Lindgren
Quoted 19 lines · Tony Lindgren
Quoted 3 lines · Tony Lindgren

We no longer need to allocate custom names as those are dynamically generated in pinctrl_register_one_pin() if no name is passed to pinctrl_register_pins().

...

Quoted 13 lines
(quoted diff) +3 -1
@@ -354,13 +337,16 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
 {
 	struct pcs_device *pcs;
 	unsigned val, mux_bytes;
+	unsigned long offset;
 
 	pcs = pinctrl_dev_get_drvdata(pctldev);
 
 	mux_bytes = pcs->width / BITS_PER_BYTE;
-	val = pcs->read(pcs->base + pin * mux_bytes);
+	offset = pin * mux_bytes;
+	val = pcs->read(pcs->base + offset);
 
Quoted 7 lines

Review static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev, · line 350

Quoted 4 lines
(quoted diff) +2 -1
-	seq_printf(s, "%08x %s " , val, DRIVER_NAME);
+	seq_printf(s, "%lx %08x %s ", pcs->res->start + offset, val,
+		   DRIVER_NAME);
 }

This should use %zx instead of %lx to avoid build warnings on 64-bit systems as reported by kbuild test robot.

Below is an updated version of this patch.

Regards,

Tony

8< ---------------------------

Quoted 1 line

From tony Mon Sep 17 00:00:00 2001

From: Tony Lindgren <[email protected]>
Date: Tue, 25 Oct 2016 08:33:34 -0700
Subject: [PATCHv2] pinctrl: single: Drop custom names

We no longer need to allocate custom names as those are dynamically generated in pinctrl_register_one_pin() if no name is passed to pinctrl_register_pins().

---

Use %z instead of %l for 64-bit systems

---
 drivers/pinctrl/pinctrl-single.c | 36 ++++++------------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)
drivers/pinctrl/pinctrl-single.c +6 -30
@@ -36,7 +36,6 @@
 #define DRIVER_NAME			"pinctrl-single"
 #define PCS_MUX_PINS_NAME		"pinctrl-single,pins"
 #define PCS_MUX_BITS_NAME		"pinctrl-single,bits"
-#define PCS_REG_NAME_LEN		((sizeof(unsigned long) * 2) + 3)
 #define PCS_OFF_DISABLED		~0U
 
 /**
@@ -142,20 +141,6 @@ struct pcs_data {
 };
 
 /**
- * struct pcs_name - register name for a pin
- * @name:	name of the pinctrl register
- *
- * REVISIT: We may want to make names optional in the pinctrl
- * framework as some drivers may not care about pin names to
- * avoid kernel bloat. The pin names can be deciphered by user
- * space tools using debugfs based on the register address and
- * SoC packaging information.
- */
-struct pcs_name {
-	char name[PCS_REG_NAME_LEN];
-};
-
-/**
  * struct pcs_soc_data - SoC specific settings
  * @flags:	initial SoC specific PCS_FEAT_xxx values
  * @irq:	optional interrupt for the controller
@@ -187,7 +172,6 @@ struct pcs_soc_data {
  * @foff:	value to turn mux off
  * @fmax:	max number of functions in fmask
  * @bits_per_pin:number of bits per pin
- * @names:	array of register names for pins
  * @pins:	physical pins on the SoC
  * @pgtree:	pingroup index radix tree
  * @ftree:	function index radix tree
@@ -223,7 +207,6 @@ struct pcs_device {
 	unsigned fmax;
 	bool bits_per_mux;
 	unsigned bits_per_pin;
-	struct pcs_name *names;
 	struct pcs_data pins;
 	struct radix_tree_root pgtree;
 	struct radix_tree_root ftree;
@@ -354,13 +337,17 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
 {
 	struct pcs_device *pcs;
 	unsigned val, mux_bytes;
+	unsigned long offset;
+	size_t pa;
 
 	pcs = pinctrl_dev_get_drvdata(pctldev);
 
 	mux_bytes = pcs->width / BITS_PER_BYTE;
-	val = pcs->read(pcs->base + pin * mux_bytes);
+	offset = pin * mux_bytes;
+	val = pcs->read(pcs->base + offset);
+	pa = pcs->res->start + offset;
 
-	seq_printf(s, "%08x %s " , val, DRIVER_NAME);
+	seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
 }
 
 static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
@@ -763,7 +750,6 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
 {
 	struct pcs_soc_data *pcs_soc = &pcs->socdata;
 	struct pinctrl_pin_desc *pin;
-	struct pcs_name *pn;
 	int i;
 
 	i = pcs->pins.cur;
@@ -786,10 +772,6 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
 	}
 
 	pin = &pcs->pins.pa[i];
-	pn = &pcs->names[i];
-	sprintf(pn->name, "%lx.%u",
-		(unsigned long)pcs->res->start + offset, pin_pos);
-	pin->name = pn->name;
 	pin->number = i;
 	pcs->pins.cur++;
 
@@ -827,12 +809,6 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
 	if (!pcs->pins.pa)
 		return -ENOMEM;
 
-	pcs->names = devm_kzalloc(pcs->dev,
-				sizeof(struct pcs_name) * nr_pins,
-				GFP_KERNEL);
-	if (!pcs->names)
-		return -ENOMEM;
-
 	pcs->desc.pins = pcs->pins.pa;
 	pcs->desc.npins = nr_pins;
 
Signature · 1 line
2.9.3
author maintainer
#7 lore raw
In reply to Linus Walleij
Quoted 6 lines · Linus Walleij
Quoted 2 lines · Tony Lindgren

In preparation for some more generic pinctrl changes, here are two clean-up patches for pinctrl-single.

Can you respin the first patch so I can merge these two?

OK posted as a reply that to it that should apply with git-am --scissors. Let me know if you want me to repost the whole thread.

Regards,

Tony

#8 lore raw
Quoted 11 lines · Tony Lindgren
Quoted 6 lines · Linus Walleij
Quoted 2 lines · Tony Lindgren

In preparation for some more generic pinctrl changes, here are two clean-up patches for pinctrl-single.

Can you respin the first patch so I can merge these two?

OK posted as a reply that to it that should apply with git-am --scissors. Let me know if you want me to repost the whole thread.

I don't see the replies :O

I wonder what happened :/

Yours,
Linus Walleij

author maintainer
#9 lore raw
Quoted 9 lines · Linus Walleij
Quoted 8 lines · Tony Lindgren
Quoted 6 lines · Linus Walleij
Quoted 2 lines · Tony Lindgren

In preparation for some more generic pinctrl changes, here are two clean-up patches for pinctrl-single.

Can you respin the first patch so I can merge these two?

Quoted 7 lines
Quoted 3 lines

OK posted as a reply that to it that should apply with git-am --scissors. Let me know if you want me to repost the whole thread.

I don't see the replies :O

I wonder what happened :/

Maybe the delivery got delayed? Seems to be appearing at least in k.o patchwork:

https://patchwork.kernel.org/patch/9399687/

Regards,

Tony