DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: "Jérôme Pouiller" <jerome.pouiller@silabs.com>
To: gregkh@linuxfoundation.org, Linus Walleij <linus.walleij@linaro.org>
Cc: devel@driverdev.osuosl.org
Subject: Re: [PATCH v4] staging: wfx: Get descriptors for GPIOs
Date: Wed, 01 Jul 2020 09:10:04 +0200
Message-ID: <5672265.akOJpMoqyi@pc-42> (raw)
In-Reply-To: <20200630082133.68675-1-linus.walleij@linaro.org>

Hello Linus,

On Tuesday 30 June 2020 10:21:33 CEST Linus Walleij wrote:
> 
> The code has the functionality to insert the GPIO lines using
> the global GPIO numbers through module parameters.
> 
> As we are clearly deprecating the use of global GPIO numbers
> look up the GPIO descriptors from the device instead. This
> usually falls back to device hardware descriptions using e.g.
> device tree or ACPI. This device clearly supports device
> tree when used over SPI for example.
> 
> For example, this can be supplied in the device tree like so:
> 
>   wfx@0x01 {
>       compatible = "silabs,wf200";
>       reset-gpios = <&gpio0 1>;
>       wakeup-gpios = <&gpio0 2>;
>   };
> 
> Cc: Jérôme Pouiller <jerome.pouiller@silabs.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Finally figured out how to compile this by selecting SPI
>   host and deselecting MMC host.

Weird, it should be selectable if MMC or SPI is selected.

> - Initialize the reset GPIO as OUT_LOW
> - Initialize the wakeup GPIO as OUT_LOW
> - Drop one more desc_to_gpio()
> - Update the warning if GPIO is not found.
> ChangeLog v2->v3:
> - ERR_CAST not PTR_CAST
> ChangeLog v1->v2:
> - Fixed a cast and a variable name.
> - I still don't know how to compile this but hey the zeroday
>   robot does.
> ---
>  drivers/staging/wfx/bus_spi.c | 14 +++++------
>  drivers/staging/wfx/main.c    | 45 ++++-------------------------------
>  drivers/staging/wfx/main.h    |  2 --
>  3 files changed, 12 insertions(+), 49 deletions(-)
> 
[...]
> diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
> index 6bd96f476388..3828a2652313 100644
> --- a/drivers/staging/wfx/main.c
> +++ b/drivers/staging/wfx/main.c
[...]
> @@ -340,7 +303,10 @@ struct wfx_dev *wfx_init_common(struct device *dev,
>         memcpy(&wdev->pdata, pdata, sizeof(*pdata));
>         of_property_read_string(dev->of_node, "config-file",
>                                 &wdev->pdata.file_pds);
> -       wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup");
> +       wdev->pdata.gpio_wakeup = devm_gpiod_get(dev, "wakeup", GPIOD_OUT_LOW);
> +       if (IS_ERR(wdev->pdata.gpio_wakeup))
> +               return ERR_CAST(wdev->pdata.gpio_wakeup);
> +       gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup");

In the original code, the gpio wakeup was not mandatory. But in this code,
wfx_init_common() will return an error if the gpio "wakeup" is not
defined.

>         wfx_sl_fill_pdata(dev, &wdev->pdata);
> 
>         mutex_init(&wdev->conf_mutex);
[...]

-- 
Jérôme Pouiller


_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  8:21 Linus Walleij
2020-07-01  7:10 ` Jérôme Pouiller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5672265.akOJpMoqyi@pc-42 \
    --to=jerome.pouiller@silabs.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git