Commit 9a3af585 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

Staging: iio: adis16220 extract bin_attribute structures from state

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 06f1962a
...@@ -141,9 +141,6 @@ struct adis16220_state { ...@@ -141,9 +141,6 @@ struct adis16220_state {
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
u8 *tx; u8 *tx;
u8 *rx; u8 *rx;
struct bin_attribute accel_bin;
struct bin_attribute adc1_bin;
struct bin_attribute adc2_bin;
struct mutex buf_lock; struct mutex buf_lock;
}; };
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#define DRIVER_NAME "adis16220" #define DRIVER_NAME "adis16220"
static int adis16220_check_status(struct device *dev);
/** /**
* adis16220_spi_write_reg_8() - write single byte to a register * adis16220_spi_write_reg_8() - write single byte to a register
* @dev: device associated with child of actual device (iio_dev or iio_trig) * @dev: device associated with child of actual device (iio_dev or iio_trig)
...@@ -133,8 +131,6 @@ static int adis16220_spi_read_reg_16(struct device *dev, ...@@ -133,8 +131,6 @@ static int adis16220_spi_read_reg_16(struct device *dev,
mutex_lock(&st->buf_lock); mutex_lock(&st->buf_lock);
st->tx[0] = ADIS16220_READ_REG(lower_reg_address); st->tx[0] = ADIS16220_READ_REG(lower_reg_address);
st->tx[1] = 0; st->tx[1] = 0;
st->tx[2] = 0;
st->tx[3] = 0;
spi_message_init(&msg); spi_message_init(&msg);
spi_message_add_tail(&xfers[0], &msg); spi_message_add_tail(&xfers[0], &msg);
...@@ -275,23 +271,6 @@ static ssize_t adis16220_write_capture(struct device *dev, ...@@ -275,23 +271,6 @@ static ssize_t adis16220_write_capture(struct device *dev,
return -1; return -1;
} }
static int adis16220_self_test(struct device *dev)
{
int ret;
ret = adis16220_spi_write_reg_16(dev,
ADIS16220_MSC_CTRL,
ADIS16220_MSC_CTRL_SELF_TEST_EN);
if (ret) {
dev_err(dev, "problem starting self test");
goto err_ret;
}
adis16220_check_status(dev);
err_ret:
return ret;
}
static int adis16220_check_status(struct device *dev) static int adis16220_check_status(struct device *dev)
{ {
u16 status; u16 status;
...@@ -320,6 +299,23 @@ static int adis16220_check_status(struct device *dev) ...@@ -320,6 +299,23 @@ static int adis16220_check_status(struct device *dev)
return ret; return ret;
} }
static int adis16220_self_test(struct device *dev)
{
int ret;
ret = adis16220_spi_write_reg_16(dev,
ADIS16220_MSC_CTRL,
ADIS16220_MSC_CTRL_SELF_TEST_EN);
if (ret) {
dev_err(dev, "problem starting self test");
goto err_ret;
}
adis16220_check_status(dev);
err_ret:
return ret;
}
static int adis16220_initial_setup(struct adis16220_state *st) static int adis16220_initial_setup(struct adis16220_state *st)
{ {
int ret; int ret;
...@@ -433,6 +429,15 @@ static ssize_t adis16220_accel_bin_read(struct kobject *kobj, ...@@ -433,6 +429,15 @@ static ssize_t adis16220_accel_bin_read(struct kobject *kobj,
ADIS16220_CAPT_BUFA); ADIS16220_CAPT_BUFA);
} }
static struct bin_attribute accel_bin = {
.attr = {
.name = "accel_bin",
.mode = S_IRUGO,
},
.read = adis16220_accel_bin_read,
.size = ADIS16220_CAPTURE_SIZE,
};
static ssize_t adis16220_adc1_bin_read(struct kobject *kobj, static ssize_t adis16220_adc1_bin_read(struct kobject *kobj,
struct bin_attribute *attr, struct bin_attribute *attr,
char *buf, loff_t off, char *buf, loff_t off,
...@@ -447,6 +452,15 @@ static ssize_t adis16220_adc1_bin_read(struct kobject *kobj, ...@@ -447,6 +452,15 @@ static ssize_t adis16220_adc1_bin_read(struct kobject *kobj,
ADIS16220_CAPT_BUF1); ADIS16220_CAPT_BUF1);
} }
static struct bin_attribute adc1_bin = {
.attr = {
.name = "in0_bin",
.mode = S_IRUGO,
},
.read = adis16220_adc1_bin_read,
.size = ADIS16220_CAPTURE_SIZE,
};
static ssize_t adis16220_adc2_bin_read(struct kobject *kobj, static ssize_t adis16220_adc2_bin_read(struct kobject *kobj,
struct bin_attribute *attr, struct bin_attribute *attr,
char *buf, loff_t off, char *buf, loff_t off,
...@@ -461,6 +475,16 @@ static ssize_t adis16220_adc2_bin_read(struct kobject *kobj, ...@@ -461,6 +475,16 @@ static ssize_t adis16220_adc2_bin_read(struct kobject *kobj,
ADIS16220_CAPT_BUF2); ADIS16220_CAPT_BUF2);
} }
static struct bin_attribute adc2_bin = {
.attr = {
.name = "in1_bin",
.mode = S_IRUGO,
},
.read = adis16220_adc2_bin_read,
.size = ADIS16220_CAPTURE_SIZE,
};
static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16220_read_12bit_unsigned, static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16220_read_12bit_unsigned,
ADIS16220_CAPT_SUPPLY); ADIS16220_CAPT_SUPPLY);
static IIO_CONST_ATTR(in_supply_scale, "0.0012207"); static IIO_CONST_ATTR(in_supply_scale, "0.0012207");
...@@ -563,33 +587,15 @@ static int __devinit adis16220_probe(struct spi_device *spi) ...@@ -563,33 +587,15 @@ static int __devinit adis16220_probe(struct spi_device *spi)
goto error_free_dev; goto error_free_dev;
regdone = 1; regdone = 1;
st->accel_bin.attr.name = "accel_bin"; ret = sysfs_create_bin_file(&st->indio_dev->dev.kobj, &accel_bin);
st->accel_bin.attr.mode = S_IRUGO;
st->accel_bin.attr.owner = THIS_MODULE;
st->accel_bin.read = adis16220_accel_bin_read;
st->accel_bin.size = ADIS16220_CAPTURE_SIZE;
ret = sysfs_create_bin_file(&st->indio_dev->dev.kobj, &st->accel_bin);
if (ret) if (ret)
goto error_free_dev; goto error_free_dev;
st->adc1_bin.attr.name = "adc1_bin"; ret = sysfs_create_bin_file(&st->indio_dev->dev.kobj, &adc1_bin);
st->adc1_bin.attr.mode = S_IRUGO;
st->adc1_bin.attr.owner = THIS_MODULE;
st->adc1_bin.read = adis16220_adc1_bin_read;
st->adc1_bin.size = ADIS16220_CAPTURE_SIZE;
ret = sysfs_create_bin_file(&st->indio_dev->dev.kobj, &st->adc1_bin);
if (ret) if (ret)
goto error_rm_accel_bin; goto error_rm_accel_bin;
st->adc2_bin.attr.name = "adc2_bin"; ret = sysfs_create_bin_file(&st->indio_dev->dev.kobj, &adc2_bin);
st->adc2_bin.attr.mode = S_IRUGO;
st->adc2_bin.attr.owner = THIS_MODULE;
st->adc2_bin.read = adis16220_adc2_bin_read;
st->adc2_bin.size = ADIS16220_CAPTURE_SIZE;
ret = sysfs_create_bin_file(&st->indio_dev->dev.kobj, &st->adc2_bin);
if (ret) if (ret)
goto error_rm_adc1_bin; goto error_rm_adc1_bin;
...@@ -600,11 +606,11 @@ static int __devinit adis16220_probe(struct spi_device *spi) ...@@ -600,11 +606,11 @@ static int __devinit adis16220_probe(struct spi_device *spi)
return 0; return 0;
error_rm_adc2_bin: error_rm_adc2_bin:
sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &st->adc2_bin); sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &adc2_bin);
error_rm_adc1_bin: error_rm_adc1_bin:
sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &st->adc1_bin); sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &adc1_bin);
error_rm_accel_bin: error_rm_accel_bin:
sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &st->accel_bin); sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &accel_bin);
error_free_dev: error_free_dev:
if (regdone) if (regdone)
iio_device_unregister(st->indio_dev); iio_device_unregister(st->indio_dev);
...@@ -627,9 +633,9 @@ static int adis16220_remove(struct spi_device *spi) ...@@ -627,9 +633,9 @@ static int adis16220_remove(struct spi_device *spi)
flush_scheduled_work(); flush_scheduled_work();
sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &st->adc2_bin); sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &adc2_bin);
sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &st->adc1_bin); sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &adc1_bin);
sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &st->accel_bin); sysfs_remove_bin_file(&st->indio_dev->dev.kobj, &accel_bin);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
kfree(st->tx); kfree(st->tx);
kfree(st->rx); kfree(st->rx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment