[BK PATCH] driver model updates

From: Patrick Mochel (mochel@osdl.org)
Date: Mon Sep 23 2002 - 20:45:26 EST


Hey there.

Here is the latest round of driver model infrastructure updates. To
summarize, these changes do:

- Add system bus type, and struct sys_device for system-level devices.
- convert i8259.c and time.c to use this interface. This gives us in
driverfs:

[mochel@cherise mochel]$ tree -d /sys/bus/system/
/sys/bus/system/
|-- devices
| |-- pic0 -> ../../../root/sys/pic0
| `-- rtc0 -> ../../../root/sys/rtc0
`-- drivers
    |-- cpu
    `-- pic

- add struct cpu, a default CPU driver, and a CPU device class.
- Register CPU devices on boot, which gives us in driverfs:

[mochel@cherise mochel]$ tree -d /sys/class/cpu/
/sys/class/cpu/
|-- devices
| |-- 0 -> ../../../root/sys/cpu0
| `-- 1 -> ../../../root/sys/cpu1
`-- drivers

- add struct platform_device to represent platform (legacy) devices.
- convert floppy.c to use this interface.
- This gives us in driverfs:

[mochel@cherise mochel]$ tree -d /sys/bus/platform/
/sys/bus/platform/
|-- devices
| `-- floppy0 -> ../../../root/legacy/floppy0
`-- drivers

- add support for multi-board systems (e.g. Numa-Q) and mechanism for
  setting the what board a system device resides on.

I've attached the entire tree(1) output of my driverfs partition for my
dual P4 workstation, to give an idea of what the entire picture looks
like. It's coming together nicely, except..

ACPI is still ugly, and doesn't deserve a top-level directory. The next
item on my list is to create a common place for firmware drivers to place
their stuff, and integrate some of the related patches I've received.

Please apply.

Thanks,

        -pat

Please pull from

        bk://ldm.bkbits.net/linux-2.5

This will update the following files:

 arch/i386/kernel/cpu/common.c | 35 +++++++++++
 arch/i386/kernel/i8259.c | 20 ++++--
 arch/i386/kernel/time.c | 15 ++--
 drivers/base/Makefile | 7 +-
 drivers/base/core.c | 54 ++++++++---------
 drivers/base/cpu.c | 28 ++++++++
 drivers/base/platform.c | 41 ++++++++++++-
 drivers/base/sys.c | 131 ++++++++++++++++++++++++++++++++++++------
 drivers/block/floppy.c | 19 +++---
 drivers/usb/core/usb.c | 10 ++-
 include/linux/cpu.h | 28 ++++++++
 include/linux/device.h | 36 ++++++++++-
 12 files changed, 350 insertions(+), 74 deletions(-)

through these ChangeSets:

<mochel@osdl.org> (02/09/23 1.607)
   driver model: add better platform device support.
   
   Platform devices are devices commonly found on the motherboard of systems. This
   includes legacy devices (serial ports, floppy controllers, parallel ports, etc)
   and host bridges to peripheral buses.
   
   We already had a platform bus type, which gives a way to group platform devices
   and drivers, and allow each to be bound to each other dynamically. Though before,
   it didn't do anything. It still doesn't do much, but we now have:
   
   - struct platform_device, which generically describes platform deviecs. This only
     includes a name and id in addition to a struct device, but more may be added later.
   
   - implelemnt platform_device_register() and platform_device_unregister() to handle
     adding and removing these devices.
   
   - Create legacy_bus - a default parent device for legacy devices.
   
   - Change the floppy driver to define a platform_device (instead of a sys_device).
     In driverfs, this gives us now:
   
   a# tree -d /sys/bus/platform/
   /sys/bus/platform/
   |-- devices
   | `-- floppy0 -> ../../../root/legacy/floppy0
   `-- drivers
   
   and
   
   # tree -d /sys/root/legacy/
   /sys/root/legacy/
   `-- floppy0

<mochel@osdl.org> (02/09/23 1.603.1.5)
   driver model: add support for multi-board systems.
   
   - device struct sys_root for describing the individual boards of a multi-board
     system.
   
   - allow for registration of alternate device roots.
   
   - check if struct sys_device::root is set on registration, and add it as a child of
     an alternative root, if it's set.

<mochel@osdl.org> (02/09/23 1.603.1.4)
   driver model: add support for CPUs.
   
   - Create struct cpu to generically describe cpus (it simply contains
     a struct sys_device in it).
   
   - Define an array of size NR_CPUS in arch/i386/kernel/cpu/common.c
     and register each on bootup. This gives us something like:
   
   # tree -d /sys/root/sys/
   /sys/root/sys/
   |-- cpu0
   |-- pic0
   `-- rtc0
   
   and:
   
   # tree -d /sys/bus/system/devices/
   /sys/bus/system/devices/
   |-- cpu0 -> ../../../root/sys/cpu0
   
   - Define arch-specific CPU driver that's also registered on boot.
     That gives us:
   
   # tree -d /sys/bus/system/drivers/
   /sys/bus/system/drivers/
   |-- cpu
   
   - Create a CPU device class that's registered very early. That
     gives us all the CPUs in the system in one place:
   
   # tree -d /sys/class/cpu/
   /sys/class/cpu/
   |-- devices
   | `-- 0 -> ../../../root/sys/cpu0
   `-- drivers
   
   Other archs are encouraged to do the same.

<mochel@osdl.org> (02/09/23 1.603.1.3)
   USB: fixup handling of generic USB driver.
   
   The generic driver is used by the virtual USB bridge device. This makes sure that
   the driver is registered before we try to use it (and it gets the bus type right).
   
   We also check for equality when matching devices to drivers, because we don't
   want to match any device to it.

<mochel@osdl.org> (02/09/23 1.603.1.2)
   Driver model: handle devices registered with ->driver set.
   
   In some cases, especially when dealing with system and platform devices, a
   device's driver is known when the device is registered. We still want to add
   the device to the driver's list and add it to the class.
   
   This makes splits driver binding into probe() and attach(). If the device already
   has a driver, we simply call attach(). Otherwise, we try to match it on the bus
   and still call found_match().
   
   This requires that all drivers that are referenced are registered beforehand.

<mochel@osdl.org> (02/09/23 1.603.1.1)
   Driver model: improve support for system devices.
     
   - Create struct sys_device to describe system-level devices (CPUs, PICs, etc.). This
     structure includes a 'name' and 'id' field for drivers to fill in with a simple
     canonical name (like 'pic' or 'floppy') and the id of the device relative to its
     discovery in the system (it's enumerated value).
   
     The core then constructs the bus_id for the device from these, giving them meaningful
     names when exporting them to userspace:
   
   # tree -d /sys/root/sys/
   /sys/root/sys/
   |-- pic0
   `-- rtc0
   
   - Replace
           int register_sys_device(struct device * dev);
           with
           int sys_device_register(struct sys_device * sysdev);
   
   - Fixup the users of the API.
   
   - Add a system_bus_type for devices to associate themselves with. This provides a
     bus/system/ directory in driverfs that looks like:
   
   # tree -d /sys/bus/system/
   /sys/bus/system/
   |-- devices
   | |-- pic0 -> ../../../root/sys/pic0
   | `-- rtc0 -> ../../../root/sys/rtc0
   `-- drivers
       `-- pic



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Sep 23 2002 - 22:00:41 EST