Re: [PATCH 2.6.10-rc1 4/4] driver-model: attach/detach sysfs node implemented

From: Dmitry Torokhov
Date: Thu Nov 04 2004 - 12:23:37 EST


On Thursday 04 November 2004 02:46 am, Tejun Heo wrote:
>  ma_04_manual_attach.patch
>
>  This patch implements device interface nodes attach and detach.
> Reading attach node shows the name of applicable drivers.  Writing a
> driver name attaches the device to the driver.  Writing anything to
> the write-only detach node detaches the driver from the currently
> associated driver.
>
...
> +/**
> + *   detach - manually detaches the device from its associated driver.
> + *
> + *   This is a write-only node.  When any value is written, it detaches
> + *   the device from its associated driver.
> + */
> +static ssize_t detach_store(struct device * dev, const char * buf, size_t
> n)
> +{
> +     down_write(&dev->bus->subsys.rwsem);
> +     device_release_driver(dev);
> +     up_write(&dev->bus->subsys.rwsem);
> +     return n;
> +}

This will not work for pretty much any bus but PCI because only PCI
allows to detach a driver leaving children devices on the bus. The
rest of buses remove children devices when disconnecting parent.

Also, there usually much more going on with regard to locking and
other bus-specific actions besides taking bus's rwsem when binding
devices. Serio bus will definitely get upset if you try to disconnect
even a leaf device in the manner presented above and I think USB
will get upset as well.

I have tried the naïve approach as well but in the end we need bus
-specific helper to do manual connect/disconnect. Please take a look
at these:

http://marc.theaimsgroup.com/?l=linux-kernel&m=109908274124446&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109912528510337&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109912553831130&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109912553827412&w=2

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