Skip to content

Commit 0a977f1

Browse files
Bjorn Helgaaslenb
authored andcommitted
PNP: add pnp_get_pnp_resource()
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>
1 parent 784f01d commit 0a977f1

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎drivers/pnp/base.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
2121

2222
void pnp_init_resource(struct resource *res);
2323

24+
struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
25+
unsigned int type, unsigned int num);
26+
2427
#define PNP_MAX_PORT 40
2528
#define PNP_MAX_MEM 24
2629
#define PNP_MAX_IRQ 2

‎drivers/pnp/resource.c‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,31 +499,43 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
499499
#endif
500500
}
501501

502-
struct resource *pnp_get_resource(struct pnp_dev *dev,
503-
unsigned int type, unsigned int num)
502+
struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
503+
unsigned int type, unsigned int num)
504504
{
505505
struct pnp_resource_table *res = dev->res;
506506

507507
switch (type) {
508508
case IORESOURCE_IO:
509509
if (num >= PNP_MAX_PORT)
510510
return NULL;
511-
return &res->port[num].res;
511+
return &res->port[num];
512512
case IORESOURCE_MEM:
513513
if (num >= PNP_MAX_MEM)
514514
return NULL;
515-
return &res->mem[num].res;
515+
return &res->mem[num];
516516
case IORESOURCE_IRQ:
517517
if (num >= PNP_MAX_IRQ)
518518
return NULL;
519-
return &res->irq[num].res;
519+
return &res->irq[num];
520520
case IORESOURCE_DMA:
521521
if (num >= PNP_MAX_DMA)
522522
return NULL;
523-
return &res->dma[num].res;
523+
return &res->dma[num];
524524
}
525525
return NULL;
526526
}
527+
528+
struct resource *pnp_get_resource(struct pnp_dev *dev,
529+
unsigned int type, unsigned int num)
530+
{
531+
struct pnp_resource *pnp_res;
532+
533+
pnp_res = pnp_get_pnp_resource(dev, type, num);
534+
if (pnp_res)
535+
return &pnp_res->res;
536+
537+
return NULL;
538+
}
527539
EXPORT_SYMBOL(pnp_get_resource);
528540

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

0 commit comments

Comments
 (0)