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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d28ff689dae5a6a35fd408020b3260d6d0f18880.camel@linaro.org>
Date: Mon, 24 Feb 2025 10:46:46 +0000
From: André Draszik <andre.draszik@...aro.org>
To: Lee Jones <lee@...nel.org>, Rob Herring <robh@...nel.org>, Krzysztof
 Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Linus
 Walleij	 <linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>,
 Srinivas Kandagatla <srinivas.kandagatla@...aro.org>, Kees Cook
 <kees@...nel.org>, "Gustavo A. R. Silva"	 <gustavoars@...nel.org>
Cc: Peter Griffin <peter.griffin@...aro.org>, Tudor Ambarus
	 <tudor.ambarus@...aro.org>, Will McVicker <willmcvicker@...gle.com>, 
	kernel-team@...roid.com, linux-kernel@...r.kernel.org, 
	devicetree@...r.kernel.org, linux-gpio@...r.kernel.org, 
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH 5/6] gpio: max77759: add Maxim MAX77759 gpio driver

On Mon, 2025-02-24 at 10:28 +0000, André Draszik wrote:
> [...]
> 
> +#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs))
> +#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0)
> +enum max77759_trigger_gpio_type {
> +	MAX77759_GPIO_TRIGGER_RISING = 0,
> +	MAX77759_GPIO_TRIGGER_FALLING = 1
> +};
> +
> +#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs))))
> +#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0)
> +enum max77759_control_gpio_dir {
> +	MAX77759_GPIO_DIR_IN = 0,
> +	MAX77759_GPIO_DIR_OUT = 1
> +};
> +
> +#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs))))
> +#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(offs, ~0)
> +
> +#define MAX77759_GPIOx_INVAL_MASK(offs) (BIT(4) << (3 * (offs)))
> +
> +[...]
> 
> +static int
> +max77759_gpio_direction_from_control(int ctrl, unsigned int offset)
> +{
> +	return (((ctrl & MAX77759_GPIOx_DIR_MASK(offset))
> +		 == MAX77759_GPIO_DIR_OUT)
> +		? GPIO_LINE_DIRECTION_OUT
> +		: GPIO_LINE_DIRECTION_IN);

Eek, I made a last minute change that I shouldn't have :-(
This should be something more like:

static int
max77759_gpio_direction_from_control(int ctrl, unsigned int offset)
{
	enum max77759_control_gpio_dir dir;

	dir = !!(ctrl & MAX77759_GPIOx_DIR_MASK(offset));
	return ((dir == MAX77759_GPIO_DIR_OUT)
		? GPIO_LINE_DIRECTION_OUT
		: GPIO_LINE_DIRECTION_IN);
}

I'll fix that for v2.


A.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