staging: iio: Remove explicit comparisons
Subsystems (5)
cover staging: iio: Remove explicit comparisons
Remove comparisons to 0 or NULL in order to provide efficiency. Done with coccinelle
@replace@
identifier e;
@@
(
-e == 0
+ !e
|
-e != 0
+ e
|
-e == NULL
+ !e
|
-e != NULL
+ e
)
Cristina Moraru (10):
staging: iio: adc: Remove explicit comparisons
staging: iio: addac: Remove explicit comparisons
staging: iio: light: Remove explicit comparisons
staging: iio: meter: Remove explicit comparisons
staging: iio: accel: Remove explicit comparisons
staging: iio: cdc: Remove explicit comparisons
staging: iio: frequency: Remove explicit comparisons
staging: iio: trigger: Remove explicit comparisons
staging: iio: gyro: Remove explicit comparisons
staging: iio: magnetometer: Remove explicit comparisons
drivers/staging/iio/accel/sca3000_ring.c | 2 +- drivers/staging/iio/adc/ad7192.c | 4 ++-- drivers/staging/iio/adc/ad7280a.c | 6 +++--- drivers/staging/iio/adc/mxs-lradc.c | 10 +++++----- drivers/staging/iio/adc/spear_adc.c | 2 +- drivers/staging/iio/addac/adt7316.c | 4 ++-- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7152.c | 2 +- drivers/staging/iio/frequency/ad9832.c | 2 +- drivers/staging/iio/frequency/ad9834.c | 2 +- drivers/staging/iio/gyro/adis16060_core.c | 2 +- drivers/staging/iio/light/isl29018.c | 6 +++--- drivers/staging/iio/light/tsl2583.c | 6 +++--- drivers/staging/iio/light/tsl2x7x_core.c | 6 +++--- drivers/staging/iio/magnetometer/hmc5843_core.c | 2 +- drivers/staging/iio/meter/ade7753.c | 2 +- drivers/staging/iio/meter/ade7754.c | 2 +- drivers/staging/iio/meter/ade7759.c | 2 +- drivers/staging/iio/meter/ade7854-spi.c | 2 +- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 4 ++-- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 4 ++-- 21 files changed, 37 insertions(+), 37 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/10 staging: iio: adc: Remove explicit comparisons
Remove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/adc/ad7192.c | 4 ++-- drivers/staging/iio/adc/ad7280a.c | 6 +++--- drivers/staging/iio/adc/mxs-lradc.c | 10 +++++----- drivers/staging/iio/adc/spear_adc.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/staging/iio/adc/ad7192.c +2 -2
@@ -330,7 +330,7 @@ static ssize_t ad7192_write_frequency(struct device *dev, ret =kstrtoul (buf,10 , &lval);if (ret)return ret; -if (lval ==0 ) +if (!lval)return -EINVAL ;mutex_lock (&indio_dev->mlock);
@@ -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);
drivers/staging/iio/adc/ad7280a.c +3 -3
@@ -365,7 +365,7 @@ static int ad7280_chain_setup(struct ad7280_state *st)for (n =0 ; n <=AD7280A_MAX_CHAIN ; n++) {__ad7280_read32 (st, &val); -if (val ==0 ) +if (!val)return n -1 ;if (ad7280_check_crc (st, val))
@@ -686,7 +686,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);
@@ -839,7 +839,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);
drivers/staging/iio/adc/mxs-lradc.c +5 -5
@@ -566,7 +566,7 @@ static unsigned mxs_lradc_read_ts_pressure(struct mxs_lradc *lradc, m1 =mxs_lradc_read_raw_channel (lradc, ch1); m2 =mxs_lradc_read_raw_channel (lradc, ch2); -if (m2 ==0 ) { +if (!m2) {dev_warn (lradc->dev,"Cannot calculate pressure\n" );return 1 << (LRADC_RESOLUTION -1 ); }
@@ -1217,7 +1217,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;
@@ -1608,14 +1608,14 @@ static int mxs_lradc_probe(struct platform_device *pdev)return PTR_ERR (lradc->clk); } ret =clk_prepare_enable (lradc->clk); -if (ret !=0 ) { +if (ret) {dev_err (dev,"Failed to enable the delay unit clock\n" );return ret; } touch_ret =mxs_lradc_probe_touchscreen (lradc, node); -if (touch_ret ==0 ) +if (!touch_ret) lradc->buffer_vchans =BUFFER_VCHANS_LIMITED ;else lradc->buffer_vchans =BUFFER_VCHANS_ALL ;
@@ -1692,7 +1692,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) goto err_dev;/* Register the touchscreen input device. */ -if (touch_ret ==0 ) { +if (!touch_ret) { ret =mxs_lradc_ts_register (lradc);if (ret) goto err_ts_register;
drivers/staging/iio/adc/spear_adc.c +1 -1
@@ -192,7 +192,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev,if ((val <SPEAR_ADC_CLK_MIN ) || (val >SPEAR_ADC_CLK_MAX ) || - (val2 !=0 )) { + val2) { ret = -EINVAL ; goto out; }
Signature · 1 line
1.9.1
PATCH 2/10 staging: iio: addac: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/addac/adt7316.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/addac/adt7316.c +2 -2
@@ -1419,7 +1419,7 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip,int ret;if (channel >=ADT7316_DA_MSB_DATA_REGS || - (channel ==0 && + (!channel && (chip->config3 &ADT7316_EN_IN_TEMP_PROP_DACA )) || (channel ==1 && (chip->config3 &ADT7316_EN_EX_TEMP_PROP_DACB )))
@@ -1452,7 +1452,7 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip,int ret;if (channel >=ADT7316_DA_MSB_DATA_REGS || - (channel ==0 && + (!channel && (chip->config3 &ADT7316_EN_IN_TEMP_PROP_DACA )) || (channel ==1 && (chip->config3 &ADT7316_EN_EX_TEMP_PROP_DACB )))
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH 02/10] staging: iio: addac: Remove explicit comparisons
drivers/staging/iio/addac/adt7316.c static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip, · line 1422
Quoted 10 lines
drivers/staging/iio/addac/adt7316.c +1
-1@@ -1419,7 +1419,7 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip,int ret; if (channel >= ADT7316_DA_MSB_DATA_REGS || - (channel == 0 && + (!channel &&
Here too it is probably better to keep the comparison to 0, since there is a comparison to 1 just below. Same in the next case.
julia
Quoted 22 lines
drivers/staging/iio/addac/adt7316.c +1
-1(chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA)) || (channel ==1 && (chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB)))@@ -1452,7 +1452,7 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip,int ret;if (channel >=ADT7316_DA_MSB_DATA_REGS || - (channel ==0 && + (!channel && (chip->config3 &ADT7316_EN_IN_TEMP_PROP_DACA )) || (channel ==1 && (chip->config3 &ADT7316_EN_EX_TEMP_PROP_DACB )))Signature · 8 lines
1.9.1 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/933f0eb8aa4bb81e75671c9531bf4d59d78e3ceb.1445291799.git.cristina.moraru09%40gmail.com. For more options, visit https://groups.google.com/d/optout.
PATCH 3/10 staging: iio: light: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/light/isl29018.c | 6 +++--- drivers/staging/iio/light/tsl2583.c | 6 +++--- drivers/staging/iio/light/tsl2x7x_core.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/iio/light/isl29018.c +3 -3
@@ -335,7 +335,7 @@ static ssize_t store_prox_infrared_suppression(struct device *dev,if (kstrtoint (buf,10 , &val))return -EINVAL ; -if (!(val ==0 || val ==1 )) { +if (!(!val || val ==1 )) {dev_err (dev,"The mode is not supported\n" );return -EINVAL ; }
@@ -370,7 +370,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 +716,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 ; }
drivers/staging/iio/light/tsl2583.c +3 -3
@@ -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);
drivers/staging/iio/light/tsl2x7x_core.c +3 -3
@@ -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;
@@ -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 ;
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH 03/10] staging: iio: light: Remove explicit comparisons
drivers/staging/iio/light/isl29018.c static ssize_t store_prox_infrared_suppression(struct device *dev, · line 338
Quoted 4 lines
drivers/staging/iio/light/isl29018.c +1
-1if (kstrtoint (buf,10 , &val))return -EINVAL ; -if (!(val ==0 || val ==1 )) { +if (!(!val || val ==1 )) {
This one looked nicer with the comparison to 0, since that is more parallel with the comparison to 1.
julia
PATCH 4/10 staging: iio: meter: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/meter/ade7753.c | 2 +- drivers/staging/iio/meter/ade7754.c | 2 +- drivers/staging/iio/meter/ade7759.c | 2 +- drivers/staging/iio/meter/ade7854-spi.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/meter/ade7753.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7754.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7759.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7854-spi.c +1 -1
@@ -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);
Signature · 1 line
1.9.1
PATCH 5/10 staging: iio: accel: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/accel/sca3000_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/accel/sca3000_ring.c +1 -1
@@ -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 ;
Signature · 1 line
1.9.1
PATCH 6/10 staging: iio: cdc: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7152.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/cdc/ad7150.c +1 -1
@@ -222,7 +222,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);
drivers/staging/iio/cdc/ad7152.c +1 -1
@@ -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; }
Signature · 1 line
1.9.1
PATCH 7/10 staging: iio: frequency: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/frequency/ad9832.c | 2 +- drivers/staging/iio/frequency/ad9834.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +1 -1
@@ -109,7 +109,7 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr,case AD9832_FREQ_SYM :if (val ==1 ) { st->ctrl_fp |=AD9832_FREQ ; - }else if (val ==0 ) { + }else if (!val) { st->ctrl_fp &= ~AD9832_FREQ ; }else { ret = -EINVAL ;
drivers/staging/iio/frequency/ad9834.c +1 -1
@@ -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;
Signature · 1 line
1.9.1
PATCH 8/10 staging: iio: trigger: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 4 ++-- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/trigger/iio-trig-bfin-timer.c +2 -2
@@ -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);
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +2 -2
@@ -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;
@@ -71,7 +71,7 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,if (val >0 ) { ret =rtc_irq_set_freq (trig_info->rtc, &trig_info->task, val); -if (ret ==0 && trig_info->state && trig_info->frequency ==0 ) +if (!ret && trig_info->state && trig_info->frequency ==0 ) ret =rtc_irq_set_state (trig_info->rtc, &trig_info->task,1 ); }else {
Signature · 1 line
1.9.1
PATCH 9/10 staging: iio: gyro: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/gyro/adis16060_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/gyro/adis16060_core.c +1 -1
@@ -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 );
Signature · 1 line
1.9.1
PATCH 10/10 staging: iio: magnetometer: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL in order to provide efficiency
--- drivers/staging/iio/magnetometer/hmc5843_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/magnetometer/hmc5843_core.c +1 -1
@@ -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++)
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH 10/10] staging: iio: magnetometer: Remove explicit comparisons
Quoted 1 line · Cristina Moraru
Remove comparisons to 0 or NULL in order to provide efficiency
I don't think it actually has any impact on effcieincy. The compiler will probably generate the same code in either case. One may think that one looks nicer than the other.
julia
Quoted 29 lines
Signed-off-by Cristina Moraru <[email protected]>--- drivers/staging/iio/magnetometer/hmc5843_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/iio/magnetometer/hmc5843_core.c +1
-1@@ -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++)Signature · 8 lines
1.9.1 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/9d1f4e46279b951b8dff1763ef89b92c14398a3c.1445291799.git.cristina.moraru09%40gmail.com. For more options, visit https://groups.google.com/d/optout.
v2 cover staging: iio: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 and NULL. Done with coccinelle:
@replace@
identifier e;
@@
(
-e == 0
+ !e
|
-e != 0
+ e
|
-e == NULL
+ !e
|
-e != NULL
+ e
)
Changes in v2:
Remove some changes for consistency of notations
Cristina Moraru (9):
staging: iio: adc: Remove explicit comparisons
staging: iio: light: Remove explicit comparisons
staging: iio: meter: Remove explicit comparisons
staging: iio: accel: Remove explicit comparisons
staging: iio: cdc: Remove explicit comparisons
staging: iio: frequency: Remove explicit comparisons
staging: iio: trigger: Remove explicit comparisons
staging: iio: gyro: Remove explicit comparisons
staging: iio: magnetometer: Remove explicit comparisons
drivers/staging/iio/accel/sca3000_ring.c | 2 +- drivers/staging/iio/adc/ad7192.c | 4 ++-- drivers/staging/iio/adc/ad7280a.c | 6 +++--- drivers/staging/iio/adc/mxs-lradc.c | 10 +++++----- drivers/staging/iio/adc/spear_adc.c | 2 +- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7152.c | 2 +- drivers/staging/iio/frequency/ad9834.c | 2 +- drivers/staging/iio/gyro/adis16060_core.c | 2 +- drivers/staging/iio/light/isl29018.c | 4 ++-- drivers/staging/iio/light/tsl2583.c | 6 +++--- drivers/staging/iio/light/tsl2x7x_core.c | 6 +++--- drivers/staging/iio/magnetometer/hmc5843_core.c | 2 +- drivers/staging/iio/meter/ade7753.c | 2 +- drivers/staging/iio/meter/ade7754.c | 2 +- drivers/staging/iio/meter/ade7759.c | 2 +- drivers/staging/iio/meter/ade7854-spi.c | 2 +- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 4 ++-- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 2 +- 19 files changed, 32 insertions(+), 32 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/9 staging: iio: adc: Remove explicit comparisons
Remove comparisons to 0 or NULL
--- drivers/staging/iio/adc/ad7192.c | 4 ++-- drivers/staging/iio/adc/ad7280a.c | 6 +++--- drivers/staging/iio/adc/mxs-lradc.c | 10 +++++----- drivers/staging/iio/adc/spear_adc.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/staging/iio/adc/ad7192.c +2 -2
@@ -330,7 +330,7 @@ static ssize_t ad7192_write_frequency(struct device *dev, ret =kstrtoul (buf,10 , &lval);if (ret)return ret; -if (lval ==0 ) +if (!lval)return -EINVAL ;mutex_lock (&indio_dev->mlock);
@@ -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);
drivers/staging/iio/adc/ad7280a.c +3 -3
@@ -365,7 +365,7 @@ static int ad7280_chain_setup(struct ad7280_state *st)for (n =0 ; n <=AD7280A_MAX_CHAIN ; n++) {__ad7280_read32 (st, &val); -if (val ==0 ) +if (!val)return n -1 ;if (ad7280_check_crc (st, val))
@@ -686,7 +686,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);
@@ -839,7 +839,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);
drivers/staging/iio/adc/mxs-lradc.c +5 -5
@@ -566,7 +566,7 @@ static unsigned mxs_lradc_read_ts_pressure(struct mxs_lradc *lradc, m1 =mxs_lradc_read_raw_channel (lradc, ch1); m2 =mxs_lradc_read_raw_channel (lradc, ch2); -if (m2 ==0 ) { +if (!m2) {dev_warn (lradc->dev,"Cannot calculate pressure\n" );return 1 << (LRADC_RESOLUTION -1 ); }
@@ -1217,7 +1217,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;
@@ -1608,14 +1608,14 @@ static int mxs_lradc_probe(struct platform_device *pdev)return PTR_ERR (lradc->clk); } ret =clk_prepare_enable (lradc->clk); -if (ret !=0 ) { +if (ret) {dev_err (dev,"Failed to enable the delay unit clock\n" );return ret; } touch_ret =mxs_lradc_probe_touchscreen (lradc, node); -if (touch_ret ==0 ) +if (!touch_ret) lradc->buffer_vchans =BUFFER_VCHANS_LIMITED ;else lradc->buffer_vchans =BUFFER_VCHANS_ALL ;
@@ -1692,7 +1692,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) goto err_dev;/* Register the touchscreen input device. */ -if (touch_ret ==0 ) { +if (!touch_ret) { ret =mxs_lradc_ts_register (lradc);if (ret) goto err_ts_register;
drivers/staging/iio/adc/spear_adc.c +1 -1
@@ -192,7 +192,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev,if ((val <SPEAR_ADC_CLK_MIN ) || (val >SPEAR_ADC_CLK_MAX ) || - (val2 !=0 )) { + val2) { ret = -EINVAL ; goto out; }
Signature · 1 line
1.9.1
PATCH v2 2/9 staging: iio: light: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/light/isl29018.c | 4 ++-- drivers/staging/iio/light/tsl2583.c | 6 +++--- drivers/staging/iio/light/tsl2x7x_core.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/iio/light/isl29018.c +2 -2
@@ -370,7 +370,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 +716,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 ; }
drivers/staging/iio/light/tsl2583.c +3 -3
@@ -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);
drivers/staging/iio/light/tsl2x7x_core.c +3 -3
@@ -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;
@@ -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 ;
Signature · 1 line
1.9.1
PATCH v2 3/9 staging: iio: meter: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/meter/ade7753.c | 2 +- drivers/staging/iio/meter/ade7754.c | 2 +- drivers/staging/iio/meter/ade7759.c | 2 +- drivers/staging/iio/meter/ade7854-spi.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/meter/ade7753.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7754.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7759.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7854-spi.c +1 -1
@@ -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);
Signature · 1 line
1.9.1
PATCH v2 4/9 staging: iio: accel: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/accel/sca3000_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/accel/sca3000_ring.c +1 -1
@@ -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 ;
Signature · 1 line
1.9.1
PATCH v2 5/9 staging: iio: cdc: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7152.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/cdc/ad7150.c +1 -1
@@ -222,7 +222,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);
drivers/staging/iio/cdc/ad7152.c +1 -1
@@ -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; }
Signature · 1 line
1.9.1
PATCH v2 6/9 staging: iio: frequency: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/frequency/ad9834.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/frequency/ad9834.c +1 -1
@@ -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;
Signature · 1 line
1.9.1
PATCH v2 7/9 staging: iio: trigger: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 4 ++-- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/trigger/iio-trig-bfin-timer.c +2 -2
@@ -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);
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +1 -1
@@ -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;
Signature · 1 line
1.9.1
PATCH v2 8/9 staging: iio: gyro: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/gyro/adis16060_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/gyro/adis16060_core.c +1 -1
@@ -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 );
Signature · 1 line
1.9.1
PATCH v2 9/9 staging: iio: magnetometer: Remove explicit comparisons
In reply to Cristina MoraruRemove comparisons to 0 or NULL
--- drivers/staging/iio/magnetometer/hmc5843_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/magnetometer/hmc5843_core.c +1 -1
@@ -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++)
Signature · 1 line
1.9.1