Re: [BKPATCH] bus notifiers for the generic device model

From: Jeff Garzik (jgarzik@pobox.com)
Date: Wed Dec 04 2002 - 13:42:12 EST


Patrick Mochel wrote:
> ===== drivers/base/bus.c 1.26 vs edited =====
> --- 1.26/drivers/base/bus.c Sun Dec 1 23:22:04 2002
> +++ edited/drivers/base/bus.c Wed Dec 4 12:02:41 2002
> @@ -228,6 +228,10 @@
> {
> pr_debug("bound device '%s' to driver '%s'\n",
> dev->bus_id,dev->driver->name);
> +
> + if (dev->driver->start)
> + dev->driver->start(dev);
> +
> list_add_tail(&dev->driver_list,&dev->driver->devices);
> sysfs_create_link(&dev->driver->kobj,&dev->kobj,dev->kobj.name);
> }
>
> I don't recall why the change was never done. Perhaps because of other
> distractions, or it seemed like it would be too much of a PITA to convert
> drivers to a two-step init sequence (though I think it could be done in a
> compatible manner).

Possibly because of the "do it in open(2)" rule?

Ignoring the device model entirely, if a driver does a lot of
talking-to-the-hardware in its probe phase, I consider it buggy, in 2.4
or 2.5.

The network driver and chardev ones typically follow this rule quite
well... probe is simple, just registering interfaces with the kernel.
dev->open is where the driver should (and usually does) power-up the
hardware, [re-]initialize it, etc.

So each time you come upon a driver that wants dev->driver->start(),
look closely at the code and wonder why it can't perform the
dev->driver->start() code in its interface's dev->open member.

        Jeff

-
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 : Sat Dec 07 2002 - 22:00:19 EST