aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/legacy/qd65xx.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-19 18:32:37 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-19 18:32:37 -0400
commitc196567a81af6988d1a71b43dd21c47e1ff46f6e (patch)
treeeac62de245dab758d11ac2347d8d7756b7618f3a /drivers/ide/legacy/qd65xx.c
parenta02bfd3ce9342453441202028df44dc58f90e225 (diff)
qd65xx: remove pointless qd_{read,write}_reg() (take 2)
These functions are atomic so locking is pointless (noticed by Sergei). v2: We can now just use local_irq_save/restore() in qd_testreg() (noticed by Jeff). Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Acked-by: Jeff Garzik <jeff@garzik.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/legacy/qd65xx.c')
-rw-r--r--drivers/ide/legacy/qd65xx.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index ffd9c0556d12..912e73853faa 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -89,28 +89,6 @@
89 89
90static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ 90static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */
91 91
92static DEFINE_SPINLOCK(qd65xx_lock);
93
94static void qd_write_reg (u8 content, unsigned long reg)
95{
96 unsigned long flags;
97
98 spin_lock_irqsave(&qd65xx_lock, flags);
99 outb(content,reg);
100 spin_unlock_irqrestore(&qd65xx_lock, flags);
101}
102
103static u8 __init qd_read_reg (unsigned long reg)
104{
105 unsigned long flags;
106 u8 read;
107
108 spin_lock_irqsave(&qd65xx_lock, flags);
109 read = inb(reg);
110 spin_unlock_irqrestore(&qd65xx_lock, flags);
111 return read;
112}
113
114/* 92/*
115 * qd_select: 93 * qd_select:
116 * 94 *
@@ -123,7 +101,7 @@ static void qd_select (ide_drive_t *drive)
123 (QD_TIMREG(drive) & 0x02); 101 (QD_TIMREG(drive) & 0x02);
124 102
125 if (timings[index] != QD_TIMING(drive)) 103 if (timings[index] != QD_TIMING(drive))
126 qd_write_reg(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); 104 outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive));
127} 105}
128 106
129/* 107/*
@@ -286,7 +264,7 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio)
286 } 264 }
287 265
288 if (!HWIF(drive)->channel && drive->media != ide_disk) { 266 if (!HWIF(drive)->channel && drive->media != ide_disk) {
289 qd_write_reg(0x5f, QD_CONTROL_PORT); 267 outb(0x5f, QD_CONTROL_PORT);
290 printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " 268 printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO "
291 "and post-write buffer on %s.\n", 269 "and post-write buffer on %s.\n",
292 drive->name, HWIF(drive)->name); 270 drive->name, HWIF(drive)->name);
@@ -306,12 +284,12 @@ static int __init qd_testreg(int port)
306 unsigned long flags; 284 unsigned long flags;
307 u8 savereg, readreg; 285 u8 savereg, readreg;
308 286
309 spin_lock_irqsave(&qd65xx_lock, flags); 287 local_irq_save(flags);
310 savereg = inb_p(port); 288 savereg = inb_p(port);
311 outb_p(QD_TESTVAL, port); /* safe value */ 289 outb_p(QD_TESTVAL, port); /* safe value */
312 readreg = inb_p(port); 290 readreg = inb_p(port);
313 outb(savereg, port); 291 outb(savereg, port);
314 spin_unlock_irqrestore(&qd65xx_lock, flags); 292 local_irq_restore(flags);
315 293
316 if (savereg == QD_TESTVAL) { 294 if (savereg == QD_TESTVAL) {
317 printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n"); 295 printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n");
@@ -365,13 +343,13 @@ static void __exit qd_unsetup(ide_hwif_t *hwif)
365 343
366 if (set_pio_mode == (void *)qd6500_set_pio_mode) { 344 if (set_pio_mode == (void *)qd6500_set_pio_mode) {
367 // will do it for both 345 // will do it for both
368 qd_write_reg(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); 346 outb(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
369 } else if (set_pio_mode == (void *)qd6580_set_pio_mode) { 347 } else if (set_pio_mode == (void *)qd6580_set_pio_mode) {
370 if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { 348 if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) {
371 qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); 349 outb(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
372 qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); 350 outb(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1]));
373 } else { 351 } else {
374 qd_write_reg(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); 352 outb(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
375 } 353 }
376 } else { 354 } else {
377 printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n"); 355 printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n");
@@ -394,7 +372,7 @@ static int __init qd_probe(int base)
394 u8 config; 372 u8 config;
395 u8 unit; 373 u8 unit;
396 374
397 config = qd_read_reg(QD_CONFIG_PORT); 375 config = inb(QD_CONFIG_PORT);
398 376
399 if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) 377 if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) )
400 return 1; 378 return 1;
@@ -438,7 +416,7 @@ static int __init qd_probe(int base)
438 416
439 /* qd6580 found */ 417 /* qd6580 found */
440 418
441 control = qd_read_reg(QD_CONTROL_PORT); 419 control = inb(QD_CONTROL_PORT);
442 420
443 printk(KERN_NOTICE "qd6580 at %#x\n", base); 421 printk(KERN_NOTICE "qd6580 at %#x\n", base);
444 printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", 422 printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n",
@@ -459,7 +437,7 @@ static int __init qd_probe(int base)
459 437
460 ide_device_add(idx); 438 ide_device_add(idx);
461 439
462 qd_write_reg(QD_DEF_CONTR, QD_CONTROL_PORT); 440 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
463 441
464 return 1; 442 return 1;
465 } else { 443 } else {
@@ -486,7 +464,7 @@ static int __init qd_probe(int base)
486 464
487 ide_device_add(idx); 465 ide_device_add(idx);
488 466
489 qd_write_reg(QD_DEF_CONTR, QD_CONTROL_PORT); 467 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
490 468
491 return 0; /* no other qd65xx possible */ 469 return 0; /* no other qd65xx possible */
492 } 470 }