linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Eddie Huang <eddie.huang@mediatek.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Xudong Chen <xudong.chen@mediatek.com>,
	srv_heupstream@mediatek.com, Pawel Moll <pawel.moll@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Wolfram Sang <wsa@the-dreams.de>,
	Liguo Zhang <liguo.zhang@mediatek.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org, linux-i2c@vger.kernel.org,
	Sascha Hauer <kernel@pengutronix.de>,
	Kumar Gala <galak@codeaurora.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v8 2/3] I2C: mediatek: Add driver for MediaTek I2C controller
Date: Wed, 20 May 2015 17:37:28 +0200	[thread overview]
Message-ID: <20150520153728.GT24769@pengutronix.de> (raw)
In-Reply-To: <1432127020.20394.15.camel@mtksdaap41>

Hello,

On Wed, May 20, 2015 at 09:03:40PM +0800, Yingjoe Chen wrote:
> On Wed, 2015-05-20 at 10:57 +0200, Uwe Kleine-König wrote:
> > On Tue, May 19, 2015 at 12:40:08AM +0800, Eddie Huang wrote:
> > > +	if (i2c->speed_hz > MAX_HS_MODE_SPEED)
> > > +		return -EINVAL;
> > According to the plan to tune for the highest possible rate <=
> > i2c->speed_hz, you should handle the case (i2c->speed_hz >
> > MAX_HS_MODE_SPEED) like i2c->speed_hz == MAX_HS_MODE_SPEED.
> > Well, you might want to prevent an overflow in the calculation below
> > however.
> 
> The check here means we don't support speed > MAX_HS_MODE_SPEED. This is
> different then slightly slower bus speed due to rounding error.
Well from outside there no difference between asking for 100 with
getting 98 or asking for 405 with getting 400. IMHO the expectation is
that you set the maximal possible rate when something too big for you is
requested. Consider a communication with a i2c device that supports 600
kHz. You have the choice to communicate with 400 kHz with that or not at
all.

> > > +	best_mul = MAX_SAMPLE_CNT_DIV * max_step_cnt;
> > > +
> > > +	for (sample_cnt = 1; sample_cnt <= MAX_SAMPLE_CNT_DIV; sample_cnt++) {
> > > +		step_cnt = (min_div + sample_cnt - 1) / sample_cnt;
> > DIV_ROUND_UP
> > 
> > > +		cnt_mul = step_cnt * sample_cnt;
> > > +		if (step_cnt > max_step_cnt)
> > > +			continue;
> > I think it can happen that you have step_cnt > max_step_cnt here, but
> > that (sample_cnt, max_step_cnt) still is a good pair to consider. So:
> 
> If step_cnt > max_step_cnt, then sample_cnt * max_step_cnt < min_div.
> This means (sample_cnt, max_step_cnt) is not a valid.
You're right.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2015-05-20 15:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 16:40 [PATCH v8 0/3] ARM: mediatek: Add driver for Mediatek I2C Eddie Huang
2015-05-18 16:40 ` [PATCH v8 1/3] dt-bindings: Add I2C bindings for mt65xx/mt81xx Eddie Huang
2015-05-18 18:29   ` Uwe Kleine-König
2015-05-18 16:40 ` [PATCH v8 2/3] I2C: mediatek: Add driver for MediaTek I2C controller Eddie Huang
2015-05-18 18:43   ` Uwe Kleine-König
2015-05-19 14:48     ` Matthias Brugger
2015-05-19 19:49       ` Uwe Kleine-König
2015-05-20  5:33         ` Eddie Huang
2015-05-20  3:07       ` Yingjoe Chen
2015-05-20  2:40     ` Eddie Huang
2015-05-20  7:11       ` Uwe Kleine-König
2015-05-20  7:59         ` Eddie Huang
2015-05-20  8:33           ` Uwe Kleine-König
2015-05-20  8:57   ` Uwe Kleine-König
2015-05-20 13:03     ` Yingjoe Chen
2015-05-20 15:37       ` Uwe Kleine-König [this message]
2015-05-21  7:01     ` Eddie Huang
2015-05-18 16:40 ` [PATCH v8 3/3] I2C: mediatek: Add driver for MediaTek MT8173 " Eddie Huang
2015-05-19 14:45   ` Matthias Brugger
2015-05-20  2:53     ` Eddie Huang

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=20150520153728.GT24769@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=eddie.huang@mediatek.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=liguo.zhang@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=srv_heupstream@mediatek.com \
    --cc=wsa@the-dreams.de \
    --cc=xudong.chen@mediatek.com \
    --cc=yingjoe.chen@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).