Skip to contentSkip to conversation

Staging: iio: Remove explicit NULL comparison

PATCH Superseded Cristina Opriceana 2 participants 9 messages Mar 29, 2015

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Staging: iio: Remove explicit NULL comparison

This patchet removes explicit NULL comparison from the iio drivers.

Cristina Opriceana (7):
Staging: iio: Simplify NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison

 drivers/staging/iio/accel/lis3l02dq_ring.c          | 6 +++---
 drivers/staging/iio/adc/ad7606_ring.c               | 2 +-
 drivers/staging/iio/adc/ad7780.c                    | 2 +-
 drivers/staging/iio/iio_dummy_evgen.c               | 4 ++--
 drivers/staging/iio/iio_simple_dummy.c              | 2 +-
 drivers/staging/iio/iio_simple_dummy_buffer.c       | 6 +++---
 drivers/staging/iio/impedance-analyzer/ad5933.c     | 2 +-
 drivers/staging/iio/meter/ade7758_core.c            | 2 +-
 drivers/staging/iio/meter/ade7758_ring.c            | 2 +-
 drivers/staging/iio/meter/ade7758_trigger.c         | 2 +-
 drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 4 ++--
 11 files changed, 17 insertions(+), 17 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/7 Staging: iio: Simplify NULL comparison

Remove explicit NULL comparison and write it in its simpler form. Replacement done with coccinelle:

@replace_rule@
expression e;
@@

-e == NULL
+ !e

---
 drivers/staging/iio/iio_dummy_evgen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/iio_dummy_evgen.c +2 -2
index 59ad5a3..0c9c86d 100644
@@ -72,7 +72,7 @@ static int iio_dummy_evgen_create(void)
 	int ret, i;
 
 	iio_evgen = kzalloc(sizeof(*iio_evgen), GFP_KERNEL);
-	if (iio_evgen == NULL)
+	if (!iio_evgen)
 		return -ENOMEM;
 
 	iio_evgen->base = irq_alloc_descs(-1, 0, IIO_EVENTGEN_NO, 0);
