28 May, 2014

1 commit

  • Having to allocate memory as part of dev_set_drvdata() is a problem
    because that memory may never get freed if the device itself is not
    created. So move driver_data back to struct device.

    This is a partial revert of commit b4028437.

    Signed-off-by: Jean Delvare
    Signed-off-by: Greg Kroah-Hartman

    Jean Delvare
     

29 Dec, 2013

1 commit

  • ACPI container devices require special hotplug handling, at least
    on some systems, since generally user space needs to carry out
    system-specific cleanup before it makes sense to offline devices in
    the container. However, the current ACPI hotplug code for containers
    first attempts to offline devices in the container and only then it
    notifies user space of the container offline.

    Moreover, after commit 202317a573b2 (ACPI / scan: Add acpi_device
    objects for all device nodes in the namespace), ACPI device objects
    representing containers are present as long as the ACPI namespace
    nodes corresponding to them are present, which may be forever, even
    if the container devices are physically detached from the system (the
    return values of the corresponding _STA methods change in those
    cases, but generally the namespace nodes themselves are still there).
    Thus it is useful to introduce entities representing containers that
    will go away during container hot-unplug.

    The goal of this change is to address both the above issues.

    The idea is to create a "companion" container system device for each
    of the ACPI container device objects during the initial namespace
    scan or on a hotplug event making the container present. That system
    device will be unregistered on container removal. A new bus type
    for container devices is added for this purpose, because device
    offline and online operations need to be defined for them. The
    online operation is a trivial function that is always successful
    and the offline uses a callback pointed to by the container device's
    offline member.

    For ACPI containers that callback simply walks the list of ACPI
    device objects right below the container object (its children) and
    checks if all of their physical companion devices are offline. If
    that's not the case, it returns -EBUSY and the container system
    devivce cannot be put offline. Consequently, to put the container
    system device offline, it is necessary to put all of the physical
    devices depending on its ACPI companion object offline beforehand.

    Container system devices created for ACPI container objects are
    initially online. They are created by the container ACPI scan
    handler whose hotplug.demand_offline flag is set. That causes
    acpi_scan_hot_remove() to check if the companion container system
    device is offline before attempting to remove an ACPI container or
    any devices below it. If the check fails, a KOBJ_CHANGE uevent is
    emitted for the container system device in question and user space
    is expected to offline all devices below the container and the
    container itself in response to it. Then, user space can finalize
    the removal of the container with the help of its ACPI device
    object's eject attribute in sysfs.

    Tested-by: Yasuaki Ishimatsu
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

13 Aug, 2013

2 commits

  • attribute groups are much more flexible than just a list of attributes,
    due to their support for visibility of the attributes, and binary
    attributes. Add drv_groups to struct bus_type which should be used
    instead of drv_attrs.

    drv_attrs will be removed from the structure soon.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • attribute groups are much more flexible than just a list of attributes,
    due to their support for visibility of the attributes, and binary
    attributes. Add dev_groups to struct bus_type which should be used
    instead of dev_attrs.

    dev_attrs will be removed from the structure soon.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

13 Mar, 2013

1 commit

  • Kay tells me the most appropriate place to expose workqueues to
    userland would be /sys/devices/virtual/workqueues/WQ_NAME which is
    symlinked to /sys/bus/workqueue/devices/WQ_NAME and that we're lacking
    a way to do that outside of driver core as virtual_device_parent()
    isn't exported and there's no inteface to conveniently create a
    virtual subsystem.

    This patch implements subsys_virtual_register() by factoring out
    subsys_register() from subsys_system_register() and using it with
    virtual_device_parent() as the origin directory. It's identical to
    subsys_system_register() other than the origin directory but we aren't
    gonna restrict the device names which should be used under it.

    This will be used to expose workqueue attributes to userland.

    Signed-off-by: Tejun Heo
    Acked-by: Greg Kroah-Hartman
    Cc: Kay Sievers

    Tejun Heo
     

09 Mar, 2012

2 commits

  • Nothing outside of the driver core needs to get to the deferred probe
    pointer, so move it inside the private area of 'struct device' so no one
    tries to mess around with it.

    Cc: Grant Likely
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Allow drivers to report at probe time that they cannot get all the resources
    required by the device, and should be retried at a later time.

    This should completely solve the problem of getting devices
    initialized in the right order. Right now this is mostly handled by
    mucking about with initcall ordering which is a complete hack, and
    doesn't even remotely handle the case where device drivers are in
    modules. This approach completely sidesteps the issues by allowing
    driver registration to occur in any order, and any driver can request
    to be retried after a few more other drivers get probed.

    v4: - Integrate Manjunath's addition of a separate workqueue
    - Change -EAGAIN to -EPROBE_DEFER for drivers to trigger deferral
    - Update comment blocks to reflect how the code really works
    v3: - Hold off workqueue scheduling until late_initcall so that the bulk
    of driver probes are complete before we start retrying deferred devices.
    - Tested with simple use cases. Still needs more testing though.
    Using it to get rid of the gpio early_initcall madness, or to replace
    the ASoC internal probe deferral code would be ideal.
    v2: - added locking so it should no longer be utterly broken in that regard
    - remove device from deferred list at device_del time.
    - Still completely untested with any real use case, but has been
    boot tested.

    Signed-off-by: Grant Likely
    Cc: Mark Brown
    Cc: Arnd Bergmann
    Cc: Dilan Lee
    Cc: Manjunath GKondaiah
    Cc: Alan Stern
    Cc: Tony Lindgren
    Cc: Alan Cox
    Reviewed-by: Mark Brown
    Acked-by: David Daney
    Reviewed-by: Arnd Bergmann
    Signed-off-by: Greg Kroah-Hartman

    Grant Likely
     

