public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Dave Penkler <dpenkler@gmail.com>
To: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Cc: Dave Penkler <dpenkler@gmail.com>
Subject: [PATCH 04/17] staging: gpib: cec_gpib console messaging cleanup
Date: Fri, 14 Feb 2025 12:46:55 +0100	[thread overview]
Message-ID: <20250214114708.28947-5-dpenkler@gmail.com> (raw)
In-Reply-To: <20250214114708.28947-1-dpenkler@gmail.com>

Enable module name to be printed in pr_xxx and dev_xxx
Use DRV_NAME defined as KBUILD_MODNAME instead of hard coded
string "cec_gpib" in pci_driver struct.

Remove "cec_gpib:" string prefix in messages since module name
printing is enabled.

Change pr_err to dev_err where possible.

Return consistent error codes with error messages:
   -EBUSY when resources are busy
   -ENODEV when device is not present
   -EIO for others.

Signed-off-by: Dave Penkler <dpenkler@gmail.com>
---
 drivers/staging/gpib/cec/cec_gpib.c | 32 +++++++++++++++--------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/gpib/cec/cec_gpib.c b/drivers/staging/gpib/cec/cec_gpib.c
index 18933223711e..8f2b4b46a446 100644
--- a/drivers/staging/gpib/cec/cec_gpib.c
+++ b/drivers/staging/gpib/cec/cec_gpib.c
@@ -4,6 +4,10 @@
  *   copyright            : (C) 2002 by Frank Mori Hess
  ***************************************************************************/
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
 #include "cec.h"
 #include <linux/pci.h>
 #include <linux/io.h>
@@ -284,31 +288,29 @@ static int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config
 			break;
 	}
 	if (!cec_priv->pci_device) {
-		pr_err("gpib: no cec PCI board found\n");
-		return -1;
+		dev_err(board->gpib_dev, "no cec PCI board found\n");
+		return -ENODEV;
 	}
 
 	if (pci_enable_device(cec_priv->pci_device)) {
-		pr_err("error enabling pci device\n");
-		return -1;
+		dev_err(board->gpib_dev, "error enabling pci device\n");
+		return -EIO;
 	}
 
 	if (pci_request_regions(cec_priv->pci_device, "cec-gpib"))
-		return -1;
+		return -EBUSY;
 
 	cec_priv->plx_iobase = pci_resource_start(cec_priv->pci_device, 1);
-	pr_info(" plx9050 base address 0x%lx\n", cec_priv->plx_iobase);
-	nec_priv->iobase = pci_resource_start(cec_priv->pci_device, 3);
-	pr_info(" nec7210 base address 0x%x\n", nec_priv->iobase);
+		nec_priv->iobase = pci_resource_start(cec_priv->pci_device, 3);
 
 	isr_flags |= IRQF_SHARED;
-	if (request_irq(cec_priv->pci_device->irq, cec_interrupt, isr_flags, "pci-gpib", board)) {
-		pr_err("gpib: can't request IRQ %d\n", cec_priv->pci_device->irq);
-		return -1;
+	if (request_irq(cec_priv->pci_device->irq, cec_interrupt, isr_flags, DRV_NAME, board)) {
+		dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", cec_priv->pci_device->irq);
+		return -EBUSY;
 	}
 	cec_priv->irq = cec_priv->pci_device->irq;
 	if (gpib_request_pseudo_irq(board, cec_interrupt)) {
-		pr_err("cec: failed to allocate pseudo irq\n");
+		dev_err(board->gpib_dev, "failed to allocate pseudo irq\n");
 		return -1;
 	}
 	cec_init(cec_priv, board);
@@ -355,7 +357,7 @@ static const struct pci_device_id cec_pci_table[] = {
 MODULE_DEVICE_TABLE(pci, cec_pci_table);
 
 static struct pci_driver cec_pci_driver = {
-	.name = "cec_gpib",
+	.name = DRV_NAME,
 	.id_table = cec_pci_table,
 	.probe = &cec_pci_probe
 };
@@ -366,13 +368,13 @@ static int __init cec_init_module(void)
 
 	result = pci_register_driver(&cec_pci_driver);
 	if (result) {
-		pr_err("cec_gpib: pci_register_driver failed: error = %d\n", result);
+		pr_err("pci_register_driver failed: error = %d\n", result);
 		return result;
 	}
 
 	result = gpib_register_driver(&cec_pci_interface, THIS_MODULE);
 	if (result) {
-		pr_err("cec_gpib: gpib_register_driver failed: error = %d\n", result);
+		pr_err("gpib_register_driver failed: error = %d\n", result);
 		return result;
 	}
 
-- 
2.48.1


  parent reply	other threads:[~2025-02-14 11:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14 11:46 [PATCH 00/17] staging: gpib: Console messaging cleanup Dave Penkler
2025-02-14 11:46 ` [PATCH 01/17] staging: gpib: agilent pci console " Dave Penkler
2025-02-14 11:46 ` [PATCH 02/17] staging: gpib: agilent usb " Dave Penkler
2025-02-14 11:46 ` [PATCH 03/17] staging: gpib: cb7210 " Dave Penkler
2025-02-14 11:46 ` Dave Penkler [this message]
2025-02-14 11:46 ` [PATCH 05/17] staging: gpib: common core " Dave Penkler
2025-02-14 11:46 ` [PATCH 06/17] staging: gpib: fluke " Dave Penkler
2025-02-14 11:46 ` [PATCH 07/17] staging: gpib: fmh " Dave Penkler
2025-02-14 11:46 ` [PATCH 08/17] staging: gpib: gpio bitbang " Dave Penkler
2025-02-14 11:47 ` [PATCH 09/17] staging: gpib: hp82335 " Dave Penkler
2025-02-14 11:47 ` [PATCH 10/17] staging: gpib: hp82341 " Dave Penkler
2025-02-14 11:47 ` [PATCH 11/17] staging: gpib: ines " Dave Penkler
2025-02-14 11:47 ` [PATCH 12/17] staging: gpib: lpvo " Dave Penkler
2025-02-14 11:47 ` [PATCH 13/17] staging: gpib: nec7210 " Dave Penkler
2025-02-14 11:47 ` [PATCH 14/17] staging: gpib: ni_usb " Dave Penkler
2025-02-14 11:47 ` [PATCH 15/17] staging: gpib: pc2 " Dave Penkler
2025-02-14 11:47 ` [PATCH 16/17] staging: gpib: tms9914 " Dave Penkler
2025-02-14 11:47 ` [PATCH 17/17] staging: gpib: tnt4882 " Dave Penkler
2025-02-19 15:48 ` [PATCH 00/17] staging: gpib: Console " Greg KH
2025-02-20  8:55   ` Dave Penkler
2025-02-20  9:19     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250214114708.28947-5-dpenkler@gmail.com \
    --to=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox