mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 06:37:59 +00:00
PNP: factor pnp_init_resource_table() and pnp_clean_resource_table()
Move the common part of pnp_init_resource_table() and pnp_clean_resource_table() into a new pnp_init_resource(). This reduces a little code duplication and will be useful later to initialize an individual resource. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
af11cb2d52
commit
d948a8daa0
2 changed files with 54 additions and 46 deletions
|
@ -18,3 +18,5 @@ int pnp_check_irq(struct pnp_dev * dev, int idx);
|
||||||
int pnp_check_dma(struct pnp_dev * dev, int idx);
|
int pnp_check_dma(struct pnp_dev * dev, int idx);
|
||||||
|
|
||||||
void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
|
void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
|
||||||
|
|
||||||
|
void pnp_init_resource(struct resource *res);
|
||||||
|
|
|
@ -234,42 +234,52 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
|
||||||
dev_dbg(&dev->dev, " disable dma %d\n", idx);
|
dev_dbg(&dev->dev, " disable dma %d\n", idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pnp_init_resource(struct resource *res)
|
||||||
|
{
|
||||||
|
unsigned long type;
|
||||||
|
|
||||||
|
type = res->flags & (IORESOURCE_IO | IORESOURCE_MEM |
|
||||||
|
IORESOURCE_IRQ | IORESOURCE_DMA);
|
||||||
|
|
||||||
|
res->name = NULL;
|
||||||
|
res->flags = type | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
||||||
|
if (type == IORESOURCE_IRQ || type == IORESOURCE_DMA) {
|
||||||
|
res->start = -1;
|
||||||
|
res->end = -1;
|
||||||
|
} else {
|
||||||
|
res->start = 0;
|
||||||
|
res->end = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pnp_init_resources - Resets a resource table to default values.
|
* pnp_init_resources - Resets a resource table to default values.
|
||||||
* @table: pointer to the desired resource table
|
* @table: pointer to the desired resource table
|
||||||
*/
|
*/
|
||||||
void pnp_init_resources(struct pnp_dev *dev)
|
void pnp_init_resources(struct pnp_dev *dev)
|
||||||
{
|
{
|
||||||
struct pnp_resource_table *table = &dev->res;
|
struct resource *res;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
|
for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
|
||||||
table->irq_resource[idx].name = NULL;
|
res = &dev->res.irq_resource[idx];
|
||||||
table->irq_resource[idx].start = -1;
|
res->flags = IORESOURCE_IRQ;
|
||||||
table->irq_resource[idx].end = -1;
|
pnp_init_resource(res);
|
||||||
table->irq_resource[idx].flags =
|
|
||||||
IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
|
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
|
||||||
table->dma_resource[idx].name = NULL;
|
res = &dev->res.dma_resource[idx];
|
||||||
table->dma_resource[idx].start = -1;
|
res->flags = IORESOURCE_DMA;
|
||||||
table->dma_resource[idx].end = -1;
|
pnp_init_resource(res);
|
||||||
table->dma_resource[idx].flags =
|
|
||||||
IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
|
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
|
||||||
table->port_resource[idx].name = NULL;
|
res = &dev->res.port_resource[idx];
|
||||||
table->port_resource[idx].start = 0;
|
res->flags = IORESOURCE_IO;
|
||||||
table->port_resource[idx].end = 0;
|
pnp_init_resource(res);
|
||||||
table->port_resource[idx].flags =
|
|
||||||
IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
|
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
|
||||||
table->mem_resource[idx].name = NULL;
|
res = &dev->res.mem_resource[idx];
|
||||||
table->mem_resource[idx].start = 0;
|
res->flags = IORESOURCE_MEM;
|
||||||
table->mem_resource[idx].end = 0;
|
pnp_init_resource(res);
|
||||||
table->mem_resource[idx].flags =
|
|
||||||
IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,40 +289,36 @@ void pnp_init_resources(struct pnp_dev *dev)
|
||||||
*/
|
*/
|
||||||
static void pnp_clean_resource_table(struct pnp_dev *dev)
|
static void pnp_clean_resource_table(struct pnp_dev *dev)
|
||||||
{
|
{
|
||||||
struct pnp_resource_table *res = &dev->res;
|
struct resource *res;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
|
for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
|
||||||
if (!(res->irq_resource[idx].flags & IORESOURCE_AUTO))
|
res = &dev->res.irq_resource[idx];
|
||||||
continue;
|
if (res->flags & IORESOURCE_AUTO) {
|
||||||
res->irq_resource[idx].start = -1;
|
res->flags = IORESOURCE_IRQ;
|
||||||
res->irq_resource[idx].end = -1;
|
pnp_init_resource(res);
|
||||||
res->irq_resource[idx].flags =
|
}
|
||||||
IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
|
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
|
||||||
if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO))
|
res = &dev->res.dma_resource[idx];
|
||||||
continue;
|
if (res->flags & IORESOURCE_AUTO) {
|
||||||
res->dma_resource[idx].start = -1;
|
res->flags = IORESOURCE_DMA;
|
||||||
res->dma_resource[idx].end = -1;
|
pnp_init_resource(res);
|
||||||
res->dma_resource[idx].flags =
|
}
|
||||||
IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
|
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
|
||||||
if (!(res->port_resource[idx].flags & IORESOURCE_AUTO))
|
res = &dev->res.port_resource[idx];
|
||||||
continue;
|
if (res->flags & IORESOURCE_AUTO) {
|
||||||
res->port_resource[idx].start = 0;
|
res->flags = IORESOURCE_IO;
|
||||||
res->port_resource[idx].end = 0;
|
pnp_init_resource(res);
|
||||||
res->port_resource[idx].flags =
|
}
|
||||||
IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
|
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
|
||||||
if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO))
|
res = &dev->res.mem_resource[idx];
|
||||||
continue;
|
if (res->flags & IORESOURCE_AUTO) {
|
||||||
res->mem_resource[idx].start = 0;
|
res->flags = IORESOURCE_MEM;
|
||||||
res->mem_resource[idx].end = 0;
|
pnp_init_resource(res);
|
||||||
res->mem_resource[idx].flags =
|
}
|
||||||
IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue