.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /** |
---|
2 | 3 | * Copyright (C) 2006 Juergen Beisert, Pengutronix |
---|
3 | 4 | * Copyright (C) 2008 Guennadi Liakhovetski, Pengutronix |
---|
4 | 5 | * Copyright (C) 2009 Wolfram Sang, Pengutronix |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | * |
---|
10 | 7 | * The Maxim MAX7300/1 device is an I2C/SPI driven GPIO expander. There are |
---|
11 | 8 | * 28 GPIOs. 8 of them can trigger an interrupt. See datasheet for more |
---|
.. | .. |
---|
50 | 47 | |
---|
51 | 48 | static int max7301_direction_input(struct gpio_chip *chip, unsigned offset) |
---|
52 | 49 | { |
---|
53 | | - struct max7301 *ts = gpiochip_get_data(chip); |
---|
| 50 | + struct max7301 *ts = container_of(chip, struct max7301, chip); |
---|
54 | 51 | u8 *config; |
---|
55 | 52 | u8 offset_bits, pin_config; |
---|
56 | 53 | int ret; |
---|
.. | .. |
---|
92 | 89 | static int max7301_direction_output(struct gpio_chip *chip, unsigned offset, |
---|
93 | 90 | int value) |
---|
94 | 91 | { |
---|
95 | | - struct max7301 *ts = gpiochip_get_data(chip); |
---|
| 92 | + struct max7301 *ts = container_of(chip, struct max7301, chip); |
---|
96 | 93 | u8 *config; |
---|
97 | 94 | u8 offset_bits; |
---|
98 | 95 | int ret; |
---|
.. | .. |
---|
192 | 189 | ts->chip.parent = dev; |
---|
193 | 190 | ts->chip.owner = THIS_MODULE; |
---|
194 | 191 | |
---|
195 | | - ret = gpiochip_add_data(&ts->chip, ts); |
---|
196 | | - if (ret) |
---|
197 | | - goto exit_destroy; |
---|
198 | | - |
---|
199 | 192 | /* |
---|
200 | 193 | * initialize pullups according to platform data and cache the |
---|
201 | 194 | * register values for later use. |
---|
.. | .. |
---|
217 | 210 | } |
---|
218 | 211 | } |
---|
219 | 212 | |
---|
220 | | - return ret; |
---|
| 213 | + ret = gpiochip_add_data(&ts->chip, ts); |
---|
| 214 | + if (!ret) |
---|
| 215 | + return ret; |
---|
221 | 216 | |
---|
222 | 217 | exit_destroy: |
---|
223 | 218 | mutex_destroy(&ts->lock); |
---|