linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr()
@ 2011-09-06  7:12 Mark Brown
  2011-09-06  7:12 ` [PATCH 2/2] lis3lv02d: Make regulator API usage unconditional Mark Brown
  2011-09-06 21:07 ` [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2011-09-06  7:12 UTC (permalink / raw)
  To: Andrew Morton, Éric Piel, Ilkka Koskinen
  Cc: linux-kernel, Mark Brown, stable

The driver is passing a struct lis3lv02d ** to the read() operation but
the read() operation wants a struct lis3lv02d * causing compiler warnings
and presumably also runtime problems.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@kernel.org
---
 drivers/misc/lis3lv02d/lis3lv02d.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index e67dcea..72a1f92 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -200,7 +200,7 @@ static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
 	u8 ctrl;
 	int shift;
 
-	lis3->read(&lis3, CTRL_REG1, &ctrl);
+	lis3->read(lis3, CTRL_REG1, &ctrl);
 	ctrl &= lis3->odr_mask;
 	shift = ffs(lis3->odr_mask) - 1;
 	return lis3->odrs[(ctrl >> shift)];
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] lis3lv02d: Make regulator API usage unconditional
  2011-09-06  7:12 [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Mark Brown
@ 2011-09-06  7:12 ` Mark Brown
  2011-09-06 21:07 ` [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-09-06  7:12 UTC (permalink / raw)
  To: Andrew Morton, Éric Piel, Ilkka Koskinen; +Cc: linux-kernel, Mark Brown

The regulator API contains a range of features for stubbing itself out
when not in use and for transparently restricting the actual effect of
regulator API calls where they can't be supported on a particular system
so that drivers don't need to individually implement this. Simplify the
driver slightly by making use of this idiom.

The only in tree user is ecovec24 which does not use the regulator API.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/misc/lis3lv02d/lis3lv02d_i2c.c |   34 +++++++++++--------------------
 include/linux/lis3lv02d.h              |    1 -
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
index 6cdc38f..c02fea0 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
@@ -79,8 +79,7 @@ static int lis3_i2c_init(struct lis3lv02d *lis3)
 	u8 reg;
 	int ret;
 
-	if (lis3->reg_ctrl)
-		lis3_reg_ctrl(lis3, LIS3_REG_ON);
+	lis3_reg_ctrl(lis3, LIS3_REG_ON);
 
 	lis3->read(lis3, WHO_AM_I, &reg);
 	if (reg != lis3->whoami)
@@ -106,10 +105,6 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
 	struct lis3lv02d_platform_data *pdata = client->dev.platform_data;
 
 	if (pdata) {
-		/* Regulator control is optional */
-		if (pdata->driver_features & LIS3_USE_REGULATOR_CTRL)
-			lis3_dev.reg_ctrl = lis3_reg_ctrl;
-
 		if ((pdata->driver_features & LIS3_USE_BLOCK_READ) &&
 			(i2c_check_functionality(client->adapter,
 						I2C_FUNC_SMBUS_I2C_BLOCK)))
@@ -131,15 +126,13 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
 			goto fail;
 	}
 
-	if (lis3_dev.reg_ctrl) {
-		lis3_dev.regulators[0].supply = reg_vdd;
-		lis3_dev.regulators[1].supply = reg_vdd_io;
-		ret = regulator_bulk_get(&client->dev,
-					ARRAY_SIZE(lis3_dev.regulators),
-					lis3_dev.regulators);
-		if (ret < 0)
-			goto fail;
-	}
+	lis3_dev.regulators[0].supply = reg_vdd;
+	lis3_dev.regulators[1].supply = reg_vdd_io;
+	ret = regulator_bulk_get(&client->dev,
+				 ARRAY_SIZE(lis3_dev.regulators),
+				 lis3_dev.regulators);
+	if (ret < 0)
+		goto fail;
 
 	lis3_dev.pdata	  = pdata;
 	lis3_dev.bus_priv = client;
@@ -153,13 +146,11 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, &lis3_dev);
 
 	/* Provide power over the init call */
-	if (lis3_dev.reg_ctrl)
-		lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
+	lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
 
 	ret = lis3lv02d_init_device(&lis3_dev);
 
-	if (lis3_dev.reg_ctrl)
-		lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
+	lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
 
 	if (ret)
 		goto fail2;
@@ -185,9 +176,8 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client)
 	lis3lv02d_joystick_disable(lis3);
 	lis3lv02d_remove_fs(&lis3_dev);
 
