All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
	linux-kernel@vger.kernel.org,
	Nikola Ciprich <nikola.ciprich@linuxbox.cz>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 3/8] parport: Convert to use managed functions pcim_* and devm_*
Date: Fri,  2 Feb 2018 20:39:50 +0200	[thread overview]
Message-ID: <20180202183955.85453-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20180202183955.85453-1-andriy.shevchenko@linux.intel.com>

This makes the error handling much more simpler than open-coding everything
and in addition makes the probe function smaller an tidier.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/parport/parport_serial.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 9689503641dc..ac72ad1cabf5 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -617,27 +617,23 @@ static int parport_serial_pci_probe(struct pci_dev *dev,
 	struct parport_serial_private *priv;
 	int err;
 
-	priv = kzalloc (sizeof *priv, GFP_KERNEL);
+	priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
+
 	pci_set_drvdata (dev, priv);
 
-	err = pci_enable_device (dev);
-	if (err) {
-		kfree (priv);
+	err = pcim_enable_device(dev);
+	if (err)
 		return err;
-	}
 
-	if (parport_register (dev, id)) {
-		kfree (priv);
+	if (parport_register(dev, id))
 		return -ENODEV;
-	}
 
 	if (serial_register (dev, id)) {
 		int i;
 		for (i = 0; i < priv->num_par; i++)
 			parport_pc_unregister_port (priv->port[i]);
-		kfree (priv);
 		return -ENODEV;
 	}
 
@@ -657,7 +653,6 @@ static void parport_serial_pci_remove(struct pci_dev *dev)
 	for (i = 0; i < priv->num_par; i++)
 		parport_pc_unregister_port (priv->port[i]);
 
-	kfree (priv);
 	return;
 }
 
-- 
2.15.1

  parent reply	other threads:[~2018-02-02 18:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 18:39 [PATCH v1 1/8] parport: Add support for BrainBoxes PX272/PX306 MIO card Andy Shevchenko
2018-02-02 18:39 ` [PATCH v1 2/8] parport: PCI core handles power state for us Andy Shevchenko
2018-02-04 16:01   ` Nikola Ciprich
2018-02-02 18:39 ` Andy Shevchenko [this message]
2018-02-04 16:02   ` [PATCH v1 3/8] parport: Convert to use managed functions pcim_* and devm_* Nikola Ciprich
2018-02-02 18:39 ` [PATCH v1 4/8] parport: Don't shadow error codes in ->probe() Andy Shevchenko
2018-02-04 16:02   ` Nikola Ciprich
2018-02-02 18:39 ` [PATCH v1 5/8] parport: Convert printk(KERN_WARN) to dev_warn() Andy Shevchenko
2018-02-04 16:02   ` Nikola Ciprich
2018-02-02 18:39 ` [PATCH v1 6/8] parport: Switch to use module_pci_driver() macro Andy Shevchenko
2018-02-04 16:02   ` Nikola Ciprich
2018-02-02 18:39 ` [PATCH v1 7/8] parport: Sort headers alphabetically Andy Shevchenko
2018-02-04 16:02   ` Nikola Ciprich
2018-02-02 18:39 ` [PATCH v1 8/8] parport: Replace short License header by SPDX identifier Andy Shevchenko
2018-02-04 16:03   ` Nikola Ciprich
2018-02-02 22:07 ` [PATCH v1 1/8] parport: Add support for BrainBoxes PX272/PX306 MIO card Nikola Ciprich

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=20180202183955.85453-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikola.ciprich@linuxbox.cz \
    --cc=sudipm.mukherjee@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.