diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2011-10-11 13:52:31 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2011-10-14 13:07:18 -0400 |
commit | dc5e44ec6f75d493df484728587b00b87a233482 (patch) | |
tree | 1c2c86410c3398d925d68965d83f310447dff062 /drivers/ata/pata_hpt366.c | |
parent | f6b56696b974a7d6d55f98ebcfb0a1099696fc2e (diff) |
pata_hpt366: add hpt36x_find_mode() helper
Factor out code for finding the register programming information
from hpt366_set_mode() to hpt36x_find_mode().
This makes pata_hpt366 driver more similar to pata_{37x,3x2n} ones.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/pata_hpt366.c')
-rw-r--r-- | drivers/ata/pata_hpt366.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index 6c77d68dbd05..42cffd38910d 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -111,6 +111,28 @@ static const struct hpt_clock hpt366_25[] = { | |||
111 | { 0, 0x01208585 } | 111 | { 0, 0x01208585 } |
112 | }; | 112 | }; |
113 | 113 | ||
114 | /** | ||
115 | * hpt36x_find_mode - find the hpt36x timing | ||
116 | * @ap: ATA port | ||
117 | * @speed: transfer mode | ||
118 | * | ||
119 | * Return the 32bit register programming information for this channel | ||
120 | * that matches the speed provided. | ||
121 | */ | ||
122 | |||
123 | static u32 hpt36x_find_mode(struct ata_port *ap, int speed) | ||
124 | { | ||
125 | struct hpt_clock *clocks = ap->host->private_data; | ||
126 | |||
127 | while (clocks->xfer_mode) { | ||
128 | if (clocks->xfer_mode == speed) | ||
129 | return clocks->timing; | ||
130 | clocks++; | ||
131 | } | ||
132 | BUG(); | ||
133 | return 0xffffffffU; /* silence compiler warning */ | ||
134 | } | ||
135 | |||
114 | static const char * const bad_ata33[] = { | 136 | static const char * const bad_ata33[] = { |
115 | "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", | 137 | "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", |
116 | "Maxtor 90845U3", "Maxtor 90650U2", | 138 | "Maxtor 90845U3", "Maxtor 90650U2", |
@@ -210,10 +232,9 @@ static int hpt36x_cable_detect(struct ata_port *ap) | |||
210 | static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev, | 232 | static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev, |
211 | u8 mode) | 233 | u8 mode) |
212 | { | 234 | { |
213 | struct hpt_clock *clocks = ap->host->private_data; | ||
214 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 235 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
215 | u32 addr = 0x40 + 4 * adev->devno; | 236 | u32 addr = 0x40 + 4 * adev->devno; |
216 | u32 mask, reg; | 237 | u32 mask, reg, t; |
217 | 238 | ||
218 | /* determine timing mask and find matching clock entry */ | 239 | /* determine timing mask and find matching clock entry */ |
219 | if (mode < XFER_MW_DMA_0) | 240 | if (mode < XFER_MW_DMA_0) |
@@ -223,13 +244,7 @@ static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev, | |||
223 | else | 244 | else |
224 | mask = 0x30070000; | 245 | mask = 0x30070000; |
225 | 246 | ||
226 | while (clocks->xfer_mode) { | 247 | t = hpt36x_find_mode(ap, mode); |
227 | if (clocks->xfer_mode == mode) | ||
228 | break; | ||
229 | clocks++; | ||
230 | } | ||
231 | if (!clocks->xfer_mode) | ||
232 | BUG(); | ||
233 | 248 | ||
234 | /* | 249 | /* |
235 | * Combine new mode bits with old config bits and disable | 250 | * Combine new mode bits with old config bits and disable |
@@ -237,7 +252,7 @@ static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev, | |||
237 | * problems handling I/O errors later. | 252 | * problems handling I/O errors later. |
238 | */ | 253 | */ |
239 | pci_read_config_dword(pdev, addr, ®); | 254 | pci_read_config_dword(pdev, addr, ®); |
240 | reg = ((reg & ~mask) | (clocks->timing & mask)) & ~0xc0000000; | 255 | reg = ((reg & ~mask) | (t & mask)) & ~0xc0000000; |
241 | pci_write_config_dword(pdev, addr, reg); | 256 | pci_write_config_dword(pdev, addr, reg); |
242 | } | 257 | } |
243 | 258 | ||