Re: [RFC] New Driver Model for 2.5

Tim Jansen
2001-10-19T18:48:14Z

On Friday 19 October 2001 09:57, Henning P. Schmiedehausen wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
> >>> struct device {
> And a version field! Please add a version field right to the
> beginning. This would make supporting legacy drivers in later versions
> _much_ easier.

IMHO it would be a good idea not to create and fill those structs using a
function, instead of letting the driver code create the struct or using
versions.

In the current version of the patch struct device is allocated using

struct device *device_alloc_dev(void);

and then later registered using

int device_register_dev(struct device *dev);

In other words the fields are set by the bus driver. The problem is that when
somebody adds a new, required field then existing code will silently break.
So I would propose to think about using something like

struct device *device_create_dev(const char *name,
const char *bus_id,
struct device_driver *driver,
void *driver_data,
void *platform_data,
u32 current_state);

The advantage is that when you add a new field the old code won't compile
before it has been fixed. It also allows you to do large changes in the
underlying code without breaking source compatibility.
The disadvantage is that you cannot add a field that should be specifier by
the caller without either adding a new function or destroying source
compatibility.

bye...