mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] Apply these staging:iio patches to staging-next.
@ 2011-07-07 19:01 Bryan Freed
  2011-07-07 19:01 ` [PATCH v2 1/4] staging:iio: Reorder channel type strings to match the iio.h enums Bryan Freed
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bryan Freed @ 2011-07-07 19:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: jic23, gregkh, rklein, linux-iio, Bryan Freed

These patches are made from
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6.git staging-next
instead of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/
as the previous patches were.

Found another bug there, so there are 4 patches instead of 3.

Bryan Freed (4):
  staging:iio: Reorder channel type strings to match the iio.h enums.
  staging:iio: Add an iio channel type string to support proximity
    sensors.
  staging:iio:light:isl29018: Convert some of the isl29018 driver to
    the new iio_chan_spec framework.
  staging:iio:light:isl29018: Fix the "Init of isl29018 fails" failure.

 drivers/staging/iio/industrialio-core.c |   11 +-
 drivers/staging/iio/light/isl29018.c    |  174 ++++++++++++++----------------
 2 files changed, 87 insertions(+), 98 deletions(-)

-- 
1.7.3.1


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

* [PATCH v2 1/4] staging:iio: Reorder channel type strings to match the iio.h enums.
  2011-07-07 19:01 [PATCH 0/4] Apply these staging:iio patches to staging-next Bryan Freed
@ 2011-07-07 19:01 ` Bryan Freed
  2011-07-07 19:01 ` [PATCH v2 2/4] staging:iio: Add an iio channel type string to support proximity sensors Bryan Freed
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Bryan Freed @ 2011-07-07 19:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: jic23, gregkh, rklein, linux-iio, Bryan Freed

This makes comparison between the iio_chan_type_name_spec_shared strings
and the iio_chan_type enums easier.

Signed-off-by: Bryan Freed <bfreed@chromium.org>
---
 drivers/staging/iio/industrialio-core.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 8fa2be6..52a02af 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -44,21 +44,21 @@ struct bus_type iio_bus_type = {
 EXPORT_SYMBOL(iio_bus_type);
 
 static const char * const iio_chan_type_name_spec_shared[] = {
-	[IIO_TIMESTAMP] = "timestamp",
-	[IIO_ACCEL] = "accel",
 	[IIO_IN] = "in",
 	[IIO_OUT] = "out",
 	[IIO_CURRENT] = "current",
 	[IIO_POWER] = "power",
+	[IIO_ACCEL] = "accel",
 	[IIO_IN_DIFF] = "in-in",
 	[IIO_GYRO] = "gyro",
-	[IIO_TEMP] = "temp",
 	[IIO_MAGN] = "magn",
+	[IIO_LIGHT] = "illuminance",
+	[IIO_INTENSITY] = "intensity",
+	[IIO_TEMP] = "temp",
 	[IIO_INCLI] = "incli",
 	[IIO_ROT] = "rot",
-	[IIO_INTENSITY] = "intensity",
-	[IIO_LIGHT] = "illuminance",
 	[IIO_ANGL] = "angl",
+	[IIO_TIMESTAMP] = "timestamp",
 };
 
 static const char * const iio_chan_type_name_spec_complex[] = {
-- 
1.7.3.1


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

* [PATCH v2 2/4] staging:iio: Add an iio channel type string to support proximity sensors.
  2011-07-07 19:01 [PATCH 0/4] Apply these staging:iio patches to staging-next Bryan Freed
  2011-07-07 19:01 ` [PATCH v2 1/4] staging:iio: Reorder channel type strings to match the iio.h enums Bryan Freed
@ 2011-07-07 19:01 ` Bryan Freed
  2011-07-07 19:01 ` [PATCH v2 3/4] staging:iio:light:isl29018: Convert some of the isl29018 driver to the new iio_chan_spec framework Bryan Freed
  2011-07-07 19:01 ` [PATCH v1 4/4] staging:iio:light:isl29018: Fix the "Init of isl29018 fails" failure Bryan Freed
  3 siblings, 0 replies; 5+ messages in thread
From: Bryan Freed @ 2011-07-07 19:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: jic23, gregkh, rklein, linux-iio, Bryan Freed

Add "proximity" to the iio_chan_type_name_spec_shared string list to
support proximity sensors.
Now this list fully matches the declared iio_chan_type enums.

Signed-off-by: Bryan Freed <bfreed@chromium.org>
---
 drivers/staging/iio/industrialio-core.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 52a02af..19819e7 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -54,6 +54,7 @@ static const char * const iio_chan_type_name_spec_shared[] = {
 	[IIO_MAGN] = "magn",
 	[IIO_LIGHT] = "illuminance",
 	[IIO_INTENSITY] = "intensity",
+	[IIO_PROXIMITY] = "proximity",
 	[IIO_TEMP] = "temp",
 	[IIO_INCLI] = "incli",
 	[IIO_ROT] = "rot",
-- 
1.7.3.1


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

* [PATCH v2 3/4] staging:iio:light:isl29018: Convert some of the isl29018 driver to the new iio_chan_spec framework.
  2011-07-07 19:01 [PATCH 0/4] Apply these staging:iio patches to staging-next Bryan Freed
  2011-07-07 19:01 ` [PATCH v2 1/4] staging:iio: Reorder channel type strings to match the iio.h enums Bryan Freed
  2011-07-07 19:01 ` [PATCH v2 2/4] staging:iio: Add an iio channel type string to support proximity sensors Bryan Freed
@ 2011-07-07 19:01 ` Bryan Freed
  2011-07-07 19:01 ` [PATCH v1 4/4] staging:iio:light:isl29018: Fix the "Init of isl29018 fails" failure Bryan Freed
  3 siblings, 0 replies; 5+ messages in thread
From: Bryan Freed @ 2011-07-07 19:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: jic23, gregkh, rklein, linux-iio, Bryan Freed

Remove the driver's get_sensor_data() interfaces and replace them with
iio_chan_spec channels.  This converts 4 files to the new framework.
Driver ABI change: The intensity_infrared_raw file is now intensity_ir_raw.

Signed-off-by: Bryan Freed <bfreed@chromium.org>
---
 drivers/staging/iio/light/isl29018.c |  168 ++++++++++++++++------------------
 1 files changed, 78 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index cc6d718..070e94d 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -224,74 +224,7 @@ static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
 	return 0;
 }
 
-static ssize_t get_sensor_data(struct device *dev, char *buf, int mode)
-{
-	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct isl29018_chip *chip = iio_priv(indio_dev);
-	struct i2c_client *client = chip->client;
-	int value = 0;
-	int status;
-
-	mutex_lock(&chip->lock);
-	switch (mode) {
-	case COMMMAND1_OPMODE_PROX_ONCE:
-		status = isl29018_read_proximity_ir(client,
-				chip->prox_scheme, &value);
-		break;
-
-	case COMMMAND1_OPMODE_ALS_ONCE:
-		status = isl29018_read_lux(client, &value);
-		break;
-
-	case COMMMAND1_OPMODE_IR_ONCE:
-		status = isl29018_read_ir(client, &value);
-		break;
-
-	default:
-		dev_err(&client->dev, "Mode %d is not supported\n", mode);
-		mutex_unlock(&chip->lock);
-		return -EBUSY;
-	}
-	if (status < 0) {
-		dev_err(&client->dev, "Error in Reading data");
-		mutex_unlock(&chip->lock);
-		return status;
-	}
-
-	mutex_unlock(&chip->lock);
-
-	return sprintf(buf, "%d\n", value);
-}
-
 /* Sysfs interface */
-/* lux_scale */
-static ssize_t show_lux_scale(struct device *dev,
-			struct device_attribute *attr, char *buf)
-{
-	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct isl29018_chip *chip = indio_dev->dev_data;
-
-	return sprintf(buf, "%d\n", chip->lux_scale);
-}
-
-static ssize_t store_lux_scale(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
-{
-	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct isl29018_chip *chip = indio_dev->dev_data;
-	unsigned long lval;
-
-	lval = simple_strtoul(buf, NULL, 10);
-	if (lval == 0)
-		return -EINVAL;
-
-	mutex_lock(&chip->lock);
-	chip->lux_scale = lval;
-	mutex_unlock(&chip->lock);
-
-	return count;
-}
-
 /* range */
 static ssize_t show_range(struct device *dev,
 			struct device_attribute *attr, char *buf)
@@ -409,27 +342,87 @@ static ssize_t store_prox_infrared_supression(struct device *dev,
 	return count;
 }
 
-/* Read lux */
-static ssize_t show_lux(struct device *dev,
-		struct device_attribute *devattr, char *buf)
+/* Channel IO */
+static int isl29018_write_raw(struct iio_dev *indio_dev,
+			      struct iio_chan_spec const *chan,
+			      int val,
+			      int val2,
+			      long mask)
 {
-	return get_sensor_data(dev, buf, COMMMAND1_OPMODE_ALS_ONCE);
-}
+	struct isl29018_chip *chip = iio_priv(indio_dev);
+	int ret = -EINVAL;
 
-/* Read ir */
-static ssize_t show_ir(struct device *dev,
-		struct device_attribute *devattr, char *buf)
-{
-	return get_sensor_data(dev, buf, COMMMAND1_OPMODE_IR_ONCE);
+	mutex_lock(&chip->lock);
+	if (mask == (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) &&
+	    chan->type == IIO_LIGHT) {
+		chip->lux_scale = val;
+		ret = 0;
+	}
+	mutex_unlock(&chip->lock);
+
+	return 0;
 }
 
-/* Read nearest ir */
-static ssize_t show_proxim_ir(struct device *dev,
-		struct device_attribute *devattr, char *buf)
+static int isl29018_read_raw(struct iio_dev *indio_dev,
+			     struct iio_chan_spec const *chan,
+			     int *val,
+			     int *val2,
+			     long mask)
 {
-	return get_sensor_data(dev, buf, COMMMAND1_OPMODE_PROX_ONCE);
+	int ret = -EINVAL;
+	struct isl29018_chip *chip = iio_priv(indio_dev);
+	struct i2c_client *client = chip->client;
+
+	mutex_lock(&chip->lock);
+	switch (mask) {
+	case 0:
+		switch (chan->type) {
+		case IIO_LIGHT:
+			ret = isl29018_read_lux(client, val);
+			break;
+		case IIO_INTENSITY:
+			ret = isl29018_read_ir(client, val);
+			break;
+		case IIO_PROXIMITY:
+			ret = isl29018_read_proximity_ir(client,
+					chip->prox_scheme, val);
+			break;
+		default:
+			break;
+		}
+		if (!ret)
+			ret = IIO_VAL_INT;
+		break;
+	case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
+		if (chan->type == IIO_LIGHT) {
+			*val = chip->lux_scale;
+			ret = IIO_VAL_INT;
+		}
+		break;
+	default:
+		break;
+	}
+	mutex_unlock(&chip->lock);
+	return ret;
 }
 
+static const struct iio_chan_spec isl29018_channels[] = {
+	{
+		.type = IIO_LIGHT,
+		.indexed = 1,
+		.channel = 0,
+		.processed_val = 1,
+		.info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE),
+	}, {
+		.type = IIO_INTENSITY,
+		.modified = 1,
+		.channel2 = IIO_MOD_LIGHT_IR,
+	}, {
+		/* Unindexed in current ABI.  But perhaps it should be. */
+		.type = IIO_PROXIMITY,
+	}
+};
+
 static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0);
 static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000");
 static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16");
@@ -439,11 +432,6 @@ static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_supression,
 					S_IRUGO | S_IWUSR,
 					show_prox_infrared_supression,
 					store_prox_infrared_supression, 0);
-static IIO_DEVICE_ATTR(illuminance0_input, S_IRUGO, show_lux, NULL, 0);
-static IIO_DEVICE_ATTR(illuminance0_calibscale, S_IRUGO | S_IWUSR,
-					show_lux_scale, store_lux_scale, 0);
-static IIO_DEVICE_ATTR(intensity_infrared_raw, S_IRUGO, show_ir, NULL, 0);
-static IIO_DEVICE_ATTR(proximity_raw, S_IRUGO, show_proxim_ir, NULL, 0);
 
 #define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr)
 #define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
@@ -453,10 +441,6 @@ static struct attribute *isl29018_attributes[] = {
 	ISL29018_DEV_ATTR(adc_resolution),
 	ISL29018_CONST_ATTR(adc_resolution_available),
 	ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_supression),
-	ISL29018_DEV_ATTR(illuminance0_input),
-	ISL29018_DEV_ATTR(illuminance0_calibscale),
-	ISL29018_DEV_ATTR(intensity_infrared_raw),
-	ISL29018_DEV_ATTR(proximity_raw),
 	NULL
 };
 
@@ -489,6 +473,8 @@ static int isl29018_chip_init(struct i2c_client *client)
 static const struct iio_info isl29108_info = {
 	.attrs = &isl29108_group,
 	.driver_module = THIS_MODULE,
+	.read_raw = &isl29018_read_raw,
+	.write_raw = &isl29018_write_raw,
 };
 
 static int __devinit isl29018_probe(struct i2c_client *client,
@@ -520,6 +506,8 @@ static int __devinit isl29018_probe(struct i2c_client *client,
 		goto exit_iio_free;
 
 	indio_dev->info = &isl29108_info;
+	indio_dev->channels = isl29018_channels;
+	indio_dev->num_channels = ARRAY_SIZE(isl29018_channels);
 	indio_dev->name = id->name;
 	indio_dev->dev.parent = &client->dev;
 	indio_dev->modes = INDIO_DIRECT_MODE;
-- 
1.7.3.1


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

* [PATCH v1 4/4] staging:iio:light:isl29018: Fix the "Init of isl29018 fails" failure.
  2011-07-07 19:01 [PATCH 0/4] Apply these staging:iio patches to staging-next Bryan Freed
                   ` (2 preceding siblings ...)
  2011-07-07 19:01 ` [PATCH v2 3/4] staging:iio:light:isl29018: Convert some of the isl29018 driver to the new iio_chan_spec framework Bryan Freed
@ 2011-07-07 19:01 ` Bryan Freed
  3 siblings, 0 replies; 5+ messages in thread
