mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 22:42:10 +00:00
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>
This commit is contained in:
parent
8447d9d52a
commit
baa8f3e94b
5 changed files with 38 additions and 62 deletions
|
@ -438,35 +438,13 @@ static void icside_dma_init(ide_hwif_t *hwif)
|
||||||
#define icside_dma_init(hwif) (0)
|
#define icside_dma_init(hwif) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ide_hwif_t *icside_find_hwif(unsigned long dataport)
|
|
||||||
{
|
|
||||||
ide_hwif_t *hwif;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
for (index = 0; index < MAX_HWIFS; ++index) {
|
|
||||||
hwif = &ide_hwifs[index];
|
|
||||||
if (hwif->io_ports[IDE_DATA_OFFSET] == dataport)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (index = 0; index < MAX_HWIFS; ++index) {
|
|
||||||
hwif = &ide_hwifs[index];
|
|
||||||
if (!hwif->io_ports[IDE_DATA_OFFSET])
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
hwif = NULL;
|
|
||||||
found:
|
|
||||||
return hwif;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ide_hwif_t *
|
static ide_hwif_t *
|
||||||
icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
|
icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
|
||||||
{
|
{
|
||||||
unsigned long port = (unsigned long)base + info->dataoffset;
|
unsigned long port = (unsigned long)base + info->dataoffset;
|
||||||
ide_hwif_t *hwif;
|
ide_hwif_t *hwif;
|
||||||
|
|
||||||
hwif = icside_find_hwif(port);
|
hwif = ide_find_port(port);
|
||||||
if (hwif) {
|
if (hwif) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -13,31 +13,16 @@
|
||||||
|
|
||||||
#include <asm/ecard.h>
|
#include <asm/ecard.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Something like this really should be in generic code, but isn't.
|
|
||||||
*/
|
|
||||||
static ide_hwif_t *
|
static ide_hwif_t *
|
||||||
rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq)
|
rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq)
|
||||||
{
|
{
|
||||||
unsigned long port = (unsigned long)base;
|
unsigned long port = (unsigned long)base;
|
||||||
ide_hwif_t *hwif;
|
ide_hwif_t *hwif = ide_find_port(port);
|
||||||
int index, i;
|
int i;
|
||||||
|
|
||||||
for (index = 0; index < MAX_HWIFS; ++index) {
|
if (hwif == NULL)
|
||||||
hwif = ide_hwifs + index;
|
goto out;
|
||||||
if (hwif->io_ports[IDE_DATA_OFFSET] == port)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (index = 0; index < MAX_HWIFS; ++index) {
|
|
||||||
hwif = ide_hwifs + index;
|
|
||||||
if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
found:
|
|
||||||
for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
|
for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
|
||||||
hwif->hw.io_ports[i] = port;
|
hwif->hw.io_ports[i] = port;
|
||||||
hwif->io_ports[i] = port;
|
hwif->io_ports[i] = port;
|
||||||
|
@ -48,7 +33,7 @@ rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int
|
||||||
hwif->hw.irq = hwif->irq = irq;
|
hwif->hw.irq = hwif->irq = irq;
|
||||||
hwif->mmio = 1;
|
hwif->mmio = 1;
|
||||||
default_hwif_mmiops(hwif);
|
default_hwif_mmiops(hwif);
|
||||||
|
out:
|
||||||
return hwif;
|
return hwif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,6 +265,30 @@ static int ide_system_bus_speed(void)
|
||||||
return system_bus_speed;
|
return system_bus_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ide_hwif_t * ide_find_port(unsigned long base)
|
||||||
|
{
|
||||||
|
ide_hwif_t *hwif;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_HWIFS; i++) {
|
||||||
|
hwif = &ide_hwifs[i];
|
||||||
|
if (hwif->io_ports[IDE_DATA_OFFSET] == base)
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_HWIFS; i++) {
|
||||||
|
hwif = &ide_hwifs[i];
|
||||||
|
if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwif = NULL;
|
||||||
|
found:
|
||||||
|
return hwif;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT_SYMBOL_GPL(ide_find_port);
|
||||||
|
|
||||||
static struct resource* hwif_request_region(ide_hwif_t *hwif,
|
static struct resource* hwif_request_region(ide_hwif_t *hwif,
|
||||||
unsigned long addr, int num)
|
unsigned long addr, int num)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,24 +33,11 @@ static ide_hwif_t *__devinit plat_ide_locate_hwif(void __iomem *base,
|
||||||
int mmio)
|
int mmio)
|
||||||
{
|
{
|
||||||
unsigned long port = (unsigned long)base;
|
unsigned long port = (unsigned long)base;
|
||||||
ide_hwif_t *hwif;
|
ide_hwif_t *hwif = ide_find_port(port);
|
||||||
int index, i;
|
int i;
|
||||||
|
|
||||||
for (index = 0; index < MAX_HWIFS; ++index) {
|
if (hwif == NULL)
|
||||||
hwif = ide_hwifs + index;
|
goto out;
|
||||||
if (hwif->io_ports[IDE_DATA_OFFSET] == port)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (index = 0; index < MAX_HWIFS; ++index) {
|
|
||||||
hwif = ide_hwifs + index;
|
|
||||||
if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
found:
|
|
||||||
|
|
||||||
hwif->hw.io_ports[IDE_DATA_OFFSET] = port;
|
hwif->hw.io_ports[IDE_DATA_OFFSET] = port;
|
||||||
|
|
||||||
|
@ -73,8 +60,8 @@ found:
|
||||||
}
|
}
|
||||||
|
|
||||||
hwif_prop.hwif = hwif;
|
hwif_prop.hwif = hwif;
|
||||||
hwif_prop.index = index;
|
hwif_prop.index = hwif->index;
|
||||||
|
out:
|
||||||
return hwif;
|
return hwif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,8 @@ typedef struct hw_regs_s {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
} hw_regs_t;
|
} hw_regs_t;
|
||||||
|
|
||||||
|
struct hwif_s * ide_find_port(unsigned long);
|
||||||
|
|
||||||
int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int,
|
int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int,
|
||||||
struct hwif_s **);
|
struct hwif_s **);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue