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

Commit 21abf103 authored by Linus Walleij's avatar Linus Walleij
Browse files

gpio: Pass a flag to gpiochip_request_own_desc()



Before things go out of hand, make it possible to pass
flags when requesting "own" descriptors from a gpio_chip.
This is necessary if the chip wants to request a GPIO with
active low semantics, for example.

Cc: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Roger Quadros <rogerq@ti.com>
Reviewed-by: default avatarGregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 67566ae4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -434,7 +434,9 @@ try_module_get()). A GPIO driver can use the following functions instead
to request and free descriptors without being pinned to the kernel forever::

	struct gpio_desc *gpiochip_request_own_desc(struct gpio_desc *desc,
						    const char *label)
						    u16 hwnum,
						    const char *label,
						    enum gpiod_flags flags)

	void gpiochip_free_own_desc(struct gpio_desc *desc)

+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip,
	}

	for (i = 0; i < ARRAY_SIZE(irq_data); i++) {
		gpiod = gpiochip_request_own_desc(chip, i, pin_name[i]);
		gpiod = gpiochip_request_own_desc(chip, i, pin_name[i], 0);
		if (IS_ERR(gpiod)) {
			pr_err("%s: failed to get GPIO pin %d (%ld)\n",
			       __func__, i, PTR_ERR(gpiod));
+1 −1
Original line number Diff line number Diff line
@@ -808,7 +808,7 @@ static void __init ams_delta_led_init(struct gpio_chip *chip)
	int i;

	for (i = LATCH1_PIN_LED_CAMERA; i < LATCH1_PIN_DOCKIT1; i++) {
		gpiod = gpiochip_request_own_desc(chip, i, NULL);
		gpiod = gpiochip_request_own_desc(chip, i, "camera-led", 0);
		if (IS_ERR(gpiod)) {
			pr_warn("%s: %s GPIO %d request failed (%ld)\n",
				__func__, LATCH1_LABEL, i, PTR_ERR(gpiod));
+1 −1
Original line number Diff line number Diff line
@@ -608,7 +608,7 @@ static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
		ret = -EBUSY;
	} else {
		desc = gpiochip_request_own_desc(&mvchip->chip,
						 pwm->hwpwm, "mvebu-pwm");
						 pwm->hwpwm, "mvebu-pwm", 0);
		if (IS_ERR(desc)) {
			ret = PTR_ERR(desc);
			goto out;
+3 −10
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
	if (!handler)
		return AE_OK;

	desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event");
	desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event", 0);
	if (IS_ERR(desc)) {
		dev_err(chip->parent, "Failed to request GPIO\n");
		return AE_ERROR;
@@ -884,21 +884,14 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
			const char *label = "ACPI:OpRegion";
			int err;

			desc = gpiochip_request_own_desc(chip, pin, label);
			desc = gpiochip_request_own_desc(chip, pin, label,
							 flags);
			if (IS_ERR(desc)) {
				status = AE_ERROR;
				mutex_unlock(&achip->conn_lock);
				goto out;
			}

			err = gpiod_configure_flags(desc, label, 0, flags);
			if (err < 0) {
				status = AE_NOT_CONFIGURED;
				gpiochip_free_own_desc(desc);
				mutex_unlock(&achip->conn_lock);
				goto out;
			}

			conn = kzalloc(sizeof(*conn), GFP_KERNEL);
			if (!conn) {
				status = AE_NO_MEMORY;
Loading