diff -u -p linux/drivers/net/irda/nsc-ircc.j2.c linux/drivers/net/irda/nsc-ircc.c --- linux/drivers/net/irda/nsc-ircc.j2.c 2004-11-16 23:53:42.000000000 -0800 +++ linux/drivers/net/irda/nsc-ircc.c 2004-11-17 03:42:04.000000000 -0800 @@ -12,6 +12,7 @@ * Copyright (c) 1998-2000 Dag Brattli * Copyright (c) 1998 Lichen Wang, * Copyright (c) 1998 Actisys Corp., www.actisys.com + * Copyright (c) 2000-2004 Jean Tourrilhes * All Rights Reserved * * This program is free software; you can redistribute it and/or @@ -53,6 +54,7 @@ #include #include #include +#include #include #include @@ -86,6 +88,7 @@ static int nsc_ircc_probe_39x(nsc_chip_t static int nsc_ircc_init_108(nsc_chip_t *chip, chipio_t *info); static int nsc_ircc_init_338(nsc_chip_t *chip, chipio_t *info); static int nsc_ircc_init_39x(nsc_chip_t *chip, chipio_t *info); +static int __devinit nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id); /* These are the known NSC chips */ static nsc_chip_t chips[] = { @@ -128,6 +131,20 @@ static char *dongle_types[] = { "No dongle connected", }; +/* PNP probing */ +static const struct pnp_device_id nsc_ircc_pnp_table[] = { + { .id = "NSC6001", .driver_data = 0 }, + { } +}; + +MODULE_DEVICE_TABLE(pnp, nsc_ircc_pnp_table); + +static struct pnp_driver nsc_ircc_pnp_driver = { + .name = "nsc-ircc", + .id_table = nsc_ircc_pnp_table, + .probe = nsc_ircc_pnp_probe, +}; + /* Some prototypes */ static int nsc_ircc_open(int i, chipio_t *info); static int nsc_ircc_close(struct nsc_ircc_cb *self); @@ -150,6 +167,9 @@ static int nsc_ircc_net_ioctl(struct ne static struct net_device_stats *nsc_ircc_net_get_stats(struct net_device *dev); static int nsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data); +/* Globals */ +static int pnp_registered_port; + /* * Function nsc_ircc_init () * @@ -165,6 +185,13 @@ static int __init nsc_ircc_init(void) int cfg, id; int reg; int i = 0; + int r; + + /* Register with PnP subsystem to detect disable ports */ + r = pnp_register_driver(&nsc_ircc_pnp_driver); + if (r >= 0) { + pnp_registered_port = 1; + } /* Probe for all the NSC chipsets we know about */ for (chip=chips; chip->name ; chip++) { @@ -231,6 +258,9 @@ static void __exit nsc_ircc_cleanup(void pm_unregister_all(nsc_ircc_pmproc); + if (pnp_registered_port) + pnp_unregister_driver(&nsc_ircc_pnp_driver); + for (i=0; i < 4; i++) { if (dev_self[i]) nsc_ircc_close(dev_self[i]); @@ -808,6 +838,46 @@ static int nsc_ircc_probe_39x(nsc_chip_t return 0; } +/* PNP probing */ +static int __devinit +nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) +{ + chipio_t info; + + memset(&info, 0, sizeof(chipio_t)); + info.irq = -1; + info.dma = -1; + + /* There don't seem to be any way to get the cfg_base. + * On my box, cfg_base is in the PnP descriptor of the + * motherboard. Oh well... Jean II */ + + if (pnp_port_valid(dev, 0) && + !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) + info.fir_base = pnp_port_start(dev, 0); + + if (pnp_irq_valid(dev, 0) && + !(pnp_irq_flags(dev, 0) & IORESOURCE_DISABLED)) + info.irq = pnp_irq(dev, 0); + + if (pnp_dma_valid(dev, 0) && + !(pnp_dma_flags(dev, 0) & IORESOURCE_DISABLED)) + info.dma = pnp_dma(dev, 0); + + IRDA_DEBUG(0, "%s() : Found cfg_base 0x%03X ; firbase 0x%03X ; irq %d ; dma %d.\n", __FUNCTION__, info.cfg_base, info.fir_base, info.irq, info.dma); + + if((info.cfg_base == 0) || (info.fir_base == 0) || + (info.irq == -1) || (info.dma == -1)) { + /* Returning an error will disable the device. Yuck ! */ + //return -EINVAL; + return 0; + } + + /* We should identify and initialise the device */ + + return 0; +} + /* * Function nsc_ircc_setup (info) * @@ -2218,5 +2288,4 @@ MODULE_PARM(dongle_id, "i"); MODULE_PARM_DESC(dongle_id, "Type-id of used dongle"); module_init(nsc_ircc_init); -module_exit(nsc_ircc_cleanup); - +m \ No newline at end of file