Skip to contentSkip to conversation

Staging: iio: light: Remove __func__ from dev_err

PATCH In review Bhumika Goyal 2 participants 5 messages Feb 20, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: iio: light: Remove __func__ from dev_err

This patch removes __func__ argument from dev_err as dev_err includes the function name in the log printout, so there is no need to include it manually.
Found using coccinelle:

@a@
expression E;
expression msg;
@@

dev_err(E, msg, __func__);

@script:python b@
e << a.msg;
y;
@@

if(e.find("%s: ") == True):

        m = e.replace("%s: ", "");
        coccinelle.y = m;
elif(e.find("%s ") == True):
        m = e.replace("%s ", "");
        coccinelle.y = m;
else:
        m = e.replace("%s", "");

@c@
expression a.E, a.msg;
identifier b.y;
@@

- dev_err(E, msg, __func__);
+ dev_err(E, y);

---
 drivers/staging/iio/light/tsl2x7x_core.c | 38 +++++++++++---------------------
 1 file changed, 13 insertions(+), 25 deletions(-)
drivers/staging/iio/light/tsl2x7x_core.c +13 -25
index 2a62718..348c9c2 100644
@@ -348,8 +348,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 
 	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
 		/* device is not enabled */
-		dev_err(&chip->client->dev, "%s: device is not enabled\n",
-				__func__);
+		dev_err(&chip->client->dev, "device is not enabled\n");
 		ret = -EBUSY;
 		goto out_unlock;
 	}
@@ -357,14 +356,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	ret = tsl2x7x_i2c_read(chip->client,
 		(TSL2X7X_CMD_REG | TSL2X7X_STATUS), &buf[0]);
 	if (ret < 0) {
-		dev_err(&chip->client->dev,
-			"%s: Failed to read STATUS Reg\n", __func__);
+		dev_err(&chip->client->dev, "Failed to read STATUS Reg\n");
 		goto out_unlock;
 	}
 	/* is data new & valid */
 	if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
-		dev_err(&chip->client->dev,
-			"%s: data not valid yet\n", __func__);
+		dev_err(&chip->client->dev, "data not valid yet\n");
 		ret = chip->als_cur_info.lux; /* return LAST VALUE */
 		goto out_unlock;
 	}
@@ -482,8 +479,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
 	if (mutex_trylock(&chip->prox_mutex) == 0) {
-		dev_err(&chip->client->dev,
-			"%s: Can't get prox mutex\n", __func__);
+		dev_err(&chip->client->dev, "Can't get prox mutex\n");
 		return -EBUSY;
 	}
 
@@ -586,8 +582,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
 	reg_val = i2c_smbus_read_byte(chip->client);
 	if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
 		!= (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
-		dev_err(&chip->client->dev,
-			"%s: failed: ADC not enabled\n", __func__);
+		dev_err(&chip->client->dev, "failed: ADC not enabled\n");
 		return -1;
 	}
 
@@ -602,14 +597,13 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
 	reg_val = i2c_smbus_read_byte(chip->client);
 	if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
 		dev_err(&chip->client->dev,
-			"%s: failed: STATUS - ADC not valid.\n", __func__);
+			"failed: STATUS - ADC not valid.\n");
 		return -ENODATA;
 	}
 
 	lux_val = tsl2x7x_get_lux(indio_dev);
 	if (lux_val < 0) {
-		dev_err(&chip->client->dev,
-		"%s: failed to get lux\n", __func__);
+		dev_err(&chip->client->dev, "failed to get lux\n");
 		return lux_val;
 	}
 
@@ -701,8 +695,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	ret = i2c_smbus_write_byte_data(chip->client,
 		TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
 	if (ret < 0) {
-		dev_err(&chip->client->dev,
-			"%s: failed on CNTRL reg.\n", __func__);
+		dev_err(&chip->client->dev, "failed on CNTRL reg.\n");
 		return ret;
 	}
 
@@ -729,8 +722,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	ret = i2c_smbus_write_byte_data(chip->client,
 			TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
 	if (ret < 0) {
-		dev_err(&chip->client->dev,
-			"%s: failed on 2nd CTRL reg.\n", __func__);
+		dev_err(&chip->client->dev, "failed on 2nd CTRL reg.\n");
 		return ret;
 	}
 
@@ -749,8 +741,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 			(TSL2X7X_CMD_REG | TSL2X7X_CNTRL), reg_val);
 		if (ret < 0)
 			dev_err(&chip->client->dev,
-				"%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
-				__func__);
+				"failed in tsl2x7x_IOCTL_INT_SET.\n");
 
 		/* Clear out any initial interrupts  */
 		ret = i2c_smbus_write_byte(chip->client,
@@ -758,8 +749,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 			TSL2X7X_CMD_PROXALS_INT_CLR);
 		if (ret < 0) {
 			dev_err(&chip->client->dev,
-				"%s: Failed to clear Int status\n",
-				__func__);
+				"Failed to clear Int status\n");
 		return ret;
 		}
 	}
@@ -1919,8 +1909,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 						"TSL2X7X_event",
 						indio_dev);
 		if (ret) {
-			dev_err(&clientp->dev,
-				"%s: irq request failed", __func__);
+			dev_err(&clientp->dev, "irq request failed");
 			return ret;
 		}
 	}
@@ -1932,8 +1921,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 
 	ret = iio_device_register(indio_dev);
 	if (ret) {
-		dev_err(&clientp->dev,
-			"%s: iio registration failed\n", __func__);
+		dev_err(&clientp->dev, "iio registration failed\n");
 		return ret;
 	}
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · Bhumika Goyal

This patch removes __func__ argument from dev_err as dev_err includes the function name in the log printout, so there is no need to include it manually.

No, it doesn't. The function name should be left there if it is useful.

julia

Quoted 174 lines

Found using coccinelle:

@a@
expression E;
expression msg;
@@

dev_err(E, msg, __func__);

@script:python b@
e << a.msg;
y;
@@

if(e.find("%s: ") == True):

        m = e.replace("%s: ", "");
        coccinelle.y = m;
elif(e.find("%s ") == True):
        m = e.replace("%s ", "");
        coccinelle.y = m;
else:
        m = e.replace("%s", "");

@c@
expression a.E, a.msg;
identifier b.y;
@@

- dev_err(E, msg, __func__);
+ dev_err(E, y);

---
 drivers/staging/iio/light/tsl2x7x_core.c | 38 +++++++++++---------------------
 1 file changed, 13 insertions(+), 25 deletions(-)
drivers/staging/iio/light/tsl2x7x_core.c +13 -26
index 2a62718..348c9c2 100644
@@ -348,8 +348,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 
 	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
 		/* device is not enabled */
-		dev_err(&chip->client->dev, "%s: device is not enabled\n",
-				__func__);
+		dev_err(&chip->client->dev, "device is not enabled\n");
 		ret = -EBUSY;
 		goto out_unlock;
 	}
@@ -357,14 +356,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	ret = tsl2x7x_i2c_read(chip->client,
 		(TSL2X7X_CMD_REG | TSL2X7X_STATUS), &buf[0]);
 	if (ret < 0) {
-		dev_err(&chip->client->dev,
-			"%s: Failed to read STATUS Reg\n", __func__);
+		dev_err(&chip->client->dev, "Failed to read STATUS Reg\n");
 		goto out_unlock;
 	}
 	/* is data new & valid */
 	if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
-		dev_err(&chip->client->dev,
-			"%s: data not valid yet\n", __func__);
+		dev_err(&chip->client->dev, "data not valid yet\n");
 		ret = chip->als_cur_info.lux; /* return LAST VALUE */
 		goto out_unlock;
 	}
@@ -482,8 +479,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
 	if (mutex_trylock(&chip->prox_mutex) == 0) {
-		dev_err(&chip->client->dev,
-			"%s: Can't get prox mutex\n", __func__);
+		dev_err(&chip->client->dev, "Can't get prox mutex\n");
 		return -EBUSY;
 	}
 
@@ -586,8 +582,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
 	reg_val = i2c_smbus_read_byte(chip->client);
 	if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
 		!= (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
-		dev_err(&chip->client->dev,
-			"%s: failed: ADC not enabled\n", __func__);
+		dev_err(&chip->client->dev, "failed: ADC not enabled\n");
 		return -1;
 	}
 
