linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 2.2 bcdDevice munging patch
@ 2001-12-04  1:41 Plato
  2001-12-04  1:44 ` Plato
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Plato @ 2001-12-04  1:41 UTC (permalink / raw)
  To: linux-hotplug

Hello,

I couldn't find a contact e-mail address on your site, so I'm posting here
instead.  Please CC me on replies, as I am not subscribed to this list.

I do not believe that your `munging' of bcdDevice numbers is working
correctly.  For instance, if PRODUCT is of the form

.../.../10.0

it does not give me .../.../0100

The attached patch seeks to rectify this.  Please let me know if it is any
use and whether or not it will be included in your releases.

Plato

(Tom Huckstep)

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.2 bcdDevice munging patch
  2001-12-04  1:41 2.2 bcdDevice munging patch Plato
@ 2001-12-04  1:44 ` Plato
  2001-12-04  3:32 ` Greg KH
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Plato @ 2001-12-04  1:44 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

On Tue, Dec 04, 2001 at 01:41:05AM +0000, Plato wrote:
OK.  I should be more careful before I post to a public mailing list!  Darn.

> I do not believe that your `munging' of bcdDevice numbers is working
> correctly.  For instance, if PRODUCT is of the form

I should say that this specifically refers to the environment variable
PRODUCT as seen by /etc/hotplug/usb.agent.

> The attached patch seeks to rectify this.  Please let me know if it is any
> use and whether or not it will be included in your releases.

Hmmm ... here it is.  This time :-)

Plato



[-- Attachment #2: hotplug-bcd_fix.patch --]
[-- Type: text/plain, Size: 1908 bytes --]

diff -u -r hotplug-2001_09_19/ChangeLog hotplug-bcd_fix/ChangeLog
--- hotplug-2001_09_19/ChangeLog	Thu Sep 20 01:20:02 2001
+++ hotplug-bcd_fix/ChangeLog	Tue Dec  4 01:20:13 2001
@@ -1,3 +1,6 @@
+Tue Dec 4 2001  Tom Huckstep <tom@redant.freeserve.co.uk>
+	- Fixed munging of usb_bcdDevice for 2.2 kernels
+
 Sun Sep 16 2001 kroah/dbrownell
 	- Added ieee1394.agent from Kristian Hogsberg
 	  <hogsberg@users.sourceforge.net>
diff -u -r hotplug-2001_09_19/etc/hotplug/usb.agent hotplug-bcd_fix/etc/hotplug/usb.agent
--- hotplug-2001_09_19/etc/hotplug/usb.agent	Tue Dec  4 01:17:19 2001
+++ hotplug-bcd_fix/etc/hotplug/usb.agent	Tue Dec  4 01:17:59 2001
@@ -120,8 +120,28 @@
     # work around 2.2 brokenness
     # munges the usb_bcdDevice such that it is a integer rather
     # than a float: e.g. 1.0 become 0100
-    PRODUCT=`echo $PRODUCT | sed -e "s+\.\([0-9]\)$+.\10+" -e "s/\.$/00/" \
-                                  -e "s+/\([0-9]\)\.\([0-9][0-9]\)+/0\1\2+"`
+
+    # In PRODUCT=x/y/z if z has only one digit after a decimal point then a
+    # trailing zero is added.  If z has only one digit before a decimal
+    # point then a leading zero is added.  The decimal point is then
+    # removed.
+
+    # e.g. a.b  -> 0ab0
+    #     ab.c  -> cab0
+    #      a.bc -> 0abc
+    #     ab.cd -> abcd
+
+    # Why does the kernel give us this in such a weird format?  I don't
+    # know, but looking at usb/usb.c in your 2.2 kernel source may help.
+    # N.B. to_bcd()
+
+    # Add the trailing zero
+    PRODUCT=`echo $PRODUCT | sed -e "s+\.\([0-9]\)$+.\10+"`
+    # Add the leading zero
+    PRODUCT=`echo $PRODUCT | sed -e "s/\/\([0-9].[0-9][0-9]\)$/\/0\1/"`
+    # Remove the decimal point
+    PRODUCT=`echo $PRODUCT | sed -e "s/\/\([0-9][0-9]\)\.\([0-9][0-9]\)/\/\1\2/"`
+
     set `echo $PRODUCT | $AWK -F/ '{print "0x" $1, "0x" $2, "0x" $3 }'` ''
     usb_idVendor=$1
     usb_idProduct=$2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.2 bcdDevice munging patch
  2001-12-04  1:41 2.2 bcdDevice munging patch Plato
  2001-12-04  1:44 ` Plato
@ 2001-12-04  3:32 ` Greg KH
  2001-12-04  3:49 ` David Brownell
  2001-12-05  0:42 ` Plato
  3 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2001-12-04  3:32 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Dec 04, 2001 at 01:44:59AM +0000, Plato wrote:
> > The attached patch seeks to rectify this.  Please let me know if it is any
> > use and whether or not it will be included in your releases.
> 
> Hmmm ... here it is.  This time :-)

I'd recommend fixing the 2.2 kernel code to work the same way as 2.4.x.
The hotplug code was enabled right at the end of the 2.2.20 development
cycle, and this problem must have slipped through.

thanks,

greg k-h

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.2 bcdDevice munging patch
  2001-12-04  1:41 2.2 bcdDevice munging patch Plato
  2001-12-04  1:44 ` Plato
  2001-12-04  3:32 ` Greg KH
@ 2001-12-04  3:49 ` David Brownell
  2001-12-05  0:42 ` Plato
  3 siblings, 0 replies; 5+ messages in thread
From: David Brownell @ 2001-12-04  3:49 UTC (permalink / raw)
  To: linux-hotplug

Sounds fair to me.  Though it'll need to be a bit smarter, since I
think the current code says "if the kernel is 2.2 then ..." and it'd
have to change to handle two types of 2.2 kernels (original, new).

That is, the newer 2.2 kernels would need updated hotplug scripts.

- Dave


----- Original Message ----- 
From: "Greg KH" <greg@kroah.com>
To: "Plato" <tom@redant.freeserve.co.uk>
Cc: <linux-hotplug-devel@lists.sourceforge.net>
Sent: Monday, December 03, 2001 7:32 PM
Subject: Re: 2.2 bcdDevice munging patch


> On Tue, Dec 04, 2001 at 01:44:59AM +0000, Plato wrote:
> > > The attached patch seeks to rectify this.  Please let me know if it is any
> > > use and whether or not it will be included in your releases.
> > 
> > Hmmm ... here it is.  This time :-)
> 
> I'd recommend fixing the 2.2 kernel code to work the same way as 2.4.x.
> The hotplug code was enabled right at the end of the 2.2.20 development
> cycle, and this problem must have slipped through.
> 
> thanks,
> 
> greg k-h
> 
> _______________________________________________
> Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
> Linux-hotplug-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel


_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 2.2 bcdDevice munging patch
  2001-12-04  1:41 2.2 bcdDevice munging patch Plato
                   ` (2 preceding siblings ...)
  2001-12-04  3:49 ` David Brownell
@ 2001-12-05  0:42 ` Plato
  3 siblings, 0 replies; 5+ messages in thread
From: Plato @ 2001-12-05  0:42 UTC (permalink / raw)
  To: linux-hotplug

Sorry for the broken thread, but I've only just subscribed to the list.

Dave:
> Sounds fair to me.  Though it'll need to be a bit smarter, since I
> think the current code says "if the kernel is 2.2 then ..." and it'd
> have to change to handle two types of 2.2 kernels (original, new).

That's not necessary.  usb.agent only cares which kernel version is running
when deciding which of $MAP_CURRENT or $MAP_DISTMAP to use.

The code which munges the bcdDevice number is kernel independent. It
will not change a four hex-digit number specified by a 2.4 kernel, but will
change a number with a decimal point from a 2.2 kernel.

> That is, the newer 2.2 kernels would need updated hotplug scripts.

If 2.2.21 produced a four hex-digit number it would _not_ need an update to
my patch.

Greg:
> I'd recommend fixing the 2.2 kernel code to work the same way as 2.4.x.
> The hotplug code was enabled right at the end of the 2.2.20 development
> cycle, and this problem must have slipped through.

The problem has been solved now in userspace.  If my patch is implemented
then `broken' 2.2 kernels will work, along with 2.4, and later 2.2 kernels
possibly incorporating a fix.

The munging already exists.  Unfortunately it does not work for all possible
values of bcdDevice.  If you are going to continue to support 2.2 kernels
you should fix this.  I believe my patch fixes this.

The problem, for those of you that are not aware, is due to a difference in
the PRODUCT environment variable for use by the usb.agent between 2.2 and 2.4 kernels.
PRODUCT is of the form xxxx/xxxx/xxxx, i.e four hex numbers separated by
slashes.

The 2.4 kernel specifies the third of these numbers as `abcd', where a, b, c,
d are four hex digits.

The 2.2 kernel specifies the third of these numbers as `ab.cd'
It also omits a and d if they are zero.

There is a `munge' in the current usb.agent which seeks to rectify this. 
Unfortunately it does not seem to work for some cases, e.g.
PRODUCT=.../.../10.0

I'd be happy to hear any comments that you may have.  Keep up the good work!

Plato

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-12-05  0:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-04  1:41 2.2 bcdDevice munging patch Plato
2001-12-04  1:44 ` Plato
2001-12-04  3:32 ` Greg KH
2001-12-04  3:49 ` David Brownell
2001-12-05  0:42 ` Plato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).