public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pcmcia/parport_cs: Refactor probe function and improve error logging
@ 2025-10-21 19:00 Biancaa Ramesh
  2025-10-22 14:09 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Biancaa Ramesh @ 2025-10-21 19:00 UTC (permalink / raw)
  To: linux-media; +Cc: awalls, mchehab, linux-kernel, Biancaa Ramesh

- Replaced pr_notice with dev_err for proper kernel error logging.
- Added explicit cleanup of link->priv on failure in probe and config.
- Improved comments and readability in parport_probe() and parport_config().
- Ensured allocation checks are consistent (kzalloc returns checked).
- Minor refactoring for clarity and maintainability.

Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.edu.in>
---
 drivers/parport/parport_cs.c | 38 +++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 8e7e3ac4bb87..c6d3f2ee03f7 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -83,19 +83,35 @@ static void parport_cs_release(struct pcmcia_device *);
 static int parport_probe(struct pcmcia_device *link)
 {
     parport_info_t *info;
+    int ret;
 
-    dev_dbg(&link->dev, "parport_attach()\n");
+    dev_dbg(&link->dev, "parport_probe()\n");
 
-    /* Create new parport device */
+    /* Allocate private driver info */
     info = kzalloc(sizeof(*info), GFP_KERNEL);
-    if (!info) return -ENOMEM;
+    if (!info) {
+        dev_err(&link->dev, "failed to allocate parport_info\n");
+        return -ENOMEM;
+    }
+
     link->priv = info;
     info->p_dev = link;
 
+    /* Enable IRQ and auto IO for configuration */
     link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
 
-    return parport_config(link);
-} /* parport_attach */
+    /* Delegate actual configuration to parport_config() */
+    ret = parport_config(link);
+    if (ret) {
+        dev_err(&link->dev, "parport configuration failed\n");
+        kfree(info);
+        link->priv = NULL;
+        return ret;
+    }
+
+    return 0;
+}
+
 
 static void parport_detach(struct pcmcia_device *link)
 {
@@ -141,10 +157,13 @@ static int parport_config(struct pcmcia_device *link)
 			      link->resource[1]->start,
 			      link->irq, PARPORT_DMA_NONE,
 			      &link->dev, IRQF_SHARED);
-    if (p == NULL) {
-	    pr_notice("parport_cs: parport_pc_probe_port() at 0x%3x, irq %u failed\n",
-		      (unsigned int)link->resource[0]->start, link->irq);
-	goto failed;
+    if (!p) {
+        dev_err(&link->dev,
+            "parport_pc_probe_port() failed at 0x%03x, irq %u\n",
+            (unsigned int)link->resource[0]->start, link->irq);
+        goto failed;
+    }   
+
     }
 
     p->modes |= PARPORT_MODE_PCSPP;
@@ -158,6 +177,7 @@ static int parport_config(struct pcmcia_device *link)
 failed:
 	parport_cs_release(link);
 	kfree(link->priv);
+    link->priv = NULL;
 	return -ENODEV;
 } /* parport_config */
 
-- 
2.43.0


-- 
::DISCLAIMER::

---------------------------------------------------------------------
The 
contents of this e-mail and any attachment(s) are confidential and
intended 
for the named recipient(s) only. Views or opinions, if any,
presented in 
this email are solely those of the author and may not
necessarily reflect 
the views or opinions of SSN Institutions (SSN) or its
affiliates. Any form 
of reproduction, dissemination, copying, disclosure,
modification, 
distribution and / or publication of this message without the
prior written 
consent of authorized representative of SSN is strictly
prohibited. If you 
have received this email in error please delete it and
notify the sender 
immediately.
---------------------------------------------------------------------
Header of this mail should have a valid DKIM signature for the domain 
ssn.edu.in <http://www.ssn.edu.in/>

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-22 20:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 19:00 [PATCH] pcmcia/parport_cs: Refactor probe function and improve error logging Biancaa Ramesh
2025-10-22 14:09 ` kernel test robot
2025-10-22 17:55   ` [PATCH] Subject: [PATCH v2] pcmcia/parport_cs: fix probe function syntax and error handling Biancaa Ramesh
2025-10-22 18:16     ` Markus Elfring
2025-10-22 16:30 ` [PATCH] parport_cs: Refactor probe function and improve error logging Markus Elfring
2025-10-22 20:24 ` [PATCH] pcmcia/parport_cs: " kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox