Skip to contentSkip to conversation

net: alacritech: Switch to use dev_err_probe()

PATCH Applied Yang Ruibin 4 participants 4 messages Aug 28, 2024 – Aug 30, 2024

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

PATCH 1/1 net: alacritech: Switch to use dev_err_probe()

use dev_err_probe() instead of dev_err() to simplify the error path and standardize the format of the error code.

---
 drivers/net/ethernet/alacritech/slicoss.c | 34 ++++++++++-------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/net/ethernet/alacritech/slicoss.c +14 -20
index 78231c852..65919ace0 100644
@@ -1051,11 +1051,9 @@ static int slic_load_rcvseq_firmware(struct slic_device *sdev)
 	file = (sdev->model == SLIC_MODEL_OASIS) ?  SLIC_RCV_FIRMWARE_OASIS :
 						    SLIC_RCV_FIRMWARE_MOJAVE;
 	err = request_firmware(&fw, file, &sdev->pdev->dev);
-	if (err) {
-		dev_err(&sdev->pdev->dev,
+	if (err)
+		return dev_err_probe(&sdev->pdev->dev, err,
 			"failed to load receive sequencer firmware %s\n", file);
-		return err;
-	}
 	/* Do an initial sanity check concerning firmware size now. A further
 	 * check follows below.
 	 */
@@ -1126,10 +1124,9 @@ static int slic_load_firmware(struct slic_device *sdev)
 	file = (sdev->model == SLIC_MODEL_OASIS) ?  SLIC_FIRMWARE_OASIS :
 						    SLIC_FIRMWARE_MOJAVE;
 	err = request_firmware(&fw, file, &sdev->pdev->dev);
-	if (err) {
-		dev_err(&sdev->pdev->dev, "failed to load firmware %s\n", file);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&sdev->pdev->dev, err,
+				"failed to load firmware %s\n", file);
 	/* Do an initial sanity check concerning firmware size now. A further
 	 * check follows below.
 	 */
@@ -1678,17 +1675,15 @@ static int slic_init(struct slic_device *sdev)
 	slic_card_reset(sdev);
 
 	err = slic_load_firmware(sdev);
-	if (err) {
-		dev_err(&sdev->pdev->dev, "failed to load firmware\n");
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&sdev->pdev->dev, err,
+			"failed to load firmware\n");
 
 	/* we need the shared memory to read EEPROM so set it up temporarily */
 	err = slic_init_shmem(sdev);
-	if (err) {
-		dev_err(&sdev->pdev->dev, "failed to init shared memory\n");
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&sdev->pdev->dev, err,
+			"failed to init shared memory\n");
 
 	err = slic_read_eeprom(sdev);
 	if (err) {
@@ -1741,10 +1736,9 @@ static int slic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	int err;
 
 	err = pci_enable_device(pdev);
-	if (err) {
-		dev_err(&pdev->dev, "failed to enable PCI device\n");
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+			"failed to enable PCI device\n");
 
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

nit: subject should include "net-next" for changes like this which are cleanups meant for the net-next tree.

On 8/28/2024 5:26 AM, Yang Ruibin wrote:x

Quoted 13 lines

use dev_err_probe() instead of dev_err() to simplify the error path and standardize the format of the error code.

---
 drivers/net/ethernet/alacritech/slicoss.c | 34 ++++++++++-------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/net/ethernet/alacritech/slicoss.c +0 -0
index 78231c852..65919ace0 100644

drivers/net/ethernet/alacritech/slicoss.c static int slic_load_rcvseq_firmware(struct slic_device *sdev) · line 1056

Quoted 8 lines
drivers/net/ethernet/alacritech/slicoss.c +2 -2
@@ -1051,11 +1051,9 @@ static int slic_load_rcvseq_firmware(struct slic_device *sdev)
 	file = (sdev->model == SLIC_MODEL_OASIS) ?  SLIC_RCV_FIRMWARE_OASIS :
 						    SLIC_RCV_FIRMWARE_MOJAVE;
 	err = request_firmware(&fw, file, &sdev->pdev->dev);
-	if (err) {
-		dev_err(&sdev->pdev->dev,
+	if (err)
+		return dev_err_probe(&sdev->pdev->dev, err,
 			"failed to load receive sequencer firmware %s\n", file);

Nice. dev_err_probe also handles some specific behavior for -EPROBE_DEFER, which isn't being used here. That's fine since the custom logic only triggers specifically on -EPROBE_DEFER. It also has custom handling to avoid logging an error message on -ENOMEM. Neat.

#2 lore raw
In reply to Yang Ruibin
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 7 lines · On Wed, 28 Aug 2024 20:26:49 +0800 you wrote:

use dev_err_probe() instead of dev_err() to simplify the error path and standardize the format of the error code.

---
 drivers/net/ethernet/alacritech/slicoss.c | 34 ++++++++++-------------
 1 file changed, 14 insertions(+), 20 deletions(-)

Here is the summary with links:
- [v1] net: alacritech: Switch to use dev_err_probe()

    https://git.kernel.org/netdev/net-next/c/bf4d87f884fe

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#3 lore raw
In reply to Yang Ruibin
Quoted 13 lines · Yang Ruibin

use dev_err_probe() instead of dev_err() to simplify the error path and standardize the format of the error code.

---
 drivers/net/ethernet/alacritech/slicoss.c | 34 ++++++++++-------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/net/ethernet/alacritech/slicoss.c +0 -0
index 78231c852..65919ace0 100644

drivers/net/ethernet/alacritech/slicoss.c static int slic_load_rcvseq_firmware(struct slic_device *sdev) · line 1056

Quoted 8 lines
drivers/net/ethernet/alacritech/slicoss.c +2 -2
@@ -1051,11 +1051,9 @@ static int slic_load_rcvseq_firmware(struct slic_device *sdev)
 	file = (sdev->model == SLIC_MODEL_OASIS) ?  SLIC_RCV_FIRMWARE_OASIS :
 						    SLIC_RCV_FIRMWARE_MOJAVE;
 	err = request_firmware(&fw, file, &sdev->pdev->dev);
-	if (err) {
-		dev_err(&sdev->pdev->dev,
+	if (err)
+		return dev_err_probe(&sdev->pdev->dev, err,
 			"failed to load receive sequencer firmware %s\n", file);

NAK.

Vivo does not understand how deferred probe works or introduces intentionally buggy code.

This must be reverted.

Best regards,
Krzysztof