@@ -602,14 +597,13 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
 	reg_val = i2c_smbus_read_byte(chip->client);
 	if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
 		dev_err(&chip->client->dev,
-			"%s: failed: STATUS - ADC not valid.\n", __func__);
+			"failed: STATUS - ADC not valid.\n");
 		return -ENODATA;
 	}
 
 	lux_val = tsl2x7x_get_lux(indio_dev);
 	if (lux_val < 0) {
-		dev_err(&chip->client->dev,
-		"%s: failed to get lux\n", __func__);
+		dev_err(&chip->client->dev, "failed to get lux\n");
 		return lux_val;
 	}
 
@@ -701,8 +695,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	ret = i2c_smbus_write_byte_data(chip->client,
 		TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
 	if (ret < 0) {
-		dev_err(&chip->client->dev,
-			"%s: failed on CNTRL reg.\n", __func__);
+		dev_err(&chip->client->dev, "failed on CNTRL reg.\n");
 		return ret;
 	}
 
@@ -729,8 +722,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	ret = i2c_smbus_write_byte_data(chip->client,
 			TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
 	if (ret < 0) {
-		dev_err(&chip->client->dev,
-			"%s: failed on 2nd CTRL reg.\n", __func__);
+		dev_err(&chip->client->dev, "failed on 2nd CTRL reg.\n");
 		return ret;
 	}
 
@@ -749,8 +741,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 			(TSL2X7X_CMD_REG | TSL2X7X_CNTRL), reg_val);
 		if (ret < 0)
 			dev_err(&chip->client->dev,
-				"%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
-				__func__);
+				"failed in tsl2x7x_IOCTL_INT_SET.\n");
 
 		/* Clear out any initial interrupts  */
 		ret = i2c_smbus_write_byte(chip->client,
@@ -758,8 +749,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 			TSL2X7X_CMD_PROXALS_INT_CLR);
 		if (ret < 0) {
 			dev_err(&chip->client->dev,
-				"%s: Failed to clear Int status\n",
-				__func__);
+				"Failed to clear Int status\n");
 		return ret;
 		}
 	}
@@ -1919,8 +1909,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 						"TSL2X7X_event",
 						indio_dev);
 		if (ret) {
-			dev_err(&clientp->dev,
-				"%s: irq request failed", __func__);
+			dev_err(&clientp->dev, "irq request failed");
 			return ret;
 		}
 	}
@@ -1932,8 +1921,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 
 	ret = iio_device_register(indio_dev);
 	if (ret) {
-		dev_err(&clientp->dev,
-			"%s: iio registration failed\n", __func__);
+		dev_err(&clientp->dev, "iio registration failed\n");
 		return ret;
 	}
 
--

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/1455980111-15231-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 4 lines · Julia Lawall

On Sat, 20 Feb 2016, Bhumika Goyal wrote:

Quoted 8 lines
Quoted 3 lines

This patch removes __func__ argument from dev_err as dev_err includes the function name in the log printout, so there is no need to include it manually.

No, it doesn't. The function name should be left there if it is useful.

julia

Ok Julia and thanks for the feedback . I thought that the function name is only useful for debugging and should not be displayed in normal module message.
Also I have a doubt because I saw some of the patches sent by other developers where they have removed __func__ from dev_err so why is removing __func__ not helping here?

Thanks
Bhumika

Quoted 174 lines
Quoted 174 lines

Found using coccinelle:

@a@
expression E;
expression msg;
@@

dev_err(E, msg, __func__);

@script:python b@
e << a.msg;
y;
@@

if(e.find("%s: ") == True):

        m = e.replace("%s: ", "");
        coccinelle.y = m;
elif(e.find("%s ") == True):
        m = e.replace("%s ", "");
        coccinelle.y = m;
else:
        m = e.replace("%s", "");

@c@
expression a.E, a.msg;
identifier b.y;
@@

- dev_err(E, msg, __func__);
+ dev_err(E, y);

---
 drivers/staging/iio/light/tsl2x7x_core.c | 38 +++++++++++---------------------
 1 file changed, 13 insertions(+), 25 deletions(-)
drivers/staging/iio/light/tsl2x7x_core.c +13 -26
index 2a62718..348c9c2 100644
@@ -348,8 +348,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 
      if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
              /* device is not enabled */
-             dev_err(&chip->client->dev, "%s: device is not enabled\n",
-                             __func__);
+             dev_err(&chip->client->dev, "device is not enabled\n");
              ret = -EBUSY;
              goto out_unlock;
      }
@@ -357,14 +356,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
      ret = tsl2x7x_i2c_read(chip->client,
              (TSL2X7X_CMD_REG | TSL2X7X_STATUS), &buf[0]);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: Failed to read STATUS Reg\n", __func__);
+             dev_err(&chip->client->dev, "Failed to read STATUS Reg\n");
              goto out_unlock;
      }
      /* is data new & valid */
      if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
-             dev_err(&chip->client->dev,
-                     "%s: data not valid yet\n", __func__);
+             dev_err(&chip->client->dev, "data not valid yet\n");
              ret = chip->als_cur_info.lux; /* return LAST VALUE */
              goto out_unlock;
      }
@@ -482,8 +479,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
      struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
      if (mutex_trylock(&chip->prox_mutex) == 0) {
-             dev_err(&chip->client->dev,
-                     "%s: Can't get prox mutex\n", __func__);
+             dev_err(&chip->client->dev, "Can't get prox mutex\n");
              return -EBUSY;
      }
 
@@ -586,8 +582,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
      reg_val = i2c_smbus_read_byte(chip->client);
      if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
              != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
-             dev_err(&chip->client->dev,
-                     "%s: failed: ADC not enabled\n", __func__);
+             dev_err(&chip->client->dev, "failed: ADC not enabled\n");
              return -1;
      }
 
@@ -602,14 +597,13 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
      reg_val = i2c_smbus_read_byte(chip->client);
      if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
              dev_err(&chip->client->dev,
-                     "%s: failed: STATUS - ADC not valid.\n", __func__);
+                     "failed: STATUS - ADC not valid.\n");
              return -ENODATA;
      }
 
      lux_val = tsl2x7x_get_lux(indio_dev);
      if (lux_val < 0) {
-             dev_err(&chip->client->dev,
-             "%s: failed to get lux\n", __func__);
+             dev_err(&chip->client->dev, "failed to get lux\n");
              return lux_val;
      }
 
@@ -701,8 +695,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
      ret = i2c_smbus_write_byte_data(chip->client,
              TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: failed on CNTRL reg.\n", __func__);
+             dev_err(&chip->client->dev, "failed on CNTRL reg.\n");
              return ret;
      }
 
@@ -729,8 +722,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
      ret = i2c_smbus_write_byte_data(chip->client,
                      TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: failed on 2nd CTRL reg.\n", __func__);
+             dev_err(&chip->client->dev, "failed on 2nd CTRL reg.\n");
              return ret;
      }
 
@@ -749,8 +741,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                      (TSL2X7X_CMD_REG | TSL2X7X_CNTRL), reg_val);
              if (ret < 0)
                      dev_err(&chip->client->dev,
-                             "%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
-                             __func__);
+                             "failed in tsl2x7x_IOCTL_INT_SET.\n");
 
              /* Clear out any initial interrupts  */
              ret = i2c_smbus_write_byte(chip->client,
@@ -758,8 +749,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                      TSL2X7X_CMD_PROXALS_INT_CLR);
              if (ret < 0) {
                      dev_err(&chip->client->dev,
-                             "%s: Failed to clear Int status\n",
-                             __func__);
+                             "Failed to clear Int status\n");
              return ret;
              }
      }
@@ -1919,8 +1909,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
                                              "TSL2X7X_event",
                                              indio_dev);
              if (ret) {
-                     dev_err(&clientp->dev,
-                             "%s: irq request failed", __func__);
+                     dev_err(&clientp->dev, "irq request failed");
                      return ret;
              }
      }
@@ -1932,8 +1921,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 
      ret = iio_device_register(indio_dev);
      if (ret) {
-             dev_err(&clientp->dev,
-                     "%s: iio registration failed\n", __func__);
+             dev_err(&clientp->dev, "iio registration failed\n");
              return ret;
      }
 
--

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/1455980111-15231-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 14 lines · Bhumika Goyal
Quoted 4 lines · Julia Lawall

On Sat, 20 Feb 2016, Bhumika Goyal wrote:

Quoted 8 lines
Quoted 3 lines

This patch removes __func__ argument from dev_err as dev_err includes the function name in the log printout, so there is no need to include it manually.

No, it doesn't. The function name should be left there if it is useful.

julia

Quoted 6 lines

Ok Julia and thanks for the feedback . I thought that the function name is only useful for debugging and should not be displayed in normal module message.
Also I have a doubt because I saw some of the patches sent by other developers where they have removed __func__ from dev_err so why is removing __func__ not helping here?

Because those patches were actually not so desirable. Sorry about it.

If you think that the function name is not useful in this particular case, then it's fine to drop it, but it's not a general pricuple that it is never useful.

julia

Quoted 186 lines

Thanks
Bhumika

Quoted 167 lines
Quoted 167 lines

Found using coccinelle:

@a@
expression E;
expression msg;
@@

dev_err(E, msg, __func__);

@script:python b@
e << a.msg;
y;
@@

if(e.find("%s: ") == True):

        m = e.replace("%s: ", "");
        coccinelle.y = m;
elif(e.find("%s ") == True):
        m = e.replace("%s ", "");
        coccinelle.y = m;
else:
        m = e.replace("%s", "");

@c@
expression a.E, a.msg;
identifier b.y;
@@

- dev_err(E, msg, __func__);
+ dev_err(E, y);

---
 drivers/staging/iio/light/tsl2x7x_core.c | 38 +++++++++++---------------------
 1 file changed, 13 insertions(+), 25 deletions(-)
drivers/staging/iio/light/tsl2x7x_core.c +13 -26
index 2a62718..348c9c2 100644
@@ -348,8 +348,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 
      if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
              /* device is not enabled */
-             dev_err(&chip->client->dev, "%s: device is not enabled\n",
-                             __func__);
+             dev_err(&chip->client->dev, "device is not enabled\n");
              ret = -EBUSY;
              goto out_unlock;
      }
@@ -357,14 +356,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
      ret = tsl2x7x_i2c_read(chip->client,
              (TSL2X7X_CMD_REG | TSL2X7X_STATUS), &buf[0]);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: Failed to read STATUS Reg\n", __func__);
+             dev_err(&chip->client->dev, "Failed to read STATUS Reg\n");
              goto out_unlock;
      }
      /* is data new & valid */
      if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
-             dev_err(&chip->client->dev,
-                     "%s: data not valid yet\n", __func__);
+             dev_err(&chip->client->dev, "data not valid yet\n");
              ret = chip->als_cur_info.lux; /* return LAST VALUE */
              goto out_unlock;
      }
@@ -482,8 +479,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
      struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
      if (mutex_trylock(&chip->prox_mutex) == 0) {
-             dev_err(&chip->client->dev,
-                     "%s: Can't get prox mutex\n", __func__);
+             dev_err(&chip->client->dev, "Can't get prox mutex\n");
              return -EBUSY;
      }
 
@@ -586,8 +582,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
      reg_val = i2c_smbus_read_byte(chip->client);
      if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
              != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
-             dev_err(&chip->client->dev,
-                     "%s: failed: ADC not enabled\n", __func__);
+             dev_err(&chip->client->dev, "failed: ADC not enabled\n");
              return -1;
      }
 
@@ -602,14 +597,13 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
      reg_val = i2c_smbus_read_byte(chip->client);
      if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
              dev_err(&chip->client->dev,
-                     "%s: failed: STATUS - ADC not valid.\n", __func__);
+                     "failed: STATUS - ADC not valid.\n");
              return -ENODATA;
      }
 
      lux_val = tsl2x7x_get_lux(indio_dev);
      if (lux_val < 0) {
-             dev_err(&chip->client->dev,
-             "%s: failed to get lux\n", __func__);
+             dev_err(&chip->client->dev, "failed to get lux\n");
              return lux_val;
      }
 
@@ -701,8 +695,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
      ret = i2c_smbus_write_byte_data(chip->client,
              TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: failed on CNTRL reg.\n", __func__);
+             dev_err(&chip->client->dev, "failed on CNTRL reg.\n");
              return ret;
      }
 
