1. 11 Jul, 2007 40 commits
    • Tejun Heo's avatar
      sysfs: make sysfs_alloc_ino() static · 42b37df6
      Tejun Heo authored
      sysfs_alloc_ino() isn't used out side of fs/sysfs/dir.c.  Make it
      static.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      42b37df6
    • Tejun Heo's avatar
      driver-core: make devt_attr and uevent_attr static · ad6a1e1c
      Tejun Heo authored
      devt_attr and uevent_attr are either allocated dynamically with or
      embedded in device and class_device as they needed their owner field
      set to the module implementing the driver.  Now that sysfs implements
      immediate disconnect and owner field removed from struct attribute,
      there is no reason to do this.  Remove these attributes from
      [class_]device and use static attribute structures instead.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      ad6a1e1c
    • Tejun Heo's avatar
      sysfs: kill unnecessary attribute->owner · 7b595756
      Tejun Heo authored
      sysfs is now completely out of driver/module lifetime game.  After
      deletion, a sysfs node doesn't access anything outside sysfs proper,
      so there's no reason to hold onto the attribute owners.  Note that
      often the wrong modules were accounted for as owners leading to
      accessing removed modules.
      
      This patch kills now unnecessary attribute->owner.  Note that with
      this change, userland holding a sysfs node does not prevent the
      backing module from being unloaded.
      
      For more info regarding lifetime rule cleanup, please read the
      following message.
      
        http://article.gmane.org/gmane.linux.kernel/510293
      
      (tweaked by Greg to not delete the field just yet, to make it easier to
      merge things properly.)
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      7b595756
    • Tejun Heo's avatar
      sysfs: reimplement sysfs_drop_dentry() · dbde0fcf
      Tejun Heo authored
      This patch reimplements sysfs_drop_dentry() such that remove_dir() can
      use it to drop dentry instead of using a separate mechanism.  With
      this change, making directories reclaimable is much easier.
      
      This patch used to contain fixes for two race conditions around
      sd->s_dentry but that part has been separated out and included into
      mainline early as commit 6aa054aa and
      dd14cbc9.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      dbde0fcf
    • Tejun Heo's avatar
      sysfs: separate out sysfs_attach_dentry() · 198a2a84
      Tejun Heo authored
      Consolidate sd <-> dentry association into sysfs_attach_dentry() and
      call it after dentry and inode are properly set up.  This is in
      preparation of sysfs_drop_dentry() updates.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      198a2a84
    • Tejun Heo's avatar
      sysfs: kill attribute file orphaning · 73107cb3
      Tejun Heo authored
      Now that sysfs_dirent can be disconnected from kobject on deletion,
      there is no need to orphan each attribute files.  All [bin_]attribute
      nodes are automatically orphaned when the parent node is deleted.
      Kill attribute file orphaning.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      73107cb3
    • Tejun Heo's avatar
      sysfs: implement sysfs_dirent active reference and immediate disconnect · 0ab66088
      Tejun Heo authored
      sysfs: implement sysfs_dirent active reference and immediate disconnect
      
      Opening a sysfs node references its associated kobject, so userland
      can arbitrarily prolong lifetime of a kobject which complicates
      lifetime rules in drivers.  This patch implements active reference and
      makes the association between kobject and sysfs immediately breakable.
      
      Now each sysfs_dirent has two reference counts - s_count and s_active.
      s_count is a regular reference count which guarantees that the
      containing sysfs_dirent is accessible.  As long as s_count reference
      is held, all sysfs internal fields in sysfs_dirent are accessible
      including s_parent and s_name.
      
      The newly added s_active is active reference count.  This is acquired
      by invoking sysfs_get_active() and it's the caller's responsibility to
      ensure sysfs_dirent itself is accessible (should be holding s_count
      one way or the other).  Dereferencing sysfs_dirent to access objects
      out of sysfs proper requires active reference.  This includes access
      to the associated kobjects, attributes and ops.
      
      The active references can be drained and denied by calling
      sysfs_deactivate().  All active sysfs_dirents must be deactivated
      after deletion but before the default reference is dropped.  This
      enables immediate disconnect of sysfs nodes.  Once a sysfs_dirent is
      deleted, it won't access any entity external to sysfs proper.
      
      Because attr/bin_attr ops access both the node itself and its parent
      for kobject, they need to hold active references to both.
      sysfs_get/put_active_two() helpers are provided to help grabbing both
      references.  Parent's is acquired first and released last.
      
      Unlike other operations, mmapped area lingers on after mmap() is
      finished and the module implement implementing it and kobj need to
      stay referenced till all the mapped pages are gone.  This is
      accomplished by holding one set of active references to the bin_attr
      and its parent if there have been any mmap during lifetime of an
      openfile.  The references are dropped when the openfile is released.
      
      This change makes sysfs lifetime rules independent from both kobject's
      and module's.  It not only fixes several race conditions caused by
      sysfs not holding onto the proper module when referencing kobject, but
      also helps fixing and simplifying lifetime management in driver model
      and drivers by taking sysfs out of the equation.
      
      Please read the following message for more info.
      
        http://article.gmane.org/gmane.linux.kernel/510293Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      0ab66088
    • Tejun Heo's avatar
      sysfs: implement bin_buffer · eb361653
      Tejun Heo authored
      Implement bin_buffer which contains a mutex and pointer to PAGE_SIZE
      buffer to properly synchronize accesses to per-openfile buffer and
      prepare for immediate-kobj-disconnect.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      eb361653
    • Tejun Heo's avatar
      sysfs: reimplement symlink using sysfs_dirent tree · 2b29ac25
      Tejun Heo authored
      sysfs symlink is implemented by referencing dentry and kobject from
      sysfs_dirent - symlink entry references kobject, dentry is used to
      walk the tree.  This complicates object lifetimes rules and is
      dangerous - for example, there is no way to tell to which module the
      target of a symlink belongs and referencing that kobject can make it
      linger after the module is gone.
      
      This patch reimplements symlink using only sysfs_dirent tree.  sd for
      a symlink points and holds reference to the target sysfs_dirent and
      all walking is done using sysfs_dirent tree.  Simpler and safer.
      
      Please read the following message for more info.
      
        http://article.gmane.org/gmane.linux.kernel/510293Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      2b29ac25
    • Tejun Heo's avatar
      sysfs: implement kobj_sysfs_assoc_lock · aecdceda
      Tejun Heo authored
      kobj->dentry can go away anytime unless the user controls when the
      associated sysfs node is deleted.  This patch implements
      kobj_sysfs_assoc_lock which protects kobj->dentry.  This will be used
      to maintain kobj based API when converting sysfs to use sysfs_dirent
      tree instead of dentry/kobject.
      
      Note that this lock belongs to kobject/driver-model not sysfs.  Once
      sysfs is converted to not use kobject in its interface, this can be
      removed from sysfs.
      
      This is in preparation of object reference simplification.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      aecdceda
    • Tejun Heo's avatar
      sysfs: make sysfs_dirent->s_element a union · 3e519038
      Tejun Heo authored
      Make sd->s_element a union of sysfs_elem_{dir|symlink|attr|bin_attr}
      and rename it to s_elem.  This is to achieve...
      
      * some level of type checking : changing symlink to point to
        sysfs_dirent instead of kobject is much safer and less painful now.
      * easier / standardized dereferencing
      * allow sysfs_elem_* to contain more than one entry
      
      Where possible, pointer is obtained by directly deferencing from sd
      instead of going through other entities.  This reduces dependencies to
      dentry, inode and kobject.  to_attr() and to_bin_attr() are unused now
      and removed.
      
      This is in preparation of object reference simplification.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      3e519038
    • Tejun Heo's avatar
      sysfs: add sysfs_dirent->s_name · 0c096b50
      Tejun Heo authored
      Add s_name to sysfs_dirent.  This is to further reduce dependency to
      the associated dentry.  Name is copied for directories and symlinks
      but not for attributes.
      
      Where possible, name dereferences are converted to use sd->s_name.
      sysfs_symlink->link_name and sysfs_get_name() are unused now and
      removed.
      
      This change allows symlink to be implemented using sysfs_dirent tree
      proper, which is the last remaining dentry-dependent sysfs walk.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      0c096b50
    • Tejun Heo's avatar
      sysfs: add sysfs_dirent->s_parent · 13b3086d
      Tejun Heo authored
      Add sysfs_dirent->s_parent.  With this patch, each sd points to and
      holds a reference to its parent.  This allows walking sysfs tree
      without referencing sd->s_dentry which can go away anytime if the user
      doesn't control when it's deleted.
      
      sd->s_parent is initialized and parent is referenced in
      sysfs_attach_dirent().  Reference to parent is released when the sd is
      released, so as long as reference to a sd is held, s_parent can be
      followed.
      
      dentry walk in sysfs_readdir() is convereted to s_parent walk.
      
      This will be used to reimplement symlink such that it uses only
      sysfs_dirent tree.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      13b3086d
    • Tejun Heo's avatar
      sysfs: consolidate sysfs_dirent creation functions · a26cd722
      Tejun Heo authored
      Currently there are four functions to create sysfs_dirent -
      __sysfs_new_dirent(), sysfs_new_dirent(), __sysfs_make_dirent() and
      sysfs_make_dirent().  Other than sysfs_make_dirent(), no function has
      two users if calls to implement other functions are excluded.
      
      This patch consolidates sysfs_dirent creation functions into the
      following two.
      
      * sysfs_new_dirent() : allocate and initialize
      * sysfs_attach_dirent() : attach to sysfs_dirent hierarchy and/or
      			  associate with dentry
      
      This simplifies interface and gives callers more flexibility.  This is
      in preparation of object reference simplification.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      a26cd722
    • Tejun Heo's avatar
      sysfs: flatten and fix sysfs_rename_dir() error handling · 996b7376
      Tejun Heo authored
      Error handling in sysfs_rename_dir() was broken.
      
      * When lookup_one_len() fails, 0 is returned.
      
      * If parent inode check fails, returns with inode mutex and rename
        rwsem held.
      
      This patch fixes the above bugs and flattens error handling such that
      it's more readable and easier to modify.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      996b7376
    • Tejun Heo's avatar
      sysfs: flatten cleanup paths in sysfs_add_link() and create_dir() · dfeb9fb0
      Tejun Heo authored
      Flatten cleanup paths in sysfs_add_link() and create_dir() to improve
      readability and ease further changes to these functions.  This is in
      preparation of object reference simplification.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      dfeb9fb0
    • Tejun Heo's avatar
      sysfs: fix error handling in binattr write() · 93e3cd82
      Tejun Heo authored
      Error handling in fs/sysfs/bin.c:write() was wrong because size_t
      count is used to receive return value from flush_write() which is
      negative on failure.
      
      This patch updates write() such that int variable is used instead.
      read() is updated the same way for consistency.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      93e3cd82
    • Tejun Heo's avatar
      sysfs: make sysfs_put() ignore NULL sd · 7a23ad44
      Tejun Heo authored
      Make sysfs_put() ignore NULL sd instead of oopsing.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      7a23ad44
    • Tejun Heo's avatar
      sysfs: allocate inode number using ida · 2b611bb7
      Tejun Heo authored
      sysfs used simple incrementing allocator which is not guaranteed to be
      unique.  This patch makes sysfs use ida to give each sd a unique and
      packed inode number.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      2b611bb7
    • Tejun Heo's avatar
      sysfs: move release_sysfs_dirent() to dir.c · fa7f912a
      Tejun Heo authored
      There is no reason this function should be inlined and soon to follow
      sysfs object reference simplification will make it heavier.  Move it
      to dir.c.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      fa7f912a
    • Tejun Heo's avatar
      ida: implement idr based id allocator · 72dba584
      Tejun Heo authored
      Implement idr based id allocator.  ida is used the same way idr is
      used but lacks id -> ptr translation and thus consumes much less
      memory.  struct ida_bitmap is attached as leaf nodes to idr tree which
      is managed by the idr code.  Each ida_bitmap is 128bytes long and
      contains slightly less than a thousand slots.
      
      ida is more aggressive with releasing extra resources acquired using
      ida_pre_get().  After every successful id allocation, ida frees one
      reserved idr_layer if possible.  Reserved ida_bitmap is not freed
      automatically but only one ida_bitmap is reserved and it's almost
      always used right away.  Under most circumstances, ida won't hold on
      to memory for too long which isn't actively used.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      72dba584
    • Tejun Heo's avatar
      idr: separate out idr_mark_full() · e33ac8bd
      Tejun Heo authored
      Separate out idr_mark_full() from sub_alloc() and make marking the
      allocated slot full the responsibility of idr_get_new_above_int().
      
      Allocation part of idr_get_new_above_int() is renamed to
      idr_get_empty_slot().  New idr_get_new_above_int() allocates a slot
      using the function, install the user pointer and marks it full using
      idr_mark_full().
      
      This change doesn't introduce any behavior change.  This will be
      used by ida.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      e33ac8bd
    • Tejun Heo's avatar
      idr: fix obscure bug in allocation path · 7aae6dd8
      Tejun Heo authored
      In sub_alloc(), when bitmap search fails, it goes up one level to
      continue search.  This is done by updating the id cursor and searching
      the upper level again.  If the cursor was at the end of the upper
      level, we need to go further than that.
      
      This wasn't implemented and when that happens the part of the cursor
      which indexes into the upper level wraps and sub_alloc() ends up
      searching the wrong bitmap.  It allocates id which doesn't match the
      actual slot.
      
      This patch fixes this by restarting from the top if the search needs
      to go higher than one level.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      7aae6dd8
    • Cornelia Huck's avatar
      Driver core: coding style cleanup · dc0afa83
      Cornelia Huck authored
      This converts code of the form
      
      	if ((error = some_func()))
      		goto fixup;
      to
      	error = some_func();
      	if (error)
      		goto fixup;
      Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      dc0afa83
    • Rafael J. Wysocki's avatar
      PM: do not use saved_state from struct dev_pm_info on ARM · 93160c63
      Rafael J. Wysocki authored
      The saved_state member of 'struct dev_pm_info' that's going to be removed
      is used in arch/arm/common/locomo.c, arch/arm/common/sa1111.c and
      arch/arm/mach-sa1100/neponset.c.  Change the code in there to use local
      variables for saving the state of devices during suspend.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Cc: Greg KH <greg@kroah.com>
      Cc: David Brownell <david-b@pacbell.net>
      Acked-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      93160c63
    • Rafael J. Wysocki's avatar
      PM: Do not check parent state in suspend and resume core code · 43a49f8b
      Rafael J. Wysocki authored
      The checks if the device's parent is in the right state done in
      drivers/base/power/suspend.c and drivers/base/power/resume.c serve no particular
      purpose, since if the parent is in a wrong power state, the device's suspend or
      resume callbacks are supposed to return an error anyway.  Moreover, they are
      also useless from the sanity checking point of view, because they rely on the
      code being checked to set dev->parent->power.power_state.event appropriately,
      which need not happen if that code is buggy.  For these reasons they can be
      removed.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      43a49f8b
    • Rafael J. Wysocki's avatar
      PM: Remove power_state.event checks from suspend core code · 1c3f7d1c
      Rafael J. Wysocki authored
      The suspend routines should be called for every device during a system sleep
      transition, regardless of the device's state, so that drivers can regard these
      method calls as notifications that the system is about to go to sleep, rather
      than as directives to put their devices into the 'off' state.
      
      This is documented in Documentation/power/devices.txt and is already done in
      the core resume code, so it seems reasonable to make the core suspend code
      behave accordingly.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      1c3f7d1c
    • Rafael J. Wysocki's avatar
      PM: Remove prev_state from struct dev_pm_info · 515c5357
      Rafael J. Wysocki authored
      The prev_state member of struct dev_pm_info (defined in include/linux/pm.h) is
      only used during a resume to check if the device's state before the suspend was
      'off', in which case the device is not resumed.  However, in such cases the
      decision whether or not to resume the device should be made on the driver level
      and the resume callbacks from the device's bus and class should be executed
      anyway (the may be needed for some things other than just powering on the
      device).
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      515c5357
    • Adrian Bunk's avatar
      Driver core: fix devres_release_all() return value · 2a013455
      Adrian Bunk authored
      Every file should include the headers containing the prototypes for
      it's global functions.
      
      Since the GNU C compiler is now able to detect that the function 
      prototype of devres_release_all() in the header and the actual function 
      disagree regarding the return value, this patch also fixes this bug.
      Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
      Acked-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      2a013455
    • Stefan Richter's avatar
    • Stefan Richter's avatar
    • Michael S. Tsirkin's avatar
      Driver core: include linux/mutex.h from attribute_container.c · f8916c11
      Michael S. Tsirkin authored
      attribute_container.c uses DEFINE_MUTEX, so while
      linux/mutex.h seems to be pulled in indirectly
      by one of the headers it includes, the right thing
      is to include linux/mutex.h directly.
      Signed-off-by: default avatarMichael S. Tsirkin <mst@dev.mellanox.co.il>
      f8916c11
    • Rafael J. Wysocki's avatar
      PM: Simplify suspend_device · 9e584a4f
      Rafael J. Wysocki authored
      Reduce code duplication in drivers/base/suspend.c by introducing a separate
      function for printing diagnostic messages.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarPavel Machek <pavel@ucw.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      9e584a4f
    • Rafael J. Wysocki's avatar
      PM: Remove saved_state from struct dev_pm_info · cc490069
      Rafael J. Wysocki authored
      The saved_state member of struct dev_pm_info, defined in include/linux/pm.h, is
      not used anywhere, so it can be removed.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      cc490069
    • Rafael J. Wysocki's avatar
      PM: Remove pm_parent from struct dev_pm_info · 9cddad77
      Rafael J. Wysocki authored
      The pm_parent member of struct dev_pm_info (defined in include/linux/pm.h) is
      only used to check if the device's parent is in the right state while the
      device is being suspended or resumed.  However, this can be done just as well
      with the help of the parent pointer in struct device, so pm_parent can be
      removed along with some code that handles it.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      9cddad77
    • Matthias Kaehlcke's avatar
      Power Management: use mutexes instead of semaphores · 11048dcf
      Matthias Kaehlcke authored
      The Power Management code uses semaphores as mutexes.  Use the mutex API
      instead of the (binary) semaphores.
      Signed-off-by: default avatarMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      11048dcf
    • Matthias Kaehlcke's avatar
      sysdev: use mutex instead of semaphore · 9f3f776b
      Matthias Kaehlcke authored
      The sysdev code use a semaphore as mutex.  Use the mutex API instead of the
      (binary) semaphore.
      Signed-off-by: default avatarMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      9f3f776b
    • Kay Sievers's avatar
      Driver core: add missing kset uevent · 80f03e34
      Kay Sievers authored
      We get uevents for a bus/class going away, but not one registering.
      Add the missing uevent in kset_register(), which will send an
      event for a new bus/class. Suppress all unwanted uevents for bus
      subdirectories like /bus/*/devices/, /bus/*/drivers/.
      
      Now we get for module usbcore:
        add      /module/usbcore (module)
        add      /bus/usb (bus)
        add      /class/usb_host (class)
        add      /bus/usb/drivers/hub (drivers)
        add      /bus/usb/drivers/usb (drivers)
        remove   /bus/usb/drivers/usb (drivers)
        remove   /bus/usb/drivers/hub (drivers)
        remove   /class/usb_host (class)
        remove   /bus/usb (bus)
        remove   /module/usbcore (module)
      
      instead of:
        add      /module/usbcore (module)
        add      /bus/usb/drivers/hub (drivers)
        add      /bus/usb/drivers/usb (drivers)
        remove   /bus/usb/drivers/usb (drivers)
        remove   /bus/usb/drivers/hub (drivers)
        remove   /class/usb_host (class)
        remove   /bus/usb/drivers (bus)
        remove   /bus/usb/devices (bus)
        remove   /bus/usb (bus)
        remove   /module/usbcore (module)
      Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      80f03e34
    • Lennart Poettering's avatar
      DMI-based module autoloading · 4f5c791a
      Lennart Poettering authored
      The patch below adds DMI/SMBIOS based module autoloading to the Linux
      kernel. The idea is to load laptop drivers automatically (and other
      drivers which cannot be autoloaded otherwise), based on the DMI system
      identification information of the BIOS.
      
      Right now most distros manually try to load all available laptop
      drivers on bootup in the hope that at least one of them loads
      successfully. This patch does away with all that, and uses udev to
      automatically load matching drivers on the right machines.
      
      Basically the patch just exports the DMI information that has been
      parsed by the kernel anyway to userspace via a sysfs device
      /sys/class/dmi/id and makes sure that proper modalias attributes are
      available. Besides adding the "modalias" attribute it also adds
      attributes for a few other DMI fields which might be useful for
      writing udev rules.
      
      This patch is not an attempt to export the entire DMI/SMBIOS data to
      userspace. We already have "dmidecode" which parses the complete DMI
      info from userspace. The purpose of this patch is machine model
      identification and good udev integration.
      
      To take advantage of DMI based module autoloading, a driver should
      export one or more MODULE_ALIAS fields similar to these:
      
      MODULE_ALIAS("dmi:*:svnMICRO-STARINT'LCO.,LTD:pnMS-1013:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*");
      MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*");
      MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*");
      MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*");
      
      These lines are specific to my msi-laptop.c driver. They are basically
      just a concatenation of a few carefully selected DMI fields with all
      potentially bad characters stripped.
      
      Besides laptop drivers, modules like "hdaps", the i2c modules
      and the hwmon modules are good candidates for "dmi:" MODULE_ALIAS
      lines.
      
      Besides merely exporting the DMI data via sysfs the patch adds
      support for a few more DMI fields. Especially the CHASSIS fields are
      very useful to identify different laptop modules. The patch also adds
      working MODULE_ALIAS lines to my msi-laptop.c driver.
      
      I'd like to thank Kay Sievers for helping me to clean up this patch
      for posting it on lkml.
      
      Patch is against Linus' current GIT HEAD. Should probably apply to
      older kernels as well without modification.
      Signed-off-by: default avatarLennart Poettering <mzxreary@0pointer.de>
      Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      
      4f5c791a
    • Jan Kara's avatar
      debugfs: add rename for debugfs files · cfc94cdf
      Jan Kara authored
      Implement debugfs_rename() to allow renaming files/directories in debugfs.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      cfc94cdf