02 Oct, 2020

1 commit

  • Change additional instances that could use sysfs_emit and sysfs_emit_at
    that the coccinelle script could not convert.

    o macros creating show functions with ## concatenation
    o unbound sprintf uses with buf+len for start of output to sysfs_emit_at
    o returns with ?: tests and sprintf to sysfs_emit
    o sysfs output with struct class * not struct device * arguments

    Miscellanea:

    o remove unnecessary initializations around these changes
    o consistently use int len for return length of show functions
    o use octal permissions and not S_
    o rename a few show function names so DEVICE_ATTR_ can be used
    o use DEVICE_ATTR_ADMIN_RO where appropriate
    o consistently use const char *output for strings
    o checkpatch/style neatening

    Signed-off-by: Joe Perches
    Link: https://lore.kernel.org/r/8bc24444fe2049a9b2de6127389b57edfdfe324d.1600285923.git.joe@perches.com
    Signed-off-by: Greg Kroah-Hartman

    Joe Perches
     

16 Dec, 2019

1 commit

  • device.h has everything and the kitchen sink when it comes to struct
    device things, so split out the struct class things things to a separate
    .h file to make things easier to maintain and manage over time.

    Cc: "Rafael J. Wysocki"
    Cc: Suzuki K Poulose
    Cc: Saravana Kannan
    Cc: Heikki Krogerus
    Link: https://lore.kernel.org/r/20191209193303.1694546-6-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

18 Jan, 2019

1 commit

  • As the description of struct device_private says, it stores data which
    is private to driver core. And it already has similar fields like:
    knode_parent, knode_driver, knode_driver and knode_bus. This look it is
    more proper to put knode_class together with those fields to make it
    private to driver core.

    This patch move device->knode_class to device_private to make it comply
    with code convention.

    Signed-off-by: Wei Yang
    Reviewed-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Wei Yang
     

08 Dec, 2017

2 commits

  • Now that the SPDX tag is in all driver core files, that identifies the
    license in a specific and legally-defined manner. So the extra GPL text
    wording can be removed as it is no longer needed at all.

    This is done on a quest to remove the 700+ different ways that files in
    the kernel describe the GPL license text. And there's unneeded stuff
    like the address (sometimes incorrect) for the FSF which is never
    needed.

    No copyright headers or other non-license-description text was removed.

    Cc: Johannes Berg
    Cc: "Luis R. Rodriguez"
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • It's good to have SPDX identifiers in all files to make it easier to
    audit the kernel tree for correct licenses.

    Update the driver core files files with the correct SPDX license
    identifier based on the license text in the file itself. The SPDX
    identifier is a legally binding shorthand, which can be used instead of
    the full boiler plate text.

    This work is based on a script and data from Thomas Gleixner, Philippe
    Ombredanne, and Kate Stewart.

    Cc: Johannes Berg
    Cc: "Luis R. Rodriguez"
    Cc: William Breathitt Gray
    Cc: Thomas Gleixner
    Cc: Kate Stewart
    Cc: Philippe Ombredanne
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

09 Jun, 2017

1 commit


30 Nov, 2016

1 commit

  • struct class needs to have a set of default groups that are added, as
    adding individual attributes does not work well in the long run. So add
    support for that.

    Future patches will convert the existing usages of class_attrs to use
    class_groups and then class_attrs will go away.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

29 Sep, 2015

1 commit


25 Mar, 2015

1 commit


27 Sep, 2013

1 commit

  • sysfs ns (namespace) implementation became more convoluted than
    necessary while trying to hide ns information from visible interface.
    The relatively recent attr ns support is a good example.

    * attr ns tag is determined by sysfs_ops->namespace() callback while
    dir tag is determined by kobj_type->namespace(). The placement is
    arbitrary.

    * Instead of performing operations with explicit ns tag, the namespace
    callback is routed through sysfs_attr_ns(), sysfs_ops->namespace(),
    class_attr_namespace(), class_attr->namespace(). It's not simpler
    in any sense. The only thing this convolution does is traversing
    the whole stack backwards.

    The namespace callbacks are unncessary because the operations involved
    are inherently synchronous. The information can be provided in in
    straight-forward top-down direction and reversing that direction is
    unnecessary and against basic design principles.

    This backward interface is unnecessarily convoluted and hinders
    properly separating out sysfs from driver model / kobject for proper
    layering. This patch updates attr ns support such that

    * sysfs_ops->namespace() and class_attr->namespace() are dropped.

    * sysfs_{create|remove}_file_ns(), which take explicit @ns param, are
    added and sysfs_{create|remove}_file() are now simple wrappers
    around the ns aware functions.

    * ns handling is dropped from sysfs_chmod_file(). Nobody uses it at
    this point. sysfs_chmod_file_ns() can be added later if necessary.

    * Explicit @ns is propagated through class_{create|remove}_file_ns()
    and netdev_class_{create|remove}_file_ns().

    * driver/net/bonding which is currently the only user of attr
    namespace is updated to use netdev_class_{create|remove}_file_ns()
    with @bh->net as the ns tag instead of using the namespace callback.

    This patch should be an equivalent conversion without any functional
    difference. It makes the code easier to follow, reduces lines of code
    a bit and helps proper separation and layering.

    Signed-off-by: Tejun Heo
    Cc: Eric W. Biederman
    Cc: Kay Sievers
    Acked-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Tejun Heo
     

23 Aug, 2013

1 commit

  • Gotta love a macro that doesn't reduce the typing you have to do.

    Also, only the driver core, and one network driver uses this. The
    driver core functions will be going away soon, and I'll convert the
    network driver soon to not need this as well, so delete it for now
    before anyone else gets some bright ideas and wants to use it.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

07 Feb, 2013

1 commit

  • All in-kernel users of class_find_device() don't really need mutable
    data for match callback.

    In two places (kernel/power/suspend_test.c, drivers/scsi/osd/osd_uld.c)
    this patch changes match callbacks to use const search data.

    The const is propagated to rtc_class_open() and power_supply_get_by_name()
    parameters.

    Note that there's a dev reference leak in suspend_test.c that's not
    touched in this patch.

    Signed-off-by: Michał Mirosław
    Acked-by: Grant Likely
    Signed-off-by: Greg Kroah-Hartman

    Michał Mirosław
     

15 Dec, 2011

1 commit

  • All sysdev classes and sysdev devices will converted to regular devices
    and buses to properly hook userspace into the event processing.

    There is no interesting difference between a 'sysdev' and 'device' which
    would justify to roll an entire own subsystem with different userspace
    export semantics. Userspace relies on events and generic sysfs subsystem
    infrastructure from sysdev devices, which are currently not properly
    available.

    Every converted sysdev class will create a regular device with the class
    name in /sys/devices/system and all registered devices will becom a children
    of theses devices.

    For compatibility reasons, the sysdev class-wide attributes are created
    at this parent device. (Do not copy that logic for anything new, subsystem-
    wide properties belong to the subsystem, not to some fake parent device
    created in /sys/devices.)

    Every sysdev driver is implemented as a simple subsystem interface now,
    and no longer called a driver.

    After all sysdev classes are ported to regular driver core entities, the
    sysdev implementation will be entirely removed from the kernel.

    Signed-off-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

20 Oct, 2011

1 commit


18 Nov, 2010

1 commit


11 Nov, 2010

1 commit


23 Oct, 2010

2 commits

  • I have some systems which need legacy sysfs due to old tools that are
    making assumptions that a directory can never be a symlink to another
    directory, and it's a big hazzle to compile separate kernels for them.

    This patch turns CONFIG_SYSFS_DEPRECATED into a run time option
    that can be switched on/off the kernel command line. This way
    the same binary can be used in both cases with just a option
    on the command line.

    The old CONFIG_SYSFS_DEPRECATED_V2 option is still there to set
    the default. I kept the weird name to not break existing
    config files.

    Also the compat code can be still completely disabled by undefining
    CONFIG_SYSFS_DEPRECATED_SWITCH -- just the optimizer takes
    care of this now instead of lots of ifdefs. This makes the code
    look nicer.

    v2: This is an updated version on top of Kay's patch to only
    handle the block devices. I tested it on my old systems
    and that seems to work.

    Cc: axboe@kernel.dk
    Signed-off-by: Andi Kleen
    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Andi Kleen
     
  • This patch removes the old CONFIG_SYSFS_DEPRECATED_V2 config option,
    but it keeps the logic around to handle block devices in the old manner
    as some people like to run new kernel versions on old (pre 2007/2008)
    distros.

    Signed-off-by: Kay Sievers
    Cc: Jens Axboe
    Cc: Stephen Hemminger
    Cc: "Eric W. Biederman"
    Cc: Alan Stern
    Cc: "James E.J. Bottomley"
    Cc: Andrew Morton
    Cc: Alexey Kuznetsov
    Cc: Randy Dunlap
    Cc: Tejun Heo
    Cc: "David S. Miller"
    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: David Howells
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

22 May, 2010

1 commit


19 Mar, 2010

1 commit


08 Mar, 2010

3 commits

  • Constify struct sysfs_ops.

    This is part of the ops structure constification
    effort started by Arjan van de Ven et al.

    Benefits of this constification:

    * prevents modification of data that is shared
    (referenced) by many other structure instances
    at runtime

    * detects/prevents accidental (but not intentional)
    modification attempts on archs that enforce
    read-only kernel data at runtime

    * potentially better optimized code as the compiler
    can assume that the const data cannot be changed

    * the compiler/linker move const data into .rodata
    and therefore exclude them from false sharing

    Signed-off-by: Emese Revfy
    Acked-by: David Teigland
    Acked-by: Matt Domsch
    Acked-by: Maciej Sosnowski
    Acked-by: Hans J. Koch
    Acked-by: Pekka Enberg
    Acked-by: Jens Axboe
    Acked-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Emese Revfy
     
  • Several drivers just export a static string as class attributes.

    Use the new extensible attribute support to define a simple
    CLASS_ATTR_STRING() macro for this.

    This will allow to remove code from drivers in followon patches.

    Signed-off-by: Andi Kleen
    Signed-off-by: Greg Kroah-Hartman

    Andi Kleen
     
  • 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.

    This makes the class attributes the same as sysdev_class attributes
    and plain attributes.

    This will allow further cleanups in drivers.

    Full tree sweep converting all users.

    Signed-off-by: Andi Kleen
    Signed-off-by: Greg Kroah-Hartman

    Andi Kleen
     

17 Feb, 2010

1 commit


16 Sep, 2009

1 commit

  • When turning class devices into bus devices, we may need to
    temporarily add links in sysfs so that user-space applications
    are not confused. This is done by adding the following API:

    * Functions to register and unregister compatibility classes.
    These appear in sysfs at the same location as regular classes, but
    instead of class devices, they contain links to bus devices.
    * Functions to create and delete such links. Additionally, the caller
    can optionally pass a target device to which a "device" link should
    point (typically that would be the device's parent), to fully emulate
    the original class device.

    The i2c subsystem will be the first user of this API, as i2c adapters
    are being converted from class devices to bus devices.

    Signed-off-by: Jean Delvare
    Signed-off-by: Kay Sievers

    Jean Delvare
     

09 Oct, 2008

1 commit

  • Iterating over entries using callback usually isn't too fun especially
    when the entry being iterated over can't be manipulated freely. This
    patch converts class->p->class_devices to klist and implements class
    device iterator so that the users can freely build their own control
    structure. The users are also free to call back into class code
    without worrying about locking.

    class_for_each_device() and class_find_device() are converted to use
    the new iterators, so their users don't have to worry about locking
    anymore either.

    Note: This depends on klist-dont-iterate-over-deleted-entries patch
    because class_intf->add/remove_dev() depends on proper synchronization
    with device removal.

    Signed-off-by: Tejun Heo
    Cc: Greg Kroah-Hartman
    Cc: Jens Axboe
    Signed-off-by: Jens Axboe

    Tejun Heo
     

22 Aug, 2008

1 commit

  • Anti-oops medicine for the class iterators ... the oops was
    observed when a class was implicitly referenced before it
    was initialized.

    [Modified by Greg to spit a warning back so someone knows to fix their code]

    Signed-off-by: David Brownell
    Signed-off-by: Greg Kroah-Hartman

    David Brownell
     

29 Jul, 2008

1 commit


22 Jul, 2008

10 commits

  • Now that the lockdep infrastructure in the class core is in place, we
    should be able to properly change the internal class semaphore to be a
    mutex.

    David wrote the original patch, and Greg fixed it up to apply properly
    due to all of the recent changes in this area.

    From: Dave Young
    Cc: Matthew Wilcox
    Cc: Kay Sievers
    Cc: Andrew Morton
    Cc: James Bottomley
    Signed-off-by: Greg Kroah-Hartman

    Dave Young
     
  • This adds the infrastructure to properly handle lockdep issues when the
    internal class semaphore is changed to a mutex.

    Matthew wrote the original patch, and Greg fixed it up to work properly
    with the class_create() function.

    From: Matthew Wilcox
    Cc: Kay Sievers
    Cc: Dave Young
    Cc: Andrew Morton
    Cc: James Bottomley
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Matthew Wilcox
     
  • This renames the struct class "sem" field to be "class_sem" to make
    things easier when struct bus_type and struct class merge in the future.
    It also makes grepping for fields easier as well.

    Based on an idea from Kay.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This renames the struct class "subsys" field to be "class_subsys" to
    make things easier when struct bus_type and struct class merge in the
    future. It also makes grepping for fields easier as well.

    Based on an idea from Kay.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This renames the struct class "interfaces" field to be
    "class_interfaces" to make things easier when struct bus_type and struct
    class merge in the future. It also makes grepping for fields easier as
    well.

    Based on an idea from Kay.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This renames the struct class "devices" field to be "class_devices" to
    make things easier when struct bus_type and struct class merge in the
    future. It also makes grepping for fields easier as well.

    Based on an idea from Kay.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This moves the portions of struct class that are dynamic (kobject and
    lock and lists) out of the main structure and into a dynamic, private,
    structure.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This mirrors the functionality that driver_find_device has as well.

    We add a start variable, and all callers of the function are fixed up at
    the same time.

    The block layer will be using this new functionality in a follow-on
    patch.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This mirrors the functionality that driver_for_each_device has as well.

    We add a start variable, and all callers of the function are fixed up at
    the same time.

    The block layer will be using this new functionality in a follow-on
    patch.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Why?:
    There are occasions where userspace would like to access sysfs
    attributes for a device but it may not know how sysfs has named the
    device or the path. For example what is the sysfs path for
    /dev/disk/by-id/ata-ST3160827AS_5MT004CK? With this change a call to
    stat(2) returns the major:minor then userspace can see that
    /sys/dev/block/8:32 links to /sys/block/sdc.

    What are the alternatives?:
    1/ Add an ioctl to return the path: Doable, but sysfs is meant to reduce
    the need to proliferate ioctl interfaces into the kernel, so this
    seems counter productive.

    2/ Use udev to create these symlinks: Also doable, but it adds a
    udev dependency to utilities that might be running in a limited
    environment like an initramfs.

    3/ Do a full-tree search of sysfs.

    [kay.sievers@vrfy.org: fix duplicate registrations]
    [kay.sievers@vrfy.org: cleanup suggestions]

    Cc: Neil Brown
    Cc: Tejun Heo
    Acked-by: Kay Sievers
    Reviewed-by: SL Baur
    Acked-by: Kay Sievers
    Acked-by: Mark Lord
    Acked-by: H. Peter Anvin
    Signed-off-by: Dan Williams
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     

15 May, 2008

1 commit


01 May, 2008

1 commit