Skip to content

Commit

Permalink
PNP: add pnp_get_pnp_resource()
Browse files Browse the repository at this point in the history
In some places, we need to get the struct pnp_resource, not just
the struct resource, because ISAPNP needs to store the register
index in the pnp_resource.

I don't like pnp_get_pnp_resource() and hope that it is temporary,
but we need it for a little while.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Bjorn Helgaas authored and lenb committed Apr 29, 2008
1 parent 784f01d commit 0a977f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions drivers/pnp/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);

void pnp_init_resource(struct resource *res);

struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
unsigned int type, unsigned int num);

#define PNP_MAX_PORT 40
#define PNP_MAX_MEM 24
#define PNP_MAX_IRQ 2
Expand Down
24 changes: 18 additions & 6 deletions drivers/pnp/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,31 +499,43 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
#endif
}

struct resource *pnp_get_resource(struct pnp_dev *dev,
unsigned int type, unsigned int num)
struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
unsigned int type, unsigned int num)
{
struct pnp_resource_table *res = dev->res;

switch (type) {
case IORESOURCE_IO:
if (num >= PNP_MAX_PORT)
return NULL;
return &res->port[num].res;
return &res->port[num];
case IORESOURCE_MEM:
if (num >= PNP_MAX_MEM)
return NULL;
return &res->mem[num].res;
return &res->mem[num];
case IORESOURCE_IRQ:
if (num >= PNP_MAX_IRQ)
return NULL;
return &res->irq[num].res;
return &res->irq[num];
case IORESOURCE_DMA:
if (num >= PNP_MAX_DMA)
return NULL;
return &res->dma[num].res;
return &res->dma[num];
}
return NULL;
}

struct resource *pnp_get_resource(struct pnp_dev *dev,
unsigned int type, unsigned int num)
{
struct pnp_resource *pnp_res;

pnp_res = pnp_get_pnp_resource(dev, type, num);
if (pnp_res)
return &pnp_res->res;

return NULL;
}
EXPORT_SYMBOL(pnp_get_resource);

/* format is: pnp_reserve_irq=irq1[,irq2] .... */
Expand Down

0 comments on commit 0a977f1

Please sign in to comment.