All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] staging:iio: Minor clean ups.
@ 2010-05-17 21:35 Jonathan Cameron
  2010-05-17 21:35 ` [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again Jonathan Cameron
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jonathan Cameron @ 2010-05-17 21:35 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

Dear All,

These are pretty mundane clean up patches. The first is the 
change the Michael suggested the other day. It gets rid
of some superfluous code.

The third cleans up some useless complexity in the lis3l02dq
driver.  As all interrupts have to be acknowledged, and as none
of the other elements of the iio_work_cont are used, we just
replace it with a single work_struct.

Jonathan Cameron (3):
  staging:iio:max1363 use device_id instead of searching on name again
  staging:iio:max1363 trivial code and comment cleanups.
  staging:iio:lis3l02dq cleanups

 drivers/staging/iio/accel/lis3l02dq.h      |    4 +-
 drivers/staging/iio/accel/lis3l02dq_core.c |   25 ++---
 drivers/staging/iio/accel/lis3l02dq_ring.c |    8 --
 drivers/staging/iio/adc/max1363.h          |    3 +-
 drivers/staging/iio/adc/max1363_core.c     |  156 +++++++++++++--------------
 drivers/staging/iio/adc/max1363_ring.c     |   10 +-
 6 files changed, 92 insertions(+), 114 deletions(-)

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

* [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again
  2010-05-17 21:35 [PATCH 0/3] staging:iio: Minor clean ups Jonathan Cameron
@ 2010-05-17 21:35 ` Jonathan Cameron
  2010-05-18 13:43   ` Hennerich, Michael
  2010-05-17 21:35 ` [PATCH 2/3] staging:iio:max1363 trivial code and comment cleanups Jonathan Cameron
  2010-05-17 21:35 ` [PATCH 3/3] staging:iio:lis3l02dq cleanups Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2010-05-17 21:35 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/max1363.h      |    3 +-
 drivers/staging/iio/adc/max1363_core.c |  152 +++++++++++++++-----------------
 2 files changed, 75 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/iio/adc/max1363.h b/drivers/staging/iio/adc/max1363.h
index 72cf367..eb20c68 100644
--- a/drivers/staging/iio/adc/max1363.h
+++ b/drivers/staging/iio/adc/max1363.h
@@ -179,7 +179,6 @@ enum max1363_modes {
  * @default_mode:	the scan mode in which the chip starts up
  */
 struct max1363_chip_info {
-	const char			*name;
 	u8				num_inputs;
 	u8				bits;
 	u16				int_vref_mv;
@@ -199,6 +198,7 @@ struct max1363_chip_info {
  * @setupbyte:		cache of current device setup byte
  * @configbyte:		cache of current device config byte
  * @chip_info:		chip model specific constants, available modes etc
+ * @name:		part name. Copy of id->device_name
  * @current_mode:	the scan mode of this chip
  * @requestedmask:	a valid requested set of channels
  * @poll_work:		bottom half of polling interrupt handler
@@ -211,6 +211,7 @@ struct max1363_state {
 	char				setupbyte;
 	char				configbyte;
 	const struct max1363_chip_info	*chip_info;
+	char				*name;
 	const struct max1363_mode	*current_mode;
 	u32				requestedmask;
 	struct work_struct		poll_work;
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index 20e2674..d2a8cfa 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -305,7 +305,7 @@ static ssize_t max1363_show_name(struct device *dev,
 {
 	struct iio_dev *dev_info = dev_get_drvdata(dev);
 	struct max1363_state *st = iio_dev_get_devdata(dev_info);
-	return sprintf(buf, "%s\n", st->chip_info->name);
+	return sprintf(buf, "%s\n", st->name);
 }
 
 static IIO_DEVICE_ATTR(name, S_IRUGO, max1363_show_name, NULL, 0);
@@ -552,8 +552,7 @@ enum { max1361,
 
 /* max1363 and max1368 tested - rest from data sheet */
 static const struct max1363_chip_info max1363_chip_info_tbl[] = {
-	{
-		.name = "max1361",
+	[max1361] = {
 		.num_inputs = 4,
 		.bits = 10,
 		.int_vref_mv = 2048,
@@ -563,8 +562,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1362",
+	},
+	[max1362] = {
 		.num_inputs = 4,
 		.bits = 10,
 		.int_vref_mv = 4096,
@@ -574,8 +573,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1363",
+	},
+	[max1363] = {
 		.num_inputs = 4,
 		.bits = 12,
 		.int_vref_mv = 2048,
@@ -585,8 +584,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1364",
+	},
+	[max1364] = {
 		.num_inputs = 4,
 		.bits = 12,
 		.int_vref_mv = 4096,
@@ -596,8 +595,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1036",
+	},
+	[max1036] = {
 		.num_inputs = 4,
 		.bits = 8,
 		.int_vref_mv = 4096,
@@ -606,8 +605,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1037",
+	},
+	[max1037] = {
 		.num_inputs = 4,
 		.bits = 8,
 		.int_vref_mv = 2048,
@@ -616,8 +615,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1038",
+	},
+	[max1038] = {
 		.num_inputs = 12,
 		.bits = 8,
 		.int_vref_mv = 4096,
@@ -626,8 +625,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max1039",
+	},
+	[max1039] = {
 		.num_inputs = 12,
 		.bits = 8,
 		.int_vref_mv = 2048,
@@ -636,8 +635,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max1136",
+	},
+	[max1136] = {
 		.num_inputs = 4,
 		.bits = 10,
 		.int_vref_mv = 4096,
@@ -646,8 +645,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1137",
+	},
+	[max1137] = {
 		.num_inputs = 4,
 		.bits = 10,
 		.int_vref_mv = 2048,
@@ -656,8 +655,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1138",
+	},
+	[max1138] = {
 		.num_inputs = 12,
 		.bits = 10,
 		.int_vref_mv = 4096,
@@ -666,8 +665,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max1139",
+	},
+	[max1139] = {
 		.num_inputs = 12,
 		.bits = 10,
 		.int_vref_mv = 2048,
@@ -676,8 +675,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max1236",
+	},
+	[max1236] = {
 		.num_inputs = 4,
 		.bits = 12,
 		.int_vref_mv = 4096,
@@ -686,8 +685,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1237",
+	},
+	[max1237] = {
 		.num_inputs = 4,
 		.bits = 12,
 		.int_vref_mv = 2048,
@@ -696,8 +695,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max1238",
+	},
+	[max1238] = {
 		.num_inputs = 12,
 		.bits = 12,
 		.int_vref_mv = 4096,
@@ -706,8 +705,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max1239",
+	},
+	[max1239] = {
 		.num_inputs = 12,
 		.bits = 12,
 		.int_vref_mv = 2048,
@@ -716,8 +715,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max11600",
+	},
+	[max11600] = {
 		.num_inputs = 4,
 		.bits = 8,
 		.int_vref_mv = 4096,
@@ -726,8 +725,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max11601",
+	},
+	[max11601] = {
 		.num_inputs = 4,
 		.bits = 8,
 		.int_vref_mv = 2048,
@@ -736,8 +735,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max11602",
+	},
+	[max11602] = {
 		.num_inputs = 8,
 		.bits = 8,
 		.int_vref_mv = 4096,
@@ -746,8 +745,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to7,
 		.dev_attrs = &max11608_dev_attr_group,
 		.scan_attrs = &max11608_scan_el_group,
-	}, {
-		.name = "max11603",
+	},
+	[max11603] = {
 		.num_inputs = 8,
 		.bits = 8,
 		.int_vref_mv = 2048,
@@ -756,8 +755,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to7,
 		.dev_attrs = &max11608_dev_attr_group,
 		.scan_attrs = &max11608_scan_el_group,
-	}, {
-		.name = "max11604",
+	},
+	[max11604] = {
 		.num_inputs = 12,
 		.bits = 8,
 		.int_vref_mv = 4098,
@@ -766,8 +765,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max11605",
+	},
+	[max11605] = {
 		.num_inputs = 12,
 		.bits = 8,
 		.int_vref_mv = 2048,
@@ -776,8 +775,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max11606",
+	},
+	[max11606] = {
 		.num_inputs = 4,
 		.bits = 10,
 		.int_vref_mv = 4096,
@@ -786,8 +785,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max11607",
+	},
+	[max11607] = {
 		.num_inputs = 4,
 		.bits = 10,
 		.int_vref_mv = 2048,
@@ -796,8 +795,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max11608",
+	},
+	[max11608] = {
 		.num_inputs = 8,
 		.bits = 10,
 		.int_vref_mv = 4096,
@@ -806,8 +805,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to7,
 		.dev_attrs = &max11608_dev_attr_group,
 		.scan_attrs = &max11608_scan_el_group,
-	}, {
-		.name = "max11609",
+	},
+	[max11609] = {
 		.num_inputs = 8,
 		.bits = 10,
 		.int_vref_mv = 2048,
@@ -816,8 +815,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to7,
 		.dev_attrs = &max11608_dev_attr_group,
 		.scan_attrs = &max11608_scan_el_group,
-	}, {
-		.name = "max11610",
+	},
+	[max11610] = {
 		.num_inputs = 12,
 		.bits = 10,
 		.int_vref_mv = 4098,
@@ -826,8 +825,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max11611",
+	},
+	[max11611] = {
 		.num_inputs = 12,
 		.bits = 10,
 		.int_vref_mv = 2048,
@@ -836,8 +835,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max11612",
+	},
+	[max11612] = {
 		.num_inputs = 4,
 		.bits = 12,
 		.int_vref_mv = 4096,
@@ -846,8 +845,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max11613",
+	},
+	[max11613] = {
 		.num_inputs = 4,
 		.bits = 12,
 		.int_vref_mv = 2048,
@@ -856,8 +855,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to3,
 		.dev_attrs = &max1363_dev_attr_group,
 		.scan_attrs = &max1363_scan_el_group,
-	}, {
-		.name = "max11614",
+	},
+	[max11614] = {
 		.num_inputs = 8,
 		.bits = 12,
 		.int_vref_mv = 4096,
@@ -866,8 +865,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to7,
 		.dev_attrs = &max11608_dev_attr_group,
 		.scan_attrs = &max11608_scan_el_group,
-	}, {
-		.name = "max11615",
+	},
+	[max11615] = {
 		.num_inputs = 8,
 		.bits = 12,
 		.int_vref_mv = 2048,
@@ -876,8 +875,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to7,
 		.dev_attrs = &max11608_dev_attr_group,
 		.scan_attrs = &max11608_scan_el_group,
-	}, {
-		.name = "max11616",
+	},
+	[max11616] = {
 		.num_inputs = 12,
 		.bits = 12,
 		.int_vref_mv = 4098,
@@ -886,8 +885,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.default_mode = s0to11,
 		.dev_attrs = &max1238_dev_attr_group,
 		.scan_attrs = &max1238_scan_el_group,
-	}, {
-		.name = "max11617",
+	},
+	[max11617] = {
 		.num_inputs = 12,
 		.bits = 12,
 		.int_vref_mv = 2048,
@@ -931,18 +930,12 @@ static int __devinit max1363_probe(struct i2c_client *client,
 	atomic_set(&st->protect_ring, 0);
 
 	/* Find the chip model specific data */
-	for (i = 0; i < ARRAY_SIZE(max1363_chip_info_tbl); i++)
-		if (!strcmp(max1363_chip_info_tbl[i].name, id->name)) {
-			st->chip_info = &max1363_chip_info_tbl[i];
-			break;
-		};
-	/* Unsupported chip */
-	if (!st->chip_info) {
-		dev_err(&client->dev, "%s is not supported\n", id->name);
-		ret = -ENODEV;
+	st->chip_info = &max1363_chip_info_tbl[id->driver_data];
+	st->name = kstrdup(id->name, GFP_KERNEL);
+	if (st->name == NULL) {
+		ret = -ENOMEM;
 		goto error_free_st;
 	}
-
 	st->reg = regulator_get(&client->dev, "vcc");
 	if (!IS_ERR(st->reg)) {
 		ret = regulator_enable(st->reg);
@@ -1010,6 +1003,7 @@ error_disable_reg:
 error_put_reg:
 	if (!IS_ERR(st->reg))
 		regulator_put(st->reg);
+	kfree(st->name);
 error_free_st:
 	i2c_set_clientdata(client, NULL);
 	kfree(st);
-- 
1.7.0.4

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

* [PATCH 2/3] staging:iio:max1363 trivial code and comment cleanups.
  2010-05-17 21:35 [PATCH 0/3] staging:iio: Minor clean ups Jonathan Cameron
  2010-05-17 21:35 ` [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again Jonathan Cameron
@ 2010-05-17 21:35 ` Jonathan Cameron
  2010-05-17 21:35 ` [PATCH 3/3] staging:iio:lis3l02dq cleanups Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2010-05-17 21:35 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/max1363_core.c |    4 ++--
 drivers/staging/iio/adc/max1363_ring.c |   10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index d2a8cfa..1a25888 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -48,7 +48,7 @@
 	IIO_SCAN_EL_C(in##number, number, IIO_UNSIGNED(16), 0, NULL);
 #define MAX1363_SCAN_EL_D(p, n, number)					\
 	IIO_SCAN_NAMED_EL_C(in##p##m##in##n, in##p-in##n,		\
-			number, IIO_SIGNED(16), 0 , NULL);
+			number, IIO_SIGNED(16), 0, NULL);
 
 static MAX1363_SCAN_EL(0);
 static MAX1363_SCAN_EL(1);
@@ -167,7 +167,7 @@ static int max1363_write_basic_config(struct i2c_client *client,
 				      unsigned char d2)
 {
 	int ret;
-	u8 *tx_buf = kmalloc(2 , GFP_KERNEL);
+	u8 *tx_buf = kmalloc(2, GFP_KERNEL);
 
 	if (!tx_buf)
 		return -ENOMEM;
diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index 56688dc..a69d1ec 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -68,7 +68,7 @@ error_ret:
 }
 
 /**
- * max1363_ring_preenable() setup the parameters of the ring before enabling
+ * max1363_ring_preenable() - setup the parameters of the ring before enabling
  *
  * The complex nature of the setting of the nuber of bytes per datum is due
  * to this driver currently ensuring that the timestamp is stored at an 8
@@ -106,7 +106,7 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
 }
 
 /**
- * max1363_ring_postenable() typical ring post enable
+ * max1363_ring_postenable() - typical ring post enable
  *
  * Only not moved into the core for the hardware ring buffer cases
  * that are more sophisticated.
@@ -120,7 +120,7 @@ static int max1363_ring_postenable(struct iio_dev *indio_dev)
 }
 
 /**
- * max1363_ring_predisable() runs just prior to ring buffer being disabled
+ * max1363_ring_predisable() - runs just prior to ring buffer being disabled
  *
  * Typical predisable function which ensures that no trigger events can
  * occur before we disable the ring buffer (and hence would have no idea
@@ -136,7 +136,7 @@ static int max1363_ring_predisable(struct iio_dev *indio_dev)
 }
 
 /**
- * max1363_poll_func_th() th of trigger launched polling to ring buffer
+ * max1363_poll_func_th() - th of trigger launched polling to ring buffer
  *
  * As sampling only occurs on i2c comms occuring, leave timestamping until
  * then.  Some triggers will generate their own time stamp.  Currently
@@ -151,7 +151,7 @@ static void max1363_poll_func_th(struct iio_dev *indio_dev)
 	return;
 }
 /**
- * max1363_poll_bh_to_ring() bh of trigger launched polling to ring buffer
+ * max1363_poll_bh_to_ring() - bh of trigger launched polling to ring buffer
  * @work_s:	the work struct through which this was scheduled
  *
  * Currently there is no option in this driver to disable the saving of
-- 
1.7.0.4

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

* [PATCH 3/3] staging:iio:lis3l02dq cleanups
  2010-05-17 21:35 [PATCH 0/3] staging:iio: Minor clean ups Jonathan Cameron
  2010-05-17 21:35 ` [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again Jonathan Cameron
  2010-05-17 21:35 ` [PATCH 2/3] staging:iio:max1363 trivial code and comment cleanups Jonathan Cameron
@ 2010-05-17 21:35 ` Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2010-05-17 21:35 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/accel/lis3l02dq.h      |    4 ++--
 drivers/staging/iio/accel/lis3l02dq_core.c |   25 ++++++++-----------------
 drivers/staging/iio/accel/lis3l02dq_ring.c |    8 --------
 3 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h
index e76a979..7f09d2e 100644
--- a/drivers/staging/iio/accel/lis3l02dq.h
+++ b/drivers/staging/iio/accel/lis3l02dq.h
@@ -150,7 +150,7 @@ Form of high byte dependant on justification set in ctrl reg */
  * struct lis3l02dq_state - device instance specific data
  * @us:			actual spi_device
  * @work_trigger_to_ring: bh for triggered event handling
- * @work_cont_thresh: CLEAN
+ * @work_thresh:	bh for threshold events
  * @inter:		used to check if new interrupt has been triggered
  * @last_timestamp:	passing timestamp from th to bh of interrupt handler
  * @indio_dev:		industrial I/O device structure
@@ -162,7 +162,7 @@ Form of high byte dependant on justification set in ctrl reg */
 struct lis3l02dq_state {
 	struct spi_device		*us;
 	struct work_struct		work_trigger_to_ring;
-	struct iio_work_cont		work_cont_thresh;
+	struct work_struct		work_thresh;
 	bool				inter;
 	s64				last_timestamp;
 	struct iio_dev			*indio_dev;
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
index 6b5577d..4034869 100644
--- a/drivers/staging/iio/accel/lis3l02dq_core.c
+++ b/drivers/staging/iio/accel/lis3l02dq_core.c
@@ -96,7 +96,7 @@ int lis3l02dq_spi_write_reg_8(struct device *dev,
 
 	spi_message_init(&msg);
 	spi_message_add_tail(&xfer, &msg);
-	ret =  spi_sync(st->us, &msg);
+	ret = spi_sync(st->us, &msg);
 	mutex_unlock(&st->buf_lock);
 
 	return ret;
@@ -524,8 +524,7 @@ static ssize_t lis3l02dq_read_interrupt_config(struct device *dev,
 				       LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
 				       (u8 *)&val);
 
-	return ret ? ret : sprintf(buf, "%d\n",
-				   (val & this_attr->mask) ? 1 : 0);;
+	return ret ? ret : sprintf(buf, "%d\n", !!(val & this_attr->mask));
 }
 
 static ssize_t lis3l02dq_write_interrupt_config(struct device *dev,
@@ -604,7 +603,7 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info,
 
 	/* Stash the timestamp somewhere convenient for the bh */
 	st->last_timestamp = timestamp;
-	schedule_work(&st->work_cont_thresh.ws);
+	schedule_work(&st->work_thresh);
 
 	return 0;
 }
@@ -615,9 +614,10 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info,
  */
 static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
 {
-	struct iio_work_cont *wc
-		= container_of(work_s, struct iio_work_cont, ws);
-	struct lis3l02dq_state *st = wc->st;
+       struct lis3l02dq_state *st
+	       = container_of(work_s,
+		       struct lis3l02dq_state, work_thresh);
+
 	u8 t;
 
 	lis3l02dq_spi_read_reg_8(&st->indio_dev->dev,
@@ -750,6 +750,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
 		ret =  -ENOMEM;
 		goto error_ret;
 	}
+	INIT_WORK(&st->work_thresh, lis3l02dq_thresh_handler_bh_no_check);
 	/* this is only used tor removal purposes */
 	spi_set_drvdata(spi, st);
 
@@ -797,16 +798,6 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
 	}
 
 	if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
-		/* This is a little unusual, in that the device seems
-		   to need a full read of the interrupt source reg before
-		   the interrupt will reset.
-		   Hence the two handlers are the same */
-		iio_init_work_cont(&st->work_cont_thresh,
-				   lis3l02dq_thresh_handler_bh_no_check,
-				   lis3l02dq_thresh_handler_bh_no_check,
-				   LIS3L02DQ_REG_WAKE_UP_SRC_ADDR,
-				   0,
-				   st);
 		st->inter = 0;
 		ret = iio_register_interrupt_line(spi->irq,
 						  st->indio_dev,
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index e4e202e..6b0b124 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -591,12 +591,4 @@ void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring)
 	iio_ring_buffer_unregister(ring);
 }
 
-int lis3l02dq_set_ring_length(struct iio_dev *indio_dev, int length)
-{
-	/* Set sensible defaults for the ring buffer */
-	if (indio_dev->ring->access.set_length)
-		return indio_dev->ring->access.set_length(indio_dev->ring, 500);
-	return 0;
-}
-
 
-- 
1.7.0.4

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

* RE: [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again
  2010-05-17 21:35 ` [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again Jonathan Cameron
@ 2010-05-18 13:43   ` Hennerich, Michael
  2010-05-18 14:25     ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Hennerich, Michael @ 2010-05-18 13:43 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: uclinux-dist-devel

Jonathan Cameron wrote on 2010-05-17:
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
>  drivers/staging/iio/adc/max1363.h      |    3 +-
>  drivers/staging/iio/adc/max1363_core.c |  152
> +++++++++++++++---------
> --------
>  2 files changed, 75 insertions(+), 80 deletions(-)
> diff --git a/drivers/staging/iio/adc/max1363.h
> b/drivers/staging/iio/adc/max1363.h index 72cf367..eb20c68 100644 ---
> a/drivers/staging/iio/adc/max1363.h +++
> b/drivers/staging/iio/adc/max1363.h @@ -179,7 +179,6 @@ enum

--[snip]--

> +     st->chip_info =3D &max1363_chip_info_tbl[id->driver_data];
> +     st->name =3D kstrdup(id->name, GFP_KERNEL);
> +     if (st->name =3D=3D NULL) {
> +             ret =3D -ENOMEM;


Isn't id->name =3D=3D client->name ?

static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id =
*id,
                                                const struct i2c_client *cl=
ient)
{
        while (id->name[0]) {
                if (strcmp(client->name, id->name) =3D=3D 0)
                        return id;
                id++;
        }
        return NULL;
}

So you don't need an extra copy simply use client->name


Greetings,
Michael

Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 4036 Geschaeft=
sfuehrer Thomas Wessel, William A. Martin, Margaret Seif

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

* Re: [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again
  2010-05-18 13:43   ` Hennerich, Michael
@ 2010-05-18 14:25     ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2010-05-18 14:25 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: linux-iio, uclinux-dist-devel

On 05/18/10 14:43, Hennerich, Michael wrote:
> Jonathan Cameron wrote on 2010-05-17:
>> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
>> ---
>>  drivers/staging/iio/adc/max1363.h      |    3 +-
>>  drivers/staging/iio/adc/max1363_core.c |  152
>> +++++++++++++++---------
>> --------
>>  2 files changed, 75 insertions(+), 80 deletions(-)
>> diff --git a/drivers/staging/iio/adc/max1363.h
>> b/drivers/staging/iio/adc/max1363.h index 72cf367..eb20c68 100644 ---
>> a/drivers/staging/iio/adc/max1363.h +++
>> b/drivers/staging/iio/adc/max1363.h @@ -179,7 +179,6 @@ enum
> 
> --[snip]--
> 
>> +     st->chip_info = &max1363_chip_info_tbl[id->driver_data];
>> +     st->name = kstrdup(id->name, GFP_KERNEL);
>> +     if (st->name == NULL) {
>> +             ret = -ENOMEM;
> 
> 
> Isn't id->name == client->name ?
> 
> static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
>                                                 const struct i2c_client *client)
> {
>         while (id->name[0]) {
>                 if (strcmp(client->name, id->name) == 0)
>                         return id;
>                 id++;
>         }
>         return NULL;
> }
> 
> So you don't need an extra copy simply use client->name
> 
Another excellent point.  Thanks!

Will redo this one later.

Jonathan


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

end of thread, other threads:[~2010-05-18 14:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17 21:35 [PATCH 0/3] staging:iio: Minor clean ups Jonathan Cameron
2010-05-17 21:35 ` [PATCH 1/3] staging:iio:max1363 use device_id instead of searching on name again Jonathan Cameron
2010-05-18 13:43   ` Hennerich, Michael
2010-05-18 14:25     ` Jonathan Cameron
2010-05-17 21:35 ` [PATCH 2/3] staging:iio:max1363 trivial code and comment cleanups Jonathan Cameron
2010-05-17 21:35 ` [PATCH 3/3] staging:iio:lis3l02dq cleanups Jonathan Cameron

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.