Commit 2612989b authored by Adam Belay's avatar Adam Belay

Merge http://linux.bkbits.net/linux-2.5

into neo.rr.com:/home/ambx1/linux/bk/linus-2.5
parents 2c12e127 3d991731
...@@ -909,7 +909,7 @@ static struct pci_driver fcpci_driver = { ...@@ -909,7 +909,7 @@ static struct pci_driver fcpci_driver = {
#ifdef CONFIG_PNP_CARD #ifdef CONFIG_PNP_CARD
static int __devinit fcpnp_probe(struct pnp_card *card, static int __devinit fcpnp_probe(struct pnp_card *card,
const struct pnp_card_id *card_id) const struct pnp_card_device_id *card_id)
{ {
struct fritz_adapter *adapter; struct fritz_adapter *adapter;
struct pnp_dev *pnp_dev; struct pnp_dev *pnp_dev;
...@@ -955,7 +955,7 @@ static void __devexit fcpnp_remove(struct pnp_card *pcard) ...@@ -955,7 +955,7 @@ static void __devexit fcpnp_remove(struct pnp_card *pcard)
delete_adapter(adapter); delete_adapter(adapter);
} }
static struct pnp_card_id fcpnp_ids[] __devinitdata = { static struct pnp_card_device_id fcpnp_ids[] __devinitdata = {
{ .id = "AVM0900", { .id = "AVM0900",
.driver_data = (unsigned long) "Fritz!Card PnP", .driver_data = (unsigned long) "Fritz!Card PnP",
.devs = { { "AVM0900" } }, .devs = { { "AVM0900" } },
......
...@@ -19,11 +19,12 @@ ...@@ -19,11 +19,12 @@
#include "base.h" #include "base.h"
LIST_HEAD(pnp_cards); LIST_HEAD(pnp_cards);
LIST_HEAD(pnp_card_drivers);
static const struct pnp_card_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card) static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card)
{ {
const struct pnp_card_id * drv_id = drv->id_table; const struct pnp_card_device_id * drv_id = drv->id_table;
while (*drv_id->id){ while (*drv_id->id){
if (compare_pnp_id(card->id,drv_id->id)) if (compare_pnp_id(card->id,drv_id->id))
return drv_id; return drv_id;
...@@ -32,21 +33,41 @@ static const struct pnp_card_id * match_card(struct pnp_card_driver * drv, struc ...@@ -32,21 +33,41 @@ static const struct pnp_card_id * match_card(struct pnp_card_driver * drv, struc
return NULL; return NULL;
} }
static void generic_card_remove(struct pnp_dev * dev) static void card_remove(struct pnp_dev * dev)
{ {
dev->card_link = NULL; dev->card_link = NULL;
} }
static void generic_card_remove_first(struct pnp_dev * dev) static void card_remove_first(struct pnp_dev * dev)
{ {
struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver); struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver);
if (!dev->card || !drv) if (!dev->card || !drv)
return; return;
if (drv->remove) if (drv->remove)
drv->remove(dev->card_link); drv->remove(dev->card_link);
drv->link.remove = &generic_card_remove; drv->link.remove = &card_remove;
kfree(dev->card_link); kfree(dev->card_link);
generic_card_remove(dev); card_remove(dev);
}
static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv)
{
const struct pnp_card_device_id *id = match_card(drv,card);
if (id) {
struct pnp_card_link * clink = pnp_alloc(sizeof(struct pnp_card_link));
if (!clink)
return 0;
clink->card = card;
clink->driver = drv;
if (drv->probe) {
if (drv->probe(clink, id)>=0)
return 1;
else
kfree(clink);
} else
return 1;
}
return 0;
} }
/** /**
...@@ -103,7 +124,7 @@ static void pnp_release_card(struct device *dmdev) ...@@ -103,7 +124,7 @@ static void pnp_release_card(struct device *dmdev)
int pnp_add_card(struct pnp_card * card) int pnp_add_card(struct pnp_card * card)
{ {
int error; int error;
struct list_head * pos; struct list_head * pos, * temp;
if (!card || !card->protocol) if (!card || !card->protocol)
return -EINVAL; return -EINVAL;
...@@ -112,6 +133,7 @@ int pnp_add_card(struct pnp_card * card) ...@@ -112,6 +133,7 @@ int pnp_add_card(struct pnp_card * card)
card->dev.bus = NULL; card->dev.bus = NULL;
card->dev.release = &pnp_release_card; card->dev.release = &pnp_release_card;
error = device_register(&card->dev); error = device_register(&card->dev);
if (error == 0) { if (error == 0) {
spin_lock(&pnp_lock); spin_lock(&pnp_lock);
list_add_tail(&card->global_list, &pnp_cards); list_add_tail(&card->global_list, &pnp_cards);
...@@ -125,6 +147,12 @@ int pnp_add_card(struct pnp_card * card) ...@@ -125,6 +147,12 @@ int pnp_add_card(struct pnp_card * card)
struct pnp_dev *dev = card_to_pnp_dev(pos); struct pnp_dev *dev = card_to_pnp_dev(pos);
__pnp_add_device(dev); __pnp_add_device(dev);
} }
/* match with card drivers */
list_for_each_safe(pos,temp,&pnp_card_drivers){
struct pnp_card_driver * drv = list_entry(pos, struct pnp_card_driver, global_list);
card_probe(card,drv);
}
} else } else
pnp_err("sysfs failure, card '%s' will be unavailable", card->dev.bus_id); pnp_err("sysfs failure, card '%s' will be unavailable", card->dev.bus_id);
return error; return error;
...@@ -248,9 +276,9 @@ void pnp_release_card_device(struct pnp_dev * dev) ...@@ -248,9 +276,9 @@ void pnp_release_card_device(struct pnp_dev * dev)
if (!drv) if (!drv)
return; return;
down_write(&dev->dev.bus->subsys.rwsem); down_write(&dev->dev.bus->subsys.rwsem);
drv->link.remove = &generic_card_remove; drv->link.remove = &card_remove;
device_release_driver(&dev->dev); device_release_driver(&dev->dev);
drv->link.remove = &generic_card_remove_first; drv->link.remove = &card_remove_first;
up_write(&dev->dev.bus->subsys.rwsem); up_write(&dev->dev.bus->subsys.rwsem);
} }
...@@ -268,25 +296,16 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) ...@@ -268,25 +296,16 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
drv->link.id_table = NULL; /* this will disable auto matching */ drv->link.id_table = NULL; /* this will disable auto matching */
drv->link.flags = drv->flags; drv->link.flags = drv->flags;
drv->link.probe = NULL; drv->link.probe = NULL;
drv->link.remove = &generic_card_remove_first; drv->link.remove = &card_remove_first;
spin_lock(&pnp_lock);
list_add_tail(&drv->global_list, &pnp_card_drivers);
spin_unlock(&pnp_lock);
pnp_register_driver(&drv->link); pnp_register_driver(&drv->link);
list_for_each_safe(pos,temp,&pnp_cards){ list_for_each_safe(pos,temp,&pnp_cards){
struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); struct pnp_card *card = list_entry(pos, struct pnp_card, global_list);
const struct pnp_card_id *id = match_card(drv,card); count += card_probe(card,drv);
if (id) {
struct pnp_card_link * clink = pnp_alloc(sizeof(struct pnp_card_link));
if (!clink)
continue;
clink->card = card;
clink->driver = drv;
if (drv->probe) {
if (drv->probe(clink, id)>=0)
count++;
} else
count++;
}
} }
return count; return count;
} }
...@@ -298,9 +317,10 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) ...@@ -298,9 +317,10 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
void pnp_unregister_card_driver(struct pnp_card_driver * drv) void pnp_unregister_card_driver(struct pnp_card_driver * drv)
{ {
spin_lock(&pnp_lock);
list_del(&drv->global_list);
spin_unlock(&pnp_lock);
pnp_unregister_driver(&drv->link); pnp_unregister_driver(&drv->link);
pnp_dbg("the card driver '%s' has been unregistered", drv->name);
} }
EXPORT_SYMBOL(pnp_add_card); EXPORT_SYMBOL(pnp_add_card);
......
...@@ -170,7 +170,7 @@ void pnp_remove_device(struct pnp_dev *dev) ...@@ -170,7 +170,7 @@ void pnp_remove_device(struct pnp_dev *dev)
static int __init pnp_init(void) static int __init pnp_init(void)
{ {
printk(KERN_INFO "Linux Plug and Play Support v0.95 (c) Adam Belay\n"); printk(KERN_INFO "Linux Plug and Play Support v0.96 (c) Adam Belay\n");
return bus_register(&pnp_bus_type); return bus_register(&pnp_bus_type);
} }
......
...@@ -632,8 +632,7 @@ int pnp_activate_dev(struct pnp_dev *dev) ...@@ -632,8 +632,7 @@ int pnp_activate_dev(struct pnp_dev *dev)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
if (dev->active) { if (dev->active) {
pnp_info("res: The PnP device '%s' is already active.", dev->dev.bus_id); return 0; /* the device is already active */
return -EBUSY;
} }
/* If this condition is true, advanced configuration failed, we need to get this device up and running /* If this condition is true, advanced configuration failed, we need to get this device up and running
* so we use the simple config engine which ignores cold conflicts, this of course may lead to new failures */ * so we use the simple config engine which ignores cold conflicts, this of course may lead to new failures */
...@@ -698,8 +697,7 @@ int pnp_disable_dev(struct pnp_dev *dev) ...@@ -698,8 +697,7 @@ int pnp_disable_dev(struct pnp_dev *dev)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
if (!dev->active) { if (!dev->active) {
pnp_info("res: The PnP device '%s' is already disabled.", dev->dev.bus_id); return 0; /* the device is already disabled */
return -EINVAL;
} }
if (dev->status != PNP_READY){ if (dev->status != PNP_READY){
pnp_info("res: Disable failed becuase the PnP device '%s' is busy.", dev->dev.bus_id); pnp_info("res: Disable failed becuase the PnP device '%s' is busy.", dev->dev.bus_id);
......
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* Change Log
*
* Adam Belay - <ambx1@neo.rr.com> - March 16, 2003
* rev 1.01 Only call pnp_bios_dev_node_info once
* Added pnpbios_print_status
* Added several new error messages and info messages
* Added pnpbios_interface_attach_device
* integrated core and proc init system
* Introduced PNPMODE flags
* Removed some useless includes
*/
#include <linux/types.h> #include <linux/types.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -46,9 +58,7 @@ ...@@ -46,9 +58,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <asm/desc.h> #include <asm/desc.h>
#include <linux/ioport.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pci.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -93,6 +103,7 @@ static struct { ...@@ -93,6 +103,7 @@ static struct {
} pnp_bios_callpoint; } pnp_bios_callpoint;
static union pnp_bios_expansion_header * pnp_bios_hdr = NULL; static union pnp_bios_expansion_header * pnp_bios_hdr = NULL;
struct pnp_dev_node_info node_info;
/* The PnP BIOS entries in the GDT */ /* The PnP BIOS entries in the GDT */
#define PNP_GDT (GDT_ENTRY_PNPBIOS_BASE * 8) #define PNP_GDT (GDT_ENTRY_PNPBIOS_BASE * 8)
...@@ -237,9 +248,46 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3, ...@@ -237,9 +248,46 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
* *
*/ */
static void pnpbios_warn_unexpected_status(const char * module, u16 status) static void pnpbios_print_status(const char * module, u16 status)
{ {
printk(KERN_ERR "PnPBIOS: %s: Unexpected status 0x%x\n", module, status); switch(status) {
case PNP_SUCCESS:
printk(KERN_ERR "PnPBIOS: %s: function successful\n", module);
case PNP_NOT_SET_STATICALLY:
printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n", module);
case PNP_UNKNOWN_FUNCTION:
printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n", module);
case PNP_FUNCTION_NOT_SUPPORTED:
printk(KERN_ERR "PnPBIOS: %s: function not supported on this system\n", module);
case PNP_INVALID_HANDLE:
printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module);
case PNP_BAD_PARAMETER:
printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n", module);
case PNP_SET_FAILED:
printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n", module);
case PNP_EVENTS_NOT_PENDING:
printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module);
case PNP_SYSTEM_NOT_DOCKED:
printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n", module);
case PNP_NO_ISA_PNP_CARDS:
printk(KERN_ERR "PnPBIOS: %s: no isapnp cards are installed on this system\n", module);
case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES:
printk(KERN_ERR "PnPBIOS: %s: cannot determine the capabilities of the docking station\n", module);
case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY:
printk(KERN_ERR "PnPBIOS: %s: unable to undock, the system does not have a battery\n", module);
case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT:
printk(KERN_ERR "PnPBIOS: %s: could not dock due to resource conflicts\n", module);
case PNP_BUFFER_TOO_SMALL:
printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n", module);
case PNP_USE_ESCD_SUPPORT:
printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module);
case PNP_MESSAGE_NOT_SUPPORTED:
printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n", module);
case PNP_HARDWARE_ERROR:
printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n", module);
default:
printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module, status);
}
} }
void *pnpbios_kmalloc(size_t size, int f) void *pnpbios_kmalloc(size_t size, int f)
...@@ -299,7 +347,7 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) ...@@ -299,7 +347,7 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
{ {
int status = __pnp_bios_dev_node_info( data ); int status = __pnp_bios_dev_node_info( data );
if ( status ) if ( status )
pnpbios_warn_unexpected_status( "dev_node_info", status ); pnpbios_print_status( "dev_node_info", status );
return status; return status;
} }
...@@ -334,7 +382,7 @@ int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) ...@@ -334,7 +382,7 @@ int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data)
int status; int status;
status = __pnp_bios_get_dev_node( nodenum, boot, data ); status = __pnp_bios_get_dev_node( nodenum, boot, data );
if ( status ) if ( status )
pnpbios_warn_unexpected_status( "get_dev_node", status ); pnpbios_print_status( "get_dev_node", status );
return status; return status;
} }
...@@ -362,7 +410,7 @@ int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) ...@@ -362,7 +410,7 @@ int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
int status; int status;
status = __pnp_bios_set_dev_node( nodenum, boot, data ); status = __pnp_bios_set_dev_node( nodenum, boot, data );
if ( status ) { if ( status ) {
pnpbios_warn_unexpected_status( "set_dev_node", status ); pnpbios_print_status( "set_dev_node", status );
return status; return status;
} }
if ( !boot ) { /* Update devlist */ if ( !boot ) { /* Update devlist */
...@@ -452,7 +500,7 @@ int pnp_bios_get_stat_res(char *info) ...@@ -452,7 +500,7 @@ int pnp_bios_get_stat_res(char *info)
int status; int status;
status = __pnp_bios_get_stat_res( info ); status = __pnp_bios_get_stat_res( info );
if ( status ) if ( status )
pnpbios_warn_unexpected_status( "get_stat_res", status ); pnpbios_print_status( "get_stat_res", status );
return status; return status;
} }
...@@ -489,7 +537,7 @@ int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) ...@@ -489,7 +537,7 @@ int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
int status; int status;
status = __pnp_bios_isapnp_config( data ); status = __pnp_bios_isapnp_config( data );
if ( status ) if ( status )
pnpbios_warn_unexpected_status( "isapnp_config", status ); pnpbios_print_status( "isapnp_config", status );
return status; return status;
} }
...@@ -511,7 +559,7 @@ int pnp_bios_escd_info(struct escd_info_struc *data) ...@@ -511,7 +559,7 @@ int pnp_bios_escd_info(struct escd_info_struc *data)
int status; int status;
status = __pnp_bios_escd_info( data ); status = __pnp_bios_escd_info( data );
if ( status ) if ( status )
pnpbios_warn_unexpected_status( "escd_info", status ); pnpbios_print_status( "escd_info", status );
return status; return status;
} }
...@@ -534,7 +582,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base) ...@@ -534,7 +582,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
int status; int status;
status = __pnp_bios_read_escd( data, nvram_base ); status = __pnp_bios_read_escd( data, nvram_base );
if ( status ) if ( status )
pnpbios_warn_unexpected_status( "read_escd", status ); pnpbios_print_status( "read_escd", status );
return status; return status;
} }
...@@ -658,7 +706,7 @@ static int pnp_dock_thread(void * unused) ...@@ -658,7 +706,7 @@ static int pnp_dock_thread(void * unused)
d = 1; d = 1;
break; break;
default: default:
pnpbios_warn_unexpected_status( "pnp_dock_thread", status ); pnpbios_print_status( "pnp_dock_thread", status );
continue; continue;
} }
if(d != docked) if(d != docked)
...@@ -753,19 +801,17 @@ static void node_id_data_to_dev(unsigned char *p, struct pnp_bios_node *node, st ...@@ -753,19 +801,17 @@ static void node_id_data_to_dev(unsigned char *p, struct pnp_bios_node *node, st
static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res)
{ {
struct pnp_dev_node_info node_info;
u8 nodenum = dev->number; u8 nodenum = dev->number;
struct pnp_bios_node * node; struct pnp_bios_node * node;
/* just in case */ /* just in case */
if(!pnpbios_is_dynamic(dev)) if(!pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
if (pnp_bios_dev_node_info(&node_info) != 0)
return -ENODEV;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -1; return -1;
if (pnp_bios_get_dev_node(&nodenum, (char )0, node)) { if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
kfree(node); kfree(node);
return -ENODEV; return -ENODEV;
} }
...@@ -777,7 +823,6 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table ...@@ -777,7 +823,6 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res)
{ {
struct pnp_dev_node_info node_info;
u8 nodenum = dev->number; u8 nodenum = dev->number;
struct pnp_bios_node * node; struct pnp_bios_node * node;
int ret; int ret;
...@@ -785,18 +830,17 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table ...@@ -785,18 +830,17 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
/* just in case */ /* just in case */
if (!pnpbios_is_dynamic(dev)) if (!pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
if (pnp_bios_dev_node_info(&node_info) != 0)
return -ENODEV;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -1; return -1;
if (pnp_bios_get_dev_node(&nodenum, (char )1, node)) if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node))
return -ENODEV; return -ENODEV;
if(!pnp_write_resources((char *)node->data,(char *)node->data + node->size,res)){ if(!pnp_write_resources((char *)node->data,(char *)node->data + node->size,res)){
kfree(node); kfree(node);
return -1; return -1;
} }
ret = pnp_bios_set_dev_node(node->handle, (char)0, node); ret = pnp_bios_set_dev_node(node->handle, (char)PNPMODE_DYNAMIC, node);
kfree(node); kfree(node);
if (ret > 0) if (ret > 0)
ret = -1; ret = -1;
...@@ -805,23 +849,18 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table ...@@ -805,23 +849,18 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
static int pnpbios_disable_resources(struct pnp_dev *dev) static int pnpbios_disable_resources(struct pnp_dev *dev)
{ {
struct pnp_dev_node_info node_info;
struct pnp_bios_node * node; struct pnp_bios_node * node;
int ret; int ret;
/* just in case */ /* just in case */
if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
if (!dev || !dev->active)
return -EINVAL;
if (pnp_bios_dev_node_info(&node_info) != 0)
return -ENODEV;
/* the value of this will be zero */ /* the value of this will be zero */
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -ENOMEM; return -ENOMEM;
ret = pnp_bios_set_dev_node(dev->number, (char)0, node); ret = pnp_bios_set_dev_node(dev->number, (char)PNPMODE_DYNAMIC, node);
dev->active = 0;
kfree(node); kfree(node);
if (ret > 0) if (ret > 0)
ret = -1; ret = -1;
...@@ -879,6 +918,8 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) ...@@ -879,6 +918,8 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
dev->protocol = &pnpbios_protocol; dev->protocol = &pnpbios_protocol;
pnp_add_device(dev); pnp_add_device(dev);
pnpbios_interface_attach_device(node);
return 0; return 0;
} }
...@@ -903,8 +944,16 @@ static void __init build_devlist(void) ...@@ -903,8 +944,16 @@ static void __init build_devlist(void)
for(nodenum=0; nodenum<0xff; ) { for(nodenum=0; nodenum<0xff; ) {
u8 thisnodenum = nodenum; u8 thisnodenum = nodenum;
if (pnp_bios_get_dev_node(&nodenum, (char )0, node)) /* eventually we will want to use PNPMODE_STATIC here but for now
* dynamic will help us catch buggy bioses to add to the blacklist.
*/
if (!pnpbios_dont_use_current_config) {
if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node))
break; break;
} else {
if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node))
break;
}
nodes_got++; nodes_got++;
dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL); dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL);
if (!dev) if (!dev)
...@@ -972,7 +1021,8 @@ int __init pnpbios_init(void) ...@@ -972,7 +1021,8 @@ int __init pnpbios_init(void)
if(pnpbios_disabled || (dmi_broken & BROKEN_PNP_BIOS)) { if(pnpbios_disabled || (dmi_broken & BROKEN_PNP_BIOS)) {
printk(KERN_INFO "PnPBIOS: Disabled\n"); printk(KERN_INFO "PnPBIOS: Disabled\n");
return -ENODEV; return -ENODEV;
} } else
printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n");
/* /*
* Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS
...@@ -1016,17 +1066,34 @@ int __init pnpbios_init(void) ...@@ -1016,17 +1066,34 @@ int __init pnpbios_init(void)
} }
break; break;
} }
if (!pnp_bios_present()) if (!pnp_bios_present()) {
printk(KERN_INFO "PnPBIOS: A PnP BIOS was not detected.\n");
return -ENODEV; return -ENODEV;
}
/*
* we found a pnpbios, now let's load the rest of the driver
*/
/* read the node info */
if (pnp_bios_dev_node_info(&node_info)) {
printk(KERN_ERR "PnPBIOS: Unable to get node info. Aborting.\n");
return -EIO;
}
/* register with the pnp layer */
pnp_register_protocol(&pnpbios_protocol); pnp_register_protocol(&pnpbios_protocol);
build_devlist();
/*if ( ! dont_reserve_resources )*/
/*reserve_resources();*/
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/* start the proc interface */
r = pnpbios_proc_init(); r = pnpbios_proc_init();
if (r) if (r)
return r; return r;
#endif #endif
/* scan for pnpbios devices */
build_devlist();
return 0; return 0;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
static struct proc_dir_entry *proc_pnp = NULL; static struct proc_dir_entry *proc_pnp = NULL;
static struct proc_dir_entry *proc_pnp_boot = NULL; static struct proc_dir_entry *proc_pnp_boot = NULL;
static struct pnp_dev_node_info node_info;
static int proc_read_pnpconfig(char *buf, char **start, off_t pos, static int proc_read_pnpconfig(char *buf, char **start, off_t pos,
int count, int *eof, void *data) int count, int *eof, void *data)
...@@ -136,7 +135,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos, ...@@ -136,7 +135,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
/* 26 = the number of characters per line sprintf'ed */ /* 26 = the number of characters per line sprintf'ed */
if ((p - buf + 26) > count) if ((p - buf + 26) > count)
break; break;
if (pnp_bios_get_dev_node(&nodenum, 1, node)) if (pnp_bios_get_dev_node(&nodenum, PNPMODE_STATIC, node))
break; break;
p += sprintf(p, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", p += sprintf(p, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n",
node->handle, node->eisa_id, node->handle, node->eisa_id,
...@@ -193,41 +192,11 @@ static int proc_write_node(struct file *file, const char *buf, ...@@ -193,41 +192,11 @@ static int proc_write_node(struct file *file, const char *buf,
return count; return count;
} }
/* int pnpbios_interface_attach_device(struct pnp_bios_node * node)
* When this is called, pnpbios functions are assumed to
* work and the pnpbios_dont_use_current_config flag
* should already have been set to the appropriate value
*/
int __init pnpbios_proc_init( void )
{ {
struct pnp_bios_node *node;
struct proc_dir_entry *ent;
char name[3]; char name[3];
u8 nodenum; struct proc_dir_entry *ent;
if (pnp_bios_dev_node_info(&node_info))
return -EIO;
proc_pnp = proc_mkdir("pnp", proc_bus);
if (!proc_pnp)
return -EIO;
proc_pnp_boot = proc_mkdir("boot", proc_pnp);
if (!proc_pnp_boot)
return -EIO;
create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL);
create_proc_read_entry("configuration_info", 0, proc_pnp, proc_read_pnpconfig, NULL);
create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, NULL);
create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
create_proc_read_entry("legacy_device_resources", 0, proc_pnp, proc_read_legacyres, NULL);
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -ENOMEM;
for (nodenum=0; nodenum<0xff; ) {
u8 thisnodenum = nodenum;
if (pnp_bios_get_dev_node(&nodenum, 1, node) != 0)
break;
sprintf(name, "%02x", node->handle); sprintf(name, "%02x", node->handle);
if ( !pnpbios_dont_use_current_config ) { if ( !pnpbios_dont_use_current_config ) {
ent = create_proc_entry(name, 0, proc_pnp); ent = create_proc_entry(name, 0, proc_pnp);
...@@ -242,13 +211,29 @@ int __init pnpbios_proc_init( void ) ...@@ -242,13 +211,29 @@ int __init pnpbios_proc_init( void )
ent->read_proc = proc_read_node; ent->read_proc = proc_read_node;
ent->write_proc = proc_write_node; ent->write_proc = proc_write_node;
ent->data = (void *)(long)(node->handle+0x100); ent->data = (void *)(long)(node->handle+0x100);
return 0;
} }
if (nodenum <= thisnodenum) { return -EIO;
printk(KERN_ERR "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", "PnPBIOS: proc_init:", (unsigned int)nodenum, (unsigned int)thisnodenum); }
break;
} /*
} * When this is called, pnpbios functions are assumed to
kfree(node); * work and the pnpbios_dont_use_current_config flag
* should already have been set to the appropriate value
*/
int __init pnpbios_proc_init( void )
{
proc_pnp = proc_mkdir("pnp", proc_bus);
if (!proc_pnp)
return -EIO;
proc_pnp_boot = proc_mkdir("boot", proc_pnp);
if (!proc_pnp_boot)
return -EIO;
create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL);
create_proc_read_entry("configuration_info", 0, proc_pnp, proc_read_pnpconfig, NULL);
create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, NULL);
create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
create_proc_read_entry("legacy_device_resources", 0, proc_pnp, proc_read_legacyres, NULL);
return 0; return 0;
} }
......
...@@ -295,7 +295,7 @@ struct pnp_device_id { ...@@ -295,7 +295,7 @@ struct pnp_device_id {
unsigned long driver_data; /* data private to the driver */ unsigned long driver_data; /* data private to the driver */
}; };
struct pnp_card_id { struct pnp_card_device_id {
char id[PNP_ID_LEN]; char id[PNP_ID_LEN];
unsigned long driver_data; /* data private to the driver */ unsigned long driver_data; /* data private to the driver */
struct { struct {
...@@ -315,10 +315,11 @@ struct pnp_driver { ...@@ -315,10 +315,11 @@ struct pnp_driver {
#define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver) #define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
struct pnp_card_driver { struct pnp_card_driver {
struct list_head global_list;
char * name; char * name;
const struct pnp_card_id *id_table; const struct pnp_card_device_id *id_table;
unsigned int flags; unsigned int flags;
int (*probe) (struct pnp_card_link *card, const struct pnp_card_id *card_id); int (*probe) (struct pnp_card_link *card, const struct pnp_card_device_id *card_id);
void (*remove) (struct pnp_card_link *card); void (*remove) (struct pnp_card_link *card);
struct pnp_driver link; struct pnp_driver link;
}; };
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/pci.h> #include <linux/pci.h>
/* /*
* Status codes (warnings and errors) * Return codes
*/ */
#define PNP_SUCCESS 0x00 #define PNP_SUCCESS 0x00
#define PNP_NOT_SET_STATICALLY 0x7f #define PNP_NOT_SET_STATICALLY 0x7f
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#define PNPMSG_POWER_OFF 0x41 #define PNPMSG_POWER_OFF 0x41
#define PNPMSG_PNP_OS_ACTIVE 0x42 #define PNPMSG_PNP_OS_ACTIVE 0x42
#define PNPMSG_PNP_OS_INACTIVE 0x43 #define PNPMSG_PNP_OS_INACTIVE 0x43
/* /*
* Plug and Play BIOS flags * Plug and Play BIOS flags
*/ */
...@@ -88,6 +89,12 @@ ...@@ -88,6 +89,12 @@
#define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000) #define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000)
#define pnpbios_is_dynamic(x) ((x)->flags & 0x0080) #define pnpbios_is_dynamic(x) ((x)->flags & 0x0080)
/*
* Function Parameters
*/
#define PNPMODE_STATIC 1
#define PNPMODE_DYNAMIC 0
/* 0x8000 through 0xffff are OEM defined */ /* 0x8000 through 0xffff are OEM defined */
#pragma pack(1) #pragma pack(1)
...@@ -125,8 +132,10 @@ struct pnp_bios_node { ...@@ -125,8 +132,10 @@ struct pnp_bios_node {
/* non-exported */ /* non-exported */
extern int pnpbios_dont_use_current_config; extern int pnpbios_dont_use_current_config;
extern struct pnp_dev_node_info node_info;
extern void *pnpbios_kmalloc(size_t size, int f); extern void *pnpbios_kmalloc(size_t size, int f);
extern int pnpbios_init (void); extern int pnpbios_init (void);
extern int pnpbios_interface_attach_device(struct pnp_bios_node * node);
extern int pnpbios_proc_init (void); extern int pnpbios_proc_init (void);
extern void pnpbios_proc_exit (void); extern void pnpbios_proc_exit (void);
......
...@@ -98,7 +98,7 @@ struct snd_card_als100 { ...@@ -98,7 +98,7 @@ struct snd_card_als100 {
struct pnp_dev *devopl; struct pnp_dev *devopl;
}; };
static struct pnp_card_id snd_als100_pnpids[] __devinitdata = { static struct pnp_card_device_id snd_als100_pnpids[] __devinitdata = {
/* ALS100 - PRO16PNP */ /* ALS100 - PRO16PNP */
{ .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, { .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } },
/* ALS110 - MF1000 - Digimate 3D Sound */ /* ALS110 - MF1000 - Digimate 3D Sound */
...@@ -118,7 +118,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); ...@@ -118,7 +118,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids);
static int __devinit snd_card_als100_isapnp(int dev, struct snd_card_als100 *acard, static int __devinit snd_card_als100_isapnp(int dev, struct snd_card_als100 *acard,
struct pnp_card_link *card, struct pnp_card_link *card,
const struct pnp_card_id *id) const struct pnp_card_device_id *id)
{ {
struct pnp_dev *pdev; struct pnp_dev *pdev;
struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table)); struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table));
...@@ -151,6 +151,7 @@ static int __devinit snd_card_als100_isapnp(int dev, struct snd_card_als100 *aca ...@@ -151,6 +151,7 @@ static int __devinit snd_card_als100_isapnp(int dev, struct snd_card_als100 *aca
err = pnp_activate_dev(pdev); err = pnp_activate_dev(pdev);
if (err < 0) { if (err < 0) {
printk(KERN_ERR PFX "AUDIO pnp configure failure\n"); printk(KERN_ERR PFX "AUDIO pnp configure failure\n");
kfree(cfg);
return err; return err;
} }
port[dev] = pnp_port_start(pdev, 0); port[dev] = pnp_port_start(pdev, 0);
...@@ -209,7 +210,7 @@ static int __devinit snd_card_als100_isapnp(int dev, struct snd_card_als100 *aca ...@@ -209,7 +210,7 @@ static int __devinit snd_card_als100_isapnp(int dev, struct snd_card_als100 *aca
static int __init snd_card_als100_probe(int dev, static int __init snd_card_als100_probe(int dev,
struct pnp_card_link *pcard, struct pnp_card_link *pcard,
const struct pnp_card_id *pid) const struct pnp_card_device_id *pid)
{ {
int error; int error;
sb_t *chip; sb_t *chip;
...@@ -287,7 +288,7 @@ static int __init snd_card_als100_probe(int dev, ...@@ -287,7 +288,7 @@ static int __init snd_card_als100_probe(int dev,
} }
static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card, static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card,
const struct pnp_card_id *id) const struct pnp_card_device_id *id)
{ {
static int dev; static int dev;
int res; int res;
......
...@@ -69,7 +69,7 @@ struct snd_card_es968 { ...@@ -69,7 +69,7 @@ struct snd_card_es968 {
struct pnp_dev *dev; struct pnp_dev *dev;
}; };
static struct pnp_card_id snd_es968_pnpids[] __devinitdata = { static struct pnp_card_device_id snd_es968_pnpids[] __devinitdata = {
{ .id = "ESS0968", .devs = { { "@@@0968" }, } }, { .id = "ESS0968", .devs = { { "@@@0968" }, } },
{ .id = "", } /* end */ { .id = "", } /* end */
}; };
...@@ -92,7 +92,7 @@ static void snd_card_es968_interrupt(int irq, void *dev_id, ...@@ -92,7 +92,7 @@ static void snd_card_es968_interrupt(int irq, void *dev_id,
static int __devinit snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard, static int __devinit snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard,
struct pnp_card_link *card, struct pnp_card_link *card,
const struct pnp_card_id *id) const struct pnp_card_device_id *id)
{ {
struct pnp_dev *pdev; struct pnp_dev *pdev;
struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table)); struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table));
...@@ -133,7 +133,7 @@ static int __devinit snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard ...@@ -133,7 +133,7 @@ static int __devinit snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard
static int __init snd_card_es968_probe(int dev, static int __init snd_card_es968_probe(int dev,
struct pnp_card_link *pcard, struct pnp_card_link *pcard,
const struct pnp_card_id *pid) const struct pnp_card_device_id *pid)
{ {
int error; int error;
sb_t *chip; sb_t *chip;
...@@ -188,7 +188,7 @@ static int __init snd_card_es968_probe(int dev, ...@@ -188,7 +188,7 @@ static int __init snd_card_es968_probe(int dev,
} }
static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card, static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card,
const struct pnp_card_id *id) const struct pnp_card_device_id *id)
{ {
static int dev; static int dev;
int res; int res;
......
...@@ -23,11 +23,7 @@ ...@@ -23,11 +23,7 @@
#include <asm/dma.h> #include <asm/dma.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#ifndef LINUX_ISAPNP_H #include <linux/pnp.h>
#include <linux/isapnp.h>
#define isapnp_card pci_bus
#define isapnp_dev pci_dev
#endif
#include <sound/core.h> #include <sound/core.h>
#include <sound/sb.h> #include <sound/sb.h>
#include <sound/sb16_csp.h> #include <sound/sb16_csp.h>
...@@ -77,7 +73,7 @@ MODULE_DEVICES("{{Creative Labs,SB AWE 32}," ...@@ -77,7 +73,7 @@ MODULE_DEVICES("{{Creative Labs,SB AWE 32},"
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
#endif #endif
static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */
...@@ -106,10 +102,10 @@ MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); ...@@ -106,10 +102,10 @@ MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(enable, "Enable SoundBlaster 16 soundcard."); MODULE_PARM_DESC(enable, "Enable SoundBlaster 16 soundcard.");
MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM(pnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard."); MODULE_PARM_DESC(pnp, "PnP detection for specified soundcard.");
MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); MODULE_PARM_SYNTAX(pnp, SNDRV_ISAPNP_DESC);
#endif #endif
MODULE_PARM(port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM(port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
MODULE_PARM_DESC(port, "Port # for SB16 driver."); MODULE_PARM_DESC(port, "Port # for SB16 driver.");
...@@ -148,231 +144,211 @@ MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); ...@@ -148,231 +144,211 @@ MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
MODULE_PARM_SYNTAX(seq_ports, SNDRV_ENABLED ",allows:{{0,8}},skill:advanced"); MODULE_PARM_SYNTAX(seq_ports, SNDRV_ENABLED ",allows:{{0,8}},skill:advanced");
#endif #endif
struct snd_sb16 { struct snd_card_sb16 {
struct resource *fm_res; /* used to block FM i/o region for legacy cards */ struct resource *fm_res; /* used to block FM i/o region for legacy cards */
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
struct isapnp_dev *dev; int dev_no;
struct pnp_dev *dev;
#ifdef SNDRV_SBAWE_EMU8000 #ifdef SNDRV_SBAWE_EMU8000
struct isapnp_dev *devwt; struct pnp_dev *devwt;
#endif #endif
#endif #endif
}; };
static snd_card_t *snd_sb16_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static snd_card_t *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
#ifdef __ISAPNP__
static struct isapnp_card *snd_sb16_isapnp_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static struct pnp_card_device_id snd_sb16_pnpids[] __devinitdata = {
static const struct isapnp_card_id *snd_sb16_isapnp_id[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
#define ISAPNP_SB16(_va, _vb, _vc, _device, _audio) \
{ \
ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
.devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), } \
}
#define ISAPNP_SBAWE(_va, _vb, _vc, _device, _audio, _awe) \
{ \
ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
.devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \
ISAPNP_DEVICE_ID(_va, _vb, _vc, _awe), } \
}
static struct isapnp_card_id snd_sb16_pnpids[] __devinitdata = {
#ifndef SNDRV_SBAWE #ifndef SNDRV_SBAWE
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x0024,0x0031), { .id = "CTL0024", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x0025,0x0031), { .id = "CTL0025", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x0026,0x0031), { .id = "CTL0026", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x0027,0x0031), { .id = "CTL0027", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x0028,0x0031), { .id = "CTL0028", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x0029,0x0031), { .id = "CTL0029", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x002a,0x0031), { .id = "CTL002a", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
/* Note: This card has also a CTL0051:StereoEnhance device!!! */ /* Note: This card has also a CTL0051:StereoEnhance device!!! */
ISAPNP_SB16('C','T','L',0x002b,0x0031), { .id = "CTL002b", .devs = { { "CTL0031" } } },
/* Sound Blaster 16 PnP */ /* Sound Blaster 16 PnP */
ISAPNP_SB16('C','T','L',0x002c,0x0031), { .id = "CTL002c", .devs = { { "CTL0031" } } },
/* Sound Blaster Vibra16S */ /* Sound Blaster Vibra16S */
ISAPNP_SB16('C','T','L',0x0051,0x0001), { .id = "CTL0051", .devs = { { "CTL0001" } } },
/* Sound Blaster Vibra16C */ /* Sound Blaster Vibra16C */
ISAPNP_SB16('C','T','L',0x0070,0x0001), { .id = "CTL0070", .devs = { { "CTL0001" } } },
/* Sound Blaster Vibra16CL - added by ctm@ardi.com */ /* Sound Blaster Vibra16CL - added by ctm@ardi.com */
ISAPNP_SB16('C','T','L',0x0080,0x0041), { .id = "CTL0080", .devs = { { "CTL0041" } } },
/* Sound Blaster 16 'value' PnP. It says model ct4130 on the pcb, */ /* Sound Blaster 16 'value' PnP. It says model ct4130 on the pcb, */
/* but ct4131 on a sticker on the board.. */ /* but ct4131 on a sticker on the board.. */
ISAPNP_SB16('C','T','L',0x0086,0x0041), { .id = "CTL0086", .devs = { { "CTL0041" } } },
/* Sound Blaster Vibra16X */ /* Sound Blaster Vibra16X */
ISAPNP_SB16('C','T','L',0x00f0,0x0043), { .id = "CTL00f0", .devs = { { "CTL0043" } } },
#else /* SNDRV_SBAWE defined */ #else /* SNDRV_SBAWE defined */
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0035,0x0031,0x0021), { .id = "CTL0035", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0039,0x0031,0x0021), { .id = "CTL0039", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0042,0x0031,0x0021), { .id = "CTL0042", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0043,0x0031,0x0021), { .id = "CTL0043", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
/* Note: This card has also a CTL0051:StereoEnhance device!!! */ /* Note: This card has also a CTL0051:StereoEnhance device!!! */
ISAPNP_SBAWE('C','T','L',0x0044,0x0031,0x0021), { .id = "CTL0044", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
/* Note: This card has also a CTL0051:StereoEnhance device!!! */ /* Note: This card has also a CTL0051:StereoEnhance device!!! */
ISAPNP_SBAWE('C','T','L',0x0045,0x0031,0x0021), { .id = "CTL0045", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0046,0x0031,0x0021), { .id = "CTL0046", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0047,0x0031,0x0021), { .id = "CTL0047", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0048,0x0031,0x0021), { .id = "CTL0048", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x0054,0x0031,0x0021), { .id = "CTL0054", .devs = { { "CTL0031" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x009a,0x0041,0x0021), { .id = "CTL009a", .devs = { { "CTL0041" }, { "CTL0021" } } },
/* Sound Blaster AWE 32 PnP */ /* Sound Blaster AWE 32 PnP */
ISAPNP_SBAWE('C','T','L',0x009c,0x0041,0x0021), { .id = "CTL009c", .devs = { { "CTL0041" }, { "CTL0021" } } },
/* Sound Blaster 32 PnP */ /* Sound Blaster 32 PnP */
ISAPNP_SBAWE('C','T','L',0x009f,0x0041,0x0021), { .id = "CTL009f", .devs = { { "CTL0041" }, { "CTL0021" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x009d,0x0042,0x0022), { .id = "CTL009d", .devs = { { "CTL0042" }, { "CTL0022" } } },
/* Sound Blaster AWE 64 PnP Gold */ /* Sound Blaster AWE 64 PnP Gold */
ISAPNP_SBAWE('C','T','L',0x009e,0x0044,0x0023), { .id = "CTL009e", .devs = { { "CTL0044" }, { "CTL0023" } } },
/* Sound Blaster AWE 64 PnP Gold */ /* Sound Blaster AWE 64 PnP Gold */
ISAPNP_SBAWE('C','T','L',0x00b2,0x0044,0x0023), { .id = "CTL00b2", .devs = { { "CTL0044" }, { "CTL0023" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x00c1,0x0042,0x0022), { .id = "CTL00c1", .devs = { { "CTL0042" }, { "CTL0022" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x00c3,0x0045,0x0022), { .id = "CTL00c3", .devs = { { "CTL0045" }, { "CTL0022" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x00c5,0x0045,0x0022), { .id = "CTL00c5", .devs = { { "CTL0045" }, { "CTL0022" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x00c7,0x0045,0x0022), { .id = "CTL00c7", .devs = { { "CTL0045" }, { "CTL0022" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x00e4,0x0045,0x0022), { .id = "CTL00e4", .devs = { { "CTL0045" }, { "CTL0022" } } },
/* Sound Blaster AWE 64 PnP */ /* Sound Blaster AWE 64 PnP */
ISAPNP_SBAWE('C','T','L',0x00e9,0x0045,0x0022), { .id = "CTL00e9", .devs = { { "CTL0045" }, { "CTL0022" } } },
/* Sound Blaster 16 PnP (AWE) */ /* Sound Blaster 16 PnP (AWE) */
ISAPNP_SBAWE('C','T','L',0x00ed,0x0041,0x0070), { .id = "CTL00ed", .devs = { { "CTL0041" }, { "CTL0070" } } },
/* Generic entries */ /* Generic entries */
ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0031,0x0021), { .id = "CTLXXXX" , .devs = { { "CTL0031" }, { "CTL0021" } } },
ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0041,0x0021), { .id = "CTLXXXX" , .devs = { { "CTL0041" }, { "CTL0021" } } },
ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0042,0x0022), { .id = "CTLXXXX" , .devs = { { "CTL0042" }, { "CTL0022" } } },
ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0044,0x0023), { .id = "CTLXXXX" , .devs = { { "CTL0044" }, { "CTL0023" } } },
ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0045,0x0022), { .id = "CTLXXXX" , .devs = { { "CTL0045" }, { "CTL0022" } } },
#endif /* SNDRV_SBAWE */ #endif /* SNDRV_SBAWE */
{ ISAPNP_CARD_END, } { .id = "", }
}; };
ISAPNP_CARD_TABLE(snd_sb16_pnpids); MODULE_DEVICE_TABLE(pnp_card, snd_sb16_pnpids);
#ifdef SNDRV_SBAWE_EMU8000
#define DRIVER_NAME "snd-card-sbawe"
#else
#define DRIVER_NAME "snd-card-sb16"
#endif
static int __init snd_sb16_isapnp(int dev, struct snd_sb16 *acard) static int __devinit snd_card_sb16_pnp(int dev, struct snd_card_sb16 *acard,
struct pnp_card_link *card,
const struct pnp_card_device_id *id)
{ {
const struct isapnp_card_id *id = snd_sb16_isapnp_id[dev]; struct pnp_dev *pdev;
struct isapnp_card *card = snd_sb16_isapnp_cards[dev]; struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table));
struct isapnp_dev *pdev; int err;
acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); if (!cfg)
if (acard->dev->active) { return -ENOMEM;
acard->dev = NULL; acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
return -EBUSY; if (acard->dev == NULL) {
kfree(cfg);
return -ENODEV;
} }
#ifdef SNDRV_SBAWE_EMU8000 #ifdef SNDRV_SBAWE_EMU8000
acard->devwt = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL); acard->devwt = pnp_request_card_device(card, id->devs[1].id, acard->dev);
if (acard->devwt->active) {
acard->dev = acard->devwt = NULL;
return -EBUSY;
}
#endif #endif
/* Audio initialization */ /* Audio initialization */
pdev = acard->dev; pdev = acard->dev;
if (pdev->prepare(pdev) < 0)
return -EAGAIN; pnp_init_resource_table(cfg);
/* override resources */
if (port[dev] != SNDRV_AUTO_PORT) if (port[dev] != SNDRV_AUTO_PORT)
isapnp_resource_change(&pdev->resource[0], port[dev], 16); pnp_resource_change(&cfg->port_resource[0], port[dev], 16);
if (mpu_port[dev] != SNDRV_AUTO_PORT) if (mpu_port[dev] != SNDRV_AUTO_PORT)
isapnp_resource_change(&pdev->resource[1], mpu_port[dev], 2); pnp_resource_change(&cfg->port_resource[1], mpu_port[dev], 2);
if (fm_port[dev] != SNDRV_AUTO_PORT) if (fm_port[dev] != SNDRV_AUTO_PORT)
isapnp_resource_change(&pdev->resource[2], fm_port[dev], 4); pnp_resource_change(&cfg->port_resource[2], fm_port[dev], 4);
if (dma8[dev] != SNDRV_AUTO_DMA) if (dma8[dev] != SNDRV_AUTO_DMA)
isapnp_resource_change(&pdev->dma_resource[0], dma8[dev], 1); pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 1);
if (dma16[dev] != SNDRV_AUTO_DMA) if (dma16[dev] != SNDRV_AUTO_DMA)
isapnp_resource_change(&pdev->dma_resource[1], dma16[dev], 1); pnp_resource_change(&cfg->dma_resource[1], dma16[dev], 1);
if (irq[dev] != SNDRV_AUTO_IRQ) if (irq[dev] != SNDRV_AUTO_IRQ)
isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);
if (pdev->activate(pdev) < 0) { if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0)
printk(KERN_ERR PFX "isapnp configure failure (out of resources?)\n"); printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n");
return -EBUSY; err = pnp_activate_dev(pdev);
if (err < 0) {
printk(KERN_ERR PFX "AUDIO pnp configure failure\n");
kfree(cfg);
return err;
} }
port[dev] = pdev->resource[0].start; port[dev] = pnp_port_start(pdev, 0);
mpu_port[dev] = pdev->resource[1].start; mpu_port[dev] = pnp_port_start(pdev, 1);
fm_port[dev] = pdev->resource[2].start; fm_port[dev] = pnp_port_start(pdev, 2);
dma8[dev] = pdev->dma_resource[0].start; dma8[dev] = pnp_dma(pdev, 0);
dma16[dev] = pdev->dma_resource[1].start; dma16[dev] = pnp_dma(pdev, 1);
irq[dev] = pdev->irq_resource[0].start; irq[dev] = pnp_irq(pdev, 0);
snd_printdd("isapnp SB16: port=0x%lx, mpu port=0x%lx, fm port=0x%lx\n", snd_printdd("pnp SB16: port=0x%lx, mpu port=0x%lx, fm port=0x%lx\n",
port[dev], mpu_port[dev], fm_port[dev]); port[dev], mpu_port[dev], fm_port[dev]);
snd_printdd("isapnp SB16: dma1=%i, dma2=%i, irq=%i\n", snd_printdd("pnp SB16: dma1=%i, dma2=%i, irq=%i\n",
dma8[dev], dma16[dev], irq[dev]); dma8[dev], dma16[dev], irq[dev]);
#ifdef SNDRV_SBAWE_EMU8000 #ifdef SNDRV_SBAWE_EMU8000
/* WaveTable initialization */ /* WaveTable initialization */
pdev = acard->devwt; pdev = acard->devwt;
if (pdev->prepare(pdev)<0) { if (pdev != NULL) {
acard->dev->deactivate(acard->dev); pnp_init_resource_table(cfg);
return -EAGAIN;
}
if (awe_port[dev] != SNDRV_AUTO_PORT) {
isapnp_resource_change(&pdev->resource[0], awe_port[dev], 4);
isapnp_resource_change(&pdev->resource[1], awe_port[dev] + 0x400, 4);
isapnp_resource_change(&pdev->resource[2], awe_port[dev] + 0x800, 4);
}
if (pdev->activate(pdev)<0) {
printk(KERN_ERR PFX "WaveTable isapnp configure failure (out of resources?)\n");
acard->dev->deactivate(acard->dev);
return -EBUSY;
}
awe_port[dev] = pdev->resource[0].start;
snd_printdd("isapnp SB16: wavetable port=0x%lx\n", pdev->resource[0].start);
#endif
return 0;
}
static void snd_sb16_deactivate(struct snd_sb16 *acard) /* override resources */
{
if (acard->dev) { if (awe_port[dev] != SNDRV_AUTO_PORT) {
acard->dev->deactivate(acard->dev); pnp_resource_change(&cfg->port_resource[0], awe_port[dev], 4);
acard->dev = NULL; pnp_resource_change(&cfg->port_resource[1], awe_port[dev] + 0x400, 4);
pnp_resource_change(&cfg->port_resource[2], awe_port[dev] + 0x800, 4);
}
if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0)
printk(KERN_ERR PFX "WaveTable the requested resources are invalid, using auto config\n");
err = pnp_activate_dev(pdev);
if (err < 0) {
goto __wt_error;
}
awe_port[dev] = pnp_port_start(pdev, 0);
snd_printdd("pnp SB16: wavetable port=0x%lx\n", pdev->resource[0].start);
} else {
__wt_error:
if (pdev) {
pnp_release_card_device(pdev);
printk(KERN_ERR PFX "WaveTable pnp configure failure\n");
} }
#ifdef SNDRV_SBAWE_EMU8000
if (acard->devwt) {
acard->devwt->deactivate(acard->devwt);
acard->devwt = NULL; acard->devwt = NULL;
awe_port[dev] = -1;
} }
#endif #endif
kfree(cfg);
return 0;
} }
#endif /* __ISAPNP__ */ static int __init snd_sb16_probe(int dev,
struct pnp_card_link *pcard,
static void snd_sb16_free(snd_card_t *card) const struct pnp_card_device_id *pid)
{
struct snd_sb16 *acard = (struct snd_sb16 *)card->private_data;
if (acard == NULL)
return;
if (acard->fm_res) {
release_resource(acard->fm_res);
kfree_nocheck(acard->fm_res);
}
#ifdef __ISAPNP__
snd_sb16_deactivate(acard);
#endif
}
static int __init snd_sb16_probe(int dev)
{ {
static int possible_irqs[] = {5, 9, 10, 7, -1}; static int possible_irqs[] = {5, 9, 10, 7, -1};
static int possible_dmas8[] = {1, 3, 0, -1}; static int possible_dmas8[] = {1, 3, 0, -1};
...@@ -380,7 +356,7 @@ static int __init snd_sb16_probe(int dev) ...@@ -380,7 +356,7 @@ static int __init snd_sb16_probe(int dev)
int xirq, xdma8, xdma16; int xirq, xdma8, xdma16;
sb_t *chip; sb_t *chip;
snd_card_t *card; snd_card_t *card;
struct snd_sb16 *acard; struct snd_card_sb16 *acard;
opl3_t *opl3; opl3_t *opl3;
snd_hwdep_t *synth = NULL; snd_hwdep_t *synth = NULL;
#ifdef CONFIG_SND_SB16_CSP #ifdef CONFIG_SND_SB16_CSP
...@@ -390,22 +366,21 @@ static int __init snd_sb16_probe(int dev) ...@@ -390,22 +366,21 @@ static int __init snd_sb16_probe(int dev)
int err; int err;
card = snd_card_new(index[dev], id[dev], THIS_MODULE, card = snd_card_new(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_sb16)); sizeof(struct snd_card_sb16));
if (card == NULL) if (card == NULL)
return -ENOMEM; return -ENOMEM;
acard = (struct snd_sb16 *) card->private_data; acard = (struct snd_card_sb16 *) card->private_data;
card->private_free = snd_sb16_free; if (isapnp[dev]) {
#ifdef __ISAPNP__ if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) {
if (isapnp[dev] && snd_sb16_isapnp(dev, acard) < 0) {
snd_card_free(card); snd_card_free(card);
return -EBUSY; return err;
}
} }
#endif
xirq = irq[dev]; xirq = irq[dev];
xdma8 = dma8[dev]; xdma8 = dma8[dev];
xdma16 = dma16[dev]; xdma16 = dma16[dev];
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
if (!isapnp[dev]) { if (!isapnp[dev]) {
#endif #endif
if (xirq == SNDRV_AUTO_IRQ) { if (xirq == SNDRV_AUTO_IRQ) {
...@@ -437,7 +412,7 @@ static int __init snd_sb16_probe(int dev) ...@@ -437,7 +412,7 @@ static int __init snd_sb16_probe(int dev)
/* non-PnP AWE port address is hardwired with base port address */ /* non-PnP AWE port address is hardwired with base port address */
awe_port[dev] = port[dev] + 0x400; awe_port[dev] = port[dev] + 0x400;
#endif #endif
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
} }
#endif #endif
...@@ -458,7 +433,7 @@ static int __init snd_sb16_probe(int dev) ...@@ -458,7 +433,7 @@ static int __init snd_sb16_probe(int dev)
return -ENODEV; return -ENODEV;
} }
chip->mpu_port = mpu_port[dev]; chip->mpu_port = mpu_port[dev];
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) { if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) {
#else #else
if ((err = snd_sb16dsp_configure(chip)) < 0) { if ((err = snd_sb16dsp_configure(chip)) < 0) {
...@@ -554,7 +529,10 @@ static int __init snd_sb16_probe(int dev) ...@@ -554,7 +529,10 @@ static int __init snd_sb16_probe(int dev)
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
snd_sb16_cards[dev] = card; if (pcard)
pnp_set_card_drvdata(pcard, card);
else
snd_sb16_legacy[dev] = card;
return 0; return 0;
} }
...@@ -566,12 +544,12 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport) ...@@ -566,12 +544,12 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport)
for ( ; dev < SNDRV_CARDS; dev++) { for ( ; dev < SNDRV_CARDS; dev++) {
if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT)
continue; continue;
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
if (isapnp[dev]) if (isapnp[dev])
continue; continue;
#endif #endif
port[dev] = xport; port[dev] = xport;
res = snd_sb16_probe(dev); res = snd_sb16_probe(dev, NULL, NULL);
if (res < 0) if (res < 0)
port[dev] = SNDRV_AUTO_PORT; port[dev] = SNDRV_AUTO_PORT;
return res; return res;
...@@ -579,10 +557,10 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport) ...@@ -579,10 +557,10 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport)
return -ENODEV; return -ENODEV;
} }
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
static int __init snd_sb16_isapnp_detect(struct isapnp_card *card, static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card,
const struct isapnp_card_id *id) const struct pnp_card_device_id *id)
{ {
static int dev; static int dev;
int res; int res;
...@@ -590,9 +568,7 @@ static int __init snd_sb16_isapnp_detect(struct isapnp_card *card, ...@@ -590,9 +568,7 @@ static int __init snd_sb16_isapnp_detect(struct isapnp_card *card,
for ( ; dev < SNDRV_CARDS; dev++) { for ( ; dev < SNDRV_CARDS; dev++) {
if (!enable[dev] || !isapnp[dev]) if (!enable[dev] || !isapnp[dev])
continue; continue;
snd_sb16_isapnp_cards[dev] = card; res = snd_sb16_probe(dev, card, id);
snd_sb16_isapnp_id[dev] = id;
res = snd_sb16_probe(dev);
if (res < 0) if (res < 0)
return res; return res;
dev++; dev++;
...@@ -602,7 +578,23 @@ static int __init snd_sb16_isapnp_detect(struct isapnp_card *card, ...@@ -602,7 +578,23 @@ static int __init snd_sb16_isapnp_detect(struct isapnp_card *card,
return -ENODEV; return -ENODEV;
} }
#endif /* __ISAPNP__ */ #endif
static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard)
{
snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);
snd_card_disconnect(card);
snd_card_free_in_thread(card);
}
static struct pnp_card_driver sb16_pnpc_driver = {
.flags = PNP_DRIVER_RES_DISABLE,
.name = "sb16",
.id_table = snd_sb16_pnpids,
.probe = snd_sb16_pnp_detect,
.remove = __devexit_p(snd_sb16_pnp_remove),
};
static int __init alsa_card_sb16_init(void) static int __init alsa_card_sb16_init(void)
{ {
...@@ -613,11 +605,11 @@ static int __init alsa_card_sb16_init(void) ...@@ -613,11 +605,11 @@ static int __init alsa_card_sb16_init(void)
for (dev = 0; dev < SNDRV_CARDS; dev++) { for (dev = 0; dev < SNDRV_CARDS; dev++) {
if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT)
continue; continue;
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
if (isapnp[dev]) if (isapnp[dev])
continue; continue;
#endif #endif
if (!snd_sb16_probe(dev)) { if (!snd_sb16_probe(dev, NULL, NULL)) {
cards++; cards++;
continue; continue;
} }
...@@ -627,9 +619,9 @@ static int __init alsa_card_sb16_init(void) ...@@ -627,9 +619,9 @@ static int __init alsa_card_sb16_init(void)
} }
/* legacy auto configured cards */ /* legacy auto configured cards */
cards += snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port); cards += snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port);
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
/* ISA PnP cards at last */ /* PnP cards at last */
cards += isapnp_probe_cards(snd_sb16_pnpids, snd_sb16_isapnp_detect); cards += pnp_register_card_driver(&sb16_pnpc_driver);
#endif #endif
if (!cards) { if (!cards) {
...@@ -650,8 +642,12 @@ static void __exit alsa_card_sb16_exit(void) ...@@ -650,8 +642,12 @@ static void __exit alsa_card_sb16_exit(void)
{ {
int dev; int dev;
#ifdef CONFIG_PNP
/* PnP cards first */
pnp_unregister_card_driver(&sb16_pnpc_driver);
#endif
for (dev = 0; dev < SNDRV_CARDS; dev++) for (dev = 0; dev < SNDRV_CARDS; dev++)
snd_card_free(snd_sb16_cards[dev]); snd_card_free(snd_sb16_legacy[dev]);
} }
module_init(alsa_card_sb16_init) module_init(alsa_card_sb16_init)
...@@ -659,7 +655,7 @@ module_exit(alsa_card_sb16_exit) ...@@ -659,7 +655,7 @@ module_exit(alsa_card_sb16_exit)
#ifndef MODULE #ifndef MODULE
/* format is: snd-sb16=enable,index,id,isapnp, /* format is: snd-sb16=enable,index,id,pnp,
port,mpu_port,fm_port, port,mpu_port,fm_port,
irq,dma8,dma16, irq,dma8,dma16,
mic_agc,csp, mic_agc,csp,
...@@ -694,7 +690,7 @@ static int __init alsa_card_sb16_setup(char *str) ...@@ -694,7 +690,7 @@ static int __init alsa_card_sb16_setup(char *str)
get_option(&str,&seq_ports[nr_dev]) == 2 get_option(&str,&seq_ports[nr_dev]) == 2
#endif #endif
); );
#ifdef __ISAPNP__ #ifdef CONFIG_PNP
if (pnp != INT_MAX) if (pnp != INT_MAX)
isapnp[nr_dev] = pnp; isapnp[nr_dev] = pnp;
#endif #endif
......
...@@ -224,7 +224,7 @@ static void sb_dev2cfg(struct pnp_dev *dev, struct sb_card_config *scc) ...@@ -224,7 +224,7 @@ static void sb_dev2cfg(struct pnp_dev *dev, struct sb_card_config *scc)
} }
/* Probe callback function for the PnP API */ /* Probe callback function for the PnP API */
static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_id *card_id) static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id)
{ {
struct sb_card_config *scc; struct sb_card_config *scc;
struct sb_module_options sbmo = {0}; /* Default to 0 for PnP */ struct sb_module_options sbmo = {0}; /* Default to 0 for PnP */
......
...@@ -23,7 +23,7 @@ struct sb_card_config { ...@@ -23,7 +23,7 @@ struct sb_card_config {
*/ */
/* Card PnP ID Table */ /* Card PnP ID Table */
static struct pnp_card_id sb_pnp_card_table[] = { static struct pnp_card_device_id sb_pnp_card_table[] = {
/* Sound Blaster 16 */ /* Sound Blaster 16 */
{.id = "CTL0024", .driver_data = 0, devs : { {.id="CTL0031"}, } }, {.id = "CTL0024", .driver_data = 0, devs : { {.id="CTL0031"}, } },
/* Sound Blaster 16 */ /* Sound Blaster 16 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment