Skip to contentSkip to conversation

iio: frequency: Fix checkpatch warnings

PATCH In review Roberta Dobrescu 5 participants 17 messages Dec 16, 2014 – Dec 26, 2014

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/3 iio: frequency: Remove 'out of memory' message

In reply to Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
 drivers/iio/frequency/adf4350.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +1 -3
index 63a25d9..2b301eb 100644
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
 	int ret;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		dev_err(dev, "could not allocate memory for platform data\n");
+	if (!pdata)
 		return NULL;
-	}
 
 	strncpy(&pdata->name[0], np->name, SPI_NAME_SIZE - 1);
 
Signature · 1 line
1.9.1
#11 lore raw

PATCH 2/3 iio: frequency: Remove unnecessary braces around single statement block

In reply to Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: braces {} are not necessary for single statement blocks

---
 drivers/iio/frequency/adf4350.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/frequency/adf4350.c +1 -2
index 2b301eb..10a0dfc 100644
@@ -611,9 +611,8 @@ static int adf4350_remove(struct spi_device *spi)
 	if (st->clk)
 		clk_disable_unprepare(st->clk);
 
-	if (!IS_ERR(reg)) {
+	if (!IS_ERR(reg))
 		regulator_disable(reg);
-	}
 
 	return 0;
 }
Signature · 1 line
1.9.1
#15 lore raw

PATCH 3/3 iio: frequency: Use usleep_range instead of msleep

In reply to Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: msleep < 20ms can sleep for up to 20ms

---
 drivers/iio/frequency/ad9523.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/frequency/ad9523.c +1 -1
index 7c5245d..2e41ca5 100644
@@ -445,7 +445,7 @@ static int ad9523_store_eeprom(struct iio_dev *indio_dev)
 
 	tmp = 4;
 	do {
-		msleep(16);
+		usleep_range(16000, 17000);
 		ret = ad9523_read(indio_dev,
 				  AD9523_EEPROM_DATA_XFER_STATUS);
 		if (ret < 0)
Signature · 1 line
1.9.1
#0 lore raw

cover iio: frequency: Fix checkpatch warnings

This patchset fixes warnings detected using checkpatch.pl, such as: useless 'out of memory' message, unnecessary braces around single statement block, inadequate usage of msleep function.

Roberta Dobrescu (3):
iio: frequency: Remove 'out of memory' message
iio: frequency: Remove unnecessary braces around single statement block
iio: frequency: Use usleep_range instead of msleep

 drivers/iio/frequency/ad9523.c  | 2 +-
 drivers/iio/frequency/adf4350.c | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

In reply to Roberta Dobrescu
Quoted 4 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Quoted 27 lines
---
 drivers/iio/frequency/adf4350.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +1 -4
index 63a25d9..2b301eb 100644
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
        int ret;
 
        pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform data\n");
+       if (!pdata)
                return NULL;
-       }
 
        strncpy(&pdata->name[0], np->name, SPI_NAME_SIZE - 1);
 
--

1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 2/3
#12 lore raw

Re: [PATCH 2/3] iio: frequency: Remove unnecessary braces around single statement block

In reply to Roberta Dobrescu
Quoted 4 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: braces {} are not necessary for single statement blocks

Quoted 26 lines
---
 drivers/iio/frequency/adf4350.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/frequency/adf4350.c +1 -3
index 2b301eb..10a0dfc 100644
@@ -611,9 +611,8 @@ static int adf4350_remove(struct spi_device *spi)
        if (st->clk)
                clk_disable_unprepare(st->clk);
 
-       if (!IS_ERR(reg)) {
+       if (!IS_ERR(reg))
                regulator_disable(reg);
-       }
 
        return 0;
 }
--

1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw

Re: [PATCH 3/3] iio: frequency: Use usleep_range instead of msleep

In reply to Roberta Dobrescu
Quoted 13 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: msleep < 20ms can sleep for up to 20ms

---
  drivers/iio/frequency/ad9523.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/frequency/ad9523.c +0 -0
index 7c5245d..2e41ca5 100644

