diff mbox

sh-pfc: return pinconf with arguments in packed format

Message ID 20160905141957.25982-1-niklas.soderlund+renesas@ragnatech.se
State New
Headers show

Commit Message

Niklas Söderlund Sept. 5, 2016, 2:19 p.m. UTC
The pinconf-generic code expects configurations with arguments to be
returned in a packed format in order to be displayed properly by
pinconf_generic_dump_one().

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/pinctrl/sh-pfc/pinctrl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven Sept. 5, 2016, 3:54 p.m. UTC | #1
Hi Niklas,

On Mon, Sep 5, 2016 at 4:19 PM, Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> The pinconf-generic code expects configurations with arguments to be
> returned in a packed format in order to be displayed properly by
> pinconf_generic_dump_one().

Some more user-oriented explanation could be helpful, like saying that
/sys/kernel/debug/pinctrl/e6060000.pfc/pinconf-pins on r8a7795/salvator-x now
shows

    pin 96 (GP_3_0): input bias disabled, output drive strength (9
mA), pin power source (3300 selector)

instead of

    pin 96 (GP_3_0): input bias disabled, output drive strength (0
mA), pin power source (0 selector)

> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

P.S. It seems like we should get rid of the WARN_ON_ONCE() checks in our
     pinctrl code, and return proper errors, as these are triggered by reading
     the sysfs files.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Niklas Söderlund Sept. 6, 2016, 6:28 a.m. UTC | #2
Hi Geert,

Thanks for your review.

On 2016-09-05 17:54:44 +0200, Geert Uytterhoeven wrote:
> Hi Niklas,
> 
> On Mon, Sep 5, 2016 at 4:19 PM, Niklas Söderlund
> <niklas.soderlund+renesas@ragnatech.se> wrote:
> > The pinconf-generic code expects configurations with arguments to be
> > returned in a packed format in order to be displayed properly by
> > pinconf_generic_dump_one().
> 
> Some more user-oriented explanation could be helpful, like saying that
> /sys/kernel/debug/pinctrl/e6060000.pfc/pinconf-pins on r8a7795/salvator-x now
> shows
> 
>     pin 96 (GP_3_0): input bias disabled, output drive strength (9
> mA), pin power source (3300 selector)
> 
> instead of
> 
>     pin 96 (GP_3_0): input bias disabled, output drive strength (0
> mA), pin power source (0 selector)

Good idea, I will send a v2 with a more user-oriented explanation.

> 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks for testing.

> 
> P.S. It seems like we should get rid of the WARN_ON_ONCE() checks in our
>      pinctrl code, and return proper errors, as these are triggered by reading
>      the sysfs files.
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
diff mbox

Patch

diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index e208ee0..c577258 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -596,6 +596,7 @@  static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
 	struct sh_pfc *pfc = pmx->pfc;
 	enum pin_config_param param = pinconf_to_config_param(*config);
 	unsigned long flags;
+	unsigned int arg;
 
 	if (!sh_pfc_pinconf_validate(pfc, _pin, param))
 		return -ENOTSUPP;
@@ -616,7 +617,7 @@  static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
 		if (bias != param)
 			return -EINVAL;
 
-		*config = 0;
+		arg = 0;
 		break;
 	}
 
@@ -627,7 +628,7 @@  static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
 		if (ret < 0)
 			return ret;
 
-		*config = ret;
+		arg = ret;
 		break;
 	}
 
@@ -646,7 +647,7 @@  static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
 		val = sh_pfc_read_reg(pfc, pocctrl, 32);
 		spin_unlock_irqrestore(&pfc->lock, flags);
 
-		*config = (val & BIT(bit)) ? 3300 : 1800;
+		arg = (val & BIT(bit)) ? 3300 : 1800;
 		break;
 	}
 
@@ -654,6 +655,7 @@  static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
 		return -ENOTSUPP;
 	}
 
+	*config = pinconf_to_config_packed(param, arg);
 	return 0;
 }