Re: [PATCH] driver core: Separate platform device name from platform device number

From: Russell King
Date: Fri Mar 25 2005 - 15:29:44 EST


On Fri, Mar 25, 2005 at 09:58:26PM +0200, Paul Mundt wrote:
> On Fri, Mar 25, 2005 at 02:38:22PM -0500, Kyle Moffett wrote:
> > So how would you tell the difference between the following?
> > device = "foobar0"
> > id = -1
> > path = "/sys/devices/platform/foobar0"
> > versus
> > device = "foobar"
> > id = 0
> > path = "/sys/devices/platform/foobar0"
> >
> Easy, we use the delimiter on anything ending with a number at the end of
> the device name.. so for device = "foobar0", this would end up as
> /sys/devices/platform/foobar0.0, whereas in the latter case this would
> end up as /sys/devices/platform/foobar0.

Eh? How do you end up with "/sys/devices/platform/foobar0.0" for the
former case? It has an ID of "-1", and not zero. Your idea doesn't
make any sense.

> The first case is a corner case, and really shouldn't happen that much in
> practice outside of broken drivers.

It does happen today. Firstly, the 8250 driver registers a device of
"serial8250" with id = -1 for the backwards-compatible devices.
Platforms can then register a platform device called "serial8250"
with zero or positive id numbers.

> > It's not as nice to add the extra period, but otherwise you end up with
> > a lot of _extra_ special cases in both the kernel _and_ applications,
> > which helps nobody.
> >
> No you don't, it's pretty easy to figure out that if the end of the
> device name is a number that there will be a delimiter between that and
> the id. This should be the exception, not the rule.

Note that id = -1 means _no id_. So, Kyle is quite correct to ask about
that case.

device = "serial8250"
id = -1
=> /sys/devices/platform/serial8250

The "-1" means "do not add the ID".

but, under the old naming scenario, the following comes out to the same
sysfs path:

device = "serial825"
id = 0
=> /sys/devices/platform/serial8250

and

device = "serial8250"
id = 0
=> /sys/devices/platform/serial82500

is just too confusing. Same problem with i82365 platform devices, etc.

> We don't go around changing /dev semantics everytime someone decides to
> call their device something silly, I don't see why platform devices
> should be treated differently, better to just fix the broken drivers..

It's not about something being called something silly. It's about
the original concept of how to generate the path being down right
stupid.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
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/