lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zjk8nU562g3YxsVm@surfacebook.localdomain>
Date: Mon, 6 May 2024 23:25:01 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Alex Soo <yuklin.soo@...rfivetech.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
	Hal Feng <hal.feng@...rfivetech.com>,
	Ley Foon Tan <leyfoon.tan@...rfivetech.com>,
	Jianlong Huang <jianlong.huang@...rfivetech.com>,
	Emil Renner Berthing <kernel@...il.dk>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Drew Fustini <drew@...gleboard.org>, linux-gpio@...r.kernel.org,
	linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
	linux-riscv@...ts.infradead.org,
	Paul Walmsley <paul.walmsley@...ive.com>,
	Palmer Dabbelt <palmer@...belt.com>,
	Albert Ou <aou@...s.berkeley.edu>
Subject: Re: [RFC PATCH v3 6/7] gpiolib: enable GPIO interrupt to wake up a
 system from sleep

Fri, May 03, 2024 at 07:14:35PM +0800, Alex Soo kirjoitti:
> Add function gpiochip_wakeup_irq_setup() to configure and enable a
> GPIO pin with interrupt wakeup capability according to user-defined
> wakeup-gpios property in the device tree. Interrupt generated by
> toggling the logic level (rising/falling edge) on the specified
> GPIO pin can wake up a system from sleep mode.

..

> +static irqreturn_t gpio_wake_irq_handler(int irq, void *data)
> +{
> +	struct irq_data *irq_data = data;
> +
> +	if (!irq_data || irq != irq_data->irq)

Hmm... When irq_data can be NULL?

> +		return IRQ_NONE;
> +
> +	return IRQ_HANDLED;
> +}

..

> +static int gpiochip_wakeup_irq_setup(struct gpio_chip *gc)
> +{
> +	struct device *dev = gc->parent;
> +	struct gpio_irq_chip *girq = &gc->irq;
> +	struct gpio_desc *wakeup_gpiod;
> +	struct irq_desc *wakeup_irqd;
> +	struct irq_domain *irq_domain;
> +	struct irq_data *irq_data;
> +	unsigned int offset;
> +	int wakeup_irq;
> +	int ret;
> +
> +	if (!(device_property_read_bool(dev, "wakeup-source")))

Too many parentheses.

> +		return 0;
> +
> +	irq_domain = girq->domain;

> +

Unneeded blank line. Ditto for all similar cases.

> +	if (!irq_domain) {
> +		dev_err(dev, "Couldn't allocate IRQ domain\n");
> +		return -ENXIO;

		return dev_err_probe(...);

Ditto for all similar cases.

> +	}

..

> +	wakeup_gpiod = devm_gpiod_get_optional(dev, "wakeup", GPIOD_IN);
> +
> +	if (IS_ERR(wakeup_gpiod)) {
> +		dev_err(dev, "invalid wakeup gpio: %lu\n", PTR_ERR(wakeup_gpiod));
> +		return PTR_ERR(wakeup_gpiod);
> +	}
> +	if (!wakeup_gpiod) {
> +		dev_dbg(dev, "property wakeup-gpios is not defined\n");
> +		return 0;
> +	}
> +
> +	offset = gpio_chip_hwgpio(wakeup_gpiod);
> +	wakeup_irq = gpiod_to_irq(wakeup_gpiod);
> +	if (wakeup_irq < 0) {
> +		dev_err(dev, "failed to convert wakeup GPIO to IRQ\n");
> +		return wakeup_irq;
> +	}

> +	irq_domain->ops->map(irq_domain, wakeup_irq, offset);
> +	wakeup_irqd = irq_to_desc(wakeup_irq);
> +	irq_data = irq_get_irq_data(wakeup_irq);

What these lines are for?

> +	girq->handler = handle_edge_irq;
> +
> +	if (!(wakeup_irqd->status_use_accessors & IRQ_NOREQUEST)) {
> +		device_init_wakeup(dev, 1);
> +		ret = devm_request_threaded_irq(dev, wakeup_irq, NULL,
> +						gpio_wake_irq_handler,

> +						IRQF_TRIGGER_FALLING |
> +						IRQF_TRIGGER_RISING |

What's wrong with the flags from DT?

> +						IRQF_ONESHOT |
> +						IRQF_SHARED,
> +						"pm-wakeup-gpio", irq_data);
> +		if (ret) {
> +			dev_err(dev, "unable to request wakeup IRQ: %d\n", ret);
> +			return ret;
> +		}
> +	}

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