All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [PATCH] fm801: move to pcim_* and devm_* functions
Date: Wed,  7 Jan 2015 01:40:17 +0200	[thread overview]
Message-ID: <1420587617-28521-1-git-send-email-andy.shevchenko@gmail.com> (raw)

The managed functions allow to get ->probe() and ->remove() simplier.
This patch converts code to use managed functions.

While here remove the dead code and fix the value printed in error
message.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 sound/pci/fm801.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index dcda3c1..2708500 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1178,12 +1178,8 @@ static int snd_fm801_free(struct fm801 *chip)
 		v4l2_device_unregister(&chip->v4l2_dev);
 	}
 #endif
-	if (chip->irq >= 0)
-		free_irq(chip->irq, chip);
 	pci_release_regions(chip->pci);
-	pci_disable_device(chip->pci);
 
-	kfree(chip);
 	return 0;
 }
 
@@ -1206,28 +1202,23 @@ static int snd_fm801_create(struct snd_card *card,
 	};
 
 	*rchip = NULL;
-	if ((err = pci_enable_device(pci)) < 0)
+	if ((err = pcim_enable_device(pci)) < 0)
 		return err;
-	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL) {
-		pci_disable_device(pci);
+	chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL);
+	if (chip == NULL)
 		return -ENOMEM;
-	}
 	spin_lock_init(&chip->reg_lock);
 	chip->card = card;
 	chip->pci = pci;
 	chip->irq = -1;
 	chip->tea575x_tuner = tea575x_tuner;
-	if ((err = pci_request_regions(pci, "FM801")) < 0) {
-		kfree(chip);
-		pci_disable_device(pci);
+	if ((err = pci_request_regions(pci, "FM801")) < 0)
 		return err;
-	}
 	chip->port = pci_resource_start(pci, 0);
 	if ((tea575x_tuner & TUNER_ONLY) == 0) {
-		if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED,
-				KBUILD_MODNAME, chip)) {
-			dev_err(card->dev, "unable to grab IRQ %d\n", chip->irq);
+		if (devm_request_irq(&pci->dev, pci->irq, snd_fm801_interrupt,
+				IRQF_SHARED, KBUILD_MODNAME, chip)) {
+			dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
 			snd_fm801_free(chip);
 			return -EBUSY;
 		}
@@ -1242,12 +1233,6 @@ static int snd_fm801_create(struct snd_card *card,
 	/* init might set tuner access method */
 	tea575x_tuner = chip->tea575x_tuner;
 
-	if (chip->irq >= 0 && (tea575x_tuner & TUNER_ONLY)) {
-		pci_clear_master(pci);
-		free_irq(chip->irq, chip);
-		chip->irq = -1;
-	}
-
 	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
 		snd_fm801_free(chip);
 		return err;
-- 
1.8.3.101.g727a46b

             reply	other threads:[~2015-01-06 23:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06 23:40 Andy Shevchenko [this message]
2015-01-07  7:11 ` [PATCH] fm801: move to pcim_* and devm_* functions Takashi Iwai
2015-01-07 10:54   ` Andy Shevchenko
2015-01-07 11:27     ` Takashi Iwai
2015-01-07 12:20       ` Andy Shevchenko
2015-01-07 13:12         ` Takashi Iwai
2015-01-07 13:27           ` Andy Shevchenko
2015-01-07 13:31             ` Takashi Iwai
2015-01-07 13:40               ` Andy Shevchenko
2015-01-07 13:43                 ` Takashi Iwai
2015-01-07 13:57                   ` Takashi Iwai
2015-01-07 14:25                     ` Andy Shevchenko
2015-01-07 14:59                       ` Takashi Iwai
2015-01-20 12:42                         ` Takashi Iwai
2015-01-20 13:46                           ` Andy Shevchenko
2015-01-20 13:48                             ` Takashi Iwai
2015-01-20 13:51                               ` Andy Shevchenko
2015-01-20 13:56                                 ` Takashi Iwai

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=1420587617-28521-1-git-send-email-andy.shevchenko@gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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.