From: Patrick Mochel Date: Fri, 8 Feb 2002 08:19:17 +0000 (-0800) Subject: Small driver model/driverfs update. X-Git-Tag: v2.5.4-pre4^2 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a0fbd4b2af59952f1859ccda547d90dda8622503;p=history.git Small driver model/driverfs update. --- diff --git a/drivers/base/core.c b/drivers/base/core.c index 0cc155572054..4a8b527c6792 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -18,7 +18,10 @@ # define DBG(x...) #endif -static struct device * device_root; +static struct device device_root = { + bus_id: "root", + name: "System Root", +}; int (*platform_notify)(struct device * dev) = NULL; int (*platform_notify_remove)(struct device * dev) = NULL; @@ -49,9 +52,9 @@ int device_register(struct device *dev) spin_lock_init(&dev->lock); atomic_set(&dev->refcount,2); - if (dev != device_root) { + if (dev != &device_root) { if (!dev->parent) - dev->parent = device_root; + dev->parent = &device_root; get_device(dev->parent); list_add_tail(&dev->node,&dev->parent->children); } @@ -117,16 +120,10 @@ void put_device(struct device * dev) static int __init device_init_root(void) { - device_root = kmalloc(sizeof(*device_root),GFP_KERNEL); - if (!device_root) - return -ENOMEM; - memset(device_root,0,sizeof(*device_root)); - strcpy(device_root->bus_id,"root"); - strcpy(device_root->name,"System Root"); - return device_register(device_root); + return device_register(&device_root); } -static int __init device_driver_init(void) +static int __init device_init(void) { int error = 0; @@ -141,17 +138,12 @@ static int __init device_driver_init(void) return error; } - error = device_init_root(); - if (error) { + if ((error = device_init_root())) printk(KERN_ERR "%s: device root init failed!\n", __FUNCTION__); - return error; - } - - DBG("DEV: Done Initialising\n"); return error; } -subsys_initcall(device_driver_init); +subsys_initcall(device_init); EXPORT_SYMBOL(device_register); EXPORT_SYMBOL(put_device); diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 875160beb31c..84df2ce5bf5e 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c @@ -279,6 +279,12 @@ int cb_alloc(socket_info_t * s) pci_readw(dev, PCI_DEVICE_ID, &dev->device); dev->hdr_type = hdr & 0x7f; + dev->dev.parent = bus->device; + dev->dev.sysdata = bus->sysdata; + strcpy(dev->dev.name, dev->name); + strcpy(dev->dev.bus_id, dev->slot_name); + device_register(&dev->dev); + pci_setup_device(dev); /* FIXME: Do we need to enable the expansion ROM? */ diff --git a/fs/driverfs/inode.c b/fs/driverfs/inode.c index 54e35bce866d..9502dc7cd85d 100644 --- a/fs/driverfs/inode.c +++ b/fs/driverfs/inode.c @@ -245,6 +245,9 @@ driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos) if (!entry->show) return 0; + if (count > PAGE_SIZE) + count = PAGE_SIZE; + dev = list_entry(entry->parent,struct device, dir); page = (unsigned char*)__get_free_page(GFP_KERNEL); @@ -260,7 +263,8 @@ driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos) if (len < 0) retval = len; break; - } + } else if (len > count) + len = count; if (copy_to_user(buf,page,len)) { retval = -EFAULT;