diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-19 18:32:31 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-19 18:32:31 -0400 |
commit | baa8f3e94bc7a7ba3650d80b67d54c3e08365dee (patch) | |
tree | caabf63904cd62f758535e16dcc4676ba3ae5095 /drivers/ide | |
parent | 8447d9d52adbe4c653482bd0d5ccb9b5d26f9c9d (diff) |
ide: add ide_find_port() helper
* Add ide_find_port() helper.
* Convert icside, rapide and ide_platform host drivers to use it.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/arm/icside.c | 24 | ||||
-rw-r--r-- | drivers/ide/arm/rapide.c | 25 | ||||
-rw-r--r-- | drivers/ide/ide.c | 24 | ||||
-rw-r--r-- | drivers/ide/legacy/ide_platform.c | 25 |
4 files changed, 36 insertions, 62 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 6298932c0589..fda3f870d7cd 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -438,35 +438,13 @@ static void icside_dma_init(ide_hwif_t *hwif) | |||
438 | #define icside_dma_init(hwif) (0) | 438 | #define icside_dma_init(hwif) (0) |
439 | #endif | 439 | #endif |
440 | 440 | ||
441 | static ide_hwif_t *icside_find_hwif(unsigned long dataport) | ||
442 | { | ||
443 | ide_hwif_t *hwif; | ||
444 | int index; | ||
445 | |||
446 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
447 | hwif = &ide_hwifs[index]; | ||
448 | if (hwif->io_ports[IDE_DATA_OFFSET] == dataport) | ||
449 | goto found; | ||
450 | } | ||
451 | |||
452 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
453 | hwif = &ide_hwifs[index]; | ||
454 | if (!hwif->io_ports[IDE_DATA_OFFSET]) | ||
455 | goto found; | ||
456 | } | ||
457 | |||
458 | hwif = NULL; | ||
459 | found: | ||
460 | return hwif; | ||
461 | } | ||
462 | |||
463 | static ide_hwif_t * | 441 | static ide_hwif_t * |
464 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) | 442 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) |
465 | { | 443 | { |
466 | unsigned long port = (unsigned long)base + info->dataoffset; | 444 | unsigned long port = (unsigned long)base + info->dataoffset; |
467 | ide_hwif_t *hwif; | 445 | ide_hwif_t *hwif; |
468 | 446 | ||
469 | hwif = icside_find_hwif(port); | 447 | hwif = ide_find_port(port); |
470 | if (hwif) { | 448 | if (hwif) { |
471 | int i; | 449 | int i; |
472 | 450 | ||
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 6d2fe21cd729..96cd3f5b9adc 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -13,31 +13,16 @@ | |||
13 | 13 | ||
14 | #include <asm/ecard.h> | 14 | #include <asm/ecard.h> |
15 | 15 | ||
16 | /* | ||
17 | * Something like this really should be in generic code, but isn't. | ||
18 | */ | ||
19 | static ide_hwif_t * | 16 | static ide_hwif_t * |
20 | rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq) | 17 | rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq) |
21 | { | 18 | { |
22 | unsigned long port = (unsigned long)base; | 19 | unsigned long port = (unsigned long)base; |
23 | ide_hwif_t *hwif; | 20 | ide_hwif_t *hwif = ide_find_port(port); |
24 | int index, i; | 21 | int i; |
25 | |||
26 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
27 | hwif = ide_hwifs + index; | ||
28 | if (hwif->io_ports[IDE_DATA_OFFSET] == port) | ||
29 | goto found; | ||
30 | } | ||
31 | 22 | ||
32 | for (index = 0; index < MAX_HWIFS; ++index) { | 23 | if (hwif == NULL) |
33 | hwif = ide_hwifs + index; | 24 | goto out; |
34 | if (hwif->io_ports[IDE_DATA_OFFSET] == 0) | ||
35 | goto found; | ||
36 | } | ||
37 | |||
38 | return NULL; | ||
39 | 25 | ||
40 | found: | ||
41 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 26 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
42 | hwif->hw.io_ports[i] = port; | 27 | hwif->hw.io_ports[i] = port; |
43 | hwif->io_ports[i] = port; | 28 | hwif->io_ports[i] = port; |
@@ -48,7 +33,7 @@ rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int | |||
48 | hwif->hw.irq = hwif->irq = irq; | 33 | hwif->hw.irq = hwif->irq = irq; |
49 | hwif->mmio = 1; | 34 | hwif->mmio = 1; |
50 | default_hwif_mmiops(hwif); | 35 | default_hwif_mmiops(hwif); |
51 | 36 | out: | |
52 | return hwif; | 37 | return hwif; |
53 | } | 38 | } |
54 | 39 | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 15741367eb35..ce6644f41b21 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -265,6 +265,30 @@ static int ide_system_bus_speed(void) | |||
265 | return system_bus_speed; | 265 | return system_bus_speed; |
266 | } | 266 | } |
267 | 267 | ||
268 | ide_hwif_t * ide_find_port(unsigned long base) | ||
269 | { | ||
270 | ide_hwif_t *hwif; | ||
271 | int i; | ||
272 | |||
273 | for (i = 0; i < MAX_HWIFS; i++) { | ||
274 | hwif = &ide_hwifs[i]; | ||
275 | if (hwif->io_ports[IDE_DATA_OFFSET] == base) | ||
276 | goto found; | ||
277 | } | ||
278 | |||
279 | for (i = 0; i < MAX_HWIFS; i++) { | ||
280 | hwif = &ide_hwifs[i]; | ||
281 | if (hwif->io_ports[IDE_DATA_OFFSET] == 0) | ||
282 | goto found; | ||
283 | } | ||
284 | |||
285 | hwif = NULL; | ||
286 | found: | ||
287 | return hwif; | ||
288 | } | ||
289 | |||
290 | EXPORT_SYMBOL_GPL(ide_find_port); | ||
291 | |||
268 | static struct resource* hwif_request_region(ide_hwif_t *hwif, | 292 | static struct resource* hwif_request_region(ide_hwif_t *hwif, |
269 | unsigned long addr, int num) | 293 | unsigned long addr, int num) |
270 | { | 294 | { |
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index 9a153915f3cf..d1e76fa7869e 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -33,24 +33,11 @@ static ide_hwif_t *__devinit plat_ide_locate_hwif(void __iomem *base, | |||
33 | int mmio) | 33 | int mmio) |
34 | { | 34 | { |
35 | unsigned long port = (unsigned long)base; | 35 | unsigned long port = (unsigned long)base; |
36 | ide_hwif_t *hwif; | 36 | ide_hwif_t *hwif = ide_find_port(port); |
37 | int index, i; | 37 | int i; |
38 | |||
39 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
40 | hwif = ide_hwifs + index; | ||
41 | if (hwif->io_ports[IDE_DATA_OFFSET] == port) | ||
42 | goto found; | ||
43 | } | ||
44 | |||
45 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
46 | hwif = ide_hwifs + index; | ||
47 | if (hwif->io_ports[IDE_DATA_OFFSET] == 0) | ||
48 | goto found; | ||
49 | } | ||
50 | 38 | ||
51 | return NULL; | 39 | if (hwif == NULL) |
52 | 40 | goto out; | |
53 | found: | ||
54 | 41 | ||
55 | hwif->hw.io_ports[IDE_DATA_OFFSET] = port; | 42 | hwif->hw.io_ports[IDE_DATA_OFFSET] = port; |
56 | 43 | ||
@@ -73,8 +60,8 @@ found: | |||
73 | } | 60 | } |
74 | 61 | ||
75 | hwif_prop.hwif = hwif; | 62 | hwif_prop.hwif = hwif; |
76 | hwif_prop.index = index; | 63 | hwif_prop.index = hwif->index; |
77 | 64 | out: | |
78 | return hwif; | 65 | return hwif; |
79 | } | 66 | } |
80 | 67 | ||