aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss
diff options
context:
space:
mode:
Diffstat (limited to 'sound/oss')
-rw-r--r--sound/oss/cmpci.c2
-rw-r--r--sound/oss/cs4232.c15
-rw-r--r--sound/oss/sb_card.c29
-rw-r--r--sound/oss/sonicvibes.c18
-rw-r--r--sound/oss/vwsnd.c40
5 files changed, 50 insertions, 54 deletions
diff --git a/sound/oss/cmpci.c b/sound/oss/cmpci.c
index 1fbd5137f6d7..de60a059ff5f 100644
--- a/sound/oss/cmpci.c
+++ b/sound/oss/cmpci.c
@@ -1713,7 +1713,7 @@ static int mixer_ioctl(struct cm_state *s, unsigned int cmd, unsigned long arg)
1713 case SOUND_MIXER_RECSRC: /* Arg contains a bit for each recording source */ 1713 case SOUND_MIXER_RECSRC: /* Arg contains a bit for each recording source */
1714 if (get_user(val, p)) 1714 if (get_user(val, p))
1715 return -EFAULT; 1715 return -EFAULT;
1716 i = generic_hweight32(val); 1716 i = hweight32(val);
1717 for (j = i = 0; i < SOUND_MIXER_NRDEVICES; i++) { 1717 for (j = i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
1718 if (!(val & (1 << i))) 1718 if (!(val & (1 << i)))
1719 continue; 1719 continue;
diff --git a/sound/oss/cs4232.c b/sound/oss/cs4232.c
index 7c59e2d4003a..c7f86f09c28d 100644
--- a/sound/oss/cs4232.c
+++ b/sound/oss/cs4232.c
@@ -360,6 +360,8 @@ static int __initdata synthio = -1;
360static int __initdata synthirq = -1; 360static int __initdata synthirq = -1;
361static int __initdata isapnp = 1; 361static int __initdata isapnp = 1;
362 362
363static unsigned int cs4232_devices;
364
363MODULE_DESCRIPTION("CS4232 based soundcard driver"); 365MODULE_DESCRIPTION("CS4232 based soundcard driver");
364MODULE_AUTHOR("Hannu Savolainen, Paul Barton-Davis"); 366MODULE_AUTHOR("Hannu Savolainen, Paul Barton-Davis");
365MODULE_LICENSE("GPL"); 367MODULE_LICENSE("GPL");
@@ -421,6 +423,7 @@ static int cs4232_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev
421 return -ENODEV; 423 return -ENODEV;
422 } 424 }
423 pnp_set_drvdata(dev,isapnpcfg); 425 pnp_set_drvdata(dev,isapnpcfg);
426 cs4232_devices++;
424 return 0; 427 return 0;
425} 428}
426 429
@@ -455,10 +458,11 @@ static int __init init_cs4232(void)
455#endif 458#endif
456 cfg.irq = -1; 459 cfg.irq = -1;
457 460
458 if (isapnp && 461 if (isapnp) {
459 (pnp_register_driver(&cs4232_driver) > 0) 462 pnp_register_driver(&cs4232_driver);
460 ) 463 if (cs4232_devices)
461 return 0; 464 return 0;
465 }
462 466
463 if(io==-1||irq==-1||dma==-1) 467 if(io==-1||irq==-1||dma==-1)
464 { 468 {
@@ -503,7 +507,8 @@ static int __init setup_cs4232(char *str)
503 int ints[7]; 507 int ints[7];
504 508
505 /* If we have isapnp cards, no need for options */ 509 /* If we have isapnp cards, no need for options */
506 if (pnp_register_driver(&cs4232_driver) > 0) 510 pnp_register_driver(&cs4232_driver);
511 if (cs4232_devices)
507 return 1; 512 return 1;
508 513
509 str = get_options(str, ARRAY_SIZE(ints), ints); 514 str = get_options(str, ARRAY_SIZE(ints), ints);
diff --git a/sound/oss/sb_card.c b/sound/oss/sb_card.c
index 680b82e15298..d38e88abc8fa 100644
--- a/sound/oss/sb_card.c
+++ b/sound/oss/sb_card.c
@@ -52,6 +52,7 @@ static int __initdata sm_games = 0; /* Logitech soundman games? */
52static struct sb_card_config *legacy = NULL; 52static struct sb_card_config *legacy = NULL;
53 53
54#ifdef CONFIG_PNP 54#ifdef CONFIG_PNP
55static int pnp_registered;
55static int __initdata pnp = 1; 56static int __initdata pnp = 1;
56/* 57/*
57static int __initdata uart401 = 0; 58static int __initdata uart401 = 0;
@@ -133,7 +134,7 @@ static void sb_unload(struct sb_card_config *scc)
133} 134}
134 135
135/* Register legacy card with OSS subsystem */ 136/* Register legacy card with OSS subsystem */
136static int sb_init_legacy(void) 137static int __init sb_init_legacy(void)
137{ 138{
138 struct sb_module_options sbmo = {0}; 139 struct sb_module_options sbmo = {0};
139 140
@@ -234,6 +235,8 @@ static void sb_dev2cfg(struct pnp_dev *dev, struct sb_card_config *scc)
234 } 235 }
235} 236}
236 237
238static unsigned int sb_pnp_devices;
239
237/* Probe callback function for the PnP API */ 240/* Probe callback function for the PnP API */
238static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id) 241static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id)
239{ 242{
@@ -264,6 +267,7 @@ static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device
264 scc->conf.dma, scc->conf.dma2); 267 scc->conf.dma, scc->conf.dma2);
265 268
266 pnp_set_card_drvdata(card, scc); 269 pnp_set_card_drvdata(card, scc);
270 sb_pnp_devices++;
267 271
268 return sb_register_oss(scc, &sbmo); 272 return sb_register_oss(scc, &sbmo);
269} 273}
@@ -289,6 +293,14 @@ static struct pnp_card_driver sb_pnp_driver = {
289MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table); 293MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table);
290#endif /* CONFIG_PNP */ 294#endif /* CONFIG_PNP */
291 295
296static void __init_or_module sb_unregister_all(void)
297{
298#ifdef CONFIG_PNP
299 if (pnp_registered)
300 pnp_unregister_card_driver(&sb_pnp_driver);
301#endif
302}
303
292static int __init sb_init(void) 304static int __init sb_init(void)
293{ 305{
294 int lres = 0; 306 int lres = 0;
@@ -307,17 +319,18 @@ static int __init sb_init(void)
307 319
308#ifdef CONFIG_PNP 320#ifdef CONFIG_PNP
309 if(pnp) { 321 if(pnp) {
310 pres = pnp_register_card_driver(&sb_pnp_driver); 322 int err = pnp_register_card_driver(&sb_pnp_driver);
323 if (!err)
324 pnp_registered = 1;
325 pres = sb_pnp_devices;
311 } 326 }
312#endif 327#endif
313 printk(KERN_INFO "sb: Init: Done\n"); 328 printk(KERN_INFO "sb: Init: Done\n");
314 329
315 /* If either PnP or Legacy registered a card then return 330 /* If either PnP or Legacy registered a card then return
316 * success */ 331 * success */
317 if (pres <= 0 && lres <= 0) { 332 if (pres == 0 && lres <= 0) {
318#ifdef CONFIG_PNP 333 sb_unregister_all();
319 pnp_unregister_card_driver(&sb_pnp_driver);
320#endif
321 return -ENODEV; 334 return -ENODEV;
322 } 335 }
323 return 0; 336 return 0;
@@ -333,9 +346,7 @@ static void __exit sb_exit(void)
333 sb_unload(legacy); 346 sb_unload(legacy);
334 } 347 }
335 348
336#ifdef CONFIG_PNP 349 sb_unregister_all();
337 pnp_unregister_card_driver(&sb_pnp_driver);
338#endif
339 350
340 if (smw_free) { 351 if (smw_free) {
341 vfree(smw_free); 352 vfree(smw_free);
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index 69a4b8778b51..4471757b7985 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -407,24 +407,6 @@ static inline unsigned ld2(unsigned int x)
407 return r; 407 return r;
408} 408}
409 409
410/*
411 * hweightN: returns the hamming weight (i.e. the number
412 * of bits set) of a N-bit word
413 */
414
415#ifdef hweight32
416#undef hweight32
417#endif
418
419static inline unsigned int hweight32(unsigned int w)
420{
421 unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
422 res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
423 res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
424 res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
425 return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
426}
427
428/* --------------------------------------------------------------------- */ 410/* --------------------------------------------------------------------- */
429 411
430/* 412/*
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index b372e88e857f..5f140c7586b3 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -248,27 +248,6 @@ typedef struct lithium {
248} lithium_t; 248} lithium_t;
249 249
250/* 250/*
251 * li_create initializes the lithium_t structure and sets up vm mappings
252 * to access the registers.
253 * Returns 0 on success, -errno on failure.
254 */
255
256static int __init li_create(lithium_t *lith, unsigned long baseaddr)
257{
258 static void li_destroy(lithium_t *);
259
260 spin_lock_init(&lith->lock);
261 lith->page0 = ioremap_nocache(baseaddr + LI_PAGE0_OFFSET, PAGE_SIZE);
262 lith->page1 = ioremap_nocache(baseaddr + LI_PAGE1_OFFSET, PAGE_SIZE);
263 lith->page2 = ioremap_nocache(baseaddr + LI_PAGE2_OFFSET, PAGE_SIZE);
264 if (!lith->page0 || !lith->page1 || !lith->page2) {
265 li_destroy(lith);
266 return -ENOMEM;
267 }
268 return 0;
269}
270
271/*
272 * li_destroy destroys the lithium_t structure and vm mappings. 251 * li_destroy destroys the lithium_t structure and vm mappings.
273 */ 252 */
274 253
@@ -289,6 +268,25 @@ static void li_destroy(lithium_t *lith)
289} 268}
290 269
291/* 270/*
271 * li_create initializes the lithium_t structure and sets up vm mappings
272 * to access the registers.
273 * Returns 0 on success, -errno on failure.
274 */
275
276static int __init li_create(lithium_t *lith, unsigned long baseaddr)
277{
278 spin_lock_init(&lith->lock);
279 lith->page0 = ioremap_nocache(baseaddr + LI_PAGE0_OFFSET, PAGE_SIZE);
280 lith->page1 = ioremap_nocache(baseaddr + LI_PAGE1_OFFSET, PAGE_SIZE);
281 lith->page2 = ioremap_nocache(baseaddr + LI_PAGE2_OFFSET, PAGE_SIZE);
282 if (!lith->page0 || !lith->page1 || !lith->page2) {
283 li_destroy(lith);
284 return -ENOMEM;
285 }
286 return 0;
287}
288
289/*
292 * basic register accessors - read/write long/byte 290 * basic register accessors - read/write long/byte
293 */ 291 */
294 292