From: Bryan Freed @ 2011-07-07 19:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: jic23, gregkh, rklein, linux-iio, Bryan Freed

The I2C clientdata is set to indio_dev instead of chip as of a couple weeks ago.
Correct the calls to i2c_get_clientdata() accordingly.
Otherwise the driver fails to initialize.

Signed-off-by: Bryan Freed <bfreed@chromium.org>
---
 drivers/staging/iio/light/isl29018.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 070e94d..426b6af 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -68,7 +68,7 @@ static int isl29018_write_data(struct i2c_client *client, u8 reg,
 {
 	u8 regval;
 	int ret = 0;
-	struct isl29018_chip *chip = i2c_get_clientdata(client);
+	struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
 
 	regval = chip->reg_cache[reg];
 	regval &= ~mask;
@@ -158,7 +158,7 @@ static int isl29018_read_sensor_input(struct i2c_client *client, int mode)
 static int isl29018_read_lux(struct i2c_client *client, int *lux)
 {
 	int lux_data;
-	struct isl29018_chip *chip = i2c_get_clientdata(client);
+	struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
 
 	lux_data = isl29018_read_sensor_input(client,
 				COMMMAND1_OPMODE_ALS_ONCE);
@@ -450,7 +450,7 @@ static const struct attribute_group isl29108_group = {
 
 static int isl29018_chip_init(struct i2c_client *client)
 {
-	struct isl29018_chip *chip = i2c_get_clientdata(client);
+	struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
 	int status;
 	int new_adc_bit;
 	unsigned int new_range;
-- 
1.7.3.1


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

end of thread, other threads:[~2011-07-07 19:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 19:01 [PATCH 0/4] Apply these staging:iio patches to staging-next Bryan Freed
2011-07-07 19:01 ` [PATCH v2 1/4] staging:iio: Reorder channel type strings to match the iio.h enums Bryan Freed
2011-07-07 19:01 ` [PATCH v2 2/4] staging:iio: Add an iio channel type string to support proximity sensors Bryan Freed
2011-07-07 19:01 ` [PATCH v2 3/4] staging:iio:light:isl29018: Convert some of the isl29018 driver to the new iio_chan_spec framework Bryan Freed
2011-07-07 19:01 ` [PATCH v1 4/4] staging:iio:light:isl29018: Fix the "Init of isl29018 fails" failure Bryan Freed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®