public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Chen-Yu Tsai <wens@csie.org>,
	linux-i2c@vger.kernel.org
Subject: Re: [RFT][PATCH 2/2] i2c: sun6i-p2wi: Prevent potential division by zero
Date: Wed, 13 Apr 2016 09:49:18 +0200	[thread overview]
Message-ID: <20160413094918.1f1ca765@bbrezillon> (raw)
In-Reply-To: <1460508870.6009.3.camel@ingics.com>

On Wed, 13 Apr 2016 08:54:30 +0800
Axel Lin <axel.lin@ingics.com> wrote:

> Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The
> variable set here is later used as a divisor.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/i2c/busses/i2c-sun6i-p2wi.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> index 7668e2e..6448291 100644
> --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
> +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> @@ -202,6 +202,11 @@ static int p2wi_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> +	if (clk_freq == 0) {
> +		dev_err(dev, "clock-frequency is set to 0 in DT\n");
> +		return -EINVAL;
> +	}
> +
>  	if (of_get_child_count(np) > 1) {
>  		dev_err(dev, "P2WI only supports one slave device\n");
>  		return -EINVAL;



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

      reply	other threads:[~2016-04-13  7:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13  0:49 [RFT][PATCH 1/2] i2c: sirf: Prevent potential division by zero Axel Lin
2016-04-13  0:54 ` [RFT][PATCH 2/2] i2c: sun6i-p2wi: " Axel Lin
2016-04-13  7:49   ` Boris Brezillon [this message]

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=20160413094918.1f1ca765@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=axel.lin@ingics.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=wens@csie.org \
    --cc=wsa@the-dreams.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox