[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5351D7EC.80902@roeck-us.net>
Date: Fri, 18 Apr 2014 18:57:00 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Boris BREZILLON <boris.brezillon@...e-electrons.com>,
Mark Brown <broonie@...nel.org>
CC: Lars-Peter Clausen <lars@...afoo.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Maxime Ripard <maxime.ripard@...e-electrons.com>,
Shuge <shuge@...winnertech.com>, kevin@...winnertech.com,
Chen-Yu Tsai <wens@...e.org>,
Hans de Goede <hdegoede@...hat.com>,
Carlo Caione <carlo@...one.org>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
dev@...ux-sunxi.org
Subject: Re: [PATCH v3] regmap: i2c: fallback to SMBus if the adapter does
not support standard I2C
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@...e-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, ®map_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, ®map_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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists