Few pinctrl-single clean-ups
Subsystems (3)
Tony Lindgren
maintainercover 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
Tony Lindgren
maintainerPATCH 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
Tony Lindgren
maintainerRe: [PATCH 1/2] pinctrl: single: Drop custom names
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 topinctrl_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
-2mux_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
Tony Lindgren
maintainerRe: [PATCH 1/2] pinctrl: single: Drop custom names
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 topinctrl_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
Tony Lindgren
maintainerPATCH 2/2 pinctrl: single: Drop pointless macro
In reply to Tony LindgrenThis 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
Re: [PATCH 2/2] pinctrl: single: Drop pointless macro
Quoted 5 lines · 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.
Signed-off-by Tony Lindgren <[email protected]>
Patch applied.
Yours,
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?
Linus
Tony Lindgren
maintainerQuoted 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
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
Tony Lindgren
maintainerQuoted 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
Quoted 6 lines · Tony Lindgren
Quoted 1 line
I wonder what happened :/
Maybe the delivery got delayed? Seems to be appearing at least in k.o patchwork:
APplied it from patchwork.
Yours,
Linus Walleij
Tony Lindgren
maintainerQuoted 10 lines · Linus Walleij
Quoted 6 lines · Tony Lindgren
Quoted 1 line
I wonder what happened :/
Maybe the delivery got delayed? Seems to be appearing at least in k.o patchwork:
APplied it from patchwork.
OK thanks.
Tony