typedef struct pnp_info_buffer pnp_info_buffer_t;
-int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...)
+static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...)
{
va_list args;
int res;
int first = 1, i;
pnp_printf(buffer, "%sirq ", space);
- for (i = 0; i < 16; i++)
- if (irq->map & (1<<i)) {
+ for (i = 0; i < PNP_IRQ_NR; i++)
+ if (test_bit(i, irq->map)) {
if (!first) {
pnp_printf(buffer, ",");
} else {
else
pnp_printf(buffer, "%i", i);
}
- if (!irq->map)
+ if (bitmap_empty(irq->map, PNP_IRQ_NR))
pnp_printf(buffer, "<none>");
if (irq->flags & IORESOURCE_IRQ_HIGHEDGE)
pnp_printf(buffer, " High-Edge");
}
-static ssize_t pnp_show_options(struct device *dmdev, char *buf)
+static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *attr, char *buf)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
struct pnp_option * independent = dev->independent;
static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL);
-static ssize_t pnp_show_current_resources(struct device *dmdev, char *buf)
+static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_attribute *attr, char *buf)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
int i, ret;
- pnp_info_buffer_t *buffer = (pnp_info_buffer_t *)
- pnp_alloc(sizeof(pnp_info_buffer_t));
- if (!buffer)
- return -ENOMEM;
+ pnp_info_buffer_t *buffer;
+
if (!dev)
return -EINVAL;
+
+ buffer = (pnp_info_buffer_t *) pnp_alloc(sizeof(pnp_info_buffer_t));
+ if (!buffer)
+ return -ENOMEM;
buffer->len = PAGE_SIZE;
buffer->buffer = buf;
buffer->curr = buffer->buffer;
if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED)
pnp_printf(buffer," disabled\n");
else
- pnp_printf(buffer," 0x%lx-0x%lx\n",
- pnp_port_start(dev, i),
- pnp_port_end(dev, i));
+ pnp_printf(buffer," 0x%llx-0x%llx\n",
+ (unsigned long long)pnp_port_start(dev, i),
+ (unsigned long long)pnp_port_end(dev, i));
}
}
for (i = 0; i < PNP_MAX_MEM; i++) {
if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED)
pnp_printf(buffer," disabled\n");
else
- pnp_printf(buffer," 0x%lx-0x%lx\n",
- pnp_mem_start(dev, i),
- pnp_mem_end(dev, i));
+ pnp_printf(buffer," 0x%llx-0x%llx\n",
+ (unsigned long long)pnp_mem_start(dev, i),
+ (unsigned long long)pnp_mem_end(dev, i));
}
}
for (i = 0; i < PNP_MAX_IRQ; i++) {
if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED)
pnp_printf(buffer," disabled\n");
else
- pnp_printf(buffer," %ld\n",
- pnp_irq(dev, i));
+ pnp_printf(buffer," %lld\n",
+ (unsigned long long)pnp_irq(dev, i));
}
}
for (i = 0; i < PNP_MAX_DMA; i++) {
if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED)
pnp_printf(buffer," disabled\n");
else
- pnp_printf(buffer," %ld\n",
- pnp_dma(dev, i));
+ pnp_printf(buffer," %lld\n",
+ (unsigned long long)pnp_dma(dev, i));
}
}
ret = (buffer->curr - buf);
extern struct semaphore pnp_res_mutex;
static ssize_t
-pnp_set_current_resources(struct device * dmdev, const char * ubuf, size_t count)
+pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, const char * ubuf, size_t count)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
char *buf = (void *)ubuf;
static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR,
pnp_show_current_resources,pnp_set_current_resources);
-static ssize_t pnp_show_current_ids(struct device *dmdev, char *buf)
+static ssize_t pnp_show_current_ids(struct device *dmdev, struct device_attribute *attr, char *buf)
{
char *str = buf;
struct pnp_dev *dev = to_pnp_dev(dmdev);
int pnp_interface_attach_device(struct pnp_dev *dev)
{
- device_create_file(&dev->dev,&dev_attr_options);
- device_create_file(&dev->dev,&dev_attr_resources);
- device_create_file(&dev->dev,&dev_attr_id);
+ int rc = device_create_file(&dev->dev,&dev_attr_options);
+ if (rc) goto err;
+ rc = device_create_file(&dev->dev,&dev_attr_resources);
+ if (rc) goto err_opt;
+ rc = device_create_file(&dev->dev,&dev_attr_id);
+ if (rc) goto err_res;
+
return 0;
+
+err_res:
+ device_remove_file(&dev->dev,&dev_attr_resources);
+err_opt:
+ device_remove_file(&dev->dev,&dev_attr_options);
+err:
+ return rc;
}