linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-i2c@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>
Subject: Re: [PATCH v1 1/4] i2c: designware: Split out i2c_dw_validate_speed() helper
Date: Mon, 11 May 2020 16:42:38 +0300	[thread overview]
Message-ID: <20200511134238.GI185537@smile.fi.intel.com> (raw)
In-Reply-To: <228e9c62-60b9-e5b8-ea5e-e012df83479b@linux.intel.com>

On Mon, May 11, 2020 at 04:11:57PM +0300, Jarkko Nikula wrote:
> On 5/7/20 4:51 PM, Andy Shevchenko wrote:
> > In order to export array supported speed for wider use,
> > split out them along with i2c_dw_validate_speed() helper.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >   drivers/i2c/busses/i2c-designware-core.h    | 31 +++++++++++++++++++++
> >   drivers/i2c/busses/i2c-designware-platdrv.c | 29 ++++---------------
> >   2 files changed, 36 insertions(+), 24 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
> > index 1674caf277451..626959573f894 100644
> > --- a/drivers/i2c/busses/i2c-designware-core.h
> > +++ b/drivers/i2c/busses/i2c-designware-core.h
> > @@ -9,6 +9,7 @@
> >    * Copyright (C) 2009 Provigent Ltd.
> >    */
> > +#include <linux/errno.h>
> >   #include <linux/i2c.h>
> >   #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C |			\
> > @@ -351,3 +352,33 @@ extern int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev);
> >   #else
> >   static inline int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev) { return 0; }
> >   #endif
> > +
> > +static const u32 i2c_dw_supported_speeds[] = {
> > +	I2C_MAX_HIGH_SPEED_MODE_FREQ,
> > +	I2C_MAX_FAST_MODE_PLUS_FREQ,
> > +	I2C_MAX_FAST_MODE_FREQ,
> > +	I2C_MAX_STANDARD_MODE_FREQ,
> > +};
> > +
> > +static inline int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
> > +{
> > +	struct i2c_timings *t = &dev->timings;
> > +	unsigned int i;
> > +
> > +	/*
> > +	 * Only standard mode at 100kHz, fast mode at 400kHz,
> > +	 * fast mode plus at 1MHz and high speed mode at 3.4MHz are supported.
> > +	 */
> > +	for (i = 0; i < ARRAY_SIZE(i2c_dw_supported_speeds); i++) {
> > +		if (t->bus_freq_hz == i2c_dw_supported_speeds[i])
> > +			break;
> > +	}
> > +	if (i == ARRAY_SIZE(i2c_dw_supported_speeds)) {
> > +		dev_err(dev->dev,
> > +			"%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n",
> > +			t->bus_freq_hz);
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> 
> This header is included by every i2c-designware-*.c file and this inline
> function is not tiny. Would it be better to have this in
> i2c-designware-common.c instead?

Yes, but then we will need to export i2c_dw_supported_speeds as well as its
array size.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2020-05-11 13:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 13:51 [PATCH v1 1/4] i2c: designware: Split out i2c_dw_validate_speed() helper Andy Shevchenko
2020-05-07 13:51 ` [PATCH v1 2/4] i2c: designware: Split out OF parts into separate module Andy Shevchenko
2020-05-07 13:51 ` [PATCH v1 3/4] i2c: designware: Split out ACPI " Andy Shevchenko
2020-05-11 13:31   ` Jarkko Nikula
2020-05-11 14:05     ` Andy Shevchenko
2020-05-07 13:51 ` [PATCH v1 4/4] i2c: designware: Read counters from ACPI for PCI driver Andy Shevchenko
2020-05-11 13:11 ` [PATCH v1 1/4] i2c: designware: Split out i2c_dw_validate_speed() helper Jarkko Nikula
2020-05-11 13:42   ` Andy Shevchenko [this message]
2020-05-12 15:12     ` Jarkko Nikula
2020-05-19 12:33       ` 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=20200511134238.GI185537@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --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;
as well as URLs for NNTP newsgroup(s).