hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpio/gpio-max730x.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**
23 * Copyright (C) 2006 Juergen Beisert, Pengutronix
34 * Copyright (C) 2008 Guennadi Liakhovetski, Pengutronix
45 * 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.
96 *
107 * The Maxim MAX7300/1 device is an I2C/SPI driven GPIO expander. There are
118 * 28 GPIOs. 8 of them can trigger an interrupt. See datasheet for more
....@@ -50,7 +47,7 @@
5047
5148 static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)
5249 {
53
- struct max7301 *ts = gpiochip_get_data(chip);
50
+ struct max7301 *ts = container_of(chip, struct max7301, chip);
5451 u8 *config;
5552 u8 offset_bits, pin_config;
5653 int ret;
....@@ -92,7 +89,7 @@
9289 static int max7301_direction_output(struct gpio_chip *chip, unsigned offset,
9390 int value)
9491 {
95
- struct max7301 *ts = gpiochip_get_data(chip);
92
+ struct max7301 *ts = container_of(chip, struct max7301, chip);
9693 u8 *config;
9794 u8 offset_bits;
9895 int ret;
....@@ -192,10 +189,6 @@
192189 ts->chip.parent = dev;
193190 ts->chip.owner = THIS_MODULE;
194191
195
- ret = gpiochip_add_data(&ts->chip, ts);
196
- if (ret)
197
- goto exit_destroy;
198
-
199192 /*
200193 * initialize pullups according to platform data and cache the
201194 * register values for later use.
....@@ -217,7 +210,9 @@
217210 }
218211 }
219212
220
- return ret;
213
+ ret = gpiochip_add_data(&ts->chip, ts);
214
+ if (!ret)
215
+ return ret;
221216
222217 exit_destroy:
223218 mutex_destroy(&ts->lock);