LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Brian Masney <masneyb@onstation.org>
To: jic23@kernel.org, linux-iio@vger.kernel.org
Cc: devel@driverdev.osuosl.org, lars@metafoo.de,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	pmeerw@pmeerw.net, knaack.h@gmx.de, drew.paterson@ams.com
Subject: [PATCH v3 4/9] staging: iio: tsl2x7x: use macro to populate tsl2X7X_device_info
Date: Thu, 10 May 2018 20:12:18 -0400	[thread overview]
Message-ID: <20180511001223.12378-5-masneyb@onstation.org> (raw)
In-Reply-To: <20180511001223.12378-1-masneyb@onstation.org>

This patch creates a macro that populates the tsl2X7X_device_info
structure to reduce duplicated code in the driver.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 61 ++++++++++---------------------------
 1 file changed, 16 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index f5ca5ada0358..51c1a90cb592 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1305,52 +1305,23 @@ static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
 	},
 };
 
+#define TSL2X7X_DEVICE_INFO(type)[type] = \
+	{ \
+		.attrs = &tsl2X7X_device_attr_group_tbl[type], \
+		.read_raw = &tsl2x7x_read_raw, \
+		.write_raw = &tsl2x7x_write_raw, \
+		.read_event_value = &tsl2x7x_read_event_value, \
+		.write_event_value = &tsl2x7x_write_event_value, \
+		.read_event_config = &tsl2x7x_read_interrupt_config, \
+		.write_event_config = &tsl2x7x_write_interrupt_config, \
+	}
+
 static const struct iio_info tsl2X7X_device_info[] = {
-	[ALS] = {
-		.attrs = &tsl2X7X_device_attr_group_tbl[ALS],
-		.read_raw = &tsl2x7x_read_raw,
-		.write_raw = &tsl2x7x_write_raw,
-		.read_event_value = &tsl2x7x_read_event_value,
-		.write_event_value = &tsl2x7x_write_event_value,
-		.read_event_config = &tsl2x7x_read_interrupt_config,
-		.write_event_config = &tsl2x7x_write_interrupt_config,
-	},
-	[PRX] = {
-		.attrs = &tsl2X7X_device_attr_group_tbl[PRX],
-		.read_raw = &tsl2x7x_read_raw,
-		.write_raw = &tsl2x7x_write_raw,
-		.read_event_value = &tsl2x7x_read_event_value,
-		.write_event_value = &tsl2x7x_write_event_value,
-		.read_event_config = &tsl2x7x_read_interrupt_config,
-		.write_event_config = &tsl2x7x_write_interrupt_config,
-	},
-	[ALSPRX] = {
-		.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
-		.read_raw = &tsl2x7x_read_raw,
-		.write_raw = &tsl2x7x_write_raw,
-		.read_event_value = &tsl2x7x_read_event_value,
-		.write_event_value = &tsl2x7x_write_event_value,
-		.read_event_config = &tsl2x7x_read_interrupt_config,
-		.write_event_config = &tsl2x7x_write_interrupt_config,
-	},
-	[PRX2] = {
-		.attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
-		.read_raw = &tsl2x7x_read_raw,
-		.write_raw = &tsl2x7x_write_raw,
-		.read_event_value = &tsl2x7x_read_event_value,
-		.write_event_value = &tsl2x7x_write_event_value,
-		.read_event_config = &tsl2x7x_read_interrupt_config,
-		.write_event_config = &tsl2x7x_write_interrupt_config,
-	},
-	[ALSPRX2] = {
-		.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
-		.read_raw = &tsl2x7x_read_raw,
-		.write_raw = &tsl2x7x_write_raw,
-		.read_event_value = &tsl2x7x_read_event_value,
-		.write_event_value = &tsl2x7x_write_event_value,
-		.read_event_config = &tsl2x7x_read_interrupt_config,
-		.write_event_config = &tsl2x7x_write_interrupt_config,
-	},
+	TSL2X7X_DEVICE_INFO(ALS),
+	TSL2X7X_DEVICE_INFO(PRX),
+	TSL2X7X_DEVICE_INFO(ALSPRX),
+	TSL2X7X_DEVICE_INFO(PRX2),
+	TSL2X7X_DEVICE_INFO(ALSPRX2),
 };
 
 static const struct iio_event_spec tsl2x7x_events[] = {
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2018-05-11  0:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11  0:12 [PATCH v3 0/9] staging: iio: tsl2x7x: move out of staging Brian Masney
2018-05-11  0:12 ` [PATCH v3 1/9] staging: iio: tsl2x7x: remove unnecessary whitespace Brian Masney
2018-05-12 11:15   ` Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 2/9] staging: iio: tsl2x7x: use direct returns Brian Masney
2018-05-12 11:16   ` Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 3/9] staging: iio: tsl2x7x: turn chip off if IIO device registration fails Brian Masney
2018-05-12 11:16   ` Jonathan Cameron
2018-05-11  0:12 ` Brian Masney [this message]
2018-05-12 11:20   ` [PATCH v3 4/9] staging: iio: tsl2x7x: use macro to populate tsl2X7X_device_info Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 5/9] staging: iio: tsl2x7x: convert to use read_avail Brian Masney
2018-05-12 11:20   ` Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 6/9] staging: iio: tsl2x7x: correct IIO_EV_INFO_PERIOD values Brian Masney
2018-05-12 11:21   ` Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 7/9] staging: iio: tsl2x7x: add range checking to tsl2x7x_write_raw Brian Masney
2018-05-12 11:23   ` Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 8/9] staging: iio: tsl2x7x: rename driver to tsl2772 Brian Masney
2018-05-12 11:25   ` Jonathan Cameron
2018-05-11  0:12 ` [PATCH v3 9/9] staging: iio: tsl2x7x/tsl2772: move out of staging Brian Masney
2018-05-11  0:32   ` Brian Masney
2018-05-12 11:44     ` Jonathan Cameron
2018-05-12 12:36       ` Brian Masney
2018-05-12 17:44         ` 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=20180511001223.12378-5-masneyb@onstation.org \
    --to=masneyb@onstation.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=drew.paterson@ams.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --subject='Re: [PATCH v3 4/9] staging: iio: tsl2x7x: use macro to populate tsl2X7X_device_info' \
    /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

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