diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-03-30 04:48:04 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2016-04-19 02:58:30 -0400 |
commit | ed1c9b3c18e33a69da0a911eadf4948ea7e5b5b9 (patch) | |
tree | 6af3a5228bc869c142c0c6a192ddfbaeb96731e8 /drivers/mfd/htc-i2cpld.c | |
parent | 8d5f095fc5f7e36f40a80e87317828be249ee454 (diff) |
mfd: htc-i2cpld: Use gpiochip data pointer
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().
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/htc-i2cpld.c')
-rw-r--r-- | drivers/mfd/htc-i2cpld.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index bd6b96d07ab8..3f9eee5f8fb9 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c | |||
@@ -227,8 +227,7 @@ static irqreturn_t htcpld_handler(int irq, void *dev) | |||
227 | static void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) | 227 | static void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) |
228 | { | 228 | { |
229 | struct i2c_client *client; | 229 | struct i2c_client *client; |
230 | struct htcpld_chip *chip_data = | 230 | struct htcpld_chip *chip_data = gpiochip_get_data(chip); |
231 | container_of(chip, struct htcpld_chip, chip_out); | ||
232 | unsigned long flags; | 231 | unsigned long flags; |
233 | 232 | ||
234 | client = chip_data->client; | 233 | client = chip_data->client; |
@@ -257,14 +256,12 @@ static void htcpld_chip_set_ni(struct work_struct *work) | |||
257 | 256 | ||
258 | static int htcpld_chip_get(struct gpio_chip *chip, unsigned offset) | 257 | static int htcpld_chip_get(struct gpio_chip *chip, unsigned offset) |
259 | { | 258 | { |
260 | struct htcpld_chip *chip_data; | 259 | struct htcpld_chip *chip_data = gpiochip_get_data(chip); |
261 | u8 cache; | 260 | u8 cache; |
262 | 261 | ||
263 | if (!strncmp(chip->label, "htcpld-out", 10)) { | 262 | if (!strncmp(chip->label, "htcpld-out", 10)) { |
264 | chip_data = container_of(chip, struct htcpld_chip, chip_out); | ||
265 | cache = chip_data->cache_out; | 263 | cache = chip_data->cache_out; |
266 | } else if (!strncmp(chip->label, "htcpld-in", 9)) { | 264 | } else if (!strncmp(chip->label, "htcpld-in", 9)) { |
267 | chip_data = container_of(chip, struct htcpld_chip, chip_in); | ||
268 | cache = chip_data->cache_in; | 265 | cache = chip_data->cache_in; |
269 | } else | 266 | } else |
270 | return -EINVAL; | 267 | return -EINVAL; |
@@ -291,9 +288,7 @@ static int htcpld_direction_input(struct gpio_chip *chip, | |||
291 | 288 | ||
292 | static int htcpld_chip_to_irq(struct gpio_chip *chip, unsigned offset) | 289 | static int htcpld_chip_to_irq(struct gpio_chip *chip, unsigned offset) |
293 | { | 290 | { |
294 | struct htcpld_chip *chip_data; | 291 | struct htcpld_chip *chip_data = gpiochip_get_data(chip); |
295 | |||
296 | chip_data = container_of(chip, struct htcpld_chip, chip_in); | ||
297 | 292 | ||
298 | if (offset < chip_data->nirqs) | 293 | if (offset < chip_data->nirqs) |
299 | return chip_data->irq_start + offset; | 294 | return chip_data->irq_start + offset; |
@@ -451,14 +446,14 @@ static int htcpld_register_chip_gpio( | |||
451 | gpio_chip->ngpio = plat_chip_data->num_gpios; | 446 | gpio_chip->ngpio = plat_chip_data->num_gpios; |
452 | 447 | ||
453 | /* Add the GPIO chips */ | 448 | /* Add the GPIO chips */ |
454 | ret = gpiochip_add(&(chip->chip_out)); | 449 | ret = gpiochip_add_data(&(chip->chip_out), chip); |
455 | if (ret) { | 450 | if (ret) { |
456 | dev_warn(dev, "Unable to register output GPIOs for 0x%x: %d\n", | 451 | dev_warn(dev, "Unable to register output GPIOs for 0x%x: %d\n", |
457 | plat_chip_data->addr, ret); | 452 | plat_chip_data->addr, ret); |
458 | return ret; | 453 | return ret; |
459 | } | 454 | } |
460 | 455 | ||
461 | ret = gpiochip_add(&(chip->chip_in)); | 456 | ret = gpiochip_add_data(&(chip->chip_in), chip); |
462 | if (ret) { | 457 | if (ret) { |
463 | dev_warn(dev, "Unable to register input GPIOs for 0x%x: %d\n", | 458 | dev_warn(dev, "Unable to register input GPIOs for 0x%x: %d\n", |
464 | plat_chip_data->addr, ret); | 459 | plat_chip_data->addr, ret); |