All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH 01/67] iio: Add broken out info_mask fields for shared_by_type and separate
Date: Sat,  2 Mar 2013 16:16:18 +0000	[thread overview]
Message-ID: <1362241044-3534-2-git-send-email-jic23@kernel.org> (raw)
In-Reply-To: <1362241044-3534-1-git-send-email-jic23@kernel.org>

This simplifies the code, removes an extensive layer of 'helper' macros
and gives us twice as much room to play with in these masks before we
have any need to be clever.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/industrialio-core.c | 30 ++++++++++++++++++++++++++++++
 include/linux/iio/iio.h         | 10 +++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 8848f16..6f1a998 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -708,6 +708,36 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
 			goto error_ret;
 		attrcount++;
 	}
+	for_each_set_bit(i, &chan->info_mask_separate, sizeof(long)*8) {
+		ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
+					     chan,
+					     &iio_read_channel_info,
+					     &iio_write_channel_info,
+					     i,
+					     0,
+					     &indio_dev->dev,
+					     &indio_dev->channel_attr_list);
+		if (ret < 0)
+			goto error_ret;
+		attrcount++;
+	}
+	for_each_set_bit(i, &chan->info_mask_shared_by_type, sizeof(long)*8) {
+		ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
+					     chan,
+					     &iio_read_channel_info,
+					     &iio_write_channel_info,
+					     i,
+					     1,
+					     &indio_dev->dev,
+					     &indio_dev->channel_attr_list);
+		if (ret == -EBUSY) {
+			ret = 0;
+			continue;
+		} else if (ret < 0) {
+			goto error_ret;
+		}
+		attrcount++;
+	}
 
 	if (chan->ext_info) {
 		unsigned int i = 0;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index da8c776..7697650 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -218,6 +218,10 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
  *			endianness:	little or big endian
  * @info_mask:		What information is to be exported about this channel.
  *			This includes calibbias, scale etc.
+ * @info_mask_separate: What information is to be exported that is specific to
+ *			this channel.
+ * @info_mask_shared_by_type: What information is to be exported that is shared
+*			by all channels of the same type.
  * @event_mask:		What events can this channel produce.
  * @ext_info:		Array of extended info attributes for this channel.
  *			The array is NULL terminated, the last element should
@@ -253,6 +257,8 @@ struct iio_chan_spec {
 		enum iio_endian endianness;
 	} scan_type;
 	long			info_mask;
+	long			info_mask_separate;
+	long			info_mask_shared_by_type;
 	long			event_mask;
 	const struct iio_chan_spec_ext_info *ext_info;
 	const char		*extend_name;
@@ -275,7 +281,9 @@ struct iio_chan_spec {
 static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
 	enum iio_chan_info_enum type)
 {
-	return chan->info_mask & IIO_CHAN_INFO_BITS(type);
+	return (chan->info_mask & IIO_CHAN_INFO_BITS(type)) |
+	       (chan->info_mask_separate & type) |
+	       (chan->info_mask_shared_by_type & type);
 }
 
 #define IIO_ST(si, rb, sb, sh)						\
-- 
1.8.1.4


  reply	other threads:[~2013-03-02 16:17 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-02 16:16 [PATCH 00/67 V2] IIO break info_mask into a pair of masks Jonathan Cameron
2013-03-02 16:16 ` Jonathan Cameron [this message]
2013-03-02 16:16 ` [PATCH 02/67] iio:adc:max1363 move to info_mask_(shared_by_type/separate) Jonathan Cameron
2013-03-02 16:16 ` [PATCH 03/67] staging:iio:dummy " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 04/67] iio:hid_sensors " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 05/67] iio:accel:kxsd9 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 06/67] iio:st_sensors " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 07/67] iio:adc:ad_sigma_delta " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 08/67] iio:adc:ad7266 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 09/67] iio:adc:ad7298 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 10/67] iio:adc:ad7476 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 11/67] iio:adc:ad7887 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 12/67] iio:adc:at91_adc " Jonathan Cameron
2013-03-10 10:41   ` Maxime Ripard
2013-03-02 16:16 ` [PATCH 13/67] iio:adc:lp8778_adc " Jonathan Cameron
2013-03-07  0:49   ` Kim, Milo
2013-03-02 16:16 ` [PATCH 14/67] iio:adc:ti-adc081 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 15/67] iio:adc:ti_am335x_adc " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 16/67] iio:adc:viperboard_adc " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 17/67] iio:amplifiers:ad8366 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 18/67] iio:dac:ad5064 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 19/67] iio:dac:ad5360 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 20/67] iio:dac:ad5380 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 21/67] iio:dac:ad5421 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 22/67] iio:dac:ad5446 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 23/67] iio:dac:ad5449 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 24/67] iio:dac:ad5504 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 25/67] iio:dac:ad5624r " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 26/67] iio:dac:ad5686 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 27/67] iio:dac:ad5755 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 28/67] iio:dac:ad5764 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 29/67] iio:dac:ad5791 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 30/67] iio:dac:max517 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 31/67] iio:dac:mcp4725 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 32/67] iio:freq:ad9523 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 33/67] iio:gyro:adis16080 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 34/67] iio:gyro:adis16136 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 35/67] iio:gyro:adxrs450 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 36/67] iio:gyro:itg3200_core " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 37/67] iio:imu:adis16400 " Jonathan Cameron
2013-03-04 18:48   ` Lars-Peter Clausen
2013-03-04 21:02     ` Jonathan Cameron
2013-03-02 16:16 ` [PATCH 38/67] iio:imu:adis16480 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 39/67] iio:imu:mpu6050 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 40/67] iio:light:adjd_s311 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 41/67] iio:light:lm3533 " Jonathan Cameron
2013-03-02 16:16 ` [PATCH 42/67] iio:light:tsl2563 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 43/67] iio:light:vcnl4000 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 44/67] staging:iio:accel:adis " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 45/67] staging:iio:accel:adis16220 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 46/67] staging:iio:accel:lis3l02dq " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 47/67] staging:iio:accel:sca3000 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 48/67] staging:iio:adc:ad7280a " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 49/67] staging:iio:adc:ad7291 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 50/67] staging:iio:adc:ad7606 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 51/67] staging:iio:adc:ad799x " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 52/67] staging:iio:cdc:ad7150 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 53/67] staging:iio:cdc:ad7152 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 54/67] staging:iio:cdc:ad7746 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 55/67] staging:iio:gyro:adis16060 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 56/67] staging:iio:gyro:adis16130 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 57/67] staging:iio:impedance:ad5933 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 58/67] staging:iio:light:isl29018 " Jonathan Cameron
2013-03-04 16:47   ` Rhyland Klein
2013-03-02 16:17 ` [PATCH 59/67] staging:iio:light:isl29028 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 60/67] staging:iio:light:tsl2x7x " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 61/67] staging:iio:mag:ak8975 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 62/67] staging:iio:magnetometer:hmc5843 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 63/67] staging:iio:meter:ade7758 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 64/67] staging:iio:resolver:ad2s1200 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 65/67] staging:iio:resolver:ad2s1210 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 66/67] staging:iio:resolver:ad2s90 " Jonathan Cameron
2013-03-02 16:17 ` [PATCH 67/67] iio:core drop info_mask from struct iio_info Jonathan Cameron
2013-03-04  9:09 ` [PATCH 00/67 V2] IIO break info_mask into a pair of masks Lars-Peter Clausen
2013-03-04  9:15   ` Jonathan Cameron
2013-03-04 18:09     ` Jonathan Cameron
2013-03-04 19:13       ` Lars-Peter Clausen
2013-03-17 19:51 ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2013-02-27 20:38 [PATCH 00/67] " Jonathan Cameron
2013-02-27 20:38 ` [PATCH 01/67] iio: Add broken out info_mask fields for shared_by_type and separate Jonathan Cameron

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=1362241044-3534-2-git-send-email-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.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.