drivers/iio/frequency/ad9523.c static int ad9523_store_eeprom(struct iio_dev *indio_dev) · line 448

Quoted 5 lines
drivers/iio/frequency/ad9523.c +1 -1
@@ -445,7 +445,7 @@ static int ad9523_store_eeprom(struct iio_dev *indio_dev)
 
  	tmp = 4;
  	do {
-		msleep(16);
+		usleep_range(16000, 17000);

I don't think this is exactly timing critical, things will work fine if this sleeps a bit longer. If you want to silence the warning for the sake of silencing the warning, maybe just replace it with a msleep(20).

Quoted 4 lines
drivers/iio/frequency/ad9523.c +0 -0
  		ret = ad9523_read(indio_dev,
  				  AD9523_EEPROM_DATA_XFER_STATUS);
  		if (ret < 0)
#4 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

In reply to Roberta Dobrescu

Roberta Dobrescu schrieb am 16.12.2014 um 10:11:

Quoted 2 lines

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Hi Roberta,
I think this is slightly more complex. This function is used in adf4350_probe():

	if (spi->dev.of_node) {
		pdata = adf4350_parse_dt(&spi->dev);
		if (pdata == NULL)
			return -EINVAL;

Since pdata will only be NULL in the case, where you dropped the error message, I think the EINVAL here should be changed to ENOMEM as well.

Quoted 23 lines
---
 drivers/iio/frequency/adf4350.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +1 -3
index 63a25d9..2b301eb 100644
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
 	int ret;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		dev_err(dev, "could not allocate memory for platform data\n");
+	if (!pdata)
 		return NULL;
-	}
 
 	strncpy(&pdata->name[0], np->name, SPI_NAME_SIZE - 1);
 
#5 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

In reply to Roberta Dobrescu
Quoted 13 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
 drivers/iio/frequency/adf4350.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +0 -0
index 63a25d9..2b301eb 100644

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 392

Quoted 9 lines
drivers/iio/frequency/adf4350.c +1 -3
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
        int ret;
 
        pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform data\n");
+       if (!pdata)
                return NULL;
-       }
 

Based on Harmut's review we can return ERR_PTR(-ENOMEM) here and then use IS_ERR and PTR_ERR inside adf4350_probe()

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 394

Quoted 2 lines
drivers/iio/frequency/adf4350.c +0 -0
        strncpy(&pdata->name[0], np->name, SPI_NAME_SIZE - 1);
 

thanks,
Daniel.

#6 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

Quoted 17 lines · Daniel Baluta
Quoted 15 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
  drivers/iio/frequency/adf4350.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +0 -0
index 63a25d9..2b301eb 100644
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
         int ret;
 
Quoted 9 lines

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 392

Quoted 7 lines
drivers/iio/frequency/adf4350.c +1 -3
         pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform data\n");
+       if (!pdata)
                 return NULL;
-       }
 

Based on Harmut's review we can return ERR_PTR(-ENOMEM) here and then use IS_ERR and PTR_ERR inside adf4350_probe()

This patch is fine as it is. It removes the redundant error message. Every thing else should be done in a second patch.

#7 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

Quoted 34 lines · Lars-Peter Clausen
Quoted 21 lines · Daniel Baluta
Quoted 18 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
  drivers/iio/frequency/adf4350.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +0 -0
index 63a25d9..2b301eb 100644
@@ -387,10 +387,8 @@ static struct adf4350_platform_data
 *adf4350_parse_dt(struct device *dev)
         int ret;
 
Quoted 10 lines

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 392

Quoted 8 lines
drivers/iio/frequency/adf4350.c +1 -3
         pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform
 data\n");
+       if (!pdata)
                 return NULL;
-       }
 

Based on Harmut's review we can return ERR_PTR(-ENOMEM) here and then use IS_ERR and PTR_ERR inside adf4350_probe()

Quoted 2 lines

This patch is fine as it is. It removes the redundant error message. Every thing else should be done in a second patch.

That's better, indeed.

Daniel.

#8 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

In reply to Lars-Peter Clausen

