lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 8 Feb 2016 12:04:31 +0900
From:	Alexandre Courbot <gnurou@...il.com>
To:	Alban Bedel <albeu@...e.fr>
Cc:	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	Linus Walleij <linus.walleij@...aro.org>,
	Antony Pavlov <antonynpavlov@...il.com>,
	Gabor Juhos <juhosg@...nwrt.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/5] gpio: ath79: Make the driver removable

On Fri, Jan 29, 2016 at 4:44 AM, Alban Bedel <albeu@...e.fr> wrote:
> As we now allow the driver to be built as a module it should be
> removable.
>
> Signed-off-by: Alban Bedel <albeu@...e.fr>
> ---
>  drivers/gpio/gpio-ath79.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
> index afb535e..6b15792 100644
> --- a/drivers/gpio/gpio-ath79.c
> +++ b/drivers/gpio/gpio-ath79.c
> @@ -46,6 +46,7 @@ static int ath79_gpio_probe(struct platform_device *pdev)
>         ctrl = devm_kzalloc(&pdev->dev, sizeof(*ctrl), GFP_KERNEL);
>         if (!ctrl)
>                 return -ENOMEM;
> +       platform_set_drvdata(pdev, ctrl);
>
>         if (np) {
>                 err = of_property_read_u32(np, "ngpios", &ath79_gpio_count);
> @@ -97,12 +98,21 @@ static int ath79_gpio_probe(struct platform_device *pdev)
>         return 0;
>  }
>
> +static int ath79_gpio_remove(struct platform_device *pdev)
> +{
> +       struct ath79_gpio_ctrl *ctrl = platform_get_drvdata(pdev);

platform_get_drvdata will return a gpio_chip *. I agree the address
will be the same, but for correctness you should use the expected
type. Especially since you will not use a member of ath79_gpio_ctrl in
this function anyway.

> +
> +       gpiochip_remove(&ctrl->gc);
> +       return 0;
> +}

I suspect this removal pattern to be quite common, maybe we should
just export bgpio_pdev_remove() to allow other drivers to use it
instead of rewriting their own version?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