All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@roeck-us.net (Guenter Roeck)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] regmap: i2c: fallback to SMBus if the adapter does not support standard I2C
Date: Fri, 18 Apr 2014 18:57:00 -0700	[thread overview]
Message-ID: <5351D7EC.80902@roeck-us.net> (raw)
In-Reply-To: <1397851901-16390-1-git-send-email-boris.brezillon@free-electrons.com>

On 04/18/2014 01:11 PM, Boris BREZILLON wrote:
> Some I2C adapters are only compatible with the SMBus protocol and do not
> support standard I2C transfers.
>
> Fallback to SMBus transfers if we encounter such kind of adapters.
> The transfer type is chosen according to the val_bits field in the regmap
> config.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---

[ ... ]

>   /**
>    * regmap_init_i2c(): Initialise register map
>    *
> @@ -109,7 +199,12 @@ static struct regmap_bus regmap_i2c = {
>   struct regmap *regmap_init_i2c(struct i2c_client *i2c,
>   			       const struct regmap_config *config)
>   {
> -	return regmap_init(&i2c->dev, &regmap_i2c, &i2c->dev, config);
> +	const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config);
> +
> +	if (IS_ERR(bus))
> +		return ERR_PTR(PTR_ERR(bus));
> +
This seems clumsy. You should be able to use ERR_CAST() instead.
Also see Documentation/coccinelle.txt and scripts/coccinelle/api/err_cast.cocci.

> +	return regmap_init(&i2c->dev, bus, &i2c->dev, config);
>   }
>   EXPORT_SYMBOL_GPL(regmap_init_i2c);
>
> @@ -126,7 +221,12 @@ EXPORT_SYMBOL_GPL(regmap_init_i2c);
>   struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
>   				    const struct regmap_config *config)
>   {
> -	return devm_regmap_init(&i2c->dev, &regmap_i2c, &i2c->dev, config);
> +	const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config);
> +
> +	if (IS_ERR(bus))
> +		return ERR_PTR(PTR_ERR(bus));
> +
Same here.

Guenter

WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Boris BREZILLON <boris.brezillon@free-electrons.com>,
	Mark Brown <broonie@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Shuge <shuge@allwinnertech.com>,
	kevin@allwinnertech.com, Chen-Yu Tsai <wens@csie.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Carlo Caione <carlo@caione.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, dev@linux-sunxi.org
Subject: Re: [PATCH v3] regmap: i2c: fallback to SMBus if the adapter does not support standard I2C
Date: Fri, 18 Apr 2014 18:57:00 -0700	[thread overview]
Message-ID: <5351D7EC.80902@roeck-us.net> (raw)
In-Reply-To: <1397851901-16390-1-git-send-email-boris.brezillon@free-electrons.com>

On 04/18/2014 01:11 PM, Boris BREZILLON wrote:
> Some I2C adapters are only compatible with the SMBus protocol and do not
> support standard I2C transfers.
>
> Fallback to SMBus transfers if we encounter such kind of adapters.
> The transfer type is chosen according to the val_bits field in the regmap
> config.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---

[ ... ]

>   /**
>    * regmap_init_i2c(): Initialise register map
>    *
> @@ -109,7 +199,12 @@ static struct regmap_bus regmap_i2c = {
>   struct regmap *regmap_init_i2c(struct i2c_client *i2c,
>   			       const struct regmap_config *config)
>   {
> -	return regmap_init(&i2c->dev, &regmap_i2c, &i2c->dev, config);
> +	const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config);
> +
> +	if (IS_ERR(bus))
> +		return ERR_PTR(PTR_ERR(bus));
> +
This seems clumsy. You should be able to use ERR_CAST() instead.
Also see Documentation/coccinelle.txt and scripts/coccinelle/api/err_cast.cocci.

> +	return regmap_init(&i2c->dev, bus, &i2c->dev, config);
>   }
>   EXPORT_SYMBOL_GPL(regmap_init_i2c);
>
> @@ -126,7 +221,12 @@ EXPORT_SYMBOL_GPL(regmap_init_i2c);
>   struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
>   				    const struct regmap_config *config)
>   {
> -	return devm_regmap_init(&i2c->dev, &regmap_i2c, &i2c->dev, config);
> +	const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config);
> +
> +	if (IS_ERR(bus))
> +		return ERR_PTR(PTR_ERR(bus));
> +
Same here.

Guenter


  reply	other threads:[~2014-04-19  1:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17  9:40 [PATCH v2 0/2] regmap: support regmap over SMBus Boris BREZILLON
2014-04-17  9:40 ` Boris BREZILLON
2014-04-17  9:40 ` [PATCH v2 1/2] regmap: add reg_read/reg_write callbacks to regmap_bus struct Boris BREZILLON
2014-04-17  9:40   ` Boris BREZILLON
2014-04-18 15:08   ` Mark Brown
2014-04-18 15:08     ` Mark Brown
2014-04-17  9:40 ` [PATCH v2 2/2] regmap: i2c: fallback to SMBus if the adapter does not support standard I2C Boris BREZILLON
2014-04-17  9:40   ` Boris BREZILLON
2014-04-18 15:10   ` Mark Brown
2014-04-18 15:10     ` Mark Brown
2014-04-18 17:08   ` Lars-Peter Clausen
2014-04-18 17:08     ` Lars-Peter Clausen
2014-04-18 20:11 ` [PATCH v3] " Boris BREZILLON
2014-04-18 20:11   ` Boris BREZILLON
2014-04-19  1:57   ` Guenter Roeck [this message]
2014-04-19  1:57     ` Guenter Roeck
2014-04-21 20:56 ` [PATCH v4] " Boris BREZILLON
2014-04-21 20:56   ` Boris BREZILLON
2014-04-22 11:57   ` Mark Brown
2014-04-22 11:57     ` Mark Brown

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=5351D7EC.80902@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.