aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-park.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:31 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:31 -0500
commit2a2ca6a96194c4744a2adeefbc09ce881f3c5abe (patch)
tree50b43d823d4a589fbfb8f8751278d6101cd3ecf3 /drivers/ide/ide-park.c
parent6ea52226ca131a99bb619bd56fbeee566ea5a966 (diff)
ide: replace the global ide_lock spinlock by per-hwgroup spinlocks (v2)
Now that (almost) all host drivers have been fixed not to abuse ide_lock and core code usage of ide_lock has been sanitized we may safely replace ide_lock by per-hwgroup locks. This patch is partially based on earlier patch from Ravikiran G Thirumalai. While at it: - don't use deprecated HWIF() and HWGROUP() macros - update locking documentation in ide.h v2: Add missing spin_lock_init(&hwgroup->lock). (Noticed by Elias Oltmanns) Cc: Vaibhav V. Nivargi <vaibhav.nivargi@gmail.com> Cc: Alok N. Kataria <alokk@calsoftinc.com> Cc: Shai Fultheim <shai@scalex86.org> Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org> Cc: Elias Oltmanns <eo@nebensachen.de> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-park.c')
-rw-r--r--drivers/ide/ide-park.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 03b00e57e93f..63d01c55f865 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -7,17 +7,16 @@ DECLARE_WAIT_QUEUE_HEAD(ide_park_wq);
7 7
8static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) 8static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
9{ 9{
10 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup;
10 struct request_queue *q = drive->queue; 11 struct request_queue *q = drive->queue;
11 struct request *rq; 12 struct request *rq;
12 int rc; 13 int rc;
13 14
14 timeout += jiffies; 15 timeout += jiffies;
15 spin_lock_irq(&ide_lock); 16 spin_lock_irq(&hwgroup->lock);
16 if (drive->dev_flags & IDE_DFLAG_PARKED) { 17 if (drive->dev_flags & IDE_DFLAG_PARKED) {
17 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 18 int reset_timer = time_before(timeout, drive->sleep);
18 int reset_timer;
19 19
20 reset_timer = time_before(timeout, drive->sleep);
21 drive->sleep = timeout; 20 drive->sleep = timeout;
22 wake_up_all(&ide_park_wq); 21 wake_up_all(&ide_park_wq);
23 if (reset_timer && hwgroup->sleeping && 22 if (reset_timer && hwgroup->sleeping &&
@@ -26,10 +25,10 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
26 hwgroup->busy = 0; 25 hwgroup->busy = 0;
27 blk_start_queueing(q); 26 blk_start_queueing(q);
28 } 27 }
29 spin_unlock_irq(&ide_lock); 28 spin_unlock_irq(&hwgroup->lock);
30 return; 29 return;
31 } 30 }
32 spin_unlock_irq(&ide_lock); 31 spin_unlock_irq(&hwgroup->lock);
33 32
34 rq = blk_get_request(q, READ, __GFP_WAIT); 33 rq = blk_get_request(q, READ, __GFP_WAIT);
35 rq->cmd[0] = REQ_PARK_HEADS; 34 rq->cmd[0] = REQ_PARK_HEADS;
@@ -62,20 +61,21 @@ ssize_t ide_park_show(struct device *dev, struct device_attribute *attr,
62 char *buf) 61 char *buf)
63{ 62{
64 ide_drive_t *drive = to_ide_device(dev); 63 ide_drive_t *drive = to_ide_device(dev);
64 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup;
65 unsigned long now; 65 unsigned long now;
66 unsigned int msecs; 66 unsigned int msecs;
67 67
68 if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD) 68 if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD)
69 return -EOPNOTSUPP; 69 return -EOPNOTSUPP;
70 70
71 spin_lock_irq(&ide_lock); 71 spin_lock_irq(&hwgroup->lock);
72 now = jiffies; 72 now = jiffies;
73 if (drive->dev_flags & IDE_DFLAG_PARKED && 73 if (drive->dev_flags & IDE_DFLAG_PARKED &&
74 time_after(drive->sleep, now)) 74 time_after(drive->sleep, now))
75 msecs = jiffies_to_msecs(drive->sleep - now); 75 msecs = jiffies_to_msecs(drive->sleep - now);
76 else 76 else
77 msecs = 0; 77 msecs = 0;
78 spin_unlock_irq(&ide_lock); 78 spin_unlock_irq(&hwgroup->lock);
79 79
80 return snprintf(buf, 20, "%u\n", msecs); 80 return snprintf(buf, 20, "%u\n", msecs);
81} 81}