Commit b74d2576 authored by Patrick Mochel's avatar Patrick Mochel

Convert users of struct device_attribute to initialize the structs using

DEVICE_ATTR macro.
parent 8d1290b8
......@@ -14,11 +14,7 @@ static ssize_t device_read_name(struct device * dev, char * buf, size_t count, l
return off ? 0 : sprintf(buf,"%s\n",dev->name);
}
static struct device_attribute device_name_entry = {
name: "name",
mode: S_IRUGO,
show: device_read_name,
};
static DEVICE_ATTR(name,"name",S_IRUGO,device_read_name,NULL);
static ssize_t
device_read_power(struct device * dev, char * page, size_t count, loff_t off)
......@@ -89,15 +85,11 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o
return error < 0 ? error : count;
}
static struct device_attribute device_power_entry = {
name: "power",
mode: S_IWUSR | S_IRUGO,
show: device_read_power,
store: device_write_power,
};
static DEVICE_ATTR(power,"power",S_IWUSR | S_IRUGO,
device_read_power,device_write_power);
struct device_attribute * device_default_files[] = {
&device_name_entry,
&device_power_entry,
&dev_attr_name,
&dev_attr_power,
NULL,
};
......@@ -378,11 +378,7 @@ static ssize_t pci_show_irq(struct device * dev, char * buf, size_t count, loff_
return off ? 0 : sprintf(buf,"%u\n",pci_dev->irq);
}
static struct device_attribute pci_irq_entry = {
name: "irq",
mode: S_IRUGO,
show: pci_show_irq,
};
static DEVICE_ATTR(irq,"irq",S_IRUGO,pci_show_irq,NULL);
static ssize_t pci_show_resources(struct device * dev, char * buf, size_t count, loff_t off)
{
......@@ -406,11 +402,7 @@ static ssize_t pci_show_resources(struct device * dev, char * buf, size_t count,
return (str - buf);
}
static struct device_attribute pci_resource_entry = {
name: "resources",
mode: S_IRUGO,
show: pci_show_resources,
};
static DEVICE_ATTR(resource,"resource",S_IRUGO,pci_show_resources,NULL);
int pci_proc_attach_device(struct pci_dev *dev)
{
......@@ -432,8 +424,8 @@ int pci_proc_attach_device(struct pci_dev *dev)
e->data = dev;
e->size = PCI_CFG_SPACE_SIZE;
device_create_file(&dev->dev,&pci_irq_entry);
device_create_file(&dev->dev,&pci_resource_entry);
device_create_file(&dev->dev,&dev_attr_irq);
device_create_file(&dev->dev,&dev_attr_resource);
return 0;
}
......
......@@ -305,12 +305,8 @@ static ssize_t scsi_device_type_read(struct device *driverfs_dev, char *page,
return 0;
}
static DEVICE_ATTR(type,"type",S_IRUGO,scsi_device_type_read,NULL);
static struct device_attribute scsi_device_type_file = {
name: "type",
mode: S_IRUGO,
show: scsi_device_type_read,
};
/* end content handlers */
static void print_inquiry(unsigned char *data)
......@@ -825,7 +821,7 @@ static int scan_scsis_single(unsigned int channel, unsigned int dev,
/* Create driverfs file entries */
device_create_file(&SDpnt->sdev_driverfs_dev,
&scsi_device_type_file);
&dev_attr_type);
sprintf (devname, "host%d/bus%d/target%d/lun%d",
SDpnt->host->host_no, SDpnt->channel, SDpnt->id, SDpnt->lun);
......
......@@ -1402,22 +1402,14 @@ static ssize_t sg_device_kdev_read(struct device *driverfs_dev, char *page,
Sg_device * sdp=list_entry(driverfs_dev, Sg_device, sg_driverfs_dev);
return off ? 0 : sprintf(page, "%x\n",sdp->i_rdev.value);
}
static struct device_attribute sg_device_kdev_file = {
name: "kdev",
mode: S_IRUGO,
show: sg_device_kdev_read,
};
static DEVICE_ATTR(kdev,"kdev",S_IRUGO,sg_device_kdev_read,NULL);
static ssize_t sg_device_type_read(struct device *driverfs_dev, char *page,
size_t count, loff_t off)
{
return off ? 0 : sprintf (page, "CHR\n");
}
static struct device_attribute sg_device_type_file = {
name: "type",
mode: S_IRUGO,
show: sg_device_type_read,
};
static DEVICE_ATTR(type,"type",S_IRUGO,sg_device_type_read,NULL);
static int sg_attach(Scsi_Device * scsidp)
{
......@@ -1485,8 +1477,8 @@ static int sg_attach(Scsi_Device * scsidp)
sdp->sg_driverfs_dev.parent = &scsidp->sdev_driverfs_dev;
sdp->sg_driverfs_dev.bus = &scsi_driverfs_bus_type;
device_register(&sdp->sg_driverfs_dev);
device_create_file(&sdp->sg_driverfs_dev, &sg_device_type_file);
device_create_file(&sdp->sg_driverfs_dev, &sg_device_kdev_file);
device_create_file(&sdp->sg_driverfs_dev, &dev_attr_type);
device_create_file(&sdp->sg_driverfs_dev, &dev_attr_kdev);
sdp->de = devfs_register (scsidp->de, "generic", DEVFS_FL_DEFAULT,
SCSI_GENERIC_MAJOR, k,
......@@ -1556,8 +1548,8 @@ static void sg_detach(Scsi_Device * scsidp)
}
SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d, dirty\n", k));
devfs_unregister (sdp->de);
device_remove_file(&sdp->sg_driverfs_dev,&sg_device_type_file);
device_remove_file(&sdp->sg_driverfs_dev,&sg_device_kdev_file);
device_remove_file(&sdp->sg_driverfs_dev,&dev_attr_type);
device_remove_file(&sdp->sg_driverfs_dev,&dev_attr_kdev);
put_device(&sdp->sg_driverfs_dev);
sdp->de = NULL;
if (NULL == sdp->headfp) {
......
......@@ -739,22 +739,14 @@ static ssize_t sr_device_kdev_read(struct device *driverfs_dev,
kdev.value=(int)driverfs_dev->driver_data;
return off ? 0 : sprintf(page, "%x\n",kdev.value);
}
static struct device_attribute sr_device_kdev_file = {
name: "kdev",
mode: S_IRUGO,
show: sr_device_kdev_read,
};
static DEVICE_ATTR(kdev,"kdev",S_IRUGO,sr_device_kdev_read,NULL);
static ssize_t sr_device_type_read(struct device *driverfs_dev,
char *page, size_t count, loff_t off)
{
return off ? 0 : sprintf (page, "CHR\n");
}
static struct device_attribute sr_device_type_file = {
name: "type",
mode: S_IRUGO,
show: sr_device_type_read,
};
static DEVICE_ATTR(type,"type",S_IRUGO,sr_device_type_read,NULL);
void sr_finish()
......@@ -813,9 +805,9 @@ void sr_finish()
(void *)__mkdev(MAJOR_NR, i);
device_register(&SCp->cdi.cdrom_driverfs_dev);
device_create_file(&SCp->cdi.cdrom_driverfs_dev,
&sr_device_type_file);
&dev_attr_type);
device_create_file(&SCp->cdi.cdrom_driverfs_dev,
&sr_device_kdev_file);
&dev_attr_kdev);
SCp->cdi.de = devfs_register(SCp->device->de, "cd",
DEVFS_FL_DEFAULT, MAJOR_NR, i,
S_IFBLK | S_IRUGO | S_IWUGO,
......
......@@ -3533,22 +3533,14 @@ static ssize_t st_device_kdev_read(struct device *driverfs_dev,
kdev.value=(int)driverfs_dev->driver_data;
return off ? 0 : sprintf(page, "%x\n",kdev.value);
}
static struct device_attribute st_device_kdev_file = {
name: "kdev",
mode: S_IRUGO,
show: st_device_kdev_read,
};
static DEVICE_ATTR(kdev,"kdev",S_IRUGO,st_device_kdev_read,NULL);
static ssize_t st_device_type_read(struct device *driverfs_dev,
char *page, size_t count, loff_t off)
{
return off ? 0 : sprintf (page, "CHR\n");
}
static struct device_attribute st_device_type_file = {
name: "type",
mode: S_IRUGO,
show: st_device_type_read,
};
static DEVICE_ATTR(type,"type",S_IRUGO,st_device_type_read,NULL);
static struct file_operations st_fops =
......@@ -3664,8 +3656,8 @@ static int st_attach(Scsi_Device * SDp)
(void *)__mkdev(MAJOR_NR, i + (mode << 5));
device_register(&tpnt->driverfs_dev_r[mode]);
device_create_file(&tpnt->driverfs_dev_r[mode],
&st_device_type_file);
device_create_file(&tpnt->driverfs_dev_r[mode], &st_device_kdev_file);
&dev_attr_type);
device_create_file(&tpnt->driverfs_dev_r[mode], &dev_attr_kdev);
tpnt->de_r[mode] =
devfs_register (SDp->de, name, DEVFS_FL_DEFAULT,
MAJOR_NR, i + (mode << 5),
......@@ -3683,9 +3675,9 @@ static int st_attach(Scsi_Device * SDp)
(void *)__mkdev(MAJOR_NR, i + (mode << 5) + 128);
device_register(&tpnt->driverfs_dev_n[mode]);
device_create_file(&tpnt->driverfs_dev_n[mode],
&st_device_type_file);
&dev_attr_type);
device_create_file(&tpnt->driverfs_dev_n[mode],
&st_device_kdev_file);
&dev_attr_kdev);
tpnt->de_n[mode] =
devfs_register (SDp->de, name, DEVFS_FL_DEFAULT,
MAJOR_NR, i + (mode << 5) + 128,
......@@ -3785,16 +3777,16 @@ static void st_detach(Scsi_Device * SDp)
devfs_unregister (tpnt->de_r[mode]);
tpnt->de_r[mode] = NULL;
device_remove_file(&tpnt->driverfs_dev_r[mode],
&st_device_type_file);
&dev_attr_type);
device_remove_file(&tpnt->driverfs_dev_r[mode],
&st_device_kdev_file);
&dev_attr_type);
put_device(&tpnt->driverfs_dev_r[mode]);
devfs_unregister (tpnt->de_n[mode]);
tpnt->de_n[mode] = NULL;
device_remove_file(&tpnt->driverfs_dev_n[mode],
st_device_type_file.name);
&dev_attr_type);
device_remove_file(&tpnt->driverfs_dev_n[mode],
st_device_kdev_file.name);
&dev_attr_kdev);
put_device(&tpnt->driverfs_dev_n[mode]);
}
if (tpnt->buffer) {
......
......@@ -835,11 +835,8 @@ show_config (struct device *dev, char *buf, size_t count, loff_t off)
udev = to_usb_device (dev);
return sprintf (buf, "%u\n", udev->actconfig->bConfigurationValue);
}
static struct device_attribute usb_config_entry = {
.name = "configuration",
.mode = S_IRUGO,
.show = show_config,
};
static DEVICE_ATTR(config,"configuration",S_IRUGO,show_config,NULL);
/* interfaces have one current setting; alternates
* can have different endpoints and class info.
......@@ -854,11 +851,7 @@ show_altsetting (struct device *dev, char *buf, size_t count, loff_t off)
interface = to_usb_interface (dev);
return sprintf (buf, "%u\n", interface->altsetting->bAlternateSetting);
}
static struct device_attribute usb_altsetting_entry = {
.name = "altsetting",
.mode = S_IRUGO,
.show = show_altsetting,
};
static DEVICE_ATTR(altsetting,"altsetting",S_IRUGO,show_altsetting,NULL);
/* product driverfs file */
static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t off)
......@@ -875,11 +868,7 @@ static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t
buf[len+1] = 0x00;
return len+1;
}
static struct device_attribute usb_product_entry = {
.name = "product",
.mode = S_IRUGO,
.show = show_product,
};
static DEVICE_ATTR(product,"product",S_IRUGO,show_product,NULL);
/* manufacturer driverfs file */
static ssize_t
......@@ -897,11 +886,7 @@ show_manufacturer (struct device *dev, char *buf, size_t count, loff_t off)
buf[len+1] = 0x00;
return len+1;
}
static struct device_attribute usb_manufacturer_entry = {
.name = "manufacturer",
.mode = S_IRUGO,
.show = show_manufacturer,
};
static DEVICE_ATTR(manufacturer,"manufacturer",S_IRUGO,show_manufacturer,NULL);
/* serial number driverfs file */
static ssize_t
......@@ -919,11 +904,7 @@ show_serial (struct device *dev, char *buf, size_t count, loff_t off)
buf[len+1] = 0x00;
return len+1;
}
static struct device_attribute usb_serial_entry = {
.name = "serial",
.mode = S_IRUGO,
.show = show_serial,
};
static DEVICE_ATTR(serial,"serial",S_IRUGO,show_serial,NULL);
/*
* This entrypoint gets called for each new device.
......@@ -965,7 +946,7 @@ static void usb_find_drivers(struct usb_device *dev)
interface->altsetting->bInterfaceNumber);
}
device_register (&interface->dev);
device_create_file (&interface->dev, &usb_altsetting_entry);
device_create_file (&interface->dev, &dev_attr_altsetting);
/* if this interface hasn't already been claimed */
if (!usb_interface_claimed(interface)) {
......@@ -1453,13 +1434,13 @@ int usb_new_device(struct usb_device *dev)
err = device_register (&dev->dev);
if (err)
return err;
device_create_file (&dev->dev, &usb_config_entry);
device_create_file (&dev->dev, &dev_attr_config);
if (dev->descriptor.iManufacturer)
device_create_file (&dev->dev, &usb_manufacturer_entry);
device_create_file (&dev->dev, &dev_attr_manufacturer);
if (dev->descriptor.iProduct)
device_create_file (&dev->dev, &usb_product_entry);
device_create_file (&dev->dev, &dev_attr_product);
if (dev->descriptor.iSerialNumber)
device_create_file (&dev->dev, &usb_serial_entry);
device_create_file (&dev->dev, &dev_attr_serial);
/* now that the basic setup is over, add a /proc/bus/usb entry */
usbfs_add_device(dev);
......
......@@ -210,22 +210,14 @@ static ssize_t partition_device_kdev_read(struct device *driverfs_dev,
kdev.value=(int)(long)driverfs_dev->driver_data;
return off ? 0 : sprintf (page, "%x\n",kdev.value);
}
static struct device_attribute partition_device_kdev_file = {
name: "kdev",
mode: S_IRUGO,
show: partition_device_kdev_read,
};
static DEVICE_ATTR(kdev,"kdev",S_IRUGO,partition_device_kdev_read,NULL);
static ssize_t partition_device_type_read(struct device *driverfs_dev,
char *page, size_t count, loff_t off)
{
return off ? 0 : sprintf (page, "BLK\n");
}
static struct device_attribute partition_device_type_file = {
name: "type",
mode: S_IRUGO,
show: partition_device_type_read,
};
static DEVICE_ATTR(type,"type",S_IRUGO,partition_device_type_read,NULL);
void driverfs_create_partitions(struct gendisk *hd, int minor)
{
......@@ -296,9 +288,9 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
if (parent) current_driverfs_dev->bus = parent->bus;
device_register(current_driverfs_dev);
device_create_file(current_driverfs_dev,
&partition_device_type_file);
&dev_attr_type);
device_create_file(current_driverfs_dev,
&partition_device_kdev_file);
&dev_attr_kdev);
}
}
}
......@@ -317,17 +309,17 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor)
if ((p[part].nr_sects >= 1)) {
current_driverfs_dev = &p[part].hd_driverfs_dev;
device_remove_file(current_driverfs_dev,
&partition_device_type_file);
&dev_attr_type);
device_remove_file(current_driverfs_dev,
&partition_device_kdev_file);
&dev_attr_kdev);
put_device(current_driverfs_dev);
}
}
current_driverfs_dev = &p->hd_driverfs_dev;
device_remove_file(current_driverfs_dev,
&partition_device_type_file);
device_remove_file(current_driverfs_dev,
&partition_device_kdev_file);
device_remove_file(current_driverfs_dev,
&dev_attr_type);
device_remove_file(current_driverfs_dev,
&dev_attr_kdev);
put_device(current_driverfs_dev);
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment