* [PATCH 045/182] gpio: octeon: use gpiochip data pointer
@ 2015-12-09 13:19 Linus Walleij
2015-12-09 17:42 ` David Daney
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2015-12-09 13:19 UTC (permalink / raw)
To: linux-gpio, Johan Hovold, Alexandre Courbot, Michael Welling,
Markus Pargmann
Cc: Linus Walleij, David Daney
This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().
Cc: David Daney <david.daney@cavium.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-octeon.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c
index afbb2417dfbc..7665ebcd0c1d 100644
--- a/drivers/gpio/gpio-octeon.c
+++ b/drivers/gpio/gpio-octeon.c
@@ -41,7 +41,7 @@ struct octeon_gpio {
static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset)
{
- struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
+ struct octeon_gpio *gpio = gpiochip_get_data(chip);
cvmx_write_csr(gpio->register_base + bit_cfg_reg(offset), 0);
return 0;
@@ -49,7 +49,7 @@ static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset)
static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
- struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
+ struct octeon_gpio *gpio = gpiochip_get_data(chip);
u64 mask = 1ull << offset;
u64 reg = gpio->register_base + (value ? TX_SET : TX_CLEAR);
cvmx_write_csr(reg, mask);
@@ -58,7 +58,7 @@ static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset,
int value)
{
- struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
+ struct octeon_gpio *gpio = gpiochip_get_data(chip);
union cvmx_gpio_bit_cfgx cfgx;
octeon_gpio_set(chip, offset, value);
@@ -72,7 +72,7 @@ static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset,
static int octeon_gpio_get(struct gpio_chip *chip, unsigned offset)
{
- struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
+ struct octeon_gpio *gpio = gpiochip_get_data(chip);
u64 read_bits = cvmx_read_csr(gpio->register_base + RX_DAT);
return ((1ull << offset) & read_bits) != 0;
@@ -117,7 +117,7 @@ static int octeon_gpio_probe(struct platform_device *pdev)
chip->get = octeon_gpio_get;
chip->direction_output = octeon_gpio_dir_out;
chip->set = octeon_gpio_set;
- err = gpiochip_add(chip);
+ err = gpiochip_add_data(chip, gpio);
if (err)
goto out;
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 045/182] gpio: octeon: use gpiochip data pointer
2015-12-09 13:19 [PATCH 045/182] gpio: octeon: use gpiochip data pointer Linus Walleij
@ 2015-12-09 17:42 ` David Daney
0 siblings, 0 replies; 2+ messages in thread
From: David Daney @ 2015-12-09 17:42 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, Johan Hovold, Alexandre Courbot, Michael Welling,
Markus Pargmann, David Daney
On 12/09/2015 05:19 AM, Linus Walleij wrote:
> This makes the driver use the data pointer added to the gpio_chip
> to store a pointer to the state container instead of relying on
> container_of().
>
> Cc: David Daney <david.daney@cavium.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This seems sane.
Reviewed-by: David Daney <david.daney@cavium.com>
> ---
> drivers/gpio/gpio-octeon.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c
> index afbb2417dfbc..7665ebcd0c1d 100644
> --- a/drivers/gpio/gpio-octeon.c
> +++ b/drivers/gpio/gpio-octeon.c
> @@ -41,7 +41,7 @@ struct octeon_gpio {
>
> static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset)
> {
> - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
> + struct octeon_gpio *gpio = gpiochip_get_data(chip);
>
> cvmx_write_csr(gpio->register_base + bit_cfg_reg(offset), 0);
> return 0;
> @@ -49,7 +49,7 @@ static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset)
>
> static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
> {
> - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
> + struct octeon_gpio *gpio = gpiochip_get_data(chip);
> u64 mask = 1ull << offset;
> u64 reg = gpio->register_base + (value ? TX_SET : TX_CLEAR);
> cvmx_write_csr(reg, mask);
> @@ -58,7 +58,7 @@ static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
> static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset,
> int value)
> {
> - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
> + struct octeon_gpio *gpio = gpiochip_get_data(chip);
> union cvmx_gpio_bit_cfgx cfgx;
>
> octeon_gpio_set(chip, offset, value);
> @@ -72,7 +72,7 @@ static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset,
>
> static int octeon_gpio_get(struct gpio_chip *chip, unsigned offset)
> {
> - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
> + struct octeon_gpio *gpio = gpiochip_get_data(chip);
> u64 read_bits = cvmx_read_csr(gpio->register_base + RX_DAT);
>
> return ((1ull << offset) & read_bits) != 0;
> @@ -117,7 +117,7 @@ static int octeon_gpio_probe(struct platform_device *pdev)
> chip->get = octeon_gpio_get;
> chip->direction_output = octeon_gpio_dir_out;
> chip->set = octeon_gpio_set;
> - err = gpiochip_add(chip);
> + err = gpiochip_add_data(chip, gpio);
> if (err)
> goto out;
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-09 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09 13:19 [PATCH 045/182] gpio: octeon: use gpiochip data pointer Linus Walleij
2015-12-09 17:42 ` David Daney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).