Blame view
drivers/ide/ide-pnp.c
2.64 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 9 10 11 12 13 |
* This file provides autodetection for ISA PnP IDE interfaces. * It was tested with "ESS ES1868 Plug and Play AudioDrive" IDE interface. * * Copyright (C) 2000 Andrey Panin <pazke@donpac.ru> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * You should have received a copy of the GNU General Public License * (for example /usr/src/linux/COPYING); if not, write to the Free |
177b8fe9a IDE: Coding Style... |
14 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 18 19 |
*/ #include <linux/init.h> #include <linux/pnp.h> #include <linux/ide.h> |
bff7832dd ide/ata: Add modu... |
20 |
#include <linux/module.h> |
1da177e4c Linux-2.6.12-rc2 |
21 |
|
134d4548a ide-pnp: manage I... |
22 |
#define DRV_NAME "ide-pnp" |
1da177e4c Linux-2.6.12-rc2 |
23 24 |
/* Add your devices here :)) */ static struct pnp_device_id idepnp_devices[] = { |
177b8fe9a IDE: Coding Style... |
25 |
/* Generic ESDI/IDE/ATA compatible hard disk controller */ |
1da177e4c Linux-2.6.12-rc2 |
26 27 28 |
{.id = "PNP0600", .driver_data = 0}, {.id = ""} }; |
ee1464a4e ide-pnp: use stru... |
29 30 |
static const struct ide_port_info ide_pnp_port_info = { .host_flags = IDE_HFLAG_NO_DMA, |
29e52cf79 ide: remove chips... |
31 |
.chipset = ide_generic, |
ee1464a4e ide-pnp: use stru... |
32 |
}; |
177b8fe9a IDE: Coding Style... |
33 |
static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) |
1da177e4c Linux-2.6.12-rc2 |
34 |
{ |
48c3c1072 ide: add struct i... |
35 |
struct ide_host *host; |
134d4548a ide-pnp: manage I... |
36 |
unsigned long base, ctl; |
6f904d015 ide: add ide_host... |
37 |
int rc; |
9f36d3143 ide: remove hw_re... |
38 |
struct ide_hw hw, *hws[] = { &hw }; |
1da177e4c Linux-2.6.12-rc2 |
39 |
|
e193c3e14 ide-pnp: print dr... |
40 41 |
printk(KERN_INFO DRV_NAME ": generic PnP IDE interface "); |
1da177e4c Linux-2.6.12-rc2 |
42 43 |
if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) return -1; |
134d4548a ide-pnp: manage I... |
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
base = pnp_port_start(dev, 0); ctl = pnp_port_start(dev, 1); if (!request_region(base, 8, DRV_NAME)) { printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free. ", DRV_NAME, base, base + 7); return -EBUSY; } if (!request_region(ctl, 1, DRV_NAME)) { printk(KERN_ERR "%s: I/O resource 0x%lX not free. ", DRV_NAME, ctl); release_region(base, 8); return -EBUSY; } |
1da177e4c Linux-2.6.12-rc2 |
61 |
memset(&hw, 0, sizeof(hw)); |
134d4548a ide-pnp: manage I... |
62 |
ide_std_init_ports(&hw, base, ctl); |
1da177e4c Linux-2.6.12-rc2 |
63 |
hw.irq = pnp_irq(dev, 0); |
1da177e4c Linux-2.6.12-rc2 |
64 |
|
dca398305 ide: pass number ... |
65 |
rc = ide_host_add(&ide_pnp_port_info, hws, 1, &host); |
6f904d015 ide: add ide_host... |
66 67 |
if (rc) goto out; |
cbb010c18 ide: drop 'initia... |
68 |
|
6f904d015 ide: add ide_host... |
69 |
pnp_set_drvdata(dev, host); |
1da177e4c Linux-2.6.12-rc2 |
70 |
|
6f904d015 ide: add ide_host... |
71 72 |
return 0; out: |
134d4548a ide-pnp: manage I... |
73 74 |
release_region(ctl, 1); release_region(base, 8); |
6f904d015 ide: add ide_host... |
75 |
return rc; |
1da177e4c Linux-2.6.12-rc2 |
76 |
} |
177b8fe9a IDE: Coding Style... |
77 |
static void idepnp_remove(struct pnp_dev *dev) |
1da177e4c Linux-2.6.12-rc2 |
78 |
{ |
48c3c1072 ide: add struct i... |
79 |
struct ide_host *host = pnp_get_drvdata(dev); |
f82c2b171 ide: add 'init_de... |
80 |
|
48c3c1072 ide: add struct i... |
81 |
ide_host_remove(host); |
134d4548a ide-pnp: manage I... |
82 83 84 |
release_region(pnp_port_start(dev, 1), 1); release_region(pnp_port_start(dev, 0), 8); |
1da177e4c Linux-2.6.12-rc2 |
85 86 87 88 89 90 91 92 |
} static struct pnp_driver idepnp_driver = { .name = "ide", .id_table = idepnp_devices, .probe = idepnp_probe, .remove = idepnp_remove, }; |
ade2daf9c ide: make remaini... |
93 |
static int __init pnpide_init(void) |
1da177e4c Linux-2.6.12-rc2 |
94 |
{ |
ade2daf9c ide: make remaini... |
95 |
return pnp_register_driver(&idepnp_driver); |
1da177e4c Linux-2.6.12-rc2 |
96 |
} |
6855036aa ide: unregister i... |
97 |
|
ade2daf9c ide: make remaini... |
98 |
static void __exit pnpide_exit(void) |
6855036aa ide: unregister i... |
99 100 101 |
{ pnp_unregister_driver(&idepnp_driver); } |
ade2daf9c ide: make remaini... |
102 103 104 |
module_init(pnpide_init); module_exit(pnpide_exit); |
a62ee6415 ide-pnp.c: add MO... |
105 106 |
MODULE_LICENSE("GPL"); |