From: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Alexandre Courbot
<acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Michael Welling <mwelling-EkmVulN54Sk@public.gmane.org>,
Markus Pargmann <mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Amit Kucheria
<amit.kucheria-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
arm-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
Haavard Skinnemoen
<hskinnemoen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>,
Greg Ungerer <gerg-JBU5SbJe1FlAfugRpC6u6w@public.gmane.org>,
Ralf Baechle <ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>,
linux-mips-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org,
Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Russell King - ARM Linux
<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Subject: Re: [PATCH 000/182] Rid struct gpio_chip from container_of() usage
Date: Wed, 9 Dec 2015 11:30:34 -0800 [thread overview]
Message-ID: <20151209193034.GE27131@dtor-ws> (raw)
In-Reply-To: <1449666515-23343-1-git-send-email-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On Wed, Dec 09, 2015 at 02:08:35PM +0100, Linus Walleij wrote:
> This removes the use of container_of() constructions from *all*
> GPIO drivers in the kernel. It is done by instead adding an
> optional void *data pointer to the struct gpio_chip and an
> accessor function, gpiochip_get_data() to get it from a driver.
>
> WHY?
>
> Because we want to have a proper userspace ABI for GPIO chips,
> which involves using a character device that the user opens
> and closes. While the character device is open, the underlying
> kernel objects must not go away.
>
> Currently the GPIO drivers keep their state in the struct
> gpio_chip, and that is often allocated by the drivers, very
> often as a part of a containing per-instance state container
> struct for the driver:
>
> struct foo_state {
> struct gpio_chip chip; <- OMG my state is there
> };
>
> Drivers cannot allocate and manage this state: if a user has the
> character device open, the objects allocated must stay around
> even if the driver goes away. Instead drivers need to pass a
> descriptor to the GPIO core, and then the core should allocate
> and manage the lifecycle of things related to the device, such
> as the chardev itself or the struct device related to the GPIO
> device.
Yes, but it does not mean that the object that is being maintained by
the subsystem and that us attached to character device needs to be
gpio_chip itself. You can have something like
struct gpio_chip_chardev {
struct cdev chardev;
struct gpio_chip *chip;
bool dead;
};
struct gpio_chip {
...
struct gpio_chip_chardev *chardev;
...
};
You alloctae the new structure when you register/export gpio chip in
gpio subsystem core and leave all the individual drivers alone.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, Johan Hovold <johan@kernel.org>,
Alexandre Courbot <acourbot@nvidia.com>,
Arnd Bergmann <arnd@arndb.de>,
Michael Welling <mwelling@ieee.org>,
Markus Pargmann <mpa@pengutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mark Brown <broonie@kernel.org>,
Amit Kucheria <amit.kucheria@linaro.org>,
arm@kernel.org, Haavard Skinnemoen <hskinnemoen@gmail.com>,
Sonic Zhang <sonic.zhang@analog.com>,
Greg Ungerer <gerg@uclinux.org>,
Ralf Baechle <ralf@linux-mips.org>,
linux-mips@linux-mips.org, Anatolij Gustschin <agust@denx.de>,
linux-wireless@vger.kernel.org, linux-input@vger.kernel.org,
Lee Jones <lee.jones@linaro.org>,
Russell King - ARM Linux <linux@arm.linux.org.uk>
Subject: Re: [PATCH 000/182] Rid struct gpio_chip from container_of() usage
Date: Wed, 9 Dec 2015 11:30:34 -0800 [thread overview]
Message-ID: <20151209193034.GE27131@dtor-ws> (raw)
In-Reply-To: <1449666515-23343-1-git-send-email-linus.walleij@linaro.org>
On Wed, Dec 09, 2015 at 02:08:35PM +0100, Linus Walleij wrote:
> This removes the use of container_of() constructions from *all*
> GPIO drivers in the kernel. It is done by instead adding an
> optional void *data pointer to the struct gpio_chip and an
> accessor function, gpiochip_get_data() to get it from a driver.
>
> WHY?
>
> Because we want to have a proper userspace ABI for GPIO chips,
> which involves using a character device that the user opens
> and closes. While the character device is open, the underlying
> kernel objects must not go away.
>
> Currently the GPIO drivers keep their state in the struct
> gpio_chip, and that is often allocated by the drivers, very
> often as a part of a containing per-instance state container
> struct for the driver:
>
> struct foo_state {
> struct gpio_chip chip; <- OMG my state is there
> };
>
> Drivers cannot allocate and manage this state: if a user has the
> character device open, the objects allocated must stay around
> even if the driver goes away. Instead drivers need to pass a
> descriptor to the GPIO core, and then the core should allocate
> and manage the lifecycle of things related to the device, such
> as the chardev itself or the struct device related to the GPIO
> device.
Yes, but it does not mean that the object that is being maintained by
the subsystem and that us attached to character device needs to be
gpio_chip itself. You can have something like
struct gpio_chip_chardev {
struct cdev chardev;
struct gpio_chip *chip;
bool dead;
};
struct gpio_chip {
...
struct gpio_chip_chardev *chardev;
...
};
You alloctae the new structure when you register/export gpio chip in
gpio subsystem core and leave all the individual drivers alone.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2015-12-09 19:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 13:08 [PATCH 000/182] Rid struct gpio_chip from container_of() usage Linus Walleij
[not found] ` <1449666515-23343-1-git-send-email-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-12-09 13:44 ` Russell King - ARM Linux
2015-12-09 13:44 ` Russell King - ARM Linux
2015-12-09 14:46 ` Linus Walleij
2015-12-14 12:46 ` Johan Hovold
2015-12-18 14:42 ` Linus Walleij
2015-12-18 14:42 ` Linus Walleij
2015-12-09 19:30 ` Dmitry Torokhov [this message]
2015-12-09 19:30 ` Dmitry Torokhov
2015-12-14 9:18 ` Linus Walleij
2015-12-15 7:25 ` Dmitry Torokhov
[not found] ` <CAKdAkRR6kEzEOtjxXqS4BPToEzKGBsLb=SzePFAiLSDhh+=qnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-18 14:46 ` Linus Walleij
2015-12-18 14:46 ` Linus Walleij
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=20151209193034.GE27131@dtor-ws \
--to=dmitry.torokhov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=agust-ynQEQJNshbs@public.gmane.org \
--cc=amit.kucheria-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=arm-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=gerg-JBU5SbJe1FlAfugRpC6u6w@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=hskinnemoen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=linux-mips-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=mwelling-EkmVulN54Sk@public.gmane.org \
--cc=ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
--cc=sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.