I have taken all of the suggestions the list has given me, and I have here, for you a single patch for the kernel to allow usb-stoarge to recognize the Maxtor OneTouch's 'onetouch' button. The diff for the 2.6.10 vanilla kernel follows:
Signed-Off-By: Nicholas M. Sillik <[EMAIL PROTECTED]>
diff -uprN linux-2.6.10/drivers/usb/storage/Kconfig linux-2.6.10nsillik/drivers/usb/storage/Kconfig --- linux-2.6.10/drivers/usb/storage/Kconfig 2004-12-24 16:35:29.000000000 -0500 +++ linux-2.6.10nsillik/drivers/usb/storage/Kconfig 2005-02-03 19:15:25.000000000 -0500 @@ -118,3 +118,9 @@ config USB_STORAGE_JUMPSHOT Say Y here to include additional code to support the Lexar Jumpshot USB CompactFlash reader.
+config USB_STORAGE_ONETOUCH + bool "Maxtor OneTouch Hard Drive (EXPERIMENTAL)" + depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL + help + Say Y here to include additional code to support the Maxtor OneTouch + USB hard drive's onetouch button. diff -uprN linux-2.6.10/drivers/usb/storage/Makefile linux-2.6.10nsillik/drivers/usb/storage/Makefile --- linux-2.6.10/drivers/usb/storage/Makefile 2004-12-24 16:35:01.000000000 -0500 +++ linux-2.6.10nsillik/drivers/usb/storage/Makefile 2005-02-03 19:14:16.000000000 -0500 @@ -18,6 +18,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DPC usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o +usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += monetouch.o
usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ initializers.o $(usb-storage-obj-y) diff -uprN linux-2.6.10/drivers/usb/storage/monetouch.c linux-2.6.10nsillik/drivers/usb/storage/monetouch.c --- linux-2.6.10/drivers/usb/storage/monetouch.c 1969-12-31 19:00:00.000000000 -0500 +++ linux-2.6.10nsillik/drivers/usb/storage/monetouch.c 2005-02-03 19:12:49.000000000 -0500 @@ -0,0 +1,237 @@ +/* + * Support for the Maxtor OneTouch USB hard drive's button + * + * Current development and maintenance by: + * Copyright (c) 2005 Nick Sillik <[EMAIL PROTECTED]> + * + * Initial work by: + * Copyright (c) 2003 Erik Thyrén <[EMAIL PROTECTED]> + * + * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) + * + */ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/input.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/module.h> +#include <linux/list.h> +#include <linux/smp_lock.h> +#include <linux/usb.h> +#include "monetouch.h" +#include "debug.h" + + +MODULE_AUTHOR("Nick Sillik <[EMAIL PROTECTED]>"); +MODULE_DESCRIPTION("Adds functionality for the onetouch button on Maxtor OneTouch external hard-drives"); +MODULE_LICENSE("GPL"); + +struct usb_onetouch { + char name[128]; + char phys[64]; + struct input_dev dev; /* input device interface */ + struct usb_device *udev; /* usb device */ + + struct urb *irq; /* urb for interrupt in report */ + unsigned char *data; /* input data */ + dma_addr_t data_dma; + + int open_count; /* reference count */ +}; + +struct usb_onetouch_wrap { + struct list_head list; + struct usb_onetouch *onetouch; +}; + +static LIST_HEAD(onetouch_list); + +static void onetouch_irq(struct urb *urb, struct pt_regs *regs) +{ + struct usb_onetouch *onetouch = urb->context; + int retval; + + switch (urb->status) { + case 0: + /* success */ + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + /* this urb is terminated, clean up */ + dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); + return; + default: + dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); + goto resubmit; + } + + input_regs(&onetouch->dev, regs); + //printk(KERN_INFO "input: %02x %02x\n", onetouch->data[0], onetouch->data[1]); + input_report_key(&onetouch->dev, ONETOUCH_BUTTON, onetouch->data[0] & 0x02); + + input_sync(&onetouch->dev); + +resubmit: + retval = usb_submit_urb (urb, GFP_ATOMIC); + if (retval) + err ("%s - usb_submit_urb failed with result %d", + __FUNCTION__, retval); +} + +static int onetouch_open(struct input_dev *dev) +{ + struct usb_onetouch *onetouch = dev->private; + + if (onetouch->open_count++) + return 0; + + onetouch->irq->dev = onetouch->udev; + if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { + onetouch->open_count--; + return -EIO; + } + + return 0; +} + +static void onetouch_close(struct input_dev *dev) +{ + struct usb_onetouch *onetouch = dev->private; + + if (!--onetouch->open_count) + usb_unlink_urb(onetouch->irq); +} + +void onetouch_connect_input(struct us_data *ss) +{ + struct usb_device *udev = ss->pusb_dev; + struct usb_onetouch_wrap *wrap; + struct usb_onetouch *onetouch; + char path[64]; + + if (udev->descriptor.idVendor != VENDOR_MAXTOR || udev->descriptor.idProduct != PRODUCT_ONETOUCH) { + return; + } + + + + US_DEBUGP("Connecting OneTouch device\n"); + + if ((onetouch = kmalloc (sizeof(struct usb_onetouch), GFP_KERNEL)) == NULL) { + err("cannot allocate memory for new onetouch"); + return; + } + memset(onetouch, 0, sizeof(struct usb_onetouch)); + + wrap = kmalloc (sizeof (struct usb_onetouch_wrap), GFP_KERNEL); + if (!wrap) { + err("cannot allocate memory for new onetouch wrapper"); + kfree(onetouch); + return; + } + + onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, + SLAB_ATOMIC, &onetouch->data_dma); + if (!onetouch->data) { + kfree(onetouch); + return; + } + + onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); + if (!onetouch->irq) { + err("cannot allocate memory for new onetouch interrupt urb"); + usb_buffer_free(udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); + kfree(onetouch); + return; + } + + usb_fill_int_urb(onetouch->irq, udev, + ss->recv_intr_pipe, + onetouch->data, ONETOUCH_PKT_LEN, onetouch_irq, + onetouch, ss->ep_bInterval); + onetouch->irq->transfer_dma = onetouch->data_dma; + onetouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + + onetouch->udev = udev; + + onetouch->dev.id.bustype = BUS_USB; + onetouch->dev.id.vendor = udev->descriptor.idVendor; + onetouch->dev.id.product = udev->descriptor.idProduct; + onetouch->dev.id.version = udev->descriptor.bcdDevice; + onetouch->dev.private = onetouch; + onetouch->dev.name = onetouch->name; + onetouch->dev.phys = onetouch->phys; + onetouch->dev.open = onetouch_open; + onetouch->dev.close = onetouch_close; + + usb_make_path(udev, path, 64); + snprintf(onetouch->phys, 64, "%s/input0", path); + snprintf(onetouch->name, 128, "%s %s", ss->vendor, ss->product); + if (!strlen(onetouch->name)) + snprintf(onetouch->name, 128, "Maxtor OneTouch"); + + set_bit(EV_KEY, onetouch->dev.evbit); + set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit); + clear_bit(0, onetouch->dev.keybit); + + input_register_device(&onetouch->dev); + + printk(KERN_INFO "input: %s on %s\n", onetouch->dev.name, path); + + wrap->onetouch = onetouch; + list_add(&wrap->list, &onetouch_list); + +} + +void onetouch_release_input(struct us_data *ss) +{ + struct usb_device *udev = ss->pusb_dev; + struct usb_onetouch *onetouch; + struct usb_onetouch_wrap *wrap; + struct list_head *tmp1, *tmp2; + + if (udev->descriptor.idVendor != VENDOR_MAXTOR || udev->descriptor.idProduct != PRODUCT_ONETOUCH) { + return; + } + + US_DEBUGP("Trying to release OneTouch device..."); + + list_for_each_safe (tmp1, tmp2, &onetouch_list) { + wrap = list_entry (tmp1, struct usb_onetouch_wrap, list); + onetouch = wrap->onetouch; + + if (onetouch->udev == udev) { + + US_DEBUGP("device found: %s. Releasing\n", onetouch->phys); + + list_del (tmp1); + usb_unlink_urb(onetouch->irq); + input_unregister_device(&onetouch->dev); + usb_free_urb(onetouch->irq); + usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); + + kfree(wrap); + kfree(onetouch); + } + } +} diff -uprN linux-2.6.10/drivers/usb/storage/monetouch.h linux-2.6.10nsillik/drivers/usb/storage/monetouch.h --- linux-2.6.10/drivers/usb/storage/monetouch.h 1969-12-31 19:00:00.000000000 -0500 +++ linux-2.6.10nsillik/drivers/usb/storage/monetouch.h 2005-02-03 19:12:49.000000000 -0500 @@ -0,0 +1,19 @@ +#ifndef _ONETOUCH_H_ +#define _ONETOUCH_H_ + +#include <linux/config.h> +#include "usb.h" +#include "linux/input.h" + + +#define ONETOUCH_PKT_LEN 0x02 + +#define ONETOUCH_BUTTON KEY_PROG1 + +#define VENDOR_MAXTOR 0x0d49 +#define PRODUCT_ONETOUCH 0x7010 + +void onetouch_connect_input(struct us_data *ss); +void onetouch_release_input(struct us_data *ss); + +#endif diff -uprN linux-2.6.10/drivers/usb/storage/usb.c linux-2.6.10nsillik/drivers/usb/storage/usb.c --- linux-2.6.10/drivers/usb/storage/usb.c 2004-12-24 16:34:27.000000000 -0500 +++ linux-2.6.10nsillik/drivers/usb/storage/usb.c 2005-02-03 19:18:28.000000000 -0500 @@ -87,7 +87,13 @@ #ifdef CONFIG_USB_STORAGE_JUMPSHOT #include "jumpshot.h" #endif - +#ifdef CONFIG_USB_STORAGE_ONETOUCH +#include "monetouch.h" +#endif +#ifndef CONFIG_USB_STORAGE_ONETOUCH +static inline void onetouch_connect_input (struct us_data *ss) {} +static inline void onetouch_release_input (struct us_data *ss) {} +#endif
#include <linux/module.h> #include <linux/init.h> @@ -946,7 +952,7 @@ static int storage_probe(struct usb_inte init_waitqueue_head(&us->dev_reset_wait); init_waitqueue_head(&us->scsi_scan_wait); init_completion(&us->scsi_scan_done); - + /* Associate the us_data structure with the USB device */ result = associate_dev(us, intf); if (result) @@ -994,6 +1000,8 @@ static int storage_probe(struct usb_inte if (result) goto BadDevice;
+ onetouch_connect_input(us); + /* Acquire all the other resources and add the host */ result = usb_stor_acquire_resources(us); if (result) @@ -1047,6 +1055,8 @@ static void storage_disconnect(struct us up(&us->dev_semaphore); scsi_remove_host(us->host);
+ onetouch_release_input(us); + /* Wait for everything to become idle and release all our resources */ usb_stor_release_resources(us); dissociate_dev(us);
signature.asc
Description: OpenPGP digital signature