[PATCH/RFC 1/4]device core changes

From: Li Shaohua
Date: Sun Nov 07 2004 - 23:19:39 EST


Hi,
This is the device core change required. Add .platform_bind method for
bus_type, so platform can do addition things when add a new device. A
case is ACPI, we want to utilize some ACPI methods for physical devices.
1. Why doesn't use 'platform_notify'?
Current device core has a 'platform_notify' mechanism, but it's not
sufficient for this. Only sepcific bus type know how to parse dev.bus_id
and know how to encode specific device's address into ACPI _ADR syntax.
2. Why adds new 'handle' in 'struct device'?
'Platform_data' is the best candidate, but a search shows some drivers
have used it. We can remove 'handle' after the drivers changes their
behavior.


Thanks,
Shaohua
---

2.6-root/drivers/base/bus.c | 2 ++
2.6-root/include/linux/device.h | 2 ++
2 files changed, 4 insertions(+)

diff -puN drivers/base/bus.c~devcore-platformbind drivers/base/bus.c
--- 2.6/drivers/base/bus.c~devcore-platformbind 2004-11-08
10:57:57.996568552 +0800
+++ 2.6-root/drivers/base/bus.c 2004-11-08 11:02:42.045386568 +0800
@@ -463,6 +463,8 @@ int bus_add_device(struct device * dev)
list_add_tail(&dev->bus_list, &dev->bus->devices.list);
device_attach(dev);
up_write(&dev->bus->subsys.rwsem);
+ if (bus->platform_bind)
+ bus->platform_bind(dev);
device_add_attrs(bus, dev);
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
}
diff -puN include/linux/device.h~devcore-platformbind
include/linux/device.h
--- 2.6/include/linux/device.h~devcore-platformbind 2004-11-08
10:57:57.998568248 +0800
+++ 2.6-root/include/linux/device.h 2004-11-08 10:57:58.001567792 +0800
@@ -63,6 +63,7 @@ struct bus_type {
int num_envp, char *buffer, int buffer_size);
int (*suspend)(struct device * dev, u32 state);
int (*resume)(struct device * dev);
+ int (*platform_bind)(struct device *dev);
};

extern int bus_register(struct bus_type * bus);
@@ -290,6 +291,7 @@ struct device {
override */

void (*release)(struct device * dev);
+ void *handle;
};

static inline struct device *
_


Add .platform_bind method for bus_type, so platform can do addition things
when add a new device. A case is ACPI, we want to utilize some ACPI methods
for physical devices.
1. Why doesn't use 'platform_notify'?
Current device core has a 'platform_notify' mechanism, but it's not
sufficient for this. Only sepcific bus type know how to parse dev.bus_id and
know how to encode specific device's address into ACPI _ADR syntax.
2. Why adds new 'handle' in 'struct device'?
'Platform_data' is the best candidate, but a search shows some drivers have
used it. We can remove 'handle' after the drivers changes their behavior.

---

2.6-root/drivers/base/bus.c | 2 ++
2.6-root/include/linux/device.h | 2 ++
2 files changed, 4 insertions(+)

diff -puN drivers/base/bus.c~devcore-platformbind drivers/base/bus.c
--- 2.6/drivers/base/bus.c~devcore-platformbind 2004-11-08 10:57:57.996568552 +0800
+++ 2.6-root/drivers/base/bus.c 2004-11-08 11:02:42.045386568 +0800
@@ -463,6 +463,8 @@ int bus_add_device(struct device * dev)
list_add_tail(&dev->bus_list, &dev->bus->devices.list);
device_attach(dev);
up_write(&dev->bus->subsys.rwsem);
+ if (bus->platform_bind)
+ bus->platform_bind(dev);
device_add_attrs(bus, dev);
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
}
diff -puN include/linux/device.h~devcore-platformbind include/linux/device.h
--- 2.6/include/linux/device.h~devcore-platformbind 2004-11-08 10:57:57.998568248 +0800
+++ 2.6-root/include/linux/device.h 2004-11-08 10:57:58.001567792 +0800
@@ -63,6 +63,7 @@ struct bus_type {
int num_envp, char *buffer, int buffer_size);
int (*suspend)(struct device * dev, u32 state);
int (*resume)(struct device * dev);
+ int (*platform_bind)(struct device *dev);
};

extern int bus_register(struct bus_type * bus);
@@ -290,6 +291,7 @@ struct device {
override */

void (*release)(struct device * dev);
+ void *handle;
};

static inline struct device *
_