@@ -729,8 +722,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
      ret = i2c_smbus_write_byte_data(chip->client,
                      TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: failed on 2nd CTRL reg.\n", __func__);
+             dev_err(&chip->client->dev, "failed on 2nd CTRL reg.\n");
              return ret;
      }
 
@@ -749,8 +741,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                      (TSL2X7X_CMD_REG | TSL2X7X_CNTRL), reg_val);
              if (ret < 0)
                      dev_err(&chip->client->dev,
-                             "%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
-                             __func__);
+                             "failed in tsl2x7x_IOCTL_INT_SET.\n");
 
              /* Clear out any initial interrupts  */
              ret = i2c_smbus_write_byte(chip->client,
@@ -758,8 +749,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                      TSL2X7X_CMD_PROXALS_INT_CLR);
              if (ret < 0) {
                      dev_err(&chip->client->dev,
-                             "%s: Failed to clear Int status\n",
-                             __func__);
+                             "Failed to clear Int status\n");
              return ret;
              }
      }
@@ -1919,8 +1909,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
                                              "TSL2X7X_event",
                                              indio_dev);
              if (ret) {
-                     dev_err(&clientp->dev,
-                             "%s: irq request failed", __func__);
+                     dev_err(&clientp->dev, "irq request failed");
                      return ret;
              }
      }
@@ -1932,8 +1921,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 
      ret = iio_device_register(indio_dev);
      if (ret) {
-             dev_err(&clientp->dev,
-                     "%s: iio registration failed\n", __func__);
+             dev_err(&clientp->dev, "iio registration failed\n");
              return ret;
      }
 
--

1.9.1

Quoted 7 lines
Quoted 7 lines

--
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/1455980111-15231-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOH%2B1jEOeWM7pR2bsX3xPxJJUNueUo8T29ODXSkzmqo0n5PLbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
Quoted 25 lines · Julia Lawall
Quoted 14 lines · Bhumika Goyal
Quoted 4 lines · Julia Lawall

On Sat, 20 Feb 2016, Bhumika Goyal wrote:

Quoted 8 lines
Quoted 3 lines

This patch removes __func__ argument from dev_err as dev_err includes the function name in the log printout, so there is no need to include it manually.

No, it doesn't. The function name should be left there if it is useful.

julia

Quoted 6 lines

Ok Julia and thanks for the feedback . I thought that the function name is only useful for debugging and should not be displayed in normal module message.
Also I have a doubt because I saw some of the patches sent by other developers where they have removed __func__ from dev_err so why is removing __func__ not helping here?

Quoted 8 lines

Because those patches were actually not so desirable. Sorry about it.

If you think that the function name is not useful in this particular case, then it's fine to drop it, but it's not a general pricuple that it is never useful.

julia

Thanks for the feedback and I got your point now. Dropping the function name is not a good idea here .

Thanks
Bhumika

Quoted 186 lines
Quoted 186 lines

Thanks
Bhumika

Quoted 167 lines
Quoted 167 lines

Found using coccinelle:

@a@
expression E;
expression msg;
@@

dev_err(E, msg, __func__);

@script:python b@
e << a.msg;
y;
@@

if(e.find("%s: ") == True):

        m = e.replace("%s: ", "");
        coccinelle.y = m;
elif(e.find("%s ") == True):
        m = e.replace("%s ", "");
        coccinelle.y = m;
else:
        m = e.replace("%s", "");

@c@
expression a.E, a.msg;
identifier b.y;
@@

- dev_err(E, msg, __func__);
+ dev_err(E, y);

---
 drivers/staging/iio/light/tsl2x7x_core.c | 38 +++++++++++---------------------
 1 file changed, 13 insertions(+), 25 deletions(-)
drivers/staging/iio/light/tsl2x7x_core.c +13 -26
index 2a62718..348c9c2 100644
@@ -348,8 +348,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 
      if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
              /* device is not enabled */
-             dev_err(&chip->client->dev, "%s: device is not enabled\n",
-                             __func__);
+             dev_err(&chip->client->dev, "device is not enabled\n");
              ret = -EBUSY;
              goto out_unlock;
      }
@@ -357,14 +356,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
      ret = tsl2x7x_i2c_read(chip->client,
              (TSL2X7X_CMD_REG | TSL2X7X_STATUS), &buf[0]);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: Failed to read STATUS Reg\n", __func__);
+             dev_err(&chip->client->dev, "Failed to read STATUS Reg\n");
              goto out_unlock;
      }
      /* is data new & valid */
      if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
-             dev_err(&chip->client->dev,
-                     "%s: data not valid yet\n", __func__);
+             dev_err(&chip->client->dev, "data not valid yet\n");
              ret = chip->als_cur_info.lux; /* return LAST VALUE */
              goto out_unlock;
      }
@@ -482,8 +479,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
      struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
      if (mutex_trylock(&chip->prox_mutex) == 0) {
-             dev_err(&chip->client->dev,
-                     "%s: Can't get prox mutex\n", __func__);
+             dev_err(&chip->client->dev, "Can't get prox mutex\n");
              return -EBUSY;
      }
 
@@ -586,8 +582,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
      reg_val = i2c_smbus_read_byte(chip->client);
      if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
              != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
-             dev_err(&chip->client->dev,
-                     "%s: failed: ADC not enabled\n", __func__);
+             dev_err(&chip->client->dev, "failed: ADC not enabled\n");
              return -1;
      }
 
@@ -602,14 +597,13 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
      reg_val = i2c_smbus_read_byte(chip->client);
      if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
              dev_err(&chip->client->dev,
-                     "%s: failed: STATUS - ADC not valid.\n", __func__);
+                     "failed: STATUS - ADC not valid.\n");
              return -ENODATA;
      }
 
      lux_val = tsl2x7x_get_lux(indio_dev);
      if (lux_val < 0) {
-             dev_err(&chip->client->dev,
-             "%s: failed to get lux\n", __func__);
+             dev_err(&chip->client->dev, "failed to get lux\n");
              return lux_val;
      }
 
@@ -701,8 +695,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
      ret = i2c_smbus_write_byte_data(chip->client,
              TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: failed on CNTRL reg.\n", __func__);
+             dev_err(&chip->client->dev, "failed on CNTRL reg.\n");
              return ret;
      }
 
@@ -729,8 +722,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
      ret = i2c_smbus_write_byte_data(chip->client,
                      TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
      if (ret < 0) {
-             dev_err(&chip->client->dev,
-                     "%s: failed on 2nd CTRL reg.\n", __func__);
+             dev_err(&chip->client->dev, "failed on 2nd CTRL reg.\n");
              return ret;
      }
 
@@ -749,8 +741,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                      (TSL2X7X_CMD_REG | TSL2X7X_CNTRL), reg_val);
              if (ret < 0)
                      dev_err(&chip->client->dev,
-                             "%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
-                             __func__);
+                             "failed in tsl2x7x_IOCTL_INT_SET.\n");
 
              /* Clear out any initial interrupts  */
              ret = i2c_smbus_write_byte(chip->client,
@@ -758,8 +749,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                      TSL2X7X_CMD_PROXALS_INT_CLR);
              if (ret < 0) {
                      dev_err(&chip->client->dev,
-                             "%s: Failed to clear Int status\n",
-                             __func__);
+                             "Failed to clear Int status\n");
              return ret;
              }
      }
@@ -1919,8 +1909,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
                                              "TSL2X7X_event",
                                              indio_dev);
              if (ret) {
-                     dev_err(&clientp->dev,
-                             "%s: irq request failed", __func__);
+                     dev_err(&clientp->dev, "irq request failed");
                      return ret;
              }
      }
@@ -1932,8 +1921,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 
      ret = iio_device_register(indio_dev);
      if (ret) {
-             dev_err(&clientp->dev,
-                     "%s: iio registration failed\n", __func__);
+             dev_err(&clientp->dev, "iio registration failed\n");
              return ret;
      }
 
--

1.9.1

Quoted 7 lines
Quoted 7 lines

--
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/1455980111-15231-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOH%2B1jEOeWM7pR2bsX3xPxJJUNueUo8T29ODXSkzmqo0n5PLbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.