All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-gpio@vger.kernel.org,
	Cristina Ciocan <cristina.ciocan@intel.com>
Subject: Re: [PATCH v1 2/3] pinctrl: baytrail: Debounce register is one per community
Date: Fri, 27 Jan 2017 10:21:09 +0100	[thread overview]
Message-ID: <20170127102109.3fb3d018@endymion> (raw)
In-Reply-To: <20170126172409.132136-3-andriy.shevchenko@linux.intel.com>

On Thu, 26 Jan 2017 19:24:08 +0200, Andy Shevchenko wrote:
> Debounce value is set globally per community. Otherwise user will easily
> get a kernel crash when they start using the feature:
> 
> BUG: unable to handle kernel paging request at ffffc900003be000
> IP: byt_gpio_dbg_show+0xa9/0x430
> 
> Make it clear in byt_gpio_reg().
> 
> Note that this fix just prevents kernel to crash, but doesn't make any
> difference to the existing logic. It means the last caller will win the
> trade and debounce value will be configured accordingly. The actual
> logic fix needs to be thought about and it's not as important as crash
> fix. That's why the latter goes separately and right now.
> 
> Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce configuration")
> Cc: Cristina Ciocan <cristina.ciocan@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-baytrail.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
> index 958db4f5ee9b..a1f85a79f186 100644
> --- a/drivers/pinctrl/intel/pinctrl-baytrail.c
> +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
> @@ -731,16 +731,23 @@ static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset,
>  				  int reg)
>  {
>  	struct byt_community *comm = byt_get_community(vg, offset);
> -	u32 reg_offset = 0;
> +	u32 reg_offset;
>  
>  	if (!comm)
>  		return NULL;
>  
>  	offset -= comm->pin_base;
> -	if (reg == BYT_INT_STAT_REG)
> +	switch (reg) {
> +	case BYT_INT_STAT_REG:
>  		reg_offset = (offset / 32) * 4;
> -	else
> +		break;
> +	case BYT_DEBOUNCE_REG:
> +		reg_offset = 0;
> +		break;
> +	default:
>  		reg_offset = comm->pad_map[offset] * 16;
> +		break;

That break isn't needed ;-)

> +	}
>  
>  	return comm->reg_base + reg_offset + reg;
>  }

The code looks sane to me, although I can't verify its correctness
without a datasheet.

Reviewed-by: Jean Delvare <jdelvare@suse.de>

-- 
Jean Delvare
SUSE L3 Support

  reply	other threads:[~2017-01-27  9:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-26 17:24 [PATCH v1 0/3] pinctrl: baytrail: Fix debounce feature Andy Shevchenko
2017-01-26 17:24 ` [PATCH v1 1/3] pinctrl: baytrail: Rectify debounce support (part 2) Andy Shevchenko
2017-01-27  9:14   ` Jean Delvare
2017-01-27 13:28     ` Andy Shevchenko
2017-01-27  9:34   ` Mika Westerberg
2017-01-30 14:47   ` Linus Walleij
2017-01-26 17:24 ` [PATCH v1 2/3] pinctrl: baytrail: Debounce register is one per community Andy Shevchenko
2017-01-27  9:21   ` Jean Delvare [this message]
2017-01-27 13:27     ` Andy Shevchenko
2017-01-27 14:06       ` Jean Delvare
2017-01-27  9:35   ` Mika Westerberg
2017-01-30 14:49   ` Linus Walleij
2017-01-26 17:24 ` [PATCH v1 3/3] pinctrl: baytrail: Add debounce to debug output Andy Shevchenko
2017-01-27  9:40   ` Mika Westerberg
2017-01-27 10:07   ` Jean Delvare
2017-01-30 14:51   ` Linus Walleij
2017-01-30 15:13     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170127102109.3fb3d018@endymion \
    --to=jdelvare@suse.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=cristina.ciocan@intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.