From d635711daa98be86d4c7fd01499c34f566b54ccb Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 10 Jun 2016 05:30:17 -0300 Subject: Linux-libre 4.6.2-gnu --- drivers/staging/iio/resolver/ad2s1210.c | 39 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'drivers/staging/iio/resolver/ad2s1210.c') diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index d97aa2827..6b992634f 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -67,7 +67,7 @@ /* default input clock on serial interface */ #define AD2S1210_DEF_CLKIN 8192000 /* clock period in nano second */ -#define AD2S1210_DEF_TCK (1000000000/AD2S1210_DEF_CLKIN) +#define AD2S1210_DEF_TCK (1000000000 / AD2S1210_DEF_CLKIN) #define AD2S1210_DEF_EXCIT 10000 enum ad2s1210_mode { @@ -98,6 +98,7 @@ static const int ad2s1210_mode_vals[4][2] = { [MOD_VEL] = { 0, 1 }, [MOD_CONFIG] = { 1, 0 }, }; + static inline void ad2s1210_set_mode(enum ad2s1210_mode mode, struct ad2s1210_state *st) { @@ -123,7 +124,7 @@ static int ad2s1210_config_write(struct ad2s1210_state *st, u8 data) /* read value from one of the registers */ static int ad2s1210_config_read(struct ad2s1210_state *st, - unsigned char address) + unsigned char address) { struct spi_transfer xfer = { .len = 2, @@ -176,9 +177,9 @@ static const int ad2s1210_res_pins[4][2] = { static inline void ad2s1210_set_resolution_pin(struct ad2s1210_state *st) { gpio_set_value(st->pdata->res[0], - ad2s1210_res_pins[(st->resolution - 10)/2][0]); + ad2s1210_res_pins[(st->resolution - 10) / 2][0]); gpio_set_value(st->pdata->res[1], - ad2s1210_res_pins[(st->resolution - 10)/2][1]); + ad2s1210_res_pins[(st->resolution - 10) / 2][1]); } static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) @@ -282,8 +283,8 @@ static ssize_t ad2s1210_show_control(struct device *dev, } static ssize_t ad2s1210_store_control(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); unsigned char udata; @@ -318,9 +319,9 @@ static ssize_t ad2s1210_store_control(struct device *dev, data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else + } else { ad2s1210_set_resolution_pin(st); - + } ret = len; st->hysteresis = !!(data & AD2S1210_ENABLE_HYSTERESIS); @@ -330,7 +331,8 @@ error_ret: } static ssize_t ad2s1210_show_resolution(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); @@ -338,8 +340,8 @@ static ssize_t ad2s1210_show_resolution(struct device *dev, } static ssize_t ad2s1210_store_resolution(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); unsigned char data; @@ -379,8 +381,9 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else + } else { ad2s1210_set_resolution_pin(st); + } ret = len; error_ret: mutex_unlock(&st->lock); @@ -389,7 +392,7 @@ error_ret: /* read the fault register since last sample */ static ssize_t ad2s1210_show_fault(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); int ret; @@ -441,7 +444,8 @@ static ssize_t ad2s1210_show_reg(struct device *dev, } static ssize_t ad2s1210_store_reg(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); unsigned char data; @@ -497,7 +501,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_ANGL: - pos = be16_to_cpup((__be16 *) st->rx); + pos = be16_to_cpup((__be16 *)st->rx); if (st->hysteresis) pos >>= 16 - st->resolution; *val = pos; @@ -505,7 +509,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, break; case IIO_ANGL_VEL: negative = st->rx[0] & 0x80; - vel = be16_to_cpup((__be16 *) st->rx); + vel = be16_to_cpup((__be16 *)st->rx); vel >>= 16 - st->resolution; if (vel & 0x8000) { negative = (0xffff >> st->resolution) << st->resolution; @@ -560,7 +564,6 @@ static IIO_DEVICE_ATTR(lot_low_thrd, S_IRUGO | S_IWUSR, ad2s1210_show_reg, ad2s1210_store_reg, AD2S1210_REG_LOT_LOW_THRD); - static const struct iio_chan_spec ad2s1210_channels[] = { { .type = IIO_ANGL, @@ -672,7 +675,7 @@ static int ad2s1210_probe(struct spi_device *spi) struct ad2s1210_state *st; int ret; - if (spi->dev.platform_data == NULL) + if (!spi->dev.platform_data) return -EINVAL; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); -- cgit v1.2.3-54-g00ecf