Lars-Peter Clausen schrieb am 23.12.2014 um 10:07:

Quoted 28 lines · Daniel Baluta
Quoted 17 lines
Quoted 15 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
  drivers/iio/frequency/adf4350.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +0 -0
index 63a25d9..2b301eb 100644
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
         int ret;
 
Quoted 9 lines

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 392

Quoted 7 lines
drivers/iio/frequency/adf4350.c +1 -3
         pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform data\n");
+       if (!pdata)
                 return NULL;
-       }
 

Based on Harmut's review we can return ERR_PTR(-ENOMEM) here and then use IS_ERR and PTR_ERR inside adf4350_probe()

Quoted 2 lines

This patch is fine as it is. It removes the redundant error message. Every thing else should be done in a second patch.

I can't follow on this one. From what I see, if memory allocation fails here, we will get an appropriate error message here, and _probe will pass up -EINVAL, causing a misleading error message. Where do you see redundancy?

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

Quoted 29 lines · Hartmut Knaack

Lars-Peter Clausen schrieb am 23.12.2014 um 10:07:

Quoted 28 lines · Daniel Baluta
Quoted 26 lines
Quoted 13 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
   drivers/iio/frequency/adf4350.c | 4 +---
   1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +0 -0
index 63a25d9..2b301eb 100644

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 392

Quoted 9 lines
drivers/iio/frequency/adf4350.c +1 -3
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
          int ret;
 
          pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform data\n");
+       if (!pdata)
                  return NULL;
-       }
 

Based on Harmut's review we can return ERR_PTR(-ENOMEM) here and then use IS_ERR and PTR_ERR inside adf4350_probe()

Quoted 6 lines
Quoted 2 lines

This patch is fine as it is. It removes the redundant error message. Every thing else should be done in a second patch.

I can't follow on this one. From what I see, if memory allocation fails here, we will get an appropriate error message here, and _probe will pass up -EINVAL, causing a misleading error message. Where do you see redundancy?

Unless you pass __GFP_NOWARN to k*alloc it will print a error message on its own if the allocation fails.

- Lars

maintainer
#10 lore raw

Re: [PATCH 1/3] iio: frequency: Remove 'out of memory' message

Quoted 30 lines · Lars-Peter Clausen
Quoted 29 lines · Hartmut Knaack

Lars-Peter Clausen schrieb am 23.12.2014 um 10:07:

Quoted 28 lines · Daniel Baluta
Quoted 26 lines
Quoted 13 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
   drivers/iio/frequency/adf4350.c | 4 +---
   1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/frequency/adf4350.c +0 -0
index 63a25d9..2b301eb 100644

drivers/iio/frequency/adf4350.c static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev) · line 392

Quoted 9 lines
drivers/iio/frequency/adf4350.c +1 -3
@@ -387,10 +387,8 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
          int ret;
 
          pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(dev, "could not allocate memory for platform data\n");
+       if (!pdata)
                  return NULL;
-       }
 

Based on Harmut's review we can return ERR_PTR(-ENOMEM) here and then use IS_ERR and PTR_ERR inside adf4350_probe()

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

This patch is fine as it is. It removes the redundant error message. Every thing else should be done in a second patch.

I can't follow on this one. From what I see, if memory allocation fails here, we will get an appropriate error message here, and _probe will pass up -EINVAL, causing a misleading error message. Where do you see redundancy?

Unless you pass __GFP_NOWARN to k*alloc it will print a error message on its own if the allocation fails.

Yes, separate issues - be it the case that they both want fixing. Anyhow, have applied this patch to the togreg branch of iio.git

Thanks

maintainer
#14 lore raw

Re: [PATCH 2/3] iio: frequency: Remove unnecessary braces around single statement block

In reply to Lars-Peter Clausen
Quoted 8 lines · Lars-Peter Clausen
Quoted 4 lines · Roberta Dobrescu

This patch fixes the following checkpatch.pl warning:
WARNING: braces {} are not necessary for single statement blocks

Applied to the togreg branch of iio.git - initially pushed out as testing etc etc.