Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47513c2f authored by Linus Walleij's avatar Linus Walleij
Browse files

hid: cp2112: 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().

Cc: linux-input@vger.kernel.org
Acked-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 78d455a2
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
 *   http://www.silabs.com/Support%20Documents/TechnicalDocs/AN495.pdf
 */

#include <linux/gpio.h>
#include <linux/gpio/driver.h>
#include <linux/hid.h>
#include <linux/i2c.h>
#include <linux/module.h>
@@ -169,8 +169,7 @@ MODULE_PARM_DESC(gpio_push_pull, "GPIO push-pull configuration bitmask");

static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
{
	struct cp2112_device *dev = container_of(chip, struct cp2112_device,
						 gc);
	struct cp2112_device *dev = gpiochip_get_data(chip);
	struct hid_device *hdev = dev->hdev;
	u8 buf[5];
	int ret;
@@ -198,8 +197,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)

static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
	struct cp2112_device *dev = container_of(chip, struct cp2112_device,
						 gc);
	struct cp2112_device *dev = gpiochip_get_data(chip);
	struct hid_device *hdev = dev->hdev;
	u8 buf[3];
	int ret;
@@ -216,8 +214,7 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)

static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset)
{
	struct cp2112_device *dev = container_of(chip, struct cp2112_device,
						 gc);
	struct cp2112_device *dev = gpiochip_get_data(chip);
	struct hid_device *hdev = dev->hdev;
	u8 buf[2];
	int ret;
@@ -235,8 +232,7 @@ static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset)
static int cp2112_gpio_direction_output(struct gpio_chip *chip,
					unsigned offset, int value)
{
	struct cp2112_device *dev = container_of(chip, struct cp2112_device,
						 gc);
	struct cp2112_device *dev = gpiochip_get_data(chip);
	struct hid_device *hdev = dev->hdev;
	u8 buf[5];
	int ret;
@@ -1106,7 +1102,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
	dev->gc.can_sleep		= 1;
	dev->gc.parent			= &hdev->dev;

	ret = gpiochip_add(&dev->gc);
	ret = gpiochip_add_data(&dev->gc, dev);
	if (ret < 0) {
		hid_err(hdev, "error registering gpio chip\n");
		goto err_free_i2c;