driver core patches against 2.6.25-git
Subsystems (3)
PATCH 1/1 driver core patches against 2.6.25-git
Here are a few remaining patches against your 2.6.25-git tree.
They provide a few apis that Tejun needs for other trees, and the biggest of all is the removal of 'struct class_device' now that it is purged from your tree through all of the different subsytem merges.
There's also a build fix in there from Randy and a few other minor things that people have posted problems with.
All of these patches have been in -next for a while.
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
Patches will be sent as a follow-on to this message to lkml for people to see.
thanks,
greg k-h
------------
drivers/base/base.h | 11 - drivers/base/class.c | 638 +---------------------------------------- drivers/base/driver.c | 10 + drivers/pcmcia/cs.c | 13 +- drivers/pcmcia/cs_internal.h | 3 +- drivers/pcmcia/socket_sysfs.c | 52 ++-- fs/debugfs/file.c | 2 +- fs/sysfs/inode.c | 2 + include/linux/device.h | 97 ------- include/linux/io.h | 4 +- include/linux/klist.h | 40 ++- include/linux/sysfs.h | 6 + lib/devres.c | 4 +- lib/klist.c | 235 ++++++++-------- lib/kobject.c | 28 +-- 15 files changed, 201 insertions(+), 944 deletions(-)
---------------
Ben Hutchings (1):
sysfs: Disallow truncation of files in sysfs
David Brownell (1):
pcmcia: remove pccard_sysfs_interface warnings
Greg Kroah-Hartman (1):
klist: fix coding style errors in klist.h and klist.c
Kay Sievers (2):
kobject: do not copy vargs, just pass them around driver core: remove no longer used "struct class_device"
Kumar Gala (1):
devres: support addresses greater than an unsigned long via dev_ioremap
Randy Dunlap (1):
sysfs: sysfs_update_group stub for CONFIG_SYSFS=n
Robert P. J. Day (1):
DEBUGFS: Correct location of debugfs API documentation.
Stas Sergeev (1):
driver core: warn about duplicate driver names on the same bus
Tejun Heo (2):
klist: implement KLIST_INIT() and DEFINE_KLIST()
klist: implement klist_add_{after|before}()
PATCH 1/11 sysfs: Disallow truncation of files in sysfs
From: Ben Hutchings <[email protected]>
sysfs allows attribute files to be truncated, e.g. using ftruncate(), with the
expected effect on their inode. For most attributes, this doesn't change the
"real" size of the file i.e. how much can be read from it. However, the parameter validation for reading and writing binary attribute files is based on the inode size and not the size specified in the file's bin_attribute, so it can be broken by this. For example, if we try using dd to write to such a file:
# pwd /sys/bus/pci/devices/0000:08:00.0 # ls -l config -rw-r--r-- 1 root root 4096 Feb 1 17:35 config # dd if=/dev/zero of=config bs=4 count=1 1+0 records in 1+0 records out # ls -l config -rw-r--r-- 1 root root 0 Feb 1 17:50 config # dd if=/dev/zero of=config bs=4 count=1 seek=128 dd: writing `config': No space left on device 1+0 records in 0+0 records out
Also, after truncation to 0, parameter validation for read and write is disabled. Most bin_attribute read and write methods also validate the size and offset, but for some this will allow out-of-range access. This may be a security issue, though access to such files is often limited to root. In any case, the validation should remain for safety's sake!)
This was previously reported in Bugzilla as bug 9867.
sysfs should ignore size changes or else refuse them (by returning -EINVAL). This patch makes it ignore them.
--- fs/sysfs/inode.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/inode.c +2 -0
@@ -59,6 +59,8 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)if (error)return error; + iattr->ia_valid &= ~ATTR_SIZE ;/* ignore size changes */ + error =inode_setattr (inode, iattr);if (error)return error;
Signature · 1 line
1.5.5.1
PATCH 2/11 klist: implement KLIST_INIT() and DEFINE_KLIST()
In reply to Greg KHFrom: Tejun Heo <[email protected]>
klist is missing static initializers and definition helper. Add them.
--- include/linux/klist.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
include/linux/klist.h +8 -0
@@ -25,6 +25,14 @@ struct klist {void (*put)(struct klist_node *); }; +#define KLIST_INIT (_name, _get, _put) \ + { .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \ + .k_list = LIST_HEAD_INIT(_name.k_list), \ + .get = _get, \ + .put = _put, } + +#define DEFINE_KLIST (_name, _get, _put) \ + struct klist _name = KLIST_INIT(_name, _get, _put)extern void klist_init (struct klist * k,void (*get)(struct klist_node *),void (*put)(struct klist_node *));
Signature · 1 line
1.5.5.1
PATCH 3/11 klist: implement klist_add_{after|before}()
In reply to Greg KHFrom: Tejun Heo <[email protected]>
Add klist_add_after() and klist_add_before() which puts a new node after and before an existing node, respectively. This is useful for callers which need to keep klist ordered. Note that synchronizing between simultaneous additions for ordering is the caller's responsibility.
--- include/linux/klist.h | 2 ++ lib/klist.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-)
include/linux/klist.h +2 -0
@@ -46,6 +46,8 @@ struct klist_node {extern void klist_add_tail (struct klist_node * n,struct klist * k);extern void klist_add_head (struct klist_node * n,struct klist * k); +extern void klist_add_after (struct klist_node *n,struct klist_node *pos); +extern void klist_add_before (struct klist_node *n,struct klist_node *pos);extern void klist_del (struct klist_node * n);extern void klist_remove (struct klist_node * n);
lib/klist.c +33 -0
@@ -120,6 +120,39 @@ void klist_add_tail(struct klist_node * n, struct klist * k)EXPORT_SYMBOL_GPL (klist_add_tail); +/** +* klist_add_after - Init a klist_node and add it after an existing node +* @n: node we're adding. +* @pos: node to put @n after +*/ +void klist_add_after (struct klist_node *n,struct klist_node *pos) +{ +struct klist *k = pos->n_klist; + +klist_node_init (k, n); +spin_lock (&k->k_lock); +list_add (&n->n_node, &pos->n_node); +spin_unlock (&k->k_lock); +} +EXPORT_SYMBOL_GPL (klist_add_after); + +/** +* klist_add_before - Init a klist_node and add it before an existing node +* @n: node we're adding. +* @pos: node to put @n after +*/ +void klist_add_before (struct klist_node *n,struct klist_node *pos) +{ +struct klist *k = pos->n_klist; + +klist_node_init (k, n); +spin_lock (&k->k_lock); +list_add_tail (&n->n_node, &pos->n_node); +spin_unlock (&k->k_lock); +} +EXPORT_SYMBOL_GPL (klist_add_before); + +static void klist_release (struct kref * kref) { struct klist_node * n = container_of(kref, struct klist_node, n_ref);
Signature · 1 line
1.5.5.1
PATCH 4/11 driver core: warn about duplicate driver names on the same bus
In reply to Greg KHFrom: Stas Sergeev <[email protected]>
Currently an attempt to register multiple drivers with the same name causes the stack trace with some cryptic error message. The attached patch adds the necessary check and the clear error message.
--- drivers/base/driver.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/base/driver.c +10 -0
@@ -217,12 +217,22 @@ static void driver_remove_groups(struct device_driver *drv,int driver_register (struct device_driver *drv) {int ret; +struct device_driver *other;if ((drv->bus->probe && drv->probe) || (drv->bus->remove && drv->remove) || (drv->bus->shutdown && drv->shutdown))printk (KERN_WARNING "Driver '%s' needs updating - please use " "bus_type methods\n" , drv->name); + + other =driver_find (drv->name, drv->bus); +if (other) { +put_driver (other); +printk (KERN_ERR "Error: Driver '%s' is already registered, " +"aborting...\n" , drv->name); +return -EEXIST ; + } + ret =bus_add_driver (drv);if (ret)return ret;
Signature · 1 line
1.5.5.1
PATCH 5/11 DEBUGFS: Correct location of debugfs API documentation.
In reply to Greg KHFrom: Robert P. J. Day <[email protected]>
--- fs/debugfs/file.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/debugfs/file.c +1 -1
@@ -9,7 +9,7 @@* 2 as published by the Free Software Foundation. * * debugfs is for people to use instead of /proc or /sys. -* See Documentation/DocBook/kernel-api for more details. +* See Documentation/DocBook/filesystems for more details. * */
Signature · 1 line
1.5.5.1
PATCH 6/11 sysfs: sysfs_update_group stub for CONFIG_SYSFS=n
In reply to Greg KHFrom: Randy Dunlap <[email protected]>
scsi_transport_spi uses sysfs_update_group() when CONFIG_SYSFS=n, so provide a stub for it.
next-20080423/drivers/scsi/scsi_transport_spi.c:1467: error: implicit declaration of function 'sysfs_update_group' make[3]: *** [drivers/scsi/scsi_transport_spi.o] Error 1
--- include/linux/sysfs.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
include/linux/sysfs.h +6 -0
@@ -190,6 +190,12 @@ static inline int sysfs_create_group(struct kobject *kobj,return 0 ; } +static inline int sysfs_update_group (struct kobject *kobj, +const struct attribute_group *grp) +{ +return 0 ; +} +static inline void sysfs_remove_group (struct kobject *kobj,const struct attribute_group *grp) {
Signature · 1 line
1.5.5.1
PATCH 7/11 kobject: do not copy vargs, just pass them around
In reply to Greg KHFrom: Kay Sievers <[email protected]>
This prevents a few unneeded copies.
--- lib/kobject.c | 28 ++++++++-------------------- 1 files changed, 8 insertions(+), 20 deletions(-)
lib/kobject.c +8 -20
@@ -216,21 +216,12 @@ static int kobject_add_internal(struct kobject *kobj)static int kobject_set_name_vargs (struct kobject *kobj,const char *fmt,va_list vargs) { -va_list aq; -char *name; - -va_copy (aq, vargs); - name =kvasprintf (GFP_KERNEL , fmt, vargs); -va_end (aq); - -if (!name) -return -ENOMEM ; -/* Free the old name, if necessary. */ kfree (kobj->name); -/* Now, set the new name */ - kobj->name = name; + kobj->name =kvasprintf (GFP_KERNEL , fmt, vargs); +if (!kobj->name) +return -ENOMEM ;return 0 ; }
@@ -246,12 +237,12 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,*/ int kobject_set_name (struct kobject *kobj,const char *fmt, ...) { -va_list args; +va_list vargs;int retval; -va_start (args, fmt); - retval =kobject_set_name_vargs (kobj, fmt, args); -va_end (args); +va_start (vargs, fmt); + retval =kobject_set_name_vargs (kobj, fmt, vargs); +va_end (vargs);return retval; }
@@ -301,12 +292,9 @@ EXPORT_SYMBOL(kobject_init);static int kobject_add_varg (struct kobject *kobj,struct kobject *parent,const char *fmt,va_list vargs) { -va_list aq;int retval; -va_copy (aq, vargs); - retval =kobject_set_name_vargs (kobj, fmt, aq); -va_end (aq); + retval =kobject_set_name_vargs (kobj, fmt, vargs);if (retval) {printk (KERN_ERR "kobject: can not set name properly!\n" );return retval;
Signature · 1 line
1.5.5.1
Re: [PATCH 07/11] kobject: do not copy vargs, just pass them around
Quoted 3 lines · Greg Kroah-Hartman
From: Kay Sievers <[email protected]>
This prevents a few unneeded copies.
That's a horrible title for what this obviously correct patch does, but I suppose it's way too late now.
s/just pass them around/just use them/
-sb
PATCH 8/11 devres: support addresses greater than an unsigned long via dev_ioremap
In reply to Greg KHFrom: Kumar Gala <[email protected]>
Use a resource_size_t instead of unsigned long since some arch's are capable of having ioremap deal with addresses greater than the size of a unsigned long.
--- include/linux/io.h | 4 ++-- lib/devres.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/io.h +2 -2
@@ -58,9 +58,9 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr) }#endif -void __iomem *devm_ioremap (struct device *dev,unsigned long offset, +void __iomem *devm_ioremap (struct device *dev,resource_size_t offset,unsigned long size); -void __iomem *devm_ioremap_nocache (struct device *dev,unsigned long offset, +void __iomem *devm_ioremap_nocache (struct device *dev,resource_size_t offset,unsigned long size);void devm_iounmap (struct device *dev,void __iomem *addr); int check_signature(const volatile void __iomem *io_addr,
lib/devres.c +2 -2
@@ -20,7 +20,7 @@ static int devm_ioremap_match(struct device *dev, void *res, void *match_data)* * Managed ioremap(). Map is automatically unmapped on driver detach. */ -void __iomem *devm_ioremap (struct device *dev,unsigned long offset, +void __iomem *devm_ioremap (struct device *dev,resource_size_t offset,unsigned long size) {void __iomem **ptr, *addr;
@@ -49,7 +49,7 @@ EXPORT_SYMBOL(devm_ioremap);* Managed ioremap_nocache(). Map is automatically unmapped on driver * detach. */ -void __iomem *devm_ioremap_nocache (struct device *dev,unsigned long offset, +void __iomem *devm_ioremap_nocache (struct device *dev,resource_size_t offset,unsigned long size) {void __iomem **ptr, *addr;
Signature · 1 line
1.5.5.1
PATCH 9/11 pcmcia: remove pccard_sysfs_interface warnings
In reply to Greg KHFrom: David Brownell <[email protected]>
Make the PCMCIA core stop using class_interface to hide socket attribute registration. This removes the associated section mismatch warnings, and helps get to the point where that mechanism can finally be removed.
Simplify that attribute registration by using an attribute_group. This is a net shrink in object size.
--- drivers/pcmcia/cs.c | 13 ++++------ drivers/pcmcia/cs_internal.h | 3 +- drivers/pcmcia/socket_sysfs.c | 52 ++++++++++++++++------------------------ 3 files changed, 28 insertions(+), 40 deletions(-)
drivers/pcmcia/cs.c +5 -8
@@ -652,6 +652,9 @@ static int pccardd(void *__skt)complete (&skt->thread_done);return 0 ; } + ret =pccard_sysfs_add_socket (&skt->dev); +if (ret) +dev_warn (&skt->dev,"err %d adding socket attributes\n" , ret);add_wait_queue (&skt->thread_wait, &wait);complete (&skt->thread_done);
@@ -694,6 +697,7 @@ static int pccardd(void *__skt)remove_wait_queue (&skt->thread_wait, &wait);/* remove from the device core */ +pccard_sysfs_remove_socket (&skt->dev);device_unregister (&skt->dev);return 0 ;
@@ -940,20 +944,13 @@ EXPORT_SYMBOL(pcmcia_socket_class);static int __init init_pcmcia_cs (void ) { -int ret; -init_completion (&pcmcia_unload); - ret =class_register (&pcmcia_socket_class); -if (ret) -return (ret); -return class_interface_register (&pccard_sysfs_interface); +return class_register (&pcmcia_socket_class); } static void __exit exit_pcmcia_cs(void) { -class_interface_unregister (&pccard_sysfs_interface);class_unregister (&pcmcia_socket_class); -wait_for_completion (&pcmcia_unload); }
drivers/pcmcia/cs_internal.h +2 -1
@@ -121,7 +121,8 @@ struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align,void release_resource_db (struct pcmcia_socket *s);/* In socket_sysfs.c */ -extern struct class_interface pccard_sysfs_interface; +extern int pccard_sysfs_add_socket (struct device *dev); +extern void pccard_sysfs_remove_socket (struct device *dev);/* In cs.c */ extern struct rw_semaphore pcmcia_socket_list_rwsem;
drivers/pcmcia/socket_sysfs.c +21 -31
75 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 10/11 driver core: remove no longer used "struct class_device"
In reply to Greg KHFrom: Kay Sievers <[email protected]>
--- drivers/base/base.h | 11 - drivers/base/class.c | 638 +----------------------------------------------- include/linux/device.h | 97 -------- 3 files changed, 1 insertions(+), 745 deletions(-)
drivers/base/base.h +0 -11
@@ -64,17 +64,6 @@ extern void sysdev_shutdown(void);extern int sysdev_suspend (pm_message_t state);extern int sysdev_resume (void ); -static inline struct class_device *to_class_dev (struct kobject *obj) -{ - return container_of(obj, struct class_device, kobj); -} - -static inline -struct class_device_attribute *to_class_dev_attr (struct attribute *_attr) -{ - return container_of(_attr, struct class_device_attribute, attr); -} -extern char *make_class_name (const char *name,struct kobject *kobj);extern int devres_release_all (struct device *dev);
drivers/base/class.c +1 -637
708 lines not on this page · raw message
include/linux/device.h +0 -97
141 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 11/11 klist: fix coding style errors in klist.h and klist.c
In reply to Greg KHFinally clean up the odd spacing in these files.
--- include/linux/klist.h | 30 ++++---- lib/klist.c | 206 ++++++++++++++++++++----------------------------- 2 files changed, 100 insertions(+), 136 deletions(-)
include/linux/klist.h +15 -15
@@ -34,38 +34,38 @@ struct klist {#define DEFINE_KLIST (_name, _get, _put) \ struct klist _name = KLIST_INIT(_name, _get, _put) -extern void klist_init (struct klist * k,void (*get)(struct klist_node *), +extern void klist_init (struct klist *k,void (*get)(struct klist_node *),void (*put)(struct klist_node *));struct klist_node { -struct klist * n_klist; +struct klist *n_klist;struct list_head n_node;struct kref n_ref;struct completion n_removed; }; -extern void klist_add_tail (struct klist_node * n,struct klist * k); -extern void klist_add_head (struct klist_node * n,struct klist * k); +extern void klist_add_tail (struct klist_node *n,struct klist *k); +extern void klist_add_head (struct klist_node *n,struct klist *k);extern void klist_add_after (struct klist_node *n,struct klist_node *pos);extern void klist_add_before (struct klist_node *n,struct klist_node *pos); -extern void klist_del (struct klist_node * n); -extern void klist_remove (struct klist_node * n); +extern void klist_del (struct klist_node *n); +extern void klist_remove (struct klist_node *n); -extern int klist_node_attached (struct klist_node * n); +extern int klist_node_attached (struct klist_node *n);struct klist_iter { -struct klist * i_klist; -struct list_head * i_head; -struct klist_node * i_cur; +struct klist *i_klist; +struct list_head *i_head; +struct klist_node *i_cur; }; -extern void klist_iter_init (struct klist * k,struct klist_iter * i); -extern void klist_iter_init_node (struct klist * k,struct klist_iter * i, -struct klist_node * n); -extern void klist_iter_exit (struct klist_iter * i); -extern struct klist_node *klist_next (struct klist_iter * i); +extern void klist_iter_init (struct klist *k,struct klist_iter *i); +extern void klist_iter_init_node (struct klist *k,struct klist_iter *i, +struct klist_node *n); +extern void klist_iter_exit (struct klist_iter *i); +extern struct klist_node *klist_next (struct klist_iter *i);#endif
lib/klist.c +85 -121
355 lines not on this page · raw message
Signature · 1 line
1.5.5.1