diff options
Diffstat (limited to 'drivers/ide/pci/sc1200.c')
-rw-r--r-- | drivers/ide/pci/sc1200.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 14c787b5d95f..8efaed16fea3 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -22,6 +22,8 @@ | |||
22 | 22 | ||
23 | #include <asm/io.h> | 23 | #include <asm/io.h> |
24 | 24 | ||
25 | #define DRV_NAME "sc1200" | ||
26 | |||
25 | #define SC1200_REV_A 0x00 | 27 | #define SC1200_REV_A 0x00 |
26 | #define SC1200_REV_B1 0x01 | 28 | #define SC1200_REV_B1 0x01 |
27 | #define SC1200_REV_B3 0x02 | 29 | #define SC1200_REV_B3 0x02 |
@@ -234,21 +236,11 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) | |||
234 | * we only save state when going from full power to less | 236 | * we only save state when going from full power to less |
235 | */ | 237 | */ |
236 | if (state.event == PM_EVENT_ON) { | 238 | if (state.event == PM_EVENT_ON) { |
237 | struct sc1200_saved_state *ss; | 239 | struct ide_host *host = pci_get_drvdata(dev); |
240 | struct sc1200_saved_state *ss = host->host_priv; | ||
238 | unsigned int r; | 241 | unsigned int r; |
239 | 242 | ||
240 | /* | 243 | /* |
241 | * allocate a permanent save area, if not already allocated | ||
242 | */ | ||
243 | ss = (struct sc1200_saved_state *)pci_get_drvdata(dev); | ||
244 | if (ss == NULL) { | ||
245 | ss = kmalloc(sizeof(*ss), GFP_KERNEL); | ||
246 | if (ss == NULL) | ||
247 | return -ENOMEM; | ||
248 | pci_set_drvdata(dev, ss); | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * save timing registers | 244 | * save timing registers |
253 | * (this may be unnecessary if BIOS also does it) | 245 | * (this may be unnecessary if BIOS also does it) |
254 | */ | 246 | */ |
@@ -263,7 +255,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) | |||
263 | 255 | ||
264 | static int sc1200_resume (struct pci_dev *dev) | 256 | static int sc1200_resume (struct pci_dev *dev) |
265 | { | 257 | { |
266 | struct sc1200_saved_state *ss; | 258 | struct ide_host *host = pci_get_drvdata(dev); |
259 | struct sc1200_saved_state *ss = host->host_priv; | ||
267 | unsigned int r; | 260 | unsigned int r; |
268 | int i; | 261 | int i; |
269 | 262 | ||
@@ -271,16 +264,12 @@ static int sc1200_resume (struct pci_dev *dev) | |||
271 | if (i) | 264 | if (i) |
272 | return i; | 265 | return i; |
273 | 266 | ||
274 | ss = (struct sc1200_saved_state *)pci_get_drvdata(dev); | ||
275 | |||
276 | /* | 267 | /* |
277 | * restore timing registers | 268 | * restore timing registers |
278 | * (this may be unnecessary if BIOS also does it) | 269 | * (this may be unnecessary if BIOS also does it) |
279 | */ | 270 | */ |
280 | if (ss) { | 271 | for (r = 0; r < 8; r++) |
281 | for (r = 0; r < 8; r++) | 272 | pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]); |
282 | pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]); | ||
283 | } | ||
284 | 273 | ||
285 | return 0; | 274 | return 0; |
286 | } | 275 | } |
@@ -304,7 +293,7 @@ static const struct ide_dma_ops sc1200_dma_ops = { | |||
304 | }; | 293 | }; |
305 | 294 | ||
306 | static const struct ide_port_info sc1200_chipset __devinitdata = { | 295 | static const struct ide_port_info sc1200_chipset __devinitdata = { |
307 | .name = "SC1200", | 296 | .name = DRV_NAME, |
308 | .port_ops = &sc1200_port_ops, | 297 | .port_ops = &sc1200_port_ops, |
309 | .dma_ops = &sc1200_dma_ops, | 298 | .dma_ops = &sc1200_dma_ops, |
310 | .host_flags = IDE_HFLAG_SERIALIZE | | 299 | .host_flags = IDE_HFLAG_SERIALIZE | |
@@ -317,7 +306,19 @@ static const struct ide_port_info sc1200_chipset __devinitdata = { | |||
317 | 306 | ||
318 | static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 307 | static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
319 | { | 308 | { |
320 | return ide_setup_pci_device(dev, &sc1200_chipset); | 309 | struct sc1200_saved_state *ss = NULL; |
310 | int rc; | ||
311 | |||
312 | #ifdef CONFIG_PM | ||
313 | ss = kmalloc(sizeof(*ss), GFP_KERNEL); | ||
314 | if (ss == NULL) | ||
315 | return -ENOMEM; | ||
316 | #endif | ||
317 | rc = ide_pci_init_one(dev, &sc1200_chipset, ss); | ||
318 | if (rc) | ||
319 | kfree(ss); | ||
320 | |||
321 | return rc; | ||
321 | } | 322 | } |
322 | 323 | ||
323 | static const struct pci_device_id sc1200_pci_tbl[] = { | 324 | static const struct pci_device_id sc1200_pci_tbl[] = { |
@@ -330,6 +331,7 @@ static struct pci_driver driver = { | |||
330 | .name = "SC1200_IDE", | 331 | .name = "SC1200_IDE", |
331 | .id_table = sc1200_pci_tbl, | 332 | .id_table = sc1200_pci_tbl, |
332 | .probe = sc1200_init_one, | 333 | .probe = sc1200_init_one, |
334 | .remove = ide_pci_remove, | ||
333 | #ifdef CONFIG_PM | 335 | #ifdef CONFIG_PM |
334 | .suspend = sc1200_suspend, | 336 | .suspend = sc1200_suspend, |
335 | .resume = sc1200_resume, | 337 | .resume = sc1200_resume, |
@@ -341,7 +343,13 @@ static int __init sc1200_ide_init(void) | |||
341 | return ide_pci_register_driver(&driver); | 343 | return ide_pci_register_driver(&driver); |
342 | } | 344 | } |
343 | 345 | ||
346 | static void __exit sc1200_ide_exit(void) | ||
347 | { | ||
348 | pci_unregister_driver(&driver); | ||
349 | } | ||
350 | |||
344 | module_init(sc1200_ide_init); | 351 | module_init(sc1200_ide_init); |
352 | module_exit(sc1200_ide_exit); | ||
345 | 353 | ||
346 | MODULE_AUTHOR("Mark Lord"); | 354 | MODULE_AUTHOR("Mark Lord"); |
347 | MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE"); | 355 | MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE"); |