@@ -105,7 +105,7 @@ int iio_dummy_evgen_get_irq(void)
 {
 	int i, ret = 0;
 
-	if (iio_evgen == NULL)
+	if (!iio_evgen)
 		return -ENODEV;
 
 	mutex_lock(&iio_evgen->lock);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/7 Staging: iio: Remove explicit NULL comparison

In reply to Cristina Opriceana

This patch removes explicit NULL comparison and writes it in its simpler form. Done with coccinelle:

@replace_rule@
expression e;
@@

-e == NULL
+ !e

---
 drivers/staging/iio/iio_simple_dummy.c        | 2 +-
 drivers/staging/iio/iio_simple_dummy_buffer.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/iio_simple_dummy.c +1 -1
index 8341dce..b47bf9f 100644
@@ -588,7 +588,7 @@ static int iio_dummy_probe(int index)
 	 * for chip specific state information.
 	 */
 	indio_dev = iio_device_alloc(sizeof(*st));
-	if (indio_dev == NULL) {
+	if (!indio_dev) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
drivers/staging/iio/iio_simple_dummy_buffer.c +3 -3
index 360a4c9..a651b89 100644
@@ -50,7 +50,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
 	u16 *data;
 
 	data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
-	if (data == NULL)
+	if (!data)
 		goto done;
 
 	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
@@ -122,7 +122,7 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
 
 	/* Allocate a buffer to use - here a kfifo */
 	buffer = iio_kfifo_allocate();
-	if (buffer == NULL) {
+	if (!buffer) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
@@ -161,7 +161,7 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
 						 "iio_simple_dummy_consumer%d",
 						 indio_dev->id);
 
-	if (indio_dev->pollfunc == NULL) {
+	if (!indio_dev->pollfunc) {
 		ret = -ENOMEM;
 		goto error_free_buffer;
 	}
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/7 Staging: iio: Remove explicit NULL comparison

In reply to Cristina Opriceana

This patch removes explicit NULL comparison and replaces it with its shorter form. Detected with coccinelle.

@replace_rule@
expression e;
@@

-e == NULL
+ !e

---
 drivers/staging/iio/meter/ade7758_core.c    | 2 +-
 drivers/staging/iio/meter/ade7758_ring.c    | 2 +-
 drivers/staging/iio/meter/ade7758_trigger.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/meter/ade7758_core.c +1 -1
index 652aa10..77141ae 100644
@@ -833,7 +833,7 @@ static int ade7758_probe(struct spi_device *spi)
 	if (!st->rx)
 		return -ENOMEM;
 	st->tx = kcalloc(ADE7758_MAX_TX, sizeof(*st->tx), GFP_KERNEL);
-	if (st->tx == NULL) {
+	if (!st->tx) {
 		ret = -ENOMEM;
 		goto error_free_rx;
 	}
drivers/staging/iio/meter/ade7758_ring.c +1 -1
index ead38a5..9a24e02 100644
@@ -132,7 +132,7 @@ int ade7758_configure_ring(struct iio_dev *indio_dev)
 						 indio_dev,
 						 "ade7759_consumer%d",
 						 indio_dev->id);
-	if (indio_dev->pollfunc == NULL) {
+	if (!indio_dev->pollfunc) {
 		ret = -ENOMEM;
 		goto error_iio_kfifo_free;
 	}
drivers/staging/iio/meter/ade7758_trigger.c +1 -1
index 6f45ce0..5b35a7f 100644
@@ -66,7 +66,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
 	st->trig = iio_trigger_alloc("%s-dev%d",
 					spi_get_device_id(st->us)->name,
 					indio_dev->id);
-	if (st->trig == NULL) {
+	if (!st->trig) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/7 Staging: iio: Remove explicit NULL comparison

In reply to Cristina Opriceana

This patch removes explicit NULL comparison and replaces it with its shorter form. Detected with coccinelle.

---
 drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +2 -2
index 89df1d3..0c1976d 100644
@@ -124,7 +124,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
 	int i, ret;
 
 	for (i = 0;; i++) {
-		if (pdata[i] == NULL)
+		if (!pdata[i])
 			break;
 		trig = iio_trigger_alloc("periodic%s", pdata[i]);
 		if (!trig) {
@@ -142,7 +142,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
 		trig->ops = &iio_prtc_trigger_ops;
 		/* RTC access */
 		trig_info->rtc = rtc_class_open(pdata[i]);
-		if (trig_info->rtc == NULL) {
+		if (!trig_info->rtc) {
 			ret = -EINVAL;
 			goto error_free_trig_info;
 		}
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/7 Staging: iio: Remove explicit NULL comparison

In reply to Cristina Opriceana

This patch removes explicit NULL comparison and replaces it with its shorter form. Detected with coccinelle.

---
 drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +1 -1
index 7919439..c18109c 100644
@@ -703,7 +703,7 @@ static int ad5933_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
-	if (indio_dev == NULL)
+	if (!indio_dev)
 		return -ENOMEM;
 
 	st = iio_priv(indio_dev);
Signature · 1 line
1.9.1
#6 lore raw

PATCH 6/7 Staging: iio: Remove explicit NULL comparison

In reply to Cristina Opriceana

This patch removes explicit NULL comparison and writes it in its shorter form. Detected with coccinelle.

---
 drivers/staging/iio/adc/ad7606_ring.c | 2 +-
 drivers/staging/iio/adc/ad7780.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/adc/ad7606_ring.c +1 -1
index 3bf174c..a6f8eb1 100644
@@ -50,7 +50,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 	int ret;
 
 	buf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
-	if (buf == NULL)
+	if (!buf)
 		return;
 
 	if (gpio_is_valid(st->pdata->gpio_frstdata)) {
drivers/staging/iio/adc/ad7780.c +1 -1
index 273add3..6cb17ec 100644
@@ -169,7 +169,7 @@ static int ad7780_probe(struct spi_device *spi)
 	int ret, voltage_uv = 0;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (indio_dev == NULL)
+	if (!indio_dev)
 		return -ENOMEM;
 
 	st = iio_priv(indio_dev);
Signature · 1 line
1.9.1
#7 lore raw

PATCH 7/7 Staging: iio: Remove explicit NULL comparison

In reply to Cristina Opriceana

This patch removes explicit NULL comparison and writes it in its equivalent shorter form. Done with coccinelle.

@replace_rule@
expression e;
@@

-e == NULL
+ !e

---
 drivers/staging/iio/accel/lis3l02dq_ring.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/accel/lis3l02dq_ring.c +3 -3
index e6101bb..677774f 100644
@@ -119,7 +119,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
 				       indio_dev->masklength);
 
 	rx_array = kcalloc(4, scan_count, GFP_KERNEL);
-	if (rx_array == NULL)
+	if (!rx_array)
 		return -ENOMEM;
 	ret = lis3l02dq_read_all(indio_dev, rx_array);
 	if (ret < 0) {
@@ -142,7 +142,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
 	char *data;
 
 	data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
-	if (data == NULL)
+	if (!data)
 		goto done;
 
 	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
@@ -410,7 +410,7 @@ int lis3l02dq_configure_buffer(struct iio_dev *indio_dev)
 						 "lis3l02dq_consumer%d",
 						 indio_dev->id);
 
-	if (indio_dev->pollfunc == NULL) {
+	if (!indio_dev->pollfunc) {
 		ret = -ENOMEM;
 		goto error_iio_sw_rb_free;
 	}
Signature · 1 line
1.9.1
#8 lore raw
In reply to Cristina Opriceana
Quoted 10 lines · Cristina Opriceana

This patchet removes explicit NULL comparison from the iio drivers.

Cristina Opriceana (7):
Staging: iio: Simplify NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison
Staging: iio: Remove explicit NULL comparison

Here you need to add a specific tag for each commit message.

e.g staging: iio: iio_simple_dummy: Simplify NULL comparison

thanks,
Daniel.