-	if (lis3_dev.reg_ctrl)
-		regulator_bulk_free(ARRAY_SIZE(lis3->regulators),
-				lis3_dev.regulators);
+	regulator_bulk_free(ARRAY_SIZE(lis3->regulators),
+			    lis3_dev.regulators);
 	return 0;
 }
 
diff --git a/include/linux/lis3lv02d.h b/include/linux/lis3lv02d.h
index d4292c8..f1664c6 100644
--- a/include/linux/lis3lv02d.h
+++ b/include/linux/lis3lv02d.h
@@ -113,7 +113,6 @@ struct lis3lv02d_platform_data {
 	s8 axis_x;
 	s8 axis_y;
 	s8 axis_z;
-#define LIS3_USE_REGULATOR_CTRL 0x01
 #define LIS3_USE_BLOCK_READ	0x02
 	u16 driver_features;
 	int default_rate;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr()
  2011-09-06  7:12 [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Mark Brown
  2011-09-06  7:12 ` [PATCH 2/2] lis3lv02d: Make regulator API usage unconditional Mark Brown
@ 2011-09-06 21:07 ` Andrew Morton
  2011-09-07  5:21   ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2011-09-06 21:07 UTC (permalink / raw)
  To: Mark Brown; +Cc: Éric Piel, Ilkka Koskinen, linux-kernel, stable

On Tue,  6 Sep 2011 00:12:28 -0700
Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:

> The driver is passing a struct lis3lv02d ** to the read() operation but
> the read() operation wants a struct lis3lv02d * causing compiler warnings
> and presumably also runtime problems.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> Cc: stable@kernel.org
> ---
>  drivers/misc/lis3lv02d/lis3lv02d.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
> index e67dcea..72a1f92 100644
> --- a/drivers/misc/lis3lv02d/lis3lv02d.c
> +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
> @@ -200,7 +200,7 @@ static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
>  	u8 ctrl;
>  	int shift;
>  
> -	lis3->read(&lis3, CTRL_REG1, &ctrl);
> +	lis3->read(lis3, CTRL_REG1, &ctrl);
>  	ctrl &= lis3->odr_mask;
>  	shift = ffs(lis3->odr_mask) - 1;
>  	return lis3->odrs[(ctrl >> shift)];

This not applicable to mainline or to -stable.  It is a fix to
lis3-remove-the-references-to-the-global-variable-in-core-driver.patch
which I already have queued, as
lis3-remove-the-references-to-the-global-variable-in-core-driver-fix.patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr()
  2011-09-06 21:07 ` [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Andrew Morton
@ 2011-09-07  5:21   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-09-07  5:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Éric Piel, Ilkka Koskinen, linux-kernel, stable

On Tue, Sep 06, 2011 at 02:07:35PM -0700, Andrew Morton wrote:

> This not applicable to mainline or to -stable.  It is a fix to
> lis3-remove-the-references-to-the-global-variable-in-core-driver.patch
> which I already have queued, as
> lis3-remove-the-references-to-the-global-variable-in-core-driver-fix.patch.

Hrm, strange - the fix doesn't seem to have shown up in -next before the
breakin.  Anyway, so long as it's fixed that's the main thing - thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-07  5:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-06  7:12 [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Mark Brown
2011-09-06  7:12 ` [PATCH 2/2] lis3lv02d: Make regulator API usage unconditional Mark Brown
2011-09-06 21:07 ` [PATCH 1/2] lis3lv02d: Fix read() call in lis3lv02d_get_odr() Andrew Morton
2011-09-07  5:21   ` Mark Brown

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).