diff -u -p linux/drivers/net/irda/smsc-ircc2.j2.c linux/drivers/net/irda/smsc-ircc2.c --- linux/drivers/net/irda/smsc-ircc2.j2.c Wed Nov 17 11:19:05 2004 +++ linux/drivers/net/irda/smsc-ircc2.c Wed Nov 17 11:33:04 2004 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -178,6 +179,7 @@ static void smsc_ircc_set_transceiver_fo static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self); /* Probing */ +static int __devinit smsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id); static int __init smsc_ircc_look_for_chips(void); static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg,const smsc_chip_t *chip,char *type); static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfg_base, char *type); @@ -291,6 +293,21 @@ static smsc_chip_address_t __initdata po {0,0} }; +/* PNP probing */ + +static const struct pnp_device_id smsc_ircc_pnp_table[] = { + { .id = "SMCf010", .driver_data = 0 }, + { } +}; + +MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table); + +static struct pnp_driver smsc_ircc_pnp_driver = { + .name = "smsc-ircc2", + .id_table = smsc_ircc_pnp_table, + .probe = smsc_ircc_pnp_probe, +}; + /* Globals */ static struct smsc_ircc_cb *dev_self[] = { NULL, NULL}; @@ -304,6 +321,8 @@ static int ircc_transceiver=0; static unsigned short dev_count=0; +static int pnp_registered_port; + static inline void register_bank(int iobase, int bank) { outb(((inb(iobase+IRCC_MASTER) & 0xf0) | (bank & 0x07)), @@ -1744,6 +1763,9 @@ static void __exit smsc_ircc_cleanup(voi IRDA_DEBUG(1, "%s\n", __FUNCTION__); + if (pnp_registered_port) + pnp_unregister_driver(&smsc_ircc_pnp_driver); + for (i=0; i < 2; i++) { if (dev_self[i]) smsc_ircc_close(dev_self[i]); @@ -2001,8 +2023,16 @@ static int __init smsc_ircc_look_for_chi smsc_chip_address_t *address; char *type; unsigned int cfg_base, found; + int r; found = 0; + + r = pnp_register_driver(&smsc_ircc_pnp_driver); + if (r >= 0) { + pnp_registered_port = 1; + found += r; + } + address = possible_addresses; while(address->cfg_base){ @@ -2032,6 +2062,43 @@ static int __init smsc_ircc_look_for_chi } return found; } + +/* PNP probing */ +static int __devinit +smsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) +{ + unsigned int firbase, sirbase; + u8 dma, irq; + + if (pnp_port_valid(dev, 0) && + !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) + sirbase = pnp_port_start(dev, 0); + else + return -EINVAL; + + if (pnp_port_valid(dev, 1) && + !(pnp_port_flags(dev, 1) & IORESOURCE_DISABLED)) + firbase = pnp_port_start(dev, 1); + else + return -EINVAL; + + if (pnp_irq_valid(dev, 0) && + !(pnp_irq_flags(dev, 0) & IORESOURCE_DISABLED)) + irq = pnp_irq(dev, 0); + else + return -EINVAL; + + if (pnp_dma_valid(dev, 0) && + !(pnp_dma_flags(dev, 0) & IORESOURCE_DISABLED)) + dma = pnp_dma(dev, 0); + else + return -EINVAL; + + if (smsc_ircc_open(firbase, sirbase, dma, irq)) + return -ENODEV; + + return 0; +} /* * Function smsc_superio_flat (chip, base, type)