Subject: Re: prototype in GENERIC for APC UPS?
To: Steven M. Bellovin <smb@cs.columbia.edu>
From: Bernd Ernesti <veego@NetBSD.org>
List: tech-kern
Date: 04/23/2007 20:39:42
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Apr 23, 2007 at 01:52:55PM -0400, Steven M. Bellovin wrote:
> On Mon, 23 Apr 2007 18:42:59 +0200
> Manuel Bouyer <bouyer@antioche.eu.org> wrote:
> 
> > On Mon, Apr 23, 2007 at 05:24:56PM +0200, Joerg Sonnenberger wrote:
> > > On Mon, Apr 23, 2007 at 04:09:56PM +0100, Matthias Scheler wrote:
> > > > Well, you could always teach uhid(4) to ignore certain devices in
> > > > which ugen(4) should get them.
> > > 
> > > I think it would be better to fix apcusbd to work with uhid
> > > instead. I think that it doesn't work is mostly a linuxism.
> > 
> > I'm not sure it's that easy. From what I remember an APC ups matched
> > by usbhid will attach 50 or so instances of usbhid. 
> 
> To be precise, 48:

kern/31884

Attached is an updated patch for -current (don't forget to regen usbdevs_data.h
and usbdevs.h), which I use now for several months.

ugen0 at uhub0 port 2
ugen0: American Power Conversion Back-UPS RS 1500 FW:8.g8 .I USB FW:g8, rev 1.10/1.06, addr 3

Bernd


--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="31884.patch"

Index: uhidev.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/uhidev.c,v
retrieving revision 1.35
diff -b -u -r1.35 uhidev.c
--- uhidev.c	15 Mar 2007 15:11:54 -0000	1.35
+++ uhidev.c	23 Apr 2007 18:33:03 -0000
@@ -91,6 +91,8 @@
 
 	if (uaa->class != UICLASS_HID)
 		return (UMATCH_NONE);
+	if (usbd_get_quirks(uaa->device)->uq_flags & UQ_HID_IGNORE)
+		return (UMATCH_NONE);
 	return (UMATCH_IFACECLASS_GENERIC);
 }
 
Index: usb_quirks.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.56
diff -b -u -r1.56 usb_quirks.c
--- usb_quirks.c	10 Feb 2007 14:28:55 -0000	1.56
+++ usb_quirks.c	23 Apr 2007 18:33:03 -0000
@@ -61,6 +61,11 @@
 	u_int16_t bcdDevice;
 	struct usbd_quirks quirks;
 } usb_quirks[] = {
+ /* Devices which should be ignored by uhid */
+ { USB_VENDOR_APC, USB_PRODUCT_APC_UPS,		    ANY,   { UQ_HID_IGNORE }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,	    ANY,   { UQ_HID_IGNORE }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,	    ANY,   { UQ_HID_IGNORE }},
+
  { USB_VENDOR_KYE, USB_PRODUCT_KYE_NICHE,	    0x100, { UQ_NO_SET_PROTO}},
  { USB_VENDOR_INSIDEOUT, USB_PRODUCT_INSIDEOUT_EDGEPORT4,
    						    0x094, { UQ_SWAP_UNICODE}},
Index: usb_quirks.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usb_quirks.h,v
retrieving revision 1.21
diff -b -u -r1.21 usb_quirks.h
--- usb_quirks.h	19 Jan 2007 22:42:05 -0000	1.21
+++ usb_quirks.h	23 Apr 2007 18:33:03 -0000
@@ -52,6 +52,7 @@
 #define UQ_AU_INP_ASYNC	0x0800	/* input is async despite claim of adaptive */
 #define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */
 #define UQ_BROKEN_BIDIR	0x2000	/* printer has broken bidir mode */
+#define UQ_HID_IGNORE	0x4000	/* device should be ignored by hid class */
 };
 
 extern const struct usbd_quirks usbd_no_quirk;
Index: usbdevs
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usbdevs,v
retrieving revision 1.461
diff -b -u -r1.461 usbdevs
--- usbdevs	8 Mar 2007 23:14:05 -0000	1.461
+++ usbdevs	23 Apr 2007 18:33:03 -0000
@@ -93,6 +93,7 @@
 vendor DIAMOND2		0x045a	Diamond (Supra)
 vendor MICROSOFT	0x045e	Microsoft
 vendor PRIMAX		0x0461	Primax Electronics
+vendor MGE		0x0463	MGE UPS Systems
 vendor AMP		0x0464	AMP
 vendor CHERRY		0x046a	Cherry Mikroschalter
 vendor MEGATRENDS	0x046b	American Megatrends
@@ -603,7 +604,7 @@
 product ALTEC ASC495		0xff05	ASC495 Speakers
 
 /* American Power Conversion products */
-product APC UPSPRO500		0x0002	Back-UPS Pro 500
+product APC UPS			0x0002	Uninterruptible Power Supply
 
 /* Anchor products */
 product ANCHOR EZUSB		0x2131	EZUSB
@@ -1360,6 +1361,10 @@
 /* Metricom products */
 product METRICOM RICOCHET_GS	0x0001	Ricochet GS
 
+/* MGE UPS Systems */
+product MGE UPS1		0x0001	MGE UPS SYSTEMS PROTECTIONCENTER 1
+product MGE UPS2		0xffff	MGE UPS SYSTEMS PROTECTIONCENTER 2
+
 /* Micro Star International products */
 product MSI BLUETOOTH		0x1967	Bluetooth USB Adapter
 product MSI MS6861		0x6861	MS-6861

--2oS5YaxWCcQjTEyO--