void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
void pnp_init_resource(struct resource *res);
+
+#define PNP_MAX_PORT 40
+#define PNP_MAX_MEM 24
+#define PNP_MAX_IRQ 2
+#define PNP_MAX_DMA 2
+
+struct pnp_resource_table {
+ struct resource port_resource[PNP_MAX_PORT];
+ struct resource mem_resource[PNP_MAX_MEM];
+ struct resource dma_resource[PNP_MAX_DMA];
+ struct resource irq_resource[PNP_MAX_IRQ];
+};
pnp_free_option(dev->independent);
pnp_free_option(dev->dependent);
pnp_free_ids(dev);
+ kfree(dev->res);
kfree(dev);
}
if (!dev)
return NULL;
+ dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
+ if (!dev->res) {
+ kfree(dev);
+ return NULL;
+ }
+
dev->protocol = protocol;
dev->number = id;
dev->dma_mask = DMA_24BIT_MASK;
dev_id = pnp_add_id(dev, pnpid);
if (!dev_id) {
+ kfree(dev->res);
kfree(dev);
return NULL;
}
static int isapnp_read_resources(struct pnp_dev *dev)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int tmp, ret;
dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
static int isapnp_set_resources(struct pnp_dev *dev)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int tmp;
dev_dbg(&dev->dev, "set resources\n");
int idx;
for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
- res = &dev->res.irq_resource[idx];
+ res = &dev->res->irq_resource[idx];
res->flags = IORESOURCE_IRQ;
pnp_init_resource(res);
}
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
- res = &dev->res.dma_resource[idx];
+ res = &dev->res->dma_resource[idx];
res->flags = IORESOURCE_DMA;
pnp_init_resource(res);
}
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
- res = &dev->res.port_resource[idx];
+ res = &dev->res->port_resource[idx];
res->flags = IORESOURCE_IO;
pnp_init_resource(res);
}
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
- res = &dev->res.mem_resource[idx];
+ res = &dev->res->mem_resource[idx];
res->flags = IORESOURCE_MEM;
pnp_init_resource(res);
}
int idx;
for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
- res = &dev->res.irq_resource[idx];
+ res = &dev->res->irq_resource[idx];
if (res->flags & IORESOURCE_AUTO) {
res->flags = IORESOURCE_IRQ;
pnp_init_resource(res);
}
}
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
- res = &dev->res.dma_resource[idx];
+ res = &dev->res->dma_resource[idx];
if (res->flags & IORESOURCE_AUTO) {
res->flags = IORESOURCE_DMA;
pnp_init_resource(res);
}
}
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
- res = &dev->res.port_resource[idx];
+ res = &dev->res->port_resource[idx];
if (res->flags & IORESOURCE_AUTO) {
res->flags = IORESOURCE_IO;
pnp_init_resource(res);
}
}
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
- res = &dev->res.mem_resource[idx];
+ res = &dev->res->mem_resource[idx];
if (res->flags & IORESOURCE_AUTO) {
res->flags = IORESOURCE_MEM;
pnp_init_resource(res);
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/pci.h>
+#include <linux/pnp.h>
+#include "../base.h"
#include "pnpacpi.h"
#ifdef CONFIG_IA64
u32 gsi, int triggering,
int polarity, int shareable)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
int irq;
int p, t;
static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
u32 dma, int flags)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
static unsigned char warned;
static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
u64 io, u64 len, int io_decode)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
static unsigned char warned;
u64 mem, u64 len,
int write_protect)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
static unsigned char warned;
static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
while (i < PNP_MAX_DMA &&
static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
int io, int len)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
int mem, int len)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
int i = 0;
while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
struct resource *pnp_get_resource(struct pnp_dev *dev,
unsigned int type, unsigned int num)
{
- struct pnp_resource_table *res = &dev->res;
+ struct pnp_resource_table *res = dev->res;
switch (type) {
case IORESOURCE_IO:
#include <linux/errno.h>
#include <linux/mod_devicetable.h>
-#define PNP_MAX_PORT 40
-#define PNP_MAX_MEM 24
-#define PNP_MAX_IRQ 2
-#define PNP_MAX_DMA 2
#define PNP_NAME_LEN 50
struct pnp_protocol;
struct pnp_dev;
+struct pnp_resource_table;
/*
* Resource Management
struct pnp_option *next; /* used to chain dependent resources */
};
-struct pnp_resource_table {
- struct resource port_resource[PNP_MAX_PORT];
- struct resource mem_resource[PNP_MAX_MEM];
- struct resource dma_resource[PNP_MAX_DMA];
- struct resource irq_resource[PNP_MAX_IRQ];
-};
-
/*
* Device Management
*/
int capabilities;
struct pnp_option *independent;
struct pnp_option *dependent;
- struct pnp_resource_table res;
+ struct pnp_resource_table *res;
char name[PNP_NAME_LEN]; /* contains a human-readable name */
unsigned short regs; /* ISAPnP: supported registers */