From: Brian Masney <masneyb@onstation.org>
To: jic23@kernel.org, linux-iio@vger.kernel.org
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
lars@metafoo.de, pmeerw@pmeerw.net, knaack.h@gmx.de,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
robh+dt@kernel.org, Mark.Rutland@arm.com
Subject: [PATCH 08/10] staging: iio: tsl2583: use IIO_*_ATTR* macros to create sysfs entries
Date: Fri, 28 Oct 2016 06:00:19 -0400 [thread overview]
Message-ID: <1477648821-3786-9-git-send-email-masneyb@onstation.org> (raw)
In-Reply-To: <1477648821-3786-1-git-send-email-masneyb@onstation.org>
Use the IIO_CONST_ATTR, IIO_DEVICE_ATTR_RW, and IIO_DEVICE_ATTR_WO
macros for creating the in_illuminance_calibscale_available,
in_illuminance_integration_time_available, in_illuminance_input_target,
in_illuminance_calibrate, and in_illuminance_lux_table sysfs entries.
Previously these sysfs entries were prefixed with illuminance0_, however
they are now prefixed with in_illuminance_ to make these sysfs entries
consistent with how the IIO core is creating the other sysfs entries.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 73 ++++++++++++++-----------------------
1 file changed, 27 insertions(+), 46 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index bfff6ca..1462374 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -29,6 +29,7 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define TSL258X_MAX_DEVICE_REGS 32
@@ -506,24 +507,9 @@ static int taos_chip_off(struct iio_dev *indio_dev)
/* Sysfs Interface Functions */
-static ssize_t taos_gain_available_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%s\n", "1 8 16 111");
-}
-
-static ssize_t taos_als_time_available_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%s\n",
- "0.000050 0.000100 0.000150 0.000200 0.000250 0.000300 0.000350 0.000400 0.000450 0.000500 0.000550 0.000600 0.000650");
-}
-
-static ssize_t taos_als_cal_target_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t in_illuminance_input_target_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
@@ -531,9 +517,9 @@ static ssize_t taos_als_cal_target_show(struct device *dev,
return sprintf(buf, "%d\n", chip->taos_settings.als_cal_target);
}
-static ssize_t taos_als_cal_target_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t in_illuminance_input_target_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
@@ -548,9 +534,9 @@ static ssize_t taos_als_cal_target_store(struct device *dev,
return len;
}
-static ssize_t taos_do_calibrate(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t in_illuminance_calibrate_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
int value;
@@ -564,8 +550,9 @@ static ssize_t taos_do_calibrate(struct device *dev,
return len;
}
-static ssize_t taos_luxtable_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t in_illuminance_lux_table_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
int i;
int offset = 0;
@@ -589,9 +576,9 @@ static ssize_t taos_luxtable_show(struct device *dev,
return offset;
}
-static ssize_t taos_luxtable_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t in_illuminance_lux_table_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
@@ -635,25 +622,19 @@ static ssize_t taos_luxtable_store(struct device *dev,
return ret;
}
-static DEVICE_ATTR(illuminance0_calibscale_available, S_IRUGO,
- taos_gain_available_show, NULL);
-
-static DEVICE_ATTR(illuminance0_integration_time_available, S_IRUGO,
- taos_als_time_available_show, NULL);
-
-static DEVICE_ATTR(illuminance0_input_target, S_IRUGO | S_IWUSR,
- taos_als_cal_target_show, taos_als_cal_target_store);
-
-static DEVICE_ATTR(illuminance0_calibrate, S_IWUSR, NULL, taos_do_calibrate);
-static DEVICE_ATTR(illuminance0_lux_table, S_IRUGO | S_IWUSR,
- taos_luxtable_show, taos_luxtable_store);
+static IIO_CONST_ATTR(in_illuminance_calibscale_available, "1 8 16 111");
+static IIO_CONST_ATTR(in_illuminance_integration_time_available,
+ "0.000050 0.000100 0.000150 0.000200 0.000250 0.000300 0.000350 0.000400 0.000450 0.000500 0.000550 0.000600 0.000650");
+static IIO_DEVICE_ATTR_RW(in_illuminance_input_target, 0);
+static IIO_DEVICE_ATTR_WO(in_illuminance_calibrate, 0);
+static IIO_DEVICE_ATTR_RW(in_illuminance_lux_table, 0);
static struct attribute *sysfs_attrs_ctrl[] = {
- &dev_attr_illuminance0_calibscale_available.attr,
- &dev_attr_illuminance0_integration_time_available.attr,
- &dev_attr_illuminance0_input_target.attr,
- &dev_attr_illuminance0_calibrate.attr,
- &dev_attr_illuminance0_lux_table.attr,
+ &iio_const_attr_in_illuminance_calibscale_available.dev_attr.attr,
+ &iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr,
+ &iio_dev_attr_in_illuminance_input_target.dev_attr.attr,
+ &iio_dev_attr_in_illuminance_calibrate.dev_attr.attr,
+ &iio_dev_attr_in_illuminance_lux_table.dev_attr.attr,
NULL
};
--
2.7.4
next prev parent reply other threads:[~2016-10-28 10:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-28 10:00 [PATCH 00/10] staging: iio: tsl2583: staging cleanups Brian Masney
2016-10-28 10:00 ` [PATCH 01/10] staging: iio: tsl2583: add of_match table for device tree support Brian Masney
2016-10-30 17:43 ` Jonathan Cameron
2016-10-30 17:44 ` Jonathan Cameron
2016-10-31 6:06 ` Rob Herring
2016-10-28 10:00 ` [PATCH 02/10] staging: iio: tsl2583: check for error code from i2c_smbus_read_byte() Brian Masney
2016-10-30 17:49 ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 03/10] staging: iio: tsl2583: return proper error code instead of -1 Brian Masney
2016-10-30 17:50 ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 04/10] staging: iio: tsl2583: remove redundant power_state sysfs attribute Brian Masney
2016-10-30 17:51 ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on,off} Brian Masney
2016-10-30 17:54 ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 06/10] staging: iio: tsl2583: convert to use iio_chan_spec and {read,write}_raw Brian Masney
2016-10-30 18:04 ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 07/10] staging: iio: tsl2583: convert illuminance0_calibscale sysfs attr to use iio_chan_spec Brian Masney
2016-10-30 18:37 ` Jonathan Cameron
2016-10-30 20:04 ` Brian Masney
2016-10-30 20:29 ` Jonathan Cameron
2016-10-28 10:00 ` Brian Masney [this message]
2016-10-30 18:38 ` [PATCH 08/10] staging: iio: tsl2583: use IIO_*_ATTR* macros to create sysfs entries Jonathan Cameron
2016-10-28 10:00 ` [PATCH 09/10] staging: iio: tsl2583: add error code to sysfs store functions Brian Masney
2016-10-30 18:39 ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 10/10] staging: iio: tsl2583: add locking to sysfs attributes Brian Masney
2016-10-30 18:43 ` 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=1477648821-3786-9-git-send-email-masneyb@onstation.org \
--to=masneyb@onstation.org \
--cc=Mark.Rutland@arm.com \
--cc=devel@driverdev.osuosl.org \
--cc=devicetree@vger.kernel.org \
--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 \
--cc=robh+dt@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 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®