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]
Date:   Mon, 27 Jun 2022 10:10:41 +0200
From:   Michael Walle <michael@...le.cc>
To:     Aidan MacDonald <aidanmacdonald.0x0@...il.com>
Cc:     linus.walleij@...aro.org, brgl@...ev.pl, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org, wens@...e.org, jic23@...nel.org,
        lee.jones@...aro.org, sre@...nel.org, broonie@...nel.org,
        gregkh@...uxfoundation.org, lgirdwood@...il.com, lars@...afoo.de,
        rafael@...nel.org, quic_gurus@...cinc.com,
        sebastian.reichel@...labora.com, andy.shevchenko@...il.com,
        linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
        linux-pm@...r.kernel.org
Subject: Re: [PATCH v3 13/16] pinctrl: Add AXP192 pin control driver

Hi,

As Linus suggested you could have a look at devm_gpio_regmap_register()
with a custom xlate() callback and some improvements. But I've never
worked with pinctrl so I might be wrong. See below.

> +static int axp192_gpio_get(struct gpio_chip *chip, unsigned int 
> offset)
> +{
> +	struct axp192_pctl *pctl = gpiochip_get_data(chip);
> +	const struct axp192_pctl_reg_info *reginfo = 
> &pctl->desc->in_regs[offset];
> +	unsigned int val;
> +	int ret;
> +
> +	ret = regmap_read(pctl->regmap, reginfo->reg, &val);
> +	if (ret)
> +		return ret;
> +
> +	return !!(val & reginfo->mask);
> +}

This should work.

> +
> +static int axp192_gpio_get_direction(struct gpio_chip *chip, unsigned
> int offset)
> +{
> +	struct axp192_pctl *pctl = gpiochip_get_data(chip);
> +	const struct axp192_pctl_reg_info *reginfo = 
> &pctl->desc->ctrl_regs[offset];
> +	const u8 *input_muxvals = 
> pctl->desc->functions[AXP192_FUNC_INPUT].muxvals;
> +	unsigned int val;
> +	int ret;
> +
> +	ret = regmap_read(pctl->regmap, reginfo->reg, &val);
> +	if (ret)
> +		return ret;
> +
> +	if ((val & reginfo->mask) == (input_muxvals[offset] <<
> (ffs(reginfo->mask) - 1)))
> +		return GPIO_LINE_DIRECTION_IN;

This isn't supported (yet) in gpio-regmap...

> +
> +	return GPIO_LINE_DIRECTION_OUT;
> +}
> +
> +static void axp192_gpio_set(struct gpio_chip *chip, unsigned int
> offset, int value)
> +{
> +	struct axp192_pctl *pctl = gpiochip_get_data(chip);
> +	const struct axp192_pctl_reg_info *reginfo = 
> &pctl->desc->out_regs[offset];
> +
> +	regmap_update_bits(pctl->regmap, reginfo->reg, reginfo->mask, value
> ? reginfo->mask : 0);
> +}
> +
> +static int axp192_gpio_direction_input(struct gpio_chip *chip,
> unsigned int offset)
> +{
> +	return pinctrl_gpio_direction_input(chip->base + offset);
> +}

..as well as this.

> +
> +static int axp192_gpio_direction_output(struct gpio_chip *chip,
> unsigned int offset, int value)
> +{
> +	chip->set(chip, offset, value);

Why don't you call pinctrl_gpio_direction_output() here?


I *think* what is needed for gpio-regmap to support this is:
  - support values and masks for the direction, for now, we
    only support single bits.
  - support the pinctrl_gpio_direction_{input,output} calls

-michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