mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Adam Belay <ambx1@neo.rr.com>
Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela <perex@suse.cz>,
	Matthieu Castet <castet.matthieu@free.fr>,
	Li Shaohua <shaohua.li@intel.com>, Andrew Morton <akpm@osdl.org>,
	Takashi Iwai <tiwai@suse.de>, Paul Laufer <paul@laufernet.com>
Subject: [PATCH 10/12] PNP: adjust pnp_register_card_driver() signature
Date: Wed, 22 Mar 2006 15:13:02 -0700	[thread overview]
Message-ID: <200603221513.02330.bjorn.helgaas@hp.com> (raw)
In-Reply-To: <200603221455.26230.bjorn.helgaas@hp.com>

Remove the assumption that pnp_register_card_driver() returns the
number of devices claimed.  And fix some __init/__devinit issues.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work-mm6/sound/oss/sb_card.c
===================================================================
--- work-mm6.orig/sound/oss/sb_card.c	2006-03-22 11:24:41.000000000 -0700
+++ work-mm6/sound/oss/sb_card.c	2006-03-22 12:18:20.000000000 -0700
@@ -52,6 +52,7 @@
 static struct sb_card_config *legacy = NULL;
 
 #ifdef CONFIG_PNP
+static int pnp_registered;
 static int __initdata pnp       = 1;
 /*
 static int __initdata uart401	= 0;
@@ -133,7 +134,7 @@
 }
 
 /* Register legacy card with OSS subsystem */
-static int sb_init_legacy(void)
+static int __init sb_init_legacy(void)
 {
 	struct sb_module_options sbmo = {0};
 
@@ -234,6 +235,8 @@
 	}
 }
 
+static unsigned int sb_pnp_devices;
+
 /* Probe callback function for the PnP API */
 static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id)
 {
@@ -264,6 +267,7 @@
 	       scc->conf.dma, scc->conf.dma2);
 
 	pnp_set_card_drvdata(card, scc);
+	sb_pnp_devices++;
 
 	return sb_register_oss(scc, &sbmo);
 }
@@ -289,6 +293,14 @@
 MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table);
 #endif /* CONFIG_PNP */
 
+static void __init_or_module sb_unregister_all(void)
+{
+#ifdef CONFIG_PNP
+	if (pnp_registered)
+		pnp_unregister_card_driver(&sb_pnp_driver);
+#endif
+}
+
 static int __init sb_init(void)
 {
 	int lres = 0;
@@ -307,17 +319,18 @@
 
 #ifdef CONFIG_PNP
 	if(pnp) {
-		pres = pnp_register_card_driver(&sb_pnp_driver);
+		int err = pnp_register_card_driver(&sb_pnp_driver);
+		if (!err)
+			pnp_registered = 1;
+		pres = sb_pnp_devices;
 	}
 #endif
 	printk(KERN_INFO "sb: Init: Done\n");
 
 	/* If either PnP or Legacy registered a card then return
 	 * success */
-	if (pres <= 0 && lres <= 0) {
-#ifdef CONFIG_PNP
-		pnp_unregister_card_driver(&sb_pnp_driver);
-#endif
+	if (pres == 0 && lres <= 0) {
+		sb_unregister_all();
 		return -ENODEV;
 	}
 	return 0;
@@ -333,9 +346,7 @@
 		sb_unload(legacy);
 	}
 
-#ifdef CONFIG_PNP
-	pnp_unregister_card_driver(&sb_pnp_driver);
-#endif
+	sb_unregister_all();
 
 	vfree(smw_free);
 	smw_free = NULL;

  parent reply	other threads:[~2006-03-22 22:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22 21:55 [PATCH 0/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 1/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 2/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 3/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 4/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 5/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 6/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 7/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 8/12] " Bjorn Helgaas
2006-03-22 22:12 ` [PATCH 9/12] " Bjorn Helgaas
2006-03-22 22:13 ` Bjorn Helgaas [this message]
2006-03-22 22:13 ` [PATCH 11/12] " Bjorn Helgaas
2006-03-22 22:13 ` [PATCH 12/12] " Bjorn Helgaas

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=200603221513.02330.bjorn.helgaas@hp.com \
    --to=bjorn.helgaas@hp.com \
    --cc=akpm@osdl.org \
    --cc=ambx1@neo.rr.com \
    --cc=castet.matthieu@free.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@laufernet.com \
    --cc=perex@suse.cz \
    --cc=shaohua.li@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®