[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOiHx==WUZ49OOdJp=S1pF8y4Mf0Hc+xAOu1n9Ofmoau0KCBTQ@mail.gmail.com>
Date: Wed, 20 Feb 2019 12:27:58 +0100
From: Jonas Gorski <jonas.gorski@...il.com>
To: George Hilliard <thirtythreeforty@...il.com>
Cc: MIPS Mailing List <linux-mips@...ux-mips.org>,
linux-kernel@...r.kernel.org, Neil Brown <neil@...wn.name>
Subject: Re: [PATCH 05/10] staging: mt7621-mmc: Use pinctrl subsystem to
select SDXC pin mode
On Wed, 20 Feb 2019 at 06:18, George Hilliard
<thirtythreeforty@...il.com> wrote:
>
> The driver previously grabbed the SD pins for itself, ignoring the pin
> controller. Replace this direct register access with appropriate calls
> to the pinctrl subsystem.
>
> This also allows this driver to work on related devices that have a
> different pin controller mapping, such as the MT7688. The hardcoded
> bit index was incorrect on that device.
>
> This change could break SD controller functionality on existing devices
> whose device trees do not specify a pin controller and state for the SD
> node.
>
> Signed-off-by: George Hilliard <thirtythreeforty@...il.com>
> ---
> drivers/staging/mt7621-mmc/sd.c | 28 ++++++++++++++++++++++------
> 1 file changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> index a7c7ec0d7bbb..97ed7510e96d 100644
> --- a/drivers/staging/mt7621-mmc/sd.c
> +++ b/drivers/staging/mt7621-mmc/sd.c
> @@ -38,6 +38,7 @@
> #include <linux/dma-mapping.h>
> #include <linux/spinlock.h>
> #include <linux/platform_device.h>
> +#include <linux/pinctrl/consumer.h>
> #include <linux/interrupt.h>
>
> #include <linux/mmc/host.h>
> @@ -1599,6 +1600,8 @@ static int msdc_drv_probe(struct platform_device *pdev)
> struct msdc_host *host;
> struct msdc_hw *hw;
> int ret;
> + struct pinctrl *pctrl;
> + struct pinctrl_state *pins_default;
>
> hw = &msdc0_hw;
>
> @@ -1671,6 +1674,25 @@ static int msdc_drv_probe(struct platform_device *pdev)
>
> host->mrq = NULL;
>
> + /* Read pin control settings from device tree */
> + pctrl = devm_pinctrl_get(&pdev->dev);
> + if (IS_ERR(pctrl)) {
> + ret = PTR_ERR(pctrl);
> + dev_err(&pdev->dev, "Cannot find pinctrl in device tree\n");
> + goto host_free;
> + }
> +
> + pins_default = pinctrl_lookup_state(pctrl, PINCTRL_STATE_DEFAULT);
> + if (IS_ERR(pins_default)) {
> + ret = PTR_ERR(pins_default);
> + dev_err(&pdev->dev, "Cannot find pinctrl state default\n");
> + goto host_free;
> + }
> +
> + ret = pinctrl_select_state(pctrl, pins_default);
> + if (ret < 0)
> + dev_warn(&pdev->dev, "Cannot select pinctrl state\n");
> +
Selecting the PINCTRL_STATE_DEFAULT is already automatically done by
the driver core on probe time[1], before calling the probe function,
so this seems redundant here. The only difference is that you enforce
the presence of a pinctrl node, while the core code is fine without
one.
Regards
Jonas
[1] https://elixir.bootlin.com/linux/latest/source/drivers/base/pinctrl.c#L21
Powered by blists - more mailing lists