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:	Fri, 18 Nov 2011 17:29:14 +0530
From:	Rabin Vincent <rabin@....in>
To:	Viresh Kumar <viresh.kumar@...com>
Cc:	linus.walleij@...ricsson.com, srinidhi.kasagar@...ricsson.com,
	sameo@...ux.intel.com, linux-kernel@...r.kernel.org,
	armando.visconti@...com, shiraz.hashim@...com, vipin.kumar@...com,
	rajeev-dlh.kumar@...com, deepak.sikri@...com,
	vipulkumar.samar@...com, amit.virdi@...com, pratyush.anand@...com,
	bhupesh.sharma@...com, viresh.linux@...il.com, bhavna.yadav@...com,
	vincenzo.frascino@...com, mirko.gardi@...com,
	grant.likely@...retlab.ca
Subject: Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801

On Thu, Nov 17, 2011 at 11:02, Viresh Kumar <viresh.kumar@...com> wrote:
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 4c980b5..000b019 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -65,7 +65,15 @@ static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
>        u8 reg = stmpe->regs[which] - (offset / 8);
>        u8 mask = 1 << (offset % 8);
>
> -       stmpe_reg_write(stmpe, reg, mask);
> +       /*
> +        * Some variants have single register for gpio set/clear functionality.
> +        * For them we need to write 0 to clear and 1 to set.
> +        */
> +       if (!val && (stmpe->regs[STMPE_IDX_GPSR_LSB] ==
> +                               stmpe->regs[STMPE_IDX_GPCR_LSB]))
> +               stmpe_set_bits(stmpe, reg, mask, ~mask);
> +       else
> +               stmpe_set_bits(stmpe, reg, mask, mask);
>  }

This code,

 (1) for 801, when clearing one GPIO, sets all the others.
 (2) for other devices, adds an an unnecessary read (within stmpe_set_bits()),
     which wasn't there before.

Please rework to something like:

	if (stmpe->regs[...)
		stmpe_set_bits(stmpe, reg, mask, val ? mask : 0);
	else
		stmpe_reg_write(stmpe, reg, mask);

>
>  static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> @@ -125,10 +133,19 @@ static struct gpio_chip template_chip = {
>  static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>  {
>        struct stmpe_gpio *stmpe_gpio = irq_data_get_irq_chip_data(d);
> +       struct stmpe *stmpe = stmpe_gpio->stmpe;
>        int offset = d->irq - stmpe_gpio->irq_base;
>        int regoffset = offset / 8;
>        int mask = 1 << (offset % 8);
>
> +       /* STMPE801 doesn't have RE and FE registers */
> +       if (stmpe->partnum == STMPE801) {
> +               if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
> +                       return 0;

This looks wrong.  From the datasheet I see that it supports edges only,
so perhaps you meant to say IRQ_TYPE_EDGE_* above.

In that case please reorganize this to add the return 0 after the
existing check which excludes levels (below).

> +               else
> +                       return -EINVAL;
> +       }
> +
>        if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
>                return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