diff options
author | Andy Shevchenko <andy.shevchenko@gmail.com> | 2015-01-06 18:40:17 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-01-07 09:53:55 -0500 |
commit | 5618955c4269b07c8177f88a8075d4879e74cd27 (patch) | |
tree | 6d5002c4739db79204b7e4934ae436724aabe8e5 /sound/pci/fm801.c | |
parent | b1940cd21c0f4abdce101253e860feff547291b0 (diff) |
ALSA: fm801: move to pcim_* and devm_* functions
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.
[removed pci_release_regions() as it's managed in pcim_release(), too
-- tiwai]
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/fm801.c')
-rw-r--r-- | sound/pci/fm801.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index d167afffce5f..dd6f23fbbdf9 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c | |||
@@ -1186,12 +1186,6 @@ static int snd_fm801_free(struct fm801 *chip) | |||
1186 | v4l2_device_unregister(&chip->v4l2_dev); | 1186 | v4l2_device_unregister(&chip->v4l2_dev); |
1187 | } | 1187 | } |
1188 | #endif | 1188 | #endif |
1189 | if (chip->irq >= 0) | ||
1190 | free_irq(chip->irq, chip); | ||
1191 | pci_release_regions(chip->pci); | ||
1192 | pci_disable_device(chip->pci); | ||
1193 | |||
1194 | kfree(chip); | ||
1195 | return 0; | 1189 | return 0; |
1196 | } | 1190 | } |
1197 | 1191 | ||
@@ -1214,28 +1208,23 @@ static int snd_fm801_create(struct snd_card *card, | |||
1214 | }; | 1208 | }; |
1215 | 1209 | ||
1216 | *rchip = NULL; | 1210 | *rchip = NULL; |
1217 | if ((err = pci_enable_device(pci)) < 0) | 1211 | if ((err = pcim_enable_device(pci)) < 0) |
1218 | return err; | 1212 | return err; |
1219 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1213 | chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL); |
1220 | if (chip == NULL) { | 1214 | if (chip == NULL) |
1221 | pci_disable_device(pci); | ||
1222 | return -ENOMEM; | 1215 | return -ENOMEM; |
1223 | } | ||
1224 | spin_lock_init(&chip->reg_lock); | 1216 | spin_lock_init(&chip->reg_lock); |
1225 | chip->card = card; | 1217 | chip->card = card; |
1226 | chip->pci = pci; | 1218 | chip->pci = pci; |
1227 | chip->irq = -1; | 1219 | chip->irq = -1; |
1228 | chip->tea575x_tuner = tea575x_tuner; | 1220 | chip->tea575x_tuner = tea575x_tuner; |
1229 | if ((err = pci_request_regions(pci, "FM801")) < 0) { | 1221 | if ((err = pci_request_regions(pci, "FM801")) < 0) |
1230 | kfree(chip); | ||
1231 | pci_disable_device(pci); | ||
1232 | return err; | 1222 | return err; |
1233 | } | ||
1234 | chip->port = pci_resource_start(pci, 0); | 1223 | chip->port = pci_resource_start(pci, 0); |
1235 | if ((tea575x_tuner & TUNER_ONLY) == 0) { | 1224 | if ((tea575x_tuner & TUNER_ONLY) == 0) { |
1236 | if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED, | 1225 | if (devm_request_irq(&pci->dev, pci->irq, snd_fm801_interrupt, |
1237 | KBUILD_MODNAME, chip)) { | 1226 | IRQF_SHARED, KBUILD_MODNAME, chip)) { |
1238 | dev_err(card->dev, "unable to grab IRQ %d\n", chip->irq); | 1227 | dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); |
1239 | snd_fm801_free(chip); | 1228 | snd_fm801_free(chip); |
1240 | return -EBUSY; | 1229 | return -EBUSY; |
1241 | } | 1230 | } |
@@ -1250,12 +1239,6 @@ static int snd_fm801_create(struct snd_card *card, | |||
1250 | /* init might set tuner access method */ | 1239 | /* init might set tuner access method */ |
1251 | tea575x_tuner = chip->tea575x_tuner; | 1240 | tea575x_tuner = chip->tea575x_tuner; |
1252 | 1241 | ||
1253 | if (chip->irq >= 0 && (tea575x_tuner & TUNER_ONLY)) { | ||
1254 | pci_clear_master(pci); | ||
1255 | free_irq(chip->irq, chip); | ||
1256 | chip->irq = -1; | ||
1257 | } | ||
1258 | |||
1259 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1242 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
1260 | snd_fm801_free(chip); | 1243 | snd_fm801_free(chip); |
1261 | return err; | 1244 | return err; |