1. 08 Mar, 2010 11 commits
    • Andi Kleen's avatar
      sysfs: Add attribute array to sysdev classes · 38457ab3
      Andi Kleen authored
      Add a attribute array that is automatically registered and unregistered
      to struct sysdev_class. This is similar to what struct class has.
      
      A lot of drivers add list of attributes, so it's better to do 
      this easily in the common sysdev layer.
      
      This adds a new field to struct sysdev_class. I audited the 
      whole tree and there are no dynamically allocated sysdev classes,
      so this is fully compatible. 
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      38457ab3
    • Andi Kleen's avatar
      sysfs: Add sysfs_add/remove_files utility functions · 1c205ae1
      Andi Kleen authored
      Adding/Removing a whole array of attributes is very common. Add a standard
      utility function to do this with a simple function call, instead of
      requiring drivers to open code this.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      1c205ae1
    • Andi Kleen's avatar
      sysdev: Convert cpu driver sysdev class attributes · 265d2e2e
      Andi Kleen authored
      Using the new attribute argument convert the cpu driver class attributes
      to carry the node state. Then use a shared function to do what a lot of
      individual functions did before.
      
      This eliminates an ugly macro.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      265d2e2e
    • Andi Kleen's avatar
      sysdev: Convert node driver class attributes to be data driven · b15f562f
      Andi Kleen authored
      Using the new attribute argument convert the node driver class
      attributes to carry the node state. Then use a shared function to do
      what a lot of individual functions did before.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      b15f562f
    • Andi Kleen's avatar
      sysdev: Pass attribute in sysdev_class attributes show/store · c9be0a36
      Andi Kleen authored
      Passing the attribute to the low level IO functions allows all kinds
      of cleanups, by sharing low level IO code without requiring
      an own function for every piece of data.
      
      Also drivers can extend the attributes with own data fields
      and use that in the low level function.
      
      Similar to sysdev_attributes and normal attributes.
      
      This is a tree-wide sweep, converting everything in one go.
      
      No functional changes in this patch other than passing the new
      argument everywhere.
      
      Tested on x86, the non x86 parts are uncompiled.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      c9be0a36
    • Eric Miao's avatar
      driver core: make platform_device_id table const · 3d03ba4d
      Eric Miao authored
      The platform ID table is normally const, force that by adding the attribute.
      Signed-off-by: default avatarEric Miao <eric.y.miao@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      3d03ba4d
    • Dmitry Torokhov's avatar
      Driver core: add platform_create_bundle() helper · ecdf6ceb
      Dmitry Torokhov authored
      Many legacy-style module create singleton platform devices themselves,
      along with corresponding platform driver. Instead of replicating error
      handling code in all such drivers, provide a helper that allocates and
      registers a single platform device and a driver and binds them together.
      Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      ecdf6ceb
    • Radu Voicilas's avatar
      kset-example: Spelling fixes. · 20ef9f46
      Radu Voicilas authored
      No change in functionality.
      Signed-off-by: default avatarRadu Voicilas <rvoicilas@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      20ef9f46
    • Radu Voicilas's avatar
      kobject-example: Spelling fixes. · a115bc07
      Radu Voicilas authored
      No change in functionality.
      Signed-off-by: default avatarRadu Voicilas <rvoicilas@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      a115bc07
    • Tejun Heo's avatar
      driver-core: fix race condition in get_device_parent() · 77d3d7c1
      Tejun Heo authored
      sysfs is creating several devices in cuse class concurrently and with
      CONFIG_SYSFS_DEPRECATED turned off, it triggers the following oops.
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
       IP: [<ffffffff81158b0a>] sysfs_addrm_start+0x4a/0xf0
       PGD 75bb067 PUD 75be067 PMD 0
       Oops: 0000 [#1] PREEMPT SMP
       last sysfs file: /sys/devices/system/cpu/cpu7/topology/core_siblings
       CPU 1
       Modules linked in: cuse fuse
       Pid: 4737, comm: osspd Not tainted 2.6.31-work #77
       RIP: 0010:[<ffffffff81158b0a>]  [<ffffffff81158b0a>] sysfs_addrm_start+0x4a/0xf0
       RSP: 0018:ffff88000042f8f8  EFLAGS: 00010296
       RAX: ffff88000042ffd8 RBX: 0000000000000000 RCX: 0000000000000000
       RDX: 0000000000000000 RSI: ffff880007eef660 RDI: 0000000000000001
       RBP: ffff88000042f918 R08: 0000000000000000 R09: 0000000000000000
       R10: 0000000000000001 R11: ffffffff81158b0a R12: ffff88000042f928
       R13: 00000000fffffff4 R14: 0000000000000000 R15: ffff88000042f9a0
       FS:  00007fe93905a950(0000) GS:ffff880008600000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000038 CR3: 00000000077c9000 CR4: 00000000000006e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Process osspd (pid: 4737, threadinfo ffff88000042e000, task ffff880007eef040)
       Stack:
        ffff880005da10e8 0000000011cc8d6e ffff88000042f928 ffff880003d28a28
       <0> ffff88000042f988 ffffffff811592d7 0000000000000000 0000000000000000
       <0> 0000000000000000 0000000000000000 ffff88000042f958 0000000011cc8d6e
       Call Trace:
        [<ffffffff811592d7>] create_dir+0x67/0xe0
        [<ffffffff811593a8>] sysfs_create_dir+0x58/0xb0
        [<ffffffff8128ca7c>] ? kobject_add_internal+0xcc/0x220
        [<ffffffff812942e1>] ? vsnprintf+0x3c1/0xb90
        [<ffffffff8128cab7>] kobject_add_internal+0x107/0x220
        [<ffffffff8128cd37>] kobject_add_varg+0x47/0x80
        [<ffffffff8128ce53>] kobject_add+0x53/0x90
        [<ffffffff81357d84>] device_add+0xd4/0x690
        [<ffffffff81356c2b>] ? dev_set_name+0x4b/0x70
        [<ffffffffa001a884>] cuse_process_init_reply+0x2b4/0x420 [cuse]
        ...
      
      The problem is that kobject_add_internal() first adds a kobject to the
      kset and then try to create sysfs directory for it.  If the creation
      fails, it remove the kobject from the kset.  get_device_parent()
      accesses class_dirs kset while only holding class_dirs.list_lock to
      see whether the cuse class dir exists.  But when it exists, it may not
      have finished initialization yet or may fail and get removed soon.  In
      the above case, the former happened so the second one ends up trying
      to create subdirectory under NULL sysfs_dirent.
      
      Fix it by grabbing a mutex in get_device_parent().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarColin Guthrie <cguthrie@mandriva.org>
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      77d3d7c1
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/amit/virtio-console · 25cf84cf
      Linus Torvalds authored
      * git://git.kernel.org/pub/scm/linux/kernel/git/amit/virtio-console:
        virtio: console: Use better variable names for fill_queue operation
        virtio: console: Fix type of 'len' as unsigned int
      25cf84cf
  2. 07 Mar, 2010 29 commits