driverfs updates, part 2

Patrick Mochel (mochel@osdl.org)
Thu, 18 Jul 2002 18:28:17 -0700 (PDT)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

--346834433-1542255995-1027042097=:2542
Content-Type: TEXT/PLAIN; charset=US-ASCII

Ok, here is the next round of driverfs updates.

Short summary:

- move device and driver interface to driverfs into drivers/base/fs/*.c
- Implement bus_{create,remove}_file and driver_{create,remove}_file to
give people an interface to create files those object types in their
respective directories.

driver_{create,remove}_file are the simplest, and exist in
drivers/base/fs/driver.c. If people are feeling frisky, and want to
play, use that as an example on how to extend driverfs for other
subsystems and object types.

I'm also attaching an example 'subsystem' driver that exports
registration and unregistration functions that do creation and teardown
of driverfs directories.

- Remove references to struct device in driverfs, making it completely
independent of the device model core.

- Update documentation

-pat

Please pull from

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

Note that this tree includes all the changes that I posted earlier today.
bk://ldm.bkbits.net/linux-2.5-driverfs still exists, with only the earlier
changes.

This will update the following files:

drivers/base/fs.c | 216 ----------------
Documentation/filesystems/driverfs.txt | 443 ++++++++++++++++++++++++---------
drivers/base/Makefile | 6
drivers/base/base.h | 7
drivers/base/bus.c | 74 -----
drivers/base/driver.c | 23 -
drivers/base/fs/Makefile | 18 -
drivers/base/fs/bus.c | 199 ++++++++++----
drivers/base/fs/device.c | 145 ++++++++--
drivers/base/fs/driver.c | 48 +++
drivers/base/fs/fs.h | 7
drivers/base/fs/lib.c | 352 ++++++++++++++++++--------
fs/driverfs/inode.c | 19 -
fs/driverfs/lib.c | 28 +-
include/linux/device.h | 5
include/linux/driverfs_fs.h | 2
16 files changed, 938 insertions(+), 654 deletions(-)

through these ChangeSets:

<mochel@osdl.org> (02/07/18 1.755)
Update driverfs documentation

<mochel@osdl.org> (02/07/18 1.754)
driverfs:
Remove all struct device references.
Don't touch device's reference count on open() and close()

<mochel@osdl.org> (02/07/18 1.753)
add functions for creating/removing driverfs files for device drivers

<mochel@osdl.org> (02/07/18 1.752)
bus driver driverfs interface:
include fs.h
fix compile error

<mochel@osdl.org> (02/07/18 1.751)
Move driverfs directory creation for drivers to drivers/base/fs/driver.c

<mochel@osdl.org> (02/07/18 1.750)
Add helpers make_one_dir and remove_one_dir for ease of creating and removing driverfs directories

<mochel@osdl.org> (02/07/18 1.749)
fixup callers of driverfs_create_file to just pass template to it (and not do own duplication of the template)

<mochel@osdl.org> (02/07/18 1.748)
driverfs:
- make driverfs_create_file do duplication of driver_file_entry passed in (instead of making each caller do it)

<mochel@osdl.org> (02/07/18 1.747)
Implement bus_{create,remove}_file, to allow creation of files for bus drivers in the bus's driverfs directory

<mochel@osdl.org> (02/07/18 1.746)
Make root bus directory dynamically allocated, like the rest of the directories in the world...

<mochel@osdl.org> (02/07/18 1.745)
Make sure mode is set when creating bus directory

<mochel@osdl.org> (02/07/18 1.744)
Move functions for bus drivers interfacing with driverfs from drivers/base/bus.c to drivers/base/fs/bus.c

<mochel@osdl.org> (02/07/18 1.743)
Move interface for creating driverfs files for devices from drivers/base/fs/lib.c to drivers/base/fs/device.c

<mochel@osdl.org> (02/07/18 1.742)
Move drivers/base/fs.c to drivers/base/fs/lib.c

<mochel@osdl.org> (02/07/18 1.741)
driverfs:
- remove stray references to struct device

--346834433-1542255995-1027042097=:2542
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pubsys.c"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.44.0207181828170.2542@cherise.pdx.osdl.net>
Content-Description:
Content-Disposition: attachment; filename="pubsys.c"

LyoNCiAqIHB1YnN5cyAtIGV4cGxvdGluZyBkcml2ZXJmcyBmb3IgZnVuIGFu
ZCBwcm9maXQNCiAqDQogKiBDb3B5cmlnaHQgKGMpIDIwMDIgUGF0cmljayBN
b2NoZWwNCiAqICAgICAgICAgICAgICAgICAgICBPcGVuIFNvdXJjZSBEZXZl
bG9wbWVudCBMYWINCiAqDQogKiAgVGhpcyBwcm9ncmFt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U9EX0lOQ19VU0VfQ09VTlQ7DQoJ
ZXJyb3IgPSBiZWVyX21ha2VfZGlyKGJlZXIpOw0KCWlmICghZXJyb3IpDQoJ
CWxpc3RfYWRkX3RhaWwoJmJlZXItPm5vZGUsJmJlZXJfbGlzdCk7DQoJZWxz
ZQ0KCQlNT0RfREVDX1VTRV9DT1VOVDsNCglyZXR1cm4gZXJyb3I7DQp9DQoN
CnZvaWQgYmVlcl91bnJlZ2lzdGVyKHN0cnVjdCBiZWVyICogYmVlcikNCnsN
CgliZWVyX3JlbW92ZV9kaXIoYmVlcik7DQoJbGlzdF9kZWwoJmJlZXItPm5v
ZGUpOw0KCU1PRF9ERUNfVVNFX0NPVU5UOw0KfQ0KDQpzdGF0aWMgaW50IF9f
aW5pdCBwdWJfaW5pdCh2b2lkKQ0Kew0KCXJldHVybiBtYWtlX29uZV9kaXIo
InB1YiIsJnB1Yl9kaXIsTlVMTCxOVUxMKTsNCn0NCg0Kc3RhdGljIHZvaWQg
X19leGl0IHB1Yl9leGl0KHZvaWQpDQp7DQoJZHJpdmVyZnNfcmVtb3ZlX2Rp
cihwdWJfZGlyKTsNCn0NCg0KbW9kdWxlX2luaXQocHViX2luaXQpOw0KbW9k
dWxlX2V4aXQocHViX2V4aXQpOw0KDQo=
--346834433-1542255995-1027042097=:2542--
-
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/