12 Jan, 2012

1 commit

  • cpu_dev_init() is only called from driver_init(), which does not check
    its return value. Therefore make cpu_dev_init() return void.

    We must register the CPU subsystem, so panic if this fails.

    If sched_create_sysfs_power_savings_entries() fails, the damage is
    contained, so ignore this (as before).

    Signed-off-by: Ben Hutchings
    Signed-off-by: Linus Torvalds

    Ben Hutchings
     

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
     

01 Nov, 2011

1 commit

  • This file is currently relying on sneaking it in
    through the implicit include paths from device.h. Once that
    is cleaned up, this will happen:

    In file included from drivers/base/init.c:12:
    drivers/base/base.h:34: error: field ‘bus_notifier’ has incomplete type
    make[3]: *** [drivers/base/init.o] Error 1

    Fix it up in advance, so the cleanup can continue.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

12 May, 2011

1 commit

  • Since suspend, resume and shutdown operations in struct sysdev_class
    and struct sysdev_driver are not used any more, remove them. Also
    drop sysdev_suspend(), sysdev_resume() and sysdev_shutdown() used
    for executing those operations and modify all of their users
    accordingly. This reduces kernel code size quite a bit and reduces
    its complexity.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

18 Nov, 2010

1 commit


16 Sep, 2009

3 commits

  • Devtmpfs lets the kernel create a tmpfs instance called devtmpfs
    very early at kernel initialization, before any driver-core device
    is registered. Every device with a major/minor will provide a
    device node in devtmpfs.

    Devtmpfs can be changed and altered by userspace at any time,
    and in any way needed - just like today's udev-mounted tmpfs.
    Unmodified udev versions will run just fine on top of it, and will
    recognize an already existing kernel-created device node and use it.
    The default node permissions are root:root 0600. Proper permissions
    and user/group ownership, meaningful symlinks, all other policy still
    needs to be applied by userspace.

    If a node is created by devtmps, devtmpfs will remove the device node
    when the device goes away. If the device node was created by
    userspace, or the devtmpfs created node was replaced by userspace, it
    will no longer be removed by devtmpfs.

    If it is requested to auto-mount it, it makes init=/bin/sh work
    without any further userspace support. /dev will be fully populated
    and dynamic, and always reflect the current device state of the kernel.
    With the commonly used dynamic device numbers, it solves the problem
    where static devices nodes may point to the wrong devices.

    It is intended to make the initial bootup logic simpler and more robust,
    by de-coupling the creation of the inital environment, to reliably run
    userspace processes, from a complex userspace bootstrap logic to provide
    a working /dev.

    Signed-off-by: Kay Sievers
    Signed-off-by: Jan Blunck
    Tested-By: Harald Hoyer
    Tested-By: Scott James Remnant
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     
  • No one should directly access the driver_data field, so remove the field
    and make it private. We dynamically create the private field now if it
    is needed, to handle drivers that call get/set before they are
    registered with the driver core.

    Also update the copyright notices on these files while we are there.

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

    Greg Kroah-Hartman
     
  • This patch (as1271) affects when new devices get linked into their
    bus's list of devices. Currently this happens after probing, and it
    doesn't happen at all if probing fails. Clearly this is wrong,
    because at that point quite a few symbolic links have already been
    created in sysfs. We are committed to adding the device, so it should
    be linked into the bus's list regardless.

    In addition, this needs to happen before the uevent announcing the new
    device gets issued. Otherwise user programs might try to access the
    device before it has been added to the bus.

    To fix both these problems, the patch moves the call to
    klist_add_tail() forward from bus_attach_device() to bus_add_device().
    Since bus_attach_device() now does nothing but probe for drivers, it
    has been renamed to bus_probe_device(). And lastly, the kerneldoc is
    updated.

    Signed-off-by: Alan Stern
    CC: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

17 Apr, 2009

1 commit

  • This patch fixes a bug introduced in commit
    49b420a13ff95b449947181190b08367348e3e1b.

    If a instance of bus_type doesn't have .match method,
    all .probe of drivers in the bus should be called, or else
    the .probe have not a chance to be called.

    Signed-off-by: Ming Lei
    Reported-by: Guennadi Liakhovetski
    Signed-off-by: Greg Kroah-Hartman

    Ming Lei
     

25 Mar, 2009

5 commits


23 Feb, 2009

1 commit


10 Jan, 2009

4 commits


07 Jan, 2009

4 commits


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 Jul, 2008

7 commits


01 May, 2008

1 commit


25 Jan, 2008

1 commit