diff options
Diffstat (limited to 'drivers/staging/iio')
45 files changed, 512 insertions, 508 deletions
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index ebcab56c81b9..7a1939a66c93 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -406,8 +406,10 @@ static int lis3l02dq_initial_setup(struct iio_dev *indio_dev) goto err_ret; } - /* Read back to check this has worked acts as loose test of correct - * chip */ + /* + * Read back to check this has worked acts as loose test of correct + * chip + */ ret = lis3l02dq_spi_read_reg_8(indio_dev, LIS3L02DQ_REG_CTRL_1_ADDR, &valtest); @@ -565,7 +567,7 @@ static int lis3l02dq_read_event_config(struct iio_dev *indio_dev, { u8 val; int ret; - u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING))); + u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING))); ret = lis3l02dq_spi_read_reg_8(indio_dev, LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, @@ -620,7 +622,7 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev, u8 val, control; u8 currentlyset; bool changed = false; - u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING))); + u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING))); mutex_lock(&indio_dev->mlock); /* read current control */ diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index b892f2cf5f9e..50c162e0c31f 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -69,25 +69,25 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) mutex_lock(&st->buf_lock); - for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) + for (i = 0; i < ARRAY_SIZE(read_all_tx_array) / 4; i++) if (test_bit(i, indio_dev->active_scan_mask)) { /* lower byte */ - xfers[j].tx_buf = st->tx + 2*j; - st->tx[2*j] = read_all_tx_array[i*4]; - st->tx[2*j + 1] = 0; + xfers[j].tx_buf = st->tx + (2 * j); + st->tx[2 * j] = read_all_tx_array[i * 4]; + st->tx[2 * j + 1] = 0; if (rx_array) - xfers[j].rx_buf = rx_array + j*2; + xfers[j].rx_buf = rx_array + (j * 2); xfers[j].bits_per_word = 8; xfers[j].len = 2; xfers[j].cs_change = 1; j++; /* upper byte */ - xfers[j].tx_buf = st->tx + 2*j; - st->tx[2*j] = read_all_tx_array[i*4 + 2]; - st->tx[2*j + 1] = 0; + xfers[j].tx_buf = st->tx + (2 * j); + st->tx[2 * j] = read_all_tx_array[i * 4 + 2]; + st->tx[2 * j + 1] = 0; if (rx_array) - xfers[j].rx_buf = rx_array + j*2; + xfers[j].rx_buf = rx_array + (j * 2); xfers[j].bits_per_word = 8; xfers[j].len = 2; xfers[j].cs_change = 1; @@ -127,11 +127,11 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev, return ret; } for (i = 0; i < scan_count; i++) - data[i] = combine_8_to_16(rx_array[i*4+1], - rx_array[i*4+3]); + data[i] = combine_8_to_16(rx_array[i * 4 + 1], + rx_array[i * 4 + 3]); kfree(rx_array); - return i*sizeof(data[0]); + return i * sizeof(data[0]); } static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) @@ -195,7 +195,8 @@ __lis3l02dq_write_data_ready_config(struct iio_dev *indio_dev, bool state) /* Enable requested */ } else if (state && !currentlyset) { /* If not set, enable requested - * first disable all events */ + * first disable all events + */ ret = lis3l02dq_disable_all_events(indio_dev); if (ret < 0) goto error_ret; @@ -255,7 +256,8 @@ static int lis3l02dq_trig_try_reen(struct iio_trigger *trig) int i; /* If gpio still high (or high again) - * In theory possible we will need to do this several times */ + * In theory possible we will need to do this several times + */ for (i = 0; i < 5; i++) if (gpio_get_value(st->gpio)) lis3l02dq_read_all(indio_dev, NULL); diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index b614f272b5f4..03cb22508a5d 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -88,7 +88,7 @@ int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val) } int sca3000_read_data_short(struct sca3000_state *st, - uint8_t reg_address_high, + u8 reg_address_high, int len) { struct spi_transfer xfer[2] = { @@ -165,10 +165,9 @@ static int __sca3000_unlock_reg_lock(struct sca3000_state *st) * Lock must be held. **/ static int sca3000_write_ctrl_reg(struct sca3000_state *st, - uint8_t sel, + u8 sel, uint8_t val) { - int ret; ret = sca3000_reg_lock_on(st); @@ -374,7 +373,6 @@ error_ret: return ret; } - /* * Not even vaguely standard attributes so defined here rather than * in the relevant IIO core headers @@ -471,12 +469,13 @@ static int sca3000_read_raw(struct iio_dev *indio_dev, return ret; } *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF; - *val = ((*val) << (sizeof(*val)*8 - 13)) >> - (sizeof(*val)*8 - 13); + *val = ((*val) << (sizeof(*val) * 8 - 13)) >> + (sizeof(*val) * 8 - 13); } else { /* get the temperature when available */ ret = sca3000_read_data_short(st, - SCA3000_REG_ADDR_TEMP_MSB, 2); + SCA3000_REG_ADDR_TEMP_MSB, + 2); if (ret < 0) { mutex_unlock(&st->lock); return ret; @@ -511,8 +510,8 @@ static int sca3000_read_raw(struct iio_dev *indio_dev, * at all. **/ static ssize_t sca3000_read_av_freq(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); @@ -529,26 +528,27 @@ static ssize_t sca3000_read_av_freq(struct device *dev, case SCA3000_MEAS_MODE_NORMAL: len += sprintf(buf + len, "%d %d %d\n", st->info->measurement_mode_freq, - st->info->measurement_mode_freq/2, - st->info->measurement_mode_freq/4); + st->info->measurement_mode_freq / 2, + st->info->measurement_mode_freq / 4); break; case SCA3000_MEAS_MODE_OP_1: len += sprintf(buf + len, "%d %d %d\n", st->info->option_mode_1_freq, - st->info->option_mode_1_freq/2, - st->info->option_mode_1_freq/4); + st->info->option_mode_1_freq / 2, + st->info->option_mode_1_freq / 4); break; case SCA3000_MEAS_MODE_OP_2: len += sprintf(buf + len, "%d %d %d\n", st->info->option_mode_2_freq, - st->info->option_mode_2_freq/2, - st->info->option_mode_2_freq/4); + st->info->option_mode_2_freq / 2, + st->info->option_mode_2_freq / 4); break; } return len; error_ret: return ret; } + /** * __sca3000_get_base_freq() obtain mode specific base frequency * @@ -582,8 +582,8 @@ error_ret: * sca3000_read_frequency() sysfs interface to get the current frequency **/ static ssize_t sca3000_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); @@ -605,10 +605,10 @@ static ssize_t sca3000_read_frequency(struct device *dev, len = sprintf(buf, "%d\n", base_freq); break; case 0x01: - len = sprintf(buf, "%d\n", base_freq/2); + len = sprintf(buf, "%d\n", base_freq / 2); break; case 0x02: - len = sprintf(buf, "%d\n", base_freq/4); + len = sprintf(buf, "%d\n", base_freq / 4); break; } @@ -623,9 +623,9 @@ error_ret: * sca3000_set_frequency() sysfs interface to set the current frequency **/ static ssize_t sca3000_set_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); @@ -650,9 +650,9 @@ static ssize_t sca3000_set_frequency(struct device *dev, /* clear the bits */ ctrlval &= ~0x03; - if (val == base_freq/2) { + if (val == base_freq / 2) { ctrlval |= SCA3000_OUT_CTRL_BUF_DIV_2; - } else if (val == base_freq/4) { + } else if (val == base_freq / 4) { ctrlval |= SCA3000_OUT_CTRL_BUF_DIV_4; } else if (val != base_freq) { ret = -EINVAL; @@ -849,9 +849,9 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev, if (ret) goto error_ret; - if ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET) + if ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET) { ret = 0; - else { + } else { ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL); if (ret < 0) goto error_ret; @@ -863,6 +863,7 @@ error_ret: return ret; } + /** * sca3000_query_free_fall_mode() is free fall mode enabled **/ @@ -979,14 +980,14 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev, if (ret) goto exit_point; /* if off and should be on */ - if ((st->mo_det_use_count) - && ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET)) + if ((st->mo_det_use_count) && + ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET)) ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, (st->rx[0] & ~protect_mask) | SCA3000_MEAS_MODE_MOT_DET); /* if on and should be off */ - else if (!(st->mo_det_use_count) - && ((st->rx[0] & protect_mask) == SCA3000_MEAS_MODE_MOT_DET)) + else if (!(st->mo_det_use_count) && + ((st->rx[0] & protect_mask) == SCA3000_MEAS_MODE_MOT_DET)) ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, (st->rx[0] & ~protect_mask)); exit_point: @@ -997,14 +998,14 @@ exit_point: /* Free fall detector related event attribute */ static IIO_DEVICE_ATTR_NAMED(accel_xayaz_mag_falling_en, - in_accel_x&y&z_mag_falling_en, + in_accel_x & y & z_mag_falling_en, S_IRUGO | S_IWUSR, sca3000_query_free_fall_mode, sca3000_set_free_fall_mode, 0); static IIO_CONST_ATTR_NAMED(accel_xayaz_mag_falling_period, - in_accel_x&y&z_mag_falling_period, + in_accel_x & y & z_mag_falling_period, "0.226"); static struct attribute *sca3000_event_attributes[] = { diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index bd2c69f85949..20b878d35ea2 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -34,9 +34,9 @@ */ static int sca3000_read_data(struct sca3000_state *st, - uint8_t reg_address_high, - u8 **rx_p, - int len) + u8 reg_address_high, + u8 **rx_p, + int len) { int ret; struct spi_transfer xfer[2] = { @@ -106,7 +106,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r, * i.e. number of time points * number of channels. */ if (count > num_available * bytes_per_sample) - num_read = num_available*bytes_per_sample; + num_read = num_available * bytes_per_sample; else num_read = count; @@ -160,9 +160,9 @@ static ssize_t sca3000_query_ring_int(struct device *dev, * sca3000_set_ring_int() set state of ring status interrupt **/ static ssize_t sca3000_set_ring_int(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); @@ -208,7 +208,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); - return sprintf(buf, "0.%06d\n", 4*st->info->scale); + return sprintf(buf, "0.%06d\n", 4 * st->info->scale); } static IIO_DEVICE_ATTR(in_accel_scale, @@ -267,7 +267,7 @@ int sca3000_configure_ring(struct iio_dev *indio_dev) struct iio_buffer *buffer; buffer = sca3000_rb_allocate(indio_dev); - if (buffer == NULL) + if (!buffer) return -ENOMEM; indio_dev->modes |= INDIO_BUFFER_HARDWARE; @@ -307,6 +307,7 @@ error_ret: return ret; } + /** * sca3000_hw_ring_preenable() hw ring buffer preenable function * diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index fe56fb6c7d30..5b87049cd3f9 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -88,7 +88,6 @@ #define AD7192_CLK_INT_CO 3 /* Internal 4.92 MHz Clock available * at the MCLK2 pin */ - /* Configuration Register Bit Designations (AD7192_REG_CONF) */ #define AD7192_CONF_CHOP BIT(23) /* CHOP enable */ @@ -125,7 +124,7 @@ #define AD7192_GPOCON_P1DAT BIT(1) /* P1 state */ #define AD7192_GPOCON_P0DAT BIT(0) /* P0 state */ -#define AD7192_INT_FREQ_MHz 4915200 +#define AD7192_INT_FREQ_MHZ 4915200 /* NOTE: * The AD7190/2/5 features a dual use data out ready DOUT/RDY output. @@ -201,7 +200,7 @@ static int ad7192_calibrate_all(struct ad7192_state *st) } static int ad7192_setup(struct ad7192_state *st, - const struct ad7192_platform_data *pdata) + const struct ad7192_platform_data *pdata) { struct iio_dev *indio_dev = spi_get_drvdata(st->sd.spi); unsigned long long scale_uv; @@ -224,19 +223,19 @@ static int ad7192_setup(struct ad7192_state *st, if (id != st->devid) dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n", - id); + id); switch (pdata->clock_source_sel) { case AD7192_CLK_EXT_MCLK1_2: case AD7192_CLK_EXT_MCLK2: - st->mclk = AD7192_INT_FREQ_MHz; + st->mclk = AD7192_INT_FREQ_MHZ; break; case AD7192_CLK_INT: case AD7192_CLK_INT_CO: - if (pdata->ext_clk_Hz) - st->mclk = pdata->ext_clk_Hz; + if (pdata->ext_clk_hz) + st->mclk = pdata->ext_clk_hz; else - st->mclk = AD7192_INT_FREQ_MHz; + st->mclk = AD7192_INT_FREQ_MHZ; break; default: ret = -EINVAL; @@ -307,8 +306,8 @@ out: } static ssize_t ad7192_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7192_state *st = iio_priv(indio_dev); @@ -318,9 +317,9 @@ static ssize_t ad7192_read_frequency(struct device *dev, } static ssize_t ad7192_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7192_state *st = iio_priv(indio_dev); @@ -359,8 +358,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ad7192_read_frequency, ad7192_write_frequency); -static ssize_t ad7192_show_scale_available(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t +ad7192_show_scale_available(struct device *dev, + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7192_state *st = iio_priv(indio_dev); @@ -383,8 +383,8 @@ static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO, ad7192_show_scale_available, NULL, 0); static ssize_t ad7192_show_ac_excitation(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7192_state *st = iio_priv(indio_dev); @@ -393,8 +393,8 @@ static ssize_t ad7192_show_ac_excitation(struct device *dev, } static ssize_t ad7192_show_bridge_switch(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7192_state *st = iio_priv(indio_dev); @@ -403,9 +403,9 @@ static ssize_t ad7192_show_bridge_switch(struct device *dev, } static ssize_t ad7192_set(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7192_state *st = iio_priv(indio_dev); @@ -423,7 +423,7 @@ static ssize_t ad7192_set(struct device *dev, return -EBUSY; } - switch ((u32) this_attr->address) { + switch ((u32)this_attr->address) { case AD7192_REG_GPOCON: if (val) st->gpocon |= AD7192_GPOCON_BPDSW; @@ -529,10 +529,10 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, } static int ad7192_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long mask) + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) { struct ad7192_state *st = iio_priv(indio_dev); int ret, i; @@ -556,7 +556,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, if (tmp == st->conf) break; ad_sd_write_reg(&st->sd, AD7192_REG_CONF, - 3, st->conf); + 3, st->conf); ad7192_calibrate_all(st); break; } @@ -571,8 +571,8 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, } static int ad7192_write_raw_get_fmt(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - long mask) + struct iio_chan_spec const *chan, + long mask) { return IIO_VAL_INT_PLUS_NANO; } @@ -625,7 +625,7 @@ static int ad7192_probe(struct spi_device *spi) } indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); @@ -639,7 +639,7 @@ static int ad7192_probe(struct spi_device *spi) voltage_uv = regulator_get_voltage(st->reg); } - if (pdata && pdata->vref_mv) + if (pdata->vref_mv) st->int_vref_mv = pdata->vref_mv; else if (voltage_uv) st->int_vref_mv = voltage_uv / 1000; diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h index a0a5b61a41f1..7433a43c2611 100644 --- a/drivers/staging/iio/adc/ad7192.h +++ b/drivers/staging/iio/adc/ad7192.h @@ -34,7 +34,7 @@ struct ad7192_platform_data { u16 vref_mv; u8 clock_source_sel; - u32 ext_clk_Hz; + u32 ext_clk_hz; bool refin2_en; bool rej60_en; bool sinc3_en; diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index d98e229c46bf..45df714cc83a 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -89,7 +89,7 @@ #define AD7280A_ALL_CELLS (0xAD << 16) -#define AD7280A_MAX_SPI_CLK_Hz 700000 /* < 1MHz */ +#define AD7280A_MAX_SPI_CLK_HZ 700000 /* < 1MHz */ #define AD7280A_MAX_CHAIN 8 #define AD7280A_CELLS_PER_DEV 6 #define AD7280A_BITS 12 @@ -224,24 +224,24 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr, } static int ad7280_read(struct ad7280_state *st, unsigned devaddr, - unsigned addr) + unsigned addr) { int ret; unsigned tmp; /* turns off the read operation on all parts */ ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, - AD7280A_CTRL_HB_CONV_INPUT_ALL | - AD7280A_CTRL_HB_CONV_RES_READ_NO | - st->ctrl_hb); + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_NO | + st->ctrl_hb); if (ret) return ret; /* turns on the read operation on the addressed part */ ret = ad7280_write(st, devaddr, AD7280A_CONTROL_HB, 0, - AD7280A_CTRL_HB_CONV_INPUT_ALL | - AD7280A_CTRL_HB_CONV_RES_READ_ALL | - st->ctrl_hb); + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_ALL | + st->ctrl_hb); if (ret) return ret; @@ -272,17 +272,17 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr, return ret; ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, - AD7280A_CTRL_HB_CONV_INPUT_ALL | - AD7280A_CTRL_HB_CONV_RES_READ_NO | - st->ctrl_hb); + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_NO | + st->ctrl_hb); if (ret) return ret; ret = ad7280_write(st, devaddr, AD7280A_CONTROL_HB, 0, - AD7280A_CTRL_HB_CONV_INPUT_ALL | - AD7280A_CTRL_HB_CONV_RES_READ_ALL | - AD7280A_CTRL_HB_CONV_START_CS | - st->ctrl_hb); + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_ALL | + AD7280A_CTRL_HB_CONV_START_CS | + st->ctrl_hb); if (ret) return ret; @@ -300,7 +300,7 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr, } static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt, - unsigned *array) + unsigned *array) { int i, ret; unsigned tmp, sum = 0; @@ -311,10 +311,10 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt, return ret; ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, - AD7280A_CTRL_HB_CONV_INPUT_ALL | - AD7280A_CTRL_HB_CONV_RES_READ_ALL | - AD7280A_CTRL_HB_CONV_START_CS | - st->ctrl_hb); + AD7280A_CTRL_HB_CONV_INPUT_ALL | + AD7280A_CTRL_HB_CONV_RES_READ_ALL | + AD7280A_CTRL_HB_CONV_START_CS | + st->ctrl_hb); if (ret) return ret; @@ -342,24 +342,24 @@ static int ad7280_chain_setup(struct ad7280_state *st) int ret; ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_LB, 1, - AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN | - AD7280A_CTRL_LB_LOCK_DEV_ADDR | - AD7280A_CTRL_LB_MUST_SET | - AD7280A_CTRL_LB_SWRST | - st->ctrl_lb); + AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN | + AD7280A_CTRL_LB_LOCK_DEV_ADDR | + AD7280A_CTRL_LB_MUST_SET | + AD7280A_CTRL_LB_SWRST | + st->ctrl_lb); if (ret) return ret; ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_LB, 1, - AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN | - AD7280A_CTRL_LB_LOCK_DEV_ADDR | - AD7280A_CTRL_LB_MUST_SET | - st->ctrl_lb); + AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN | + AD7280A_CTRL_LB_LOCK_DEV_ADDR | + AD7280A_CTRL_LB_MUST_SET | + st->ctrl_lb); if (ret) return ret; ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_READ, 1, - AD7280A_CONTROL_LB << 2); + AD7280A_CONTROL_LB << 2); if (ret) return ret; @@ -379,8 +379,8 @@ static int ad7280_chain_setup(struct ad7280_state *st) } static ssize_t ad7280_show_balance_sw(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7280_state *st = iio_priv(indio_dev); @@ -392,9 +392,9 @@ static ssize_t ad7280_show_balance_sw(struct device *dev, } static ssize_t ad7280_store_balance_sw(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7280_state *st = iio_priv(indio_dev); @@ -424,8 +424,8 @@ static ssize_t ad7280_store_balance_sw(struct device *dev, } static ssize_t ad7280_show_balance_timer(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7280_state *st = iio_priv(indio_dev); @@ -435,7 +435,7 @@ static ssize_t ad7280_show_balance_timer(struct device *dev, mutex_lock(&indio_dev->mlock); ret = ad7280_read(st, this_attr->address >> 8, - this_attr->address & 0xFF); + this_attr->address & 0xFF); mutex_unlock(&indio_dev->mlock); if (ret < 0) @@ -447,9 +447,9 @@ static ssize_t ad7280_show_balance_timer(struct device *dev, } static ssize_t ad7280_store_balance_timer(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7280_state *st = iio_priv(indio_dev); @@ -488,12 +488,12 @@ static int ad7280_channel_init(struct ad7280_state *st) st->channels = kcalloc((st->slave_num + 1) * 12 + 2, sizeof(*st->channels), GFP_KERNEL); - if (st->channels == NULL) + if (!st->channels) return -ENOMEM; for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) - for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; ch++, - cnt++) { + for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; + ch++, cnt++) { if (ch < AD7280A_AUX_ADC_1) { st->channels[cnt].type = IIO_VOLTAGE; st->channels[cnt].differential = 1; @@ -550,7 +550,7 @@ static int ad7280_attr_init(struct ad7280_state *st) st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) * (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, GFP_KERNEL); - if (st->iio_attr == NULL) + if (!st->iio_attr) return -ENOMEM; for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) @@ -566,9 +566,9 @@ static int ad7280_attr_init(struct ad7280_state *st) ad7280_store_balance_sw; st->iio_attr[cnt].dev_attr.attr.name = kasprintf(GFP_KERNEL, - "in%d-in%d_balance_switch_en", - (dev * AD7280A_CELLS_PER_DEV) + ch, - (dev * AD7280A_CELLS_PER_DEV) + ch + 1); + "in%d-in%d_balance_switch_en", + dev * AD7280A_CELLS_PER_DEV + ch, + dev * AD7280A_CELLS_PER_DEV + ch + 1); ad7280_attributes[cnt] = &st->iio_attr[cnt].dev_attr.attr; cnt++; @@ -582,9 +582,10 @@ static int ad7280_attr_init(struct ad7280_state *st) st->iio_attr[cnt].dev_attr.store = ad7280_store_balance_timer; st->iio_attr[cnt].dev_attr.attr.name = - kasprintf(GFP_KERNEL, "in%d-in%d_balance_timer", - (dev * AD7280A_CELLS_PER_DEV) + ch, - (dev * AD7280A_CELLS_PER_DEV) + ch + 1); + kasprintf(GFP_KERNEL, + "in%d-in%d_balance_timer", + dev * AD7280A_CELLS_PER_DEV + ch, + dev * AD7280A_CELLS_PER_DEV + ch + 1); ad7280_attributes[cnt] = &st->iio_attr[cnt].dev_attr.attr; } @@ -595,15 +596,15 @@ static int ad7280_attr_init(struct ad7280_state *st) } static ssize_t ad7280_read_channel_config(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); unsigned val; - switch ((u32) this_attr->address) { + switch ((u32)this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: val = 1000 + (st->cell_threshhigh * 1568) / 100; break; @@ -624,9 +625,9 @@ static ssize_t ad7280_read_channel_config(struct device *dev, } static ssize_t ad7280_write_channel_config(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7280_state *st = iio_priv(indio_dev); @@ -639,7 +640,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev, if (ret) return ret; - switch ((u32) this_attr->address) { + switch ((u32)this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: case AD7280A_CELL_UNDERVOLTAGE: val = ((val - 1000) * 100) / 1568; /* LSB 15.68mV */ @@ -655,7 +656,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev, val = clamp(val, 0L, 0xFFL); mutex_lock(&indio_dev->mlock); - switch ((u32) this_attr->address) { + switch ((u32)this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: st->cell_threshhigh = val; break; @@ -686,7 +687,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) int i, ret; channels = kcalloc(st->scan_cnt, sizeof(*channels), GFP_KERNEL); - if (channels == NULL) + if (!channels) return IRQ_HANDLED; ret = ad7280_read_all_channels(st, st->scan_cnt, channels); @@ -698,39 +699,41 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) if (((channels[i] >> 11) & 0xFFF) >= st->cell_threshhigh) iio_push_event(indio_dev, - IIO_EVENT_CODE(IIO_VOLTAGE, - 1, - 0, - IIO_EV_DIR_RISING, - IIO_EV_TYPE_THRESH, - 0, 0, 0), - iio_get_time_ns()); + IIO_EVENT_CODE(IIO_VOLTAGE, + 1, + 0, + IIO_EV_DIR_RISING, + IIO_EV_TYPE_THRESH, + 0, 0, 0), + iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->cell_threshlow) iio_push_event(indio_dev, - IIO_EVENT_CODE(IIO_VOLTAGE, - 1, - 0, - IIO_EV_DIR_FALLING, - IIO_EV_TYPE_THRESH, - 0, 0, 0), - iio_get_time_ns()); + IIO_EVENT_CODE(IIO_VOLTAGE, + 1, + 0, + IIO_EV_DIR_FALLING, + IIO_EV_TYPE_THRESH, + 0, 0, 0), + iio_get_time_ns()); } else { if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_TEMP, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING), - iio_get_time_ns()); + IIO_UNMOD_EVENT_CODE( + IIO_TEMP, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), + iio_get_time_ns()); else if (((channels[i] >> 11) & 0xFFF) <= st->aux_threshlow) iio_push_event(indio_dev, - IIO_UNMOD_EVENT_CODE(IIO_TEMP, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - iio_get_time_ns()); + IIO_UNMOD_EVENT_CODE( + IIO_TEMP, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), + iio_get_time_ns()); } } @@ -766,7 +769,6 @@ static IIO_DEVICE_ATTR(in_temp_thresh_high_value, ad7280_write_channel_config, AD7280A_AUX_ADC_OVERVOLTAGE); - static struct attribute *ad7280_event_attributes[] = { &iio_dev_attr_in_thresh_low_value.dev_attr.attr, &iio_dev_attr_in_thresh_high_value.dev_attr.attr, @@ -817,7 +819,7 @@ static int ad7280_read_raw(struct iio_dev *indio_dev, } static const struct iio_info ad7280_info = { - .read_raw = &ad7280_read_raw, + .read_raw = ad7280_read_raw, .event_attrs = &ad7280_event_attrs_group, .attrs = &ad7280_attrs_group, .driver_module = THIS_MODULE, @@ -839,7 +841,7 @@ static int ad7280_probe(struct spi_device *spi) struct iio_dev *indio_dev; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); @@ -851,7 +853,7 @@ static int ad7280_probe(struct spi_device *spi) ad7280_crc8_build_table(st->crc_tab); - st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_Hz; + st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_HZ; st->spi->mode = SPI_MODE_1; spi_setup(st->spi); @@ -955,7 +957,7 @@ static int ad7280_remove(struct spi_device *spi) iio_device_unregister(indio_dev); ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, - AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); + AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); kfree(st->channels); kfree(st->iio_attr); diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index bf2c8013134c..5796ed2409d0 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -97,7 +97,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, if (ret < 0) return ret; - *val = (short) ret; + *val = (short)ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = st->range * 2; @@ -108,7 +108,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, } static ssize_t ad7606_show_range(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7606_state *st = iio_priv(indio_dev); @@ -117,7 +117,8 @@ static ssize_t ad7606_show_range(struct device *dev, } static ssize_t ad7606_store_range(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7606_state *st = iio_priv(indio_dev); @@ -145,7 +146,8 @@ static IIO_DEVICE_ATTR(in_voltage_range, S_IRUGO | S_IWUSR, static IIO_CONST_ATTR(in_voltage_range_available, "5000 10000"); static ssize_t ad7606_show_oversampling_ratio(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7606_state *st = iio_priv(indio_dev); @@ -166,7 +168,8 @@ static int ad7606_oversampling_get_index(unsigned val) } static ssize_t ad7606_store_oversampling_ratio(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7606_state *st = iio_priv(indio_dev); @@ -460,9 +463,9 @@ static const struct iio_info ad7606_info_range = { }; struct iio_dev *ad7606_probe(struct device *dev, int irq, - void __iomem *base_address, - unsigned id, - const struct ad7606_bus_ops *bops) + void __iomem *base_address, + unsigned id, + const struct ad7606_bus_ops *bops) { struct ad7606_platform_data *pdata = dev->platform_data; struct ad7606_state *st; @@ -529,7 +532,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n"); ret = request_irq(irq, ad7606_interrupt, - IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev); + IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev); if (ret) goto error_free_gpios; @@ -591,7 +594,7 @@ void ad7606_resume(struct iio_dev *indio_dev) if (gpio_is_valid(st->pdata->gpio_stby)) { if (gpio_is_valid(st->pdata->gpio_range)) gpio_set_value(st->pdata->gpio_range, - st->range == 10000); + st->range == 10000); gpio_set_value(st->pdata->gpio_stby, 1); ad7606_reset(st); diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c index 1d48ae381d16..adc370ee8632 100644 --- a/drivers/staging/iio/adc/ad7606_par.c +++ b/drivers/staging/iio/adc/ad7606_par.c @@ -16,13 +16,13 @@ #include "ad7606.h" static int ad7606_par16_read_block(struct device *dev, - int count, void *buf) + int count, void *buf) { struct platform_device *pdev = to_platform_device(dev); struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct ad7606_state *st = iio_priv(indio_dev); - insw((unsigned long) st->base_address, buf, count); + insw((unsigned long)st->base_address, buf, count); return 0; } @@ -32,13 +32,13 @@ static const struct ad7606_bus_ops ad7606_par16_bops = { }; static int ad7606_par8_read_block(struct device *dev, - int count, void *buf) + int count, void *buf) { struct platform_device *pdev = to_platform_device(dev); struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct ad7606_state *st = iio_priv(indio_dev); - insb((unsigned long) st->base_address, buf, count * 2); + insb((unsigned long)st->base_address, buf, count * 2); return 0; } @@ -69,9 +69,9 @@ static int ad7606_par_probe(struct platform_device *pdev) remap_size = resource_size(res); indio_dev = ad7606_probe(&pdev->dev, irq, addr, - platform_get_device_id(pdev)->driver_data, - remap_size > 1 ? &ad7606_par16_bops : - &ad7606_par8_bops); + platform_get_device_id(pdev)->driver_data, + remap_size > 1 ? &ad7606_par16_bops : + &ad7606_par8_bops); if (IS_ERR(indio_dev)) return PTR_ERR(indio_dev); @@ -113,6 +113,7 @@ static const struct dev_pm_ops ad7606_pm_ops = { .suspend = ad7606_par_suspend, .resume = ad7606_par_resume, }; + #define AD7606_PAR_PM_OPS (&ad7606_pm_ops) #else diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c index 7303983e64a7..b88f8825797d 100644 --- a/drivers/staging/iio/adc/ad7606_spi.c +++ b/drivers/staging/iio/adc/ad7606_spi.c @@ -44,8 +44,8 @@ static int ad7606_spi_probe(struct spi_device *spi) struct iio_dev *indio_dev; indio_dev = ad7606_probe(&spi->dev, spi->irq, NULL, - spi_get_device_id(spi)->driver_data, - &ad7606_spi_bops); + spi_get_device_id(spi)->driver_data, + &ad7606_spi_bops); if (IS_ERR(indio_dev)) return PTR_ERR(indio_dev); @@ -85,6 +85,7 @@ static const struct dev_pm_ops ad7606_pm_ops = { .suspend = ad7606_spi_suspend, .resume = ad7606_spi_resume, }; + #define AD7606_SPI_PM_OPS (&ad7606_pm_ops) #else diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 9f03fe3ee3d9..618b41faa289 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -62,7 +62,7 @@ static struct ad7780_state *ad_sigma_delta_to_ad7780(struct ad_sigma_delta *sd) } static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta, - enum ad_sigma_delta_mode mode) + enum ad_sigma_delta_mode mode) { struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); unsigned val; @@ -107,13 +107,13 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, } static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, - unsigned int raw_sample) + unsigned int raw_sample) { struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); const struct ad7780_chip_info *chip_info = st->chip_info; if ((raw_sample & AD7780_ERR) || - ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) + ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) return -EIO; if (raw_sample & AD7780_GAIN) @@ -206,9 +206,10 @@ static int ad7780_probe(struct spi_device *spi) indio_dev->info = &ad7780_info; if (pdata && gpio_is_valid(pdata->gpio_pdrst)) { - - ret = devm_gpio_request_one(&spi->dev, pdata->gpio_pdrst, - GPIOF_OUT_INIT_LOW, "AD7780 /PDRST"); + ret = devm_gpio_request_one(&spi->dev, + pdata->gpio_pdrst, + GPIOF_OUT_INIT_LOW, + "AD7780 /PDRST"); if (ret) { dev_err(&spi->dev, "failed to request GPIO PDRST\n"); goto error_disable_reg; diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 48b1c3740030..ccec57c5f70d 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -38,7 +38,6 @@ #define AD7816_TEMP_FLOAT_OFFSET 2 #define AD7816_TEMP_FLOAT_MASK 0x3 - /* * struct ad7816_chip_info - chip specific information */ @@ -48,7 +47,7 @@ struct ad7816_chip_info { u16 rdwr_pin; u16 convert_pin; u16 busy_pin; - u8 oti_data[AD7816_CS_MAX+1]; + u8 oti_data[AD7816_CS_MAX + 1]; u8 channel_id; /* 0 always be temperature */ u8 mode; }; @@ -60,6 +59,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) { struct spi_device *spi_dev = chip->spi_dev; int ret = 0; + __be16 buf; gpio_set_value(chip->rdwr_pin, 1); gpio_set_value(chip->rdwr_pin, 0); @@ -70,7 +70,6 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) } gpio_set_value(chip->rdwr_pin, 1); - if (chip->mode == AD7816_PD) { /* operating mode 2 */ gpio_set_value(chip->convert_pin, 1); gpio_set_value(chip->convert_pin, 0); @@ -84,13 +83,13 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) gpio_set_value(chip->rdwr_pin, 0); gpio_set_value(chip->rdwr_pin, 1); - ret = spi_read(spi_dev, (u8 *)data, sizeof(*data)); + ret = spi_read(spi_dev, &buf, sizeof(*data)); if (ret < 0) { dev_err(&spi_dev->dev, "SPI data read error\n"); return ret; } - *data = be16_to_cpu(*data); + *data = be16_to_cpu(buf); return ret; } @@ -110,8 +109,8 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data) } static ssize_t ad7816_show_mode(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -122,9 +121,9 @@ static ssize_t ad7816_show_mode(struct device *dev, } static ssize_t ad7816_store_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -146,8 +145,8 @@ static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, 0); static ssize_t ad7816_show_available_modes(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { return sprintf(buf, "full\npower-save\n"); } @@ -156,8 +155,8 @@ static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7816_show_available_modes, NULL, 0); static ssize_t ad7816_show_channel(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -166,9 +165,9 @@ static ssize_t ad7816_show_channel(struct device *dev, } static ssize_t ad7816_store_channel(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -203,10 +202,9 @@ static IIO_DEVICE_ATTR(channel, S_IRUGO | S_IWUSR, ad7816_store_channel, 0); - static ssize_t ad7816_show_value(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -260,8 +258,8 @@ static irqreturn_t ad7816_event_handler(int irq, void *private) } static ssize_t ad7816_show_oti(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -280,9 +278,9 @@ static ssize_t ad7816_show_oti(struct device *dev, } static inline ssize_t ad7816_set_oti(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); @@ -299,7 +297,7 @@ static inline ssize_t ad7816_set_oti(struct device *dev, return -EINVAL; } else if (chip->channel_id == 0) { if (ret || value < AD7816_BOUND_VALUE_MIN || - value > AD7816_BOUND_VALUE_MAX) + value > AD7816_BOUND_VALUE_MAX) return -EINVAL; data = (u8)(value - AD7816_BOUND_VALUE_MIN + @@ -371,7 +369,7 @@ static int ad7816_probe(struct spi_device *spi_dev) chip->busy_pin = pins[2]; ret = devm_gpio_request(&spi_dev->dev, chip->rdwr_pin, - spi_get_device_id(spi_dev)->name); + spi_get_device_id(spi_dev)->name); if (ret) { dev_err(&spi_dev->dev, "Fail to request rdwr gpio PIN %d.\n", chip->rdwr_pin); @@ -379,7 +377,7 @@ static int ad7816_probe(struct spi_device *spi_dev) } gpio_direction_input(chip->rdwr_pin); ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin, - spi_get_device_id(spi_dev)->name); + spi_get_device_id(spi_dev)->name); if (ret) { dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n", chip->convert_pin); @@ -387,7 +385,7 @@ static int ad7816_probe(struct spi_device *spi_dev) } gpio_direction_input(chip->convert_pin); ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin, - spi_get_device_id(spi_dev)->name); + spi_get_device_id(spi_dev)->name); if (ret) { dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n", chip->busy_pin); @@ -417,7 +415,7 @@ static int ad7816_probe(struct spi_device *spi_dev) return ret; dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n", - indio_dev->name); + indio_dev->name); return 0; } diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c index 5331c442fcfc..d11c54b72186 100644 --- a/drivers/staging/iio/adc/lpc32xx_adc.c +++ b/drivers/staging/iio/adc/lpc32xx_adc.c @@ -67,10 +67,10 @@ struct lpc32xx_adc_info { }; static int lpc32xx_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) { struct lpc32xx_adc_info *info = iio_priv(indio_dev); @@ -79,10 +79,10 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev, clk_enable(info->clk); /* Measurement setup */ __raw_writel(AD_INTERNAL | (chan->address) | AD_REFp | AD_REFm, - LPC32XX_ADC_SELECT(info->adc_base)); + LPC32XX_ADC_SELECT(info->adc_base)); /* Trigger conversion */ __raw_writel(AD_PDN_CTRL | AD_STROBE, - LPC32XX_ADC_CTRL(info->adc_base)); + LPC32XX_ADC_CTRL(info->adc_base)); wait_for_completion(&info->completion); /* set by ISR */ clk_disable(info->clk); *val = info->value; @@ -137,7 +137,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform I/O memory\n"); - return -EBUSY; + return -ENXIO; } iodev = devm_iio_device_alloc(&pdev->dev, sizeof(*info)); @@ -162,11 +162,11 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq <= 0) { dev_err(&pdev->dev, "failed getting interrupt resource\n"); - return -EINVAL; + return -ENXIO; } retval = devm_request_irq(&pdev->dev, irq, lpc32xx_adc_isr, 0, - MOD_NAME, info); + MOD_NAME, info); if (retval < 0) { dev_err(&pdev->dev, "failed requesting interrupt\n"); return retval; diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 47fc00a3f63b..d997d9c74ca8 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -108,12 +108,12 @@ static const char * const mx28_lradc_irq_names[] = { struct mxs_lradc_of_config { const int irq_count; const char * const *irq_name; - const uint32_t *vref_mv; + const u32 *vref_mv; }; #define VREF_MV_BASE 1850 -static const uint32_t mx23_vref_mv[LRADC_MAX_TOTAL_CHANS] = { +static const u32 mx23_vref_mv[LRADC_MAX_TOTAL_CHANS] = { VREF_MV_BASE, /* CH0 */ VREF_MV_BASE, /* CH1 */ VREF_MV_BASE, /* CH2 */ @@ -132,7 +132,7 @@ static const uint32_t mx23_vref_mv[LRADC_MAX_TOTAL_CHANS] = { VREF_MV_BASE * 4, /* CH15 VDD5V */ }; -static const uint32_t mx28_vref_mv[LRADC_MAX_TOTAL_CHANS] = { +static const u32 mx28_vref_mv[LRADC_MAX_TOTAL_CHANS] = { VREF_MV_BASE, /* CH0 */ VREF_MV_BASE, /* CH1 */ VREF_MV_BASE, /* CH2 */ @@ -198,14 +198,14 @@ struct mxs_lradc { struct clk *clk; - uint32_t *buffer; + u32 *buffer; struct iio_trigger *trig; struct mutex lock; struct completion completion; - const uint32_t *vref_mv; + const u32 *vref_mv; struct mxs_lradc_scale scale_avail[LRADC_MAX_TOTAL_CHANS][2]; unsigned long is_divided; @@ -425,7 +425,7 @@ static void mxs_lradc_map_channel(struct mxs_lradc *lradc, unsigned vch, unsigned ch) { mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(vch), - LRADC_CTRL4); + LRADC_CTRL4); mxs_lradc_reg_set(lradc, LRADC_CTRL4_LRADCSELECT(vch, ch), LRADC_CTRL4); } @@ -440,8 +440,8 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) * otherwise, the IRQs will not fire." */ mxs_lradc_reg_wrt(lradc, LRADC_CH_ACCUMULATE | - LRADC_CH_NUM_SAMPLES(lradc->over_sample_cnt - 1), - LRADC_CH(ch)); + LRADC_CH_NUM_SAMPLES(lradc->over_sample_cnt - 1), + LRADC_CH(ch)); /* from the datasheet: * "Software must clear this register in preparation for a @@ -458,10 +458,10 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) * the LRADC will not trigger the delay group." */ mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(1 << ch) | - LRADC_DELAY_TRIGGER_DELAYS(0) | - LRADC_DELAY_LOOP(lradc->over_sample_cnt - 1) | - LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), - LRADC_DELAY(3)); + LRADC_DELAY_TRIGGER_DELAYS(0) | + LRADC_DELAY_LOOP(lradc->over_sample_cnt - 1) | + LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), + LRADC_DELAY(3)); mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(ch), LRADC_CTRL1); @@ -471,12 +471,13 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) * SoC's delay unit and start the conversion later * and automatically. */ - mxs_lradc_reg_wrt(lradc, + mxs_lradc_reg_wrt( + lradc, LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */ LRADC_DELAY_TRIGGER_DELAYS(BIT(3)) | /* trigger DELAY unit#3 */ LRADC_DELAY_KICK | LRADC_DELAY_DELAY(lradc->settling_delay), - LRADC_DELAY(2)); + LRADC_DELAY(2)); } /* @@ -486,7 +487,7 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) * hardware report one interrupt if both conversions are done */ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1, - unsigned ch2) + unsigned ch2) { u32 reg; @@ -511,12 +512,14 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1, mxs_lradc_reg_clear(lradc, LRADC_CH_VALUE_MASK, LRADC_CH(ch2)); /* prepare the delay/loop unit according to the oversampling count */ - mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(1 << ch1) | - LRADC_DELAY_TRIGGER(1 << ch2) | /* start both channels */ - LRADC_DELAY_TRIGGER_DELAYS(0) | - LRADC_DELAY_LOOP(lradc->over_sample_cnt - 1) | - LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), - LRADC_DELAY(3)); + mxs_lradc_reg_wrt( + lradc, + LRADC_DELAY_TRIGGER(1 << ch1) | + LRADC_DELAY_TRIGGER(1 << ch2) | /* start both channels */ + LRADC_DELAY_TRIGGER_DELAYS(0) | + LRADC_DELAY_LOOP(lradc->over_sample_cnt - 1) | + LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), + LRADC_DELAY(3)); mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(ch2), LRADC_CTRL1); @@ -526,7 +529,8 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1, * SoC's delay unit and start the conversion later * and automatically. */ - mxs_lradc_reg_wrt(lradc, + mxs_lradc_reg_wrt( + lradc, LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */ LRADC_DELAY_TRIGGER_DELAYS(BIT(3)) | /* trigger DELAY unit#3 */ LRADC_DELAY_KICK | @@ -534,7 +538,7 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1, } static unsigned mxs_lradc_read_raw_channel(struct mxs_lradc *lradc, - unsigned channel) + unsigned channel) { u32 reg; unsigned num_samples, val; @@ -550,7 +554,7 @@ static unsigned mxs_lradc_read_raw_channel(struct mxs_lradc *lradc, } static unsigned mxs_lradc_read_ts_pressure(struct mxs_lradc *lradc, - unsigned ch1, unsigned ch2) + unsigned ch1, unsigned ch2) { u32 reg, mask; unsigned pressure, m1, m2; @@ -607,7 +611,7 @@ static void mxs_lradc_setup_touch_detection(struct mxs_lradc *lradc) */ mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), LRADC_CTRL0); mxs_lradc_reg_set(lradc, mxs_lradc_touch_detect_bit(lradc), - LRADC_CTRL0); + LRADC_CTRL0); } /* @@ -675,7 +679,7 @@ static void mxs_lradc_prepare_pressure(struct mxs_lradc *lradc) mxs_lradc_map_channel(lradc, TOUCHSCREEN_VCHANNEL1, TS_CH_YM); mxs_lradc_map_channel(lradc, TOUCHSCREEN_VCHANNEL2, TS_CH_XP); mxs_lradc_setup_ts_pressure(lradc, TOUCHSCREEN_VCHANNEL2, - TOUCHSCREEN_VCHANNEL1); + TOUCHSCREEN_VCHANNEL1); } static void mxs_lradc_enable_touch_detection(struct mxs_lradc *lradc) @@ -684,16 +688,18 @@ static void mxs_lradc_enable_touch_detection(struct mxs_lradc *lradc) lradc->cur_plate = LRADC_TOUCH; mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ | - LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); + LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); } static void mxs_lradc_start_touch_event(struct mxs_lradc *lradc) { - mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, - LRADC_CTRL1); + mxs_lradc_reg_clear(lradc, + LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, + LRADC_CTRL1); mxs_lradc_reg_set(lradc, - LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1), LRADC_CTRL1); + LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1), + LRADC_CTRL1); /* * start with the Y-pos, because it uses nearly the same plate * settings like the touch detection @@ -720,12 +726,14 @@ static void mxs_lradc_complete_touch_event(struct mxs_lradc *lradc) */ mxs_lradc_reg_wrt(lradc, 0, LRADC_CH(TOUCHSCREEN_VCHANNEL1)); mxs_lradc_reg_clear(lradc, - LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1) | - LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2), LRADC_CTRL1); - mxs_lradc_reg_wrt(lradc, - LRADC_DELAY_TRIGGER(1 << TOUCHSCREEN_VCHANNEL1) | - LRADC_DELAY_KICK | LRADC_DELAY_DELAY(10), /* waste 5 ms */ - LRADC_DELAY(2)); + LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1) | + LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2), + LRADC_CTRL1); + mxs_lradc_reg_wrt( + lradc, + LRADC_DELAY_TRIGGER(1 << TOUCHSCREEN_VCHANNEL1) | + LRADC_DELAY_KICK | LRADC_DELAY_DELAY(10), /* waste 5 ms */ + LRADC_DELAY(2)); } /* @@ -757,9 +765,11 @@ static void mxs_lradc_finish_touch_event(struct mxs_lradc *lradc, bool valid) lradc->cur_plate = LRADC_TOUCH; mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(2)); mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(3)); - mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ | - LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1) | - LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1), LRADC_CTRL1); + mxs_lradc_reg_clear(lradc, + LRADC_CTRL1_TOUCH_DETECT_IRQ | + LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1) | + LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1), + LRADC_CTRL1); mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); } @@ -771,25 +781,28 @@ static void mxs_lradc_handle_touch(struct mxs_lradc *lradc) if (mxs_lradc_check_touch_event(lradc)) mxs_lradc_start_touch_event(lradc); mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, - LRADC_CTRL1); + LRADC_CTRL1); return; case LRADC_SAMPLE_Y: - lradc->ts_y_pos = mxs_lradc_read_raw_channel(lradc, - TOUCHSCREEN_VCHANNEL1); + lradc->ts_y_pos = + mxs_lradc_read_raw_channel(lradc, + TOUCHSCREEN_VCHANNEL1); mxs_lradc_prepare_x_pos(lradc); return; case LRADC_SAMPLE_X: - lradc->ts_x_pos = mxs_lradc_read_raw_channel(lradc, - TOUCHSCREEN_VCHANNEL1); + lradc->ts_x_pos = + mxs_lradc_read_raw_channel(lradc, + TOUCHSCREEN_VCHANNEL1); mxs_lradc_prepare_pressure(lradc); return; case LRADC_SAMPLE_PRESSURE: - lradc->ts_pressure = mxs_lradc_read_ts_pressure(lradc, - TOUCHSCREEN_VCHANNEL2, - TOUCHSCREEN_VCHANNEL1); + lradc->ts_pressure = + mxs_lradc_read_ts_pressure(lradc, + TOUCHSCREEN_VCHANNEL2, + TOUCHSCREEN_VCHANNEL1); mxs_lradc_complete_touch_event(lradc); return; @@ -826,20 +839,22 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val) */ if (lradc->soc == IMX28_LRADC) mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ_EN(0), - LRADC_CTRL1); + LRADC_CTRL1); mxs_lradc_reg_clear(lradc, 0x1, LRADC_CTRL0); /* Enable / disable the divider per requirement */ if (test_bit(chan, &lradc->is_divided)) - mxs_lradc_reg_set(lradc, 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, - LRADC_CTRL2); + mxs_lradc_reg_set(lradc, + 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, + LRADC_CTRL2); else mxs_lradc_reg_clear(lradc, - 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, LRADC_CTRL2); + 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, + LRADC_CTRL2); /* Clean the slot's previous content, then set new one. */ mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), - LRADC_CTRL4); + LRADC_CTRL4); mxs_lradc_reg_set(lradc, chan, LRADC_CTRL4); mxs_lradc_reg_wrt(lradc, 0, LRADC_CH(0)); @@ -885,8 +900,8 @@ static int mxs_lradc_read_temp(struct iio_dev *iio_dev, int *val) } static int mxs_lradc_read_raw(struct iio_dev *iio_dev, - const struct iio_chan_spec *chan, - int *val, int *val2, long m) + const struct iio_chan_spec *chan, + int *val, int *val2, long m) { struct mxs_lradc *lradc = iio_priv(iio_dev); @@ -981,9 +996,9 @@ static int mxs_lradc_write_raw_get_fmt(struct iio_dev *iio_dev, } static ssize_t mxs_lradc_show_scale_available_ch(struct device *dev, - struct device_attribute *attr, - char *buf, - int ch) + struct device_attribute *attr, + char *buf, + int ch) { struct iio_dev *iio = dev_to_iio_dev(dev); struct mxs_lradc *lradc = iio_priv(iio); @@ -1000,8 +1015,8 @@ static ssize_t mxs_lradc_show_scale_available_ch(struct device *dev, } static ssize_t mxs_lradc_show_scale_available(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev_attr *iio_attr = to_iio_dev_attr(attr); @@ -1139,8 +1154,8 @@ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data) struct iio_dev *iio = data; struct mxs_lradc *lradc = iio_priv(iio); unsigned long reg = readl(lradc->base + LRADC_CTRL1); - uint32_t clr_irq = mxs_lradc_irq_mask(lradc); - const uint32_t ts_irq_mask = + u32 clr_irq = mxs_lradc_irq_mask(lradc); + const u32 ts_irq_mask = LRADC_CTRL1_TOUCH_DETECT_IRQ | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1) | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2); @@ -1176,7 +1191,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *iio = pf->indio_dev; struct mxs_lradc *lradc = iio_priv(iio); - const uint32_t chan_value = LRADC_CH_ACCUMULATE | + const u32 chan_value = LRADC_CH_ACCUMULATE | ((LRADC_DELAY_TIMER_LOOP - 1) << LRADC_CH_NUM_SAMPLES_OFFSET); unsigned int i, j = 0; @@ -1199,7 +1214,7 @@ static int mxs_lradc_configure_trigger(struct iio_trigger *trig, bool state) { struct iio_dev *iio = iio_trigger_get_drvdata(trig); struct mxs_lradc *lradc = iio_priv(iio); - const uint32_t st = state ? STMP_OFFSET_REG_SET : STMP_OFFSET_REG_CLR; + const u32 st = state ? STMP_OFFSET_REG_SET : STMP_OFFSET_REG_CLR; mxs_lradc_reg_wrt(lradc, LRADC_DELAY_KICK, LRADC_DELAY(0) + st); @@ -1218,7 +1233,7 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) struct mxs_lradc *lradc = iio_priv(iio); trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); - if (trig == NULL) + if (!trig) return -ENOMEM; trig->dev.parent = lradc->dev; @@ -1249,10 +1264,10 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) struct mxs_lradc *lradc = iio_priv(iio); int ret = 0, chan, ofs = 0; unsigned long enable = 0; - uint32_t ctrl4_set = 0; - uint32_t ctrl4_clr = 0; - uint32_t ctrl1_irq = 0; - const uint32_t chan_value = LRADC_CH_ACCUMULATE | + u32 ctrl4_set = 0; + u32 ctrl4_clr = 0; + u32 ctrl1_irq = 0; + const u32 chan_value = LRADC_CH_ACCUMULATE | ((LRADC_DELAY_TIMER_LOOP - 1) << LRADC_CH_NUM_SAMPLES_OFFSET); const int len = bitmap_weight(iio->active_scan_mask, LRADC_MAX_TOTAL_CHANS); @@ -1275,7 +1290,8 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) } if (lradc->soc == IMX28_LRADC) - mxs_lradc_reg_clear(lradc, + mxs_lradc_reg_clear( + lradc, lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET, LRADC_CTRL1); mxs_lradc_reg_clear(lradc, lradc->buffer_vchans, LRADC_CTRL0); @@ -1290,12 +1306,12 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) } mxs_lradc_reg_clear(lradc, LRADC_DELAY_TRIGGER_LRADCS_MASK | - LRADC_DELAY_KICK, LRADC_DELAY(0)); + LRADC_DELAY_KICK, LRADC_DELAY(0)); mxs_lradc_reg_clear(lradc, ctrl4_clr, LRADC_CTRL4); mxs_lradc_reg_set(lradc, ctrl4_set, LRADC_CTRL4); mxs_lradc_reg_set(lradc, ctrl1_irq, LRADC_CTRL1); mxs_lradc_reg_set(lradc, enable << LRADC_DELAY_TRIGGER_LRADCS_OFFSET, - LRADC_DELAY(0)); + LRADC_DELAY(0)); return 0; @@ -1309,11 +1325,12 @@ static int mxs_lradc_buffer_postdisable(struct iio_dev *iio) struct mxs_lradc *lradc = iio_priv(iio); mxs_lradc_reg_clear(lradc, LRADC_DELAY_TRIGGER_LRADCS_MASK | - LRADC_DELAY_KICK, LRADC_DELAY(0)); + LRADC_DELAY_KICK, LRADC_DELAY(0)); mxs_lradc_reg_clear(lradc, lradc->buffer_vchans, LRADC_CTRL0); if (lradc->soc == IMX28_LRADC) - mxs_lradc_reg_clear(lradc, + mxs_lradc_reg_clear( + lradc, lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET, LRADC_CTRL1); @@ -1324,7 +1341,7 @@ static int mxs_lradc_buffer_postdisable(struct iio_dev *iio) } static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, - const unsigned long *mask) + const unsigned long *mask) { struct mxs_lradc *lradc = iio_priv(iio); const int map_chans = bitmap_weight(mask, LRADC_MAX_TOTAL_CHANS); @@ -1457,7 +1474,7 @@ static const struct iio_chan_spec mx28_lradc_chan_spec[] = { static int mxs_lradc_hw_init(struct mxs_lradc *lradc) { /* The ADC always uses DELAY CHANNEL 0. */ - const uint32_t adc_cfg = + const u32 adc_cfg = (1 << (LRADC_DELAY_TRIGGER_DELAYS_OFFSET + 0)) | (LRADC_DELAY_TIMER_PER << LRADC_DELAY_DELAY_OFFSET); @@ -1477,11 +1494,11 @@ static int mxs_lradc_hw_init(struct mxs_lradc *lradc) /* Configure the touchscreen type */ if (lradc->soc == IMX28_LRADC) { mxs_lradc_reg_clear(lradc, LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE, - LRADC_CTRL0); + LRADC_CTRL0); if (lradc->use_touchscreen == MXS_LRADC_TOUCHSCREEN_5WIRE) mxs_lradc_reg_set(lradc, LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE, - LRADC_CTRL0); + LRADC_CTRL0); } /* Start internal temperature sensing. */ @@ -1508,13 +1525,13 @@ static const struct of_device_id mxs_lradc_dt_ids[] = { MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids); static int mxs_lradc_probe_touchscreen(struct mxs_lradc *lradc, - struct device_node *lradc_node) + struct device_node *lradc_node) { int ret; u32 ts_wires = 0, adapt; ret = of_property_read_u32(lradc_node, "fsl,lradc-touchscreen-wires", - &ts_wires); + &ts_wires); if (ret) return -ENODEV; /* touchscreen feature disabled */ @@ -1584,7 +1601,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) struct resource *iores; int ret = 0, touch_ret; int i, s; - uint64_t scale_uv; + u64 scale_uv; /* Allocate the IIO device. */ iio = devm_iio_device_alloc(dev, sizeof(*lradc)); @@ -1630,8 +1647,8 @@ static int mxs_lradc_probe(struct platform_device *pdev) } ret = devm_request_irq(dev, lradc->irq[i], - mxs_lradc_handle_irq, 0, - of_cfg->irq_name[i], iio); + mxs_lradc_handle_irq, 0, + of_cfg->irq_name[i], iio); if (ret) goto err_clk; } @@ -1658,8 +1675,8 @@ static int mxs_lradc_probe(struct platform_device *pdev) } ret = iio_triggered_buffer_setup(iio, &iio_pollfunc_store_time, - &mxs_lradc_trigger_handler, - &mxs_lradc_buffer_ops); + &mxs_lradc_trigger_handler, + &mxs_lradc_buffer_ops); if (ret) goto err_clk; diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index c5382374ddf6..712cae0e8608 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -191,8 +191,8 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev, mutex_lock(&indio_dev->mlock); if ((val < SPEAR_ADC_CLK_MIN) || - (val > SPEAR_ADC_CLK_MAX) || - (val2 != 0)) { + (val > SPEAR_ADC_CLK_MAX) || + (val2 != 0)) { ret = -EINVAL; goto out; } diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 5b11b42c0254..3adc4516918c 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1756,43 +1756,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) stat1 &= 0x1F; time = iio_get_time_ns(); - if (stat1 & (1 << 0)) + if (stat1 & BIT(0)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), time); - if (stat1 & (1 << 1)) + if (stat1 & BIT(1)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), time); - if (stat1 & (1 << 2)) + if (stat1 & BIT(2)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), time); - if (stat1 & (1 << 3)) + if (stat1 & BIT(3)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), time); - if (stat1 & (1 << 5)) + if (stat1 & BIT(5)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); - if (stat1 & (1 << 6)) + if (stat1 & BIT(6)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), time); - if (stat1 & (1 << 7)) + if (stat1 & BIT(7)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, IIO_EV_TYPE_THRESH, @@ -2152,7 +2152,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, - &adt7316_event_handler, + adt7316_event_handler, chip->bus.irq_flags | IRQF_ONESHOT, indio_dev->name, diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index a2b7ae3329c0..e8d0ff2d5c9b 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -179,12 +179,9 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev, /* Note completely different from the adaptive versions */ case IIO_EV_TYPE_THRESH: value = chip->threshold[rising][chan]; - ret = i2c_smbus_write_word_data(chip->client, + return i2c_smbus_write_word_data(chip->client, ad7150_addresses[chan][3], swab16(value)); - if (ret < 0) - return ret; - return 0; case IIO_EV_TYPE_MAG_ADAPTIVE: sens = chip->mag_sensitivity[rising][chan]; timeout = chip->mag_timeout[rising][chan]; @@ -222,7 +219,7 @@ static int ad7150_write_event_config(struct iio_dev *indio_dev, u64 event_code; /* Something must always be turned on */ - if (state == 0) + if (!state) return -EINVAL; event_code = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, type, dir); @@ -636,7 +633,7 @@ static int ad7150_probe(struct i2c_client *client, return ret; } - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret) return ret; @@ -646,15 +643,6 @@ static int ad7150_probe(struct i2c_client *client, return 0; } -static int ad7150_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - - return 0; -} - static const struct i2c_device_id ad7150_id[] = { { "ad7150", 0 }, { "ad7151", 0 }, @@ -669,7 +657,6 @@ static struct i2c_driver ad7150_driver = { .name = "ad7150", }, .probe = ad7150_probe, - .remove = ad7150_remove, .id_table = ad7150_id, }; module_i2c_driver(ad7150_driver); diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index 87110d940e9a..485d0a5af53c 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c @@ -290,7 +290,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev, ret = 0; break; case IIO_CHAN_INFO_SCALE: - if (val != 0) { + if (val) { ret = -EINVAL; goto out; } @@ -502,7 +502,7 @@ static int ad7152_probe(struct i2c_client *client, indio_dev->num_channels = ARRAY_SIZE(ad7152_channels); indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret) return ret; @@ -511,15 +511,6 @@ static int ad7152_probe(struct i2c_client *client, return 0; } -static int ad7152_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - - return 0; -} - static const struct i2c_device_id ad7152_id[] = { { "ad7152", 0 }, { "ad7153", 1 }, @@ -533,7 +524,6 @@ static struct i2c_driver ad7152_driver = { .name = KBUILD_MODNAME, }, .probe = ad7152_probe, - .remove = ad7152_remove, .id_table = ad7152_id, }; module_i2c_driver(ad7152_driver); diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index e6e9eaa9eab5..2c5d27784ed3 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -27,11 +27,7 @@ #define AD7746_REG_STATUS 0 #define AD7746_REG_CAP_DATA_HIGH 1 -#define AD7746_REG_CAP_DATA_MID 2 -#define AD7746_REG_CAP_DATA_LOW 3 #define AD7746_REG_VT_DATA_HIGH 4 -#define AD7746_REG_VT_DATA_MID 5 -#define AD7746_REG_VT_DATA_LOW 6 #define AD7746_REG_CAP_SETUP 7 #define AD7746_REG_VT_SETUP 8 #define AD7746_REG_EXC_SETUP 9 @@ -39,17 +35,14 @@ #define AD7746_REG_CAPDACA 11 #define AD7746_REG_CAPDACB 12 #define AD7746_REG_CAP_OFFH 13 -#define AD7746_REG_CAP_OFFL 14 #define AD7746_REG_CAP_GAINH 15 -#define AD7746_REG_CAP_GAINL 16 #define AD7746_REG_VOLT_GAINH 17 -#define AD7746_REG_VOLT_GAINL 18 /* Status Register Bit Designations (AD7746_REG_STATUS) */ -#define AD7746_STATUS_EXCERR (1 << 3) -#define AD7746_STATUS_RDY (1 << 2) -#define AD7746_STATUS_RDYVT (1 << 1) -#define AD7746_STATUS_RDYCAP (1 << 0) +#define AD7746_STATUS_EXCERR BIT(3) +#define AD7746_STATUS_RDY BIT(2) +#define AD7746_STATUS_RDYVT BIT(1) +#define AD7746_STATUS_RDYCAP BIT(0) /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */ #define AD7746_CAPSETUP_CAPEN (1 << 7) @@ -68,12 +61,12 @@ #define AD7746_VTSETUP_VTCHOP (1 << 0) /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */ -#define AD7746_EXCSETUP_CLKCTRL (1 << 7) -#define AD7746_EXCSETUP_EXCON (1 << 6) -#define AD7746_EXCSETUP_EXCB (1 << 5) -#define AD7746_EXCSETUP_NEXCB (1 << 4) -#define AD7746_EXCSETUP_EXCA (1 << 3) -#define AD7746_EXCSETUP_NEXCA (1 << 2) +#define AD7746_EXCSETUP_CLKCTRL BIT(7) +#define AD7746_EXCSETUP_EXCON BIT(6) +#define AD7746_EXCSETUP_EXCB BIT(5) +#define AD7746_EXCSETUP_NEXCB BIT(4) +#define AD7746_EXCSETUP_EXCA BIT(3) +#define AD7746_EXCSETUP_NEXCA BIT(2) #define AD7746_EXCSETUP_EXCLVL(x) (((x) & 0x3) << 0) /* Config Register Bit Designations (AD7746_REG_CFG) */ @@ -528,10 +521,11 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, goto out; } - /* CAPDAC Scale = 21pF_typ / 127 + /* + * CAPDAC Scale = 21pF_typ / 127 * CIN Scale = 8.192pF / 2^24 * Offset Scale = CAPDAC Scale / CIN Scale = 338646 - * */ + */ val /= 338646; @@ -600,7 +594,8 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_TEMP: - /* temperature in milli degrees Celsius + /* + * temperature in milli degrees Celsius * T = ((*val / 2048) - 4096) * 1000 */ *val = (*val * 125) / 256; @@ -749,21 +744,10 @@ static int ad7746_probe(struct i2c_client *client, if (ret < 0) return ret; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret) return ret; - dev_info(&client->dev, "%s capacitive sensor registered\n", id->name); - - return 0; -} - -static int ad7746_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - return 0; } @@ -781,7 +765,6 @@ static struct i2c_driver ad7746_driver = { .name = KBUILD_MODNAME, }, .probe = ad7746_probe, - .remove = ad7746_remove, .id_table = ad7746_id, }; module_i2c_driver(ad7746_driver); diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index d02bb44fb8fc..fcffe2c11685 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -111,7 +111,7 @@ static ssize_t ad9834_write(struct device *dev, break; case AD9834_FSEL: case AD9834_PSEL: - if (val == 0) { + if (!val) { st->control &= ~(this_attr->address | AD9834_PIN_SW); } else if (val == 1) { st->control |= this_attr->address; diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 4c5869dd8223..981b63f83a7b 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -67,7 +67,7 @@ static int adis16060_spi_read(struct iio_dev *indio_dev, u16 *val) * starts to place data MSB first on the DOUT line at * the 6th falling edge of SCLK */ - if (ret == 0) + if (!ret) *val = ((st->buf[0] & 0x3) << 12) | (st->buf[1] << 4) | ((st->buf[2] >> 4) & 0xF); @@ -89,11 +89,13 @@ static int adis16060_read_raw(struct iio_dev *indio_dev, /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); ret = adis16060_spi_write(indio_dev, chan->address); - if (ret < 0) { - mutex_unlock(&indio_dev->mlock); - return ret; - } + if (ret < 0) + goto out_unlock; + ret = adis16060_spi_read(indio_dev, &tval); + if (ret < 0) + goto out_unlock; + mutex_unlock(&indio_dev->mlock); *val = tval; return IIO_VAL_INT; @@ -108,6 +110,10 @@ static int adis16060_read_raw(struct iio_dev *indio_dev, } return -EINVAL; + +out_unlock: + mutex_unlock(&indio_dev->mlock); + return ret; } static const struct iio_info adis16060_info = { diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c index 6d38854c38c8..9e83f348df51 100644 --- a/drivers/staging/iio/iio_dummy_evgen.c +++ b/drivers/staging/iio/iio_dummy_evgen.c @@ -24,9 +24,21 @@ #include "iio_dummy_evgen.h" #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> +#include <linux/irq_work.h> /* Fiddly bit of faking and irq without hardware */ #define IIO_EVENTGEN_NO 10 + +/** + * struct iio_dummy_handle_irq - helper struct to simulate interrupt generation + * @work: irq_work used to run handlers from hardirq context + * @irq: fake irq line number to trigger an interrupt + */ +struct iio_dummy_handle_irq { + struct irq_work work; + int irq; +}; + /** * struct iio_dummy_evgen - evgen state * @chip: irq chip we are faking @@ -35,6 +47,7 @@ * @inuse: mask of which irqs are connected * @regs: irq regs we are faking * @lock: protect the evgen state + * @handler: helper for a 'hardware-like' interrupt simulation */ struct iio_dummy_eventgen { struct irq_chip chip; @@ -43,6 +56,7 @@ struct iio_dummy_eventgen { bool inuse[IIO_EVENTGEN_NO]; struct iio_dummy_regs regs[IIO_EVENTGEN_NO]; struct mutex lock; + struct iio_dummy_handle_irq handler; }; /* We can only ever have one instance of this 'device' */ @@ -67,6 +81,14 @@ static void iio_dummy_event_irqunmask(struct irq_data *d) evgen->enabled[d->irq - evgen->base] = true; } +static void iio_dummy_work_handler(struct irq_work *work) +{ + struct iio_dummy_handle_irq *irq_handler; + + irq_handler = container_of(work, struct iio_dummy_handle_irq, work); + handle_simple_irq(irq_to_desc(irq_handler->irq)); +} + static int iio_dummy_evgen_create(void) { int ret, i; @@ -91,6 +113,7 @@ static int iio_dummy_evgen_create(void) IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); } + init_irq_work(&iio_evgen->handler.work, iio_dummy_work_handler); mutex_init(&iio_evgen->lock); return 0; } @@ -169,8 +192,9 @@ static ssize_t iio_evgen_poke(struct device *dev, iio_evgen->regs[this_attr->address].reg_id = this_attr->address; iio_evgen->regs[this_attr->address].reg_data = event; + iio_evgen->handler.irq = iio_evgen->base + this_attr->address; if (iio_evgen->enabled[this_attr->address]) - handle_nested_irq(iio_evgen->base + this_attr->address); + irq_work_queue(&iio_evgen->handler.work); return len; } diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index 381f90ff468a..43fe4ba7d0dc 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -137,7 +137,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { */ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = DUMMY_INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */ @@ -176,7 +176,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { * sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = DUMMY_INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */ @@ -194,7 +194,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = DUMMY_INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11, @@ -221,7 +221,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { BIT(IIO_CHAN_INFO_CALIBSCALE) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = DUMMY_INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */ @@ -364,8 +364,7 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret = IIO_VAL_INT_PLUS_MICRO; break; case 1: - /* all differential adc channels -> - * 0.000001344 */ + /* all differential adc -> 0.000001344 */ *val = 0; *val2 = 1344; ret = IIO_VAL_INT_PLUS_NANO; diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h index 8d00224e6fad..b9069a180672 100644 --- a/drivers/staging/iio/iio_simple_dummy.h +++ b/drivers/staging/iio/iio_simple_dummy.h @@ -46,6 +46,7 @@ struct iio_dummy_state { int event_irq; int event_val; bool event_en; + s64 event_timestamp; #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ }; @@ -97,18 +98,18 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) /** * enum iio_simple_dummy_scan_elements - scan index enum - * @voltage0: the single ended voltage channel - * @diffvoltage1m2: first differential channel - * @diffvoltage3m4: second differenial channel - * @accelx: acceleration channel + * @DUMMY_INDEX_VOLTAGE_0: the single ended voltage channel + * @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel + * @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel + * @DUMMY_INDEX_ACCELX: acceleration channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, + DUMMY_INDEX_VOLTAGE_0, + DUMMY_INDEX_DIFFVOLTAGE_1M2, + DUMMY_INDEX_DIFFVOLTAGE_3M4, + DUMMY_INDEX_ACCELX, }; #ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c index 00ed7745f3c5..cf44a6f79431 100644 --- a/drivers/staging/iio/iio_simple_dummy_buffer.c +++ b/drivers/staging/iio/iio_simple_dummy_buffer.c @@ -27,10 +27,10 @@ /* Some fake data */ static const s16 fakedata[] = { - [voltage0] = 7, - [diffvoltage1m2] = -33, - [diffvoltage3m4] = -2, - [accelx] = 344, + [DUMMY_INDEX_VOLTAGE_0] = 7, + [DUMMY_INDEX_DIFFVOLTAGE_1M2] = -33, + [DUMMY_INDEX_DIFFVOLTAGE_3M4] = -2, + [DUMMY_INDEX_ACCELX] = 344, }; /** diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c index 73108baf80ad..bfbf1c56bd22 100644 --- a/drivers/staging/iio/iio_simple_dummy_events.c +++ b/drivers/staging/iio/iio_simple_dummy_events.c @@ -153,6 +153,15 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev, return 0; } +static irqreturn_t iio_simple_dummy_get_timestamp(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct iio_dummy_state *st = iio_priv(indio_dev); + + st->event_timestamp = iio_get_time_ns(); + return IRQ_HANDLED; +} + /** * iio_simple_dummy_event_handler() - identify and pass on event * @irq: irq of event line @@ -177,7 +186,7 @@ static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private) IIO_EVENT_CODE(IIO_VOLTAGE, 0, 0, IIO_EV_DIR_RISING, IIO_EV_TYPE_THRESH, 0, 0, 0), - iio_get_time_ns()); + st->event_timestamp); break; case 1: if (st->activity_running > st->event_val) @@ -187,7 +196,7 @@ static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private) IIO_EV_DIR_RISING, IIO_EV_TYPE_THRESH, 0, 0, 0), - iio_get_time_ns()); + st->event_timestamp); break; case 2: if (st->activity_walking < st->event_val) @@ -197,14 +206,14 @@ static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private) IIO_EV_DIR_FALLING, IIO_EV_TYPE_THRESH, 0, 0, 0), - iio_get_time_ns()); + st->event_timestamp); break; case 3: iio_push_event(indio_dev, IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD, IIO_EV_DIR_NONE, IIO_EV_TYPE_CHANGE, 0, 0, 0), - iio_get_time_ns()); + st->event_timestamp); break; default: break; @@ -238,7 +247,7 @@ int iio_simple_dummy_events_register(struct iio_dev *indio_dev) st->regs = iio_dummy_evgen_get_regs(st->event_irq); ret = request_threaded_irq(st->event_irq, - NULL, + &iio_simple_dummy_get_timestamp, &iio_simple_dummy_event_handler, IRQF_ONESHOT, "iio_simple_event", diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index c18109c55497..10c43dda0f5a 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -644,7 +644,8 @@ static void ad5933_work(struct work_struct *work) struct ad5933_state *st = container_of(work, struct ad5933_state, work.work); struct iio_dev *indio_dev = i2c_get_clientdata(st->client); - signed short buf[2]; + __be16 buf[2]; + int val[2]; unsigned char status; mutex_lock(&indio_dev->mlock); @@ -668,12 +669,12 @@ static void ad5933_work(struct work_struct *work) scan_count * 2, (u8 *)buf); if (scan_count == 2) { - buf[0] = be16_to_cpu(buf[0]); - buf[1] = be16_to_cpu(buf[1]); + val[0] = be16_to_cpu(buf[0]); + val[1] = be16_to_cpu(buf[1]); } else { - buf[0] = be16_to_cpu(buf[0]); + val[0] = be16_to_cpu(buf[0]); } - iio_push_to_buffers(indio_dev, buf); + iio_push_to_buffers(indio_dev, val); } else { /* no data available - try again later */ schedule_delayed_work(&st->work, st->poll_time_jiffies); diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 019ba5245c23..bbf7e35cbc7d 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -117,12 +117,10 @@ static int isl29018_set_integration_time(struct isl29018_chip *chip, { int i, ret; unsigned int int_time, new_int_time; - struct isl29018_scale new_scale; for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i) { if (utime == isl29018_int_utimes[chip->type][i]) { new_int_time = i; - new_scale = isl29018_scales[new_int_time][0]; break; } } @@ -370,7 +368,7 @@ static int isl29018_write_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_INT_TIME: if (chan->type == IIO_LIGHT) { - if (val != 0) { + if (val) { mutex_unlock(&chip->lock); return -EINVAL; } @@ -716,7 +714,7 @@ static int isl29018_probe(struct i2c_client *client, int dev_id = 0; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); - if (indio_dev == NULL) { + if (!indio_dev) { dev_err(&client->dev, "iio allocation fails\n"); return -ENOMEM; } diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c index cd6f2727aa58..32ae1127da33 100644 --- a/drivers/staging/iio/light/isl29028.c +++ b/drivers/staging/iio/light/isl29028.c @@ -513,7 +513,7 @@ static int isl29028_probe(struct i2c_client *client, indio_dev->name = id->name; indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret < 0) { dev_err(chip->dev, "iio registration fails with error %d\n", ret); @@ -522,14 +522,6 @@ static int isl29028_probe(struct i2c_client *client, return 0; } -static int isl29028_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - return 0; -} - static const struct i2c_device_id isl29028_id[] = { {"isl29028", 0}, {} @@ -550,7 +542,6 @@ static struct i2c_driver isl29028_driver = { .of_match_table = isl29028_of_match, }, .probe = isl29028_probe, - .remove = isl29028_remove, .id_table = isl29028_id, }; diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index b5e1b8b0a6f0..3100d960fe2c 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -263,7 +263,7 @@ static int taos_get_lux(struct iio_dev *indio_dev) if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation)) goto return_max; - if (ch0 == 0) { + if (!ch0) { /* have no data, so return LAST VALUE */ ret = chip->als_cur_info.lux = 0; goto out_unlock; @@ -415,7 +415,7 @@ static int taos_chip_on(struct iio_dev *indio_dev) /* determine als integration register */ als_count = (chip->taos_settings.als_time * 100 + 135) / 270; - if (als_count == 0) + if (!als_count) als_count = 1; /* ensure at least one cycle */ /* convert back to time (encompasses overrides) */ @@ -499,7 +499,7 @@ static ssize_t taos_power_state_store(struct device *dev, if (kstrtoint(buf, 0, &value)) return -EINVAL; - if (value == 0) + if (!value) taos_chip_off(indio_dev); else taos_chip_on(indio_dev); @@ -862,7 +862,7 @@ static int taos_probe(struct i2c_client *clientp, indio_dev->dev.parent = &clientp->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->name = chip->client->name; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret) { dev_err(&clientp->dev, "iio registration failed\n"); return ret; @@ -917,13 +917,6 @@ static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume); #define TAOS_PM_OPS NULL #endif -static int taos_remove(struct i2c_client *client) -{ - iio_device_unregister(i2c_get_clientdata(client)); - - return 0; -} - static struct i2c_device_id taos_idtable[] = { { "tsl2580", 0 }, { "tsl2581", 1 }, @@ -940,7 +933,6 @@ static struct i2c_driver taos_driver = { }, .id_table = taos_idtable, .probe = taos_probe, - .remove = taos_remove, }; module_i2c_driver(taos_driver); diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c index 010e607dd880..9dfd04855a1b 100644 --- a/drivers/staging/iio/light/tsl2x7x_core.c +++ b/drivers/staging/iio/light/tsl2x7x_core.c @@ -403,7 +403,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) goto return_max; } - if (ch0 == 0) { + if (!ch0) { /* have no data, so return LAST VALUE */ ret = chip->als_cur_info.lux; goto out_unlock; @@ -418,9 +418,9 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) if (p->ratio == 0) { lux = 0; } else { - ch0lux = DIV_ROUND_UP((ch0 * p->ch0), + ch0lux = DIV_ROUND_UP(ch0 * p->ch0, tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]); - ch1lux = DIV_ROUND_UP((ch1 * p->ch1), + ch1lux = DIV_ROUND_UP(ch1 * p->ch1, tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]); lux = ch0lux - ch1lux; } @@ -678,7 +678,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) /* determine als integration register */ als_count = (chip->tsl2x7x_settings.als_time * 100 + 135) / 270; - if (als_count == 0) + if (!als_count) als_count = 1; /* ensure at least one cycle */ /* convert back to time (encompasses overrides) */ @@ -825,7 +825,7 @@ void tsl2x7x_prox_calculate(int *data, int length, int sample_sum; int tmp; - if (length == 0) + if (!length) length = 1; sample_sum = 0; @@ -1057,7 +1057,7 @@ static ssize_t tsl2x7x_als_persistence_store(struct device *dev, z = y * TSL2X7X_MIN_ITIME; filter_delay = - DIV_ROUND_UP(((result.integer * 1000) + result.fract), z); + DIV_ROUND_UP((result.integer * 1000) + result.fract, z); chip->tsl2x7x_settings.persistence &= 0xF0; chip->tsl2x7x_settings.persistence |= (filter_delay & 0x0F); @@ -1103,7 +1103,7 @@ static ssize_t tsl2x7x_prox_persistence_store(struct device *dev, z = y * TSL2X7X_MIN_ITIME; filter_delay = - DIV_ROUND_UP(((result.integer * 1000) + result.fract), z); + DIV_ROUND_UP((result.integer * 1000) + result.fract, z); chip->tsl2x7x_settings.persistence &= 0x0F; chip->tsl2x7x_settings.persistence |= ((filter_delay << 4) & 0xF0); diff --git a/drivers/staging/iio/magnetometer/hmc5843.h b/drivers/staging/iio/magnetometer/hmc5843.h index f3d0da2fe458..06f35d3828e4 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.h +++ b/drivers/staging/iio/magnetometer/hmc5843.h @@ -48,7 +48,7 @@ struct hmc5843_data { }; int hmc5843_common_probe(struct device *dev, struct regmap *regmap, - enum hmc5843_ids id); + enum hmc5843_ids id, const char *name); int hmc5843_common_remove(struct device *dev); int hmc5843_common_suspend(struct device *dev); diff --git a/drivers/staging/iio/magnetometer/hmc5843_core.c b/drivers/staging/iio/magnetometer/hmc5843_core.c index fffca3a9f637..394bc141a1b0 100644 --- a/drivers/staging/iio/magnetometer/hmc5843_core.c +++ b/drivers/staging/iio/magnetometer/hmc5843_core.c @@ -334,7 +334,7 @@ static int hmc5843_get_scale_index(struct hmc5843_data *data, int val, int val2) { int i; - if (val != 0) + if (val) return -EINVAL; for (i = 0; i < data->variant->n_regval_to_nanoscale; i++) @@ -577,7 +577,7 @@ int hmc5843_common_resume(struct device *dev) EXPORT_SYMBOL(hmc5843_common_resume); int hmc5843_common_probe(struct device *dev, struct regmap *regmap, - enum hmc5843_ids id) + enum hmc5843_ids id, const char *name) { struct hmc5843_data *data; struct iio_dev *indio_dev; @@ -597,7 +597,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap, mutex_init(&data->lock); indio_dev->dev.parent = dev; - indio_dev->name = dev->driver->name; + indio_dev->name = name; indio_dev->info = &hmc5843_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = data->variant->channels; diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c index ff08667fa2f6..3e06ceb32059 100644 --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c @@ -61,7 +61,7 @@ static int hmc5843_i2c_probe(struct i2c_client *cli, { return hmc5843_common_probe(&cli->dev, devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config), - id->driver_data); + id->driver_data, id->name); } static int hmc5843_i2c_remove(struct i2c_client *client) diff --git a/drivers/staging/iio/magnetometer/hmc5843_spi.c b/drivers/staging/iio/magnetometer/hmc5843_spi.c index 8e658f736e1f..1549192c0dec 100644 --- a/drivers/staging/iio/magnetometer/hmc5843_spi.c +++ b/drivers/staging/iio/magnetometer/hmc5843_spi.c @@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = { static int hmc5843_spi_probe(struct spi_device *spi) { int ret; + const struct spi_device_id *id = spi_get_device_id(spi); spi->mode = SPI_MODE_3; spi->max_speed_hz = 8000000; @@ -69,7 +70,7 @@ static int hmc5843_spi_probe(struct spi_device *spi) return hmc5843_common_probe(&spi->dev, devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config), - HMC5983_ID); + id->driver_data, id->name); } static int hmc5843_spi_remove(struct spi_device *spi) @@ -81,6 +82,7 @@ static const struct spi_device_id hmc5843_id[] = { { "hmc5983", HMC5983_ID }, { } }; +MODULE_DEVICE_TABLE(spi, hmc5843_id); static struct spi_driver hmc5843_driver = { .driver = { diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index ffc7f0ddff14..188830d7e257 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -219,7 +219,7 @@ static int ade7753_reset(struct device *dev) u16 val; ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val); - val |= 1 << 6; /* Software Chip Reset */ + val |= BIT(6); /* Software Chip Reset */ return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); } @@ -328,10 +328,10 @@ static int ade7753_set_irq(struct device *dev, bool enable) goto error_ret; if (enable) - irqen |= 1 << 3; /* Enables an interrupt when a data is + irqen |= BIT(3); /* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 << 3); + irqen &= ~BIT(3); ret = ade7753_spi_write_reg_8(dev, ADE7753_IRQEN, irqen); @@ -345,7 +345,7 @@ static int ade7753_stop_device(struct device *dev) u16 val; ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val); - val |= 1 << 4; /* AD converters can be turned off */ + val |= BIT(4); /* AD converters can be turned off */ return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); } @@ -406,7 +406,7 @@ static ssize_t ade7753_write_frequency(struct device *dev, ret = kstrtou16(buf, 10, &val); if (ret) return ret; - if (val == 0) + if (!val) return -EINVAL; mutex_lock(&indio_dev->mlock); diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index f12b2e50329b..664c6e5f76b1 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -223,7 +223,7 @@ static int ade7754_reset(struct device *dev) if (ret < 0) return ret; - val |= 1 << 6; /* Software Chip Reset */ + val |= BIT(6); /* Software Chip Reset */ return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val); } @@ -350,10 +350,10 @@ static int ade7754_set_irq(struct device *dev, bool enable) goto error_ret; if (enable) - irqen |= 1 << 14; /* Enables an interrupt when a data is + irqen |= BIT(14); /* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 << 14); + irqen &= ~BIT(14); ret = ade7754_spi_write_reg_16(dev, ADE7754_IRQEN, irqen); if (ret) @@ -438,7 +438,7 @@ static ssize_t ade7754_write_frequency(struct device *dev, ret = kstrtou16(buf, 10, &val); if (ret) return ret; - if (val == 0) + if (!val) return -EINVAL; mutex_lock(&indio_dev->mlock); diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 77141ae1349d..38838085824f 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -308,7 +308,7 @@ static int ade7758_reset(struct device *dev) dev_err(dev, "Failed to read opmode reg\n"); return ret; } - val |= 1 << 6; /* Software Chip Reset */ + val |= BIT(6); /* Software Chip Reset */ ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val); if (ret < 0) dev_err(dev, "Failed to write opmode reg\n"); @@ -426,10 +426,10 @@ int ade7758_set_irq(struct device *dev, bool enable) goto error_ret; if (enable) - irqen |= 1 << 16; /* Enables an interrupt when a data is + irqen |= BIT(16); /* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 << 16); + irqen &= ~BIT(16); ret = ade7758_spi_write_reg_24(dev, ADE7758_MASK, irqen); if (ret) diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index dbceda1e67ea..11c1edcc1ed6 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -224,7 +224,7 @@ static int ade7759_reset(struct device *dev) if (ret < 0) return ret; - val |= 1 << 6; /* Software Chip Reset */ + val |= BIT(6); /* Software Chip Reset */ return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val); @@ -288,10 +288,10 @@ static int ade7759_set_irq(struct device *dev, bool enable) goto error_ret; if (enable) - irqen |= 1 << 3; /* Enables an interrupt when a data is + irqen |= BIT(3); /* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 << 3); + irqen &= ~BIT(3); ret = ade7759_spi_write_reg_8(dev, ADE7759_IRQEN, irqen); @@ -314,7 +314,7 @@ static int ade7759_stop_device(struct device *dev) return ret; } - val |= 1 << 4; /* AD converters can be turned off */ + val |= BIT(4); /* AD converters can be turned off */ return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val); } @@ -377,7 +377,7 @@ static ssize_t ade7759_write_frequency(struct device *dev, ret = kstrtou16(buf, 10, &val); if (ret) return ret; - if (val == 0) + if (!val) return -EINVAL; mutex_lock(&indio_dev->mlock); diff --git a/drivers/staging/iio/meter/ade7854-spi.c b/drivers/staging/iio/meter/ade7854-spi.c index 9b255a5f62c3..da774866512c 100644 --- a/drivers/staging/iio/meter/ade7854-spi.c +++ b/drivers/staging/iio/meter/ade7854-spi.c @@ -278,7 +278,7 @@ static int ade7854_spi_probe(struct spi_device *spi) struct iio_dev *indio_dev; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index d620bbd603a3..a83883596dbc 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -181,7 +181,7 @@ static int ade7854_reset(struct device *dev) u16 val; st->read_reg_16(dev, ADE7854_CONFIG, &val); - val |= 1 << 7; /* Software Chip Reset */ + val |= BIT(7); /* Software Chip Reset */ return st->write_reg_16(dev, ADE7854_CONFIG, val); } @@ -420,10 +420,10 @@ static int ade7854_set_irq(struct device *dev, bool enable) goto error_ret; if (enable) - irqen |= 1 << 17; /* 1: interrupt enabled when all periodical + irqen |= BIT(17); /* 1: interrupt enabled when all periodical (at 8 kHz rate) DSP computations finish. */ else - irqen &= ~(1 << 17); + irqen &= ~BIT(17); ret = st->write_reg_32(dev, ADE7854_MASK0, irqen); if (ret) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 7bc3e4a73834..3bd65f5c9cf5 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -633,7 +633,7 @@ error_ret: } static const struct iio_info ad2s1210_info = { - .read_raw = &ad2s1210_read_raw, + .read_raw = ad2s1210_read_raw, .attrs = &ad2s1210_attribute_group, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index e24c5890652f..c57a29616223 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -79,7 +79,7 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels = 1; indio_dev->name = spi_get_device_id(spi)->name; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret) return ret; @@ -91,13 +91,6 @@ static int ad2s90_probe(struct spi_device *spi) return 0; } -static int ad2s90_remove(struct spi_device *spi) -{ - iio_device_unregister(spi_get_drvdata(spi)); - - return 0; -} - static const struct spi_device_id ad2s90_id[] = { { "ad2s90" }, {} @@ -110,7 +103,6 @@ static struct spi_driver ad2s90_driver = { .owner = THIS_MODULE, }, .probe = ad2s90_probe, - .remove = ad2s90_remove, .id_table = ad2s90_id, }; module_spi_driver(ad2s90_driver); diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 9fe48ef11473..035dd456d7d6 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -100,7 +100,7 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev, if (enabled) disable_gptimers(st->t->bit); - if (val == 0) + if (!val) return count; val = get_sclk() / val; @@ -125,7 +125,7 @@ static ssize_t iio_bfin_tmr_frequency_show(struct device *dev, unsigned int period = get_gptimer_period(st->t->id); unsigned long val; - if (period == 0) + if (!period) val = 0; else val = get_sclk() / get_gptimer_period(st->t->id); diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c index 2db885750fb8..00d139331261 100644 --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c @@ -39,7 +39,7 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state) dev_dbg(&trig_info->rtc->dev, "trigger frequency is %u\n", trig_info->frequency); ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, state); - if (ret == 0) + if (!ret) trig_info->state = state; return ret; |