Skip to contentSkip to conversation

linux-input: bcm5974-0.31: fixed resource leak, removed work struct, device data struct introduced

PATCH In review Henrik Rydberg 4 participants 9 messages Jun 28, 2008 – Jul 3, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 linux-input: bcm5974-0.31: fixed resource leak, removed work struct, device data struct introduced

From: Henrik Rydberg <[email protected]>

BCM5974: This driver adds support for the multitouch trackpad on the new Apple Macbook Air and Macbook Pro Penryn laptops. It replaces the appletouch driver on those computers, and integrates well with the synaptics driver of the Xorg system.

---

The touchpad on the new Macbook Air and Macbook Pro Penryn laptops is based on the Broadcom BCM5974 chip, of which very little is publicly known. The device is currently not recognized by the kernel, and as a consequence the synaptics system fails to operate. The fall-back mouse handling is very poor. The attached driver, bcm5974, remedies this. It operates similarly to the appletouch driver.

This is version bcm5974-0.31, incorporating changes suggested by Oliver Neukum. The driver usability is also discussed at
http://ubuntuforums.org/showthread.php?t=840040.

drivers/input/mouse/Kconfig +23 -0
index 7bbea09..89ef7c3 100644
@@ -130,6 +130,29 @@ config MOUSE_APPLETOUCH
 	  To compile this driver as a module, choose M here: the
 	  module will be called appletouch.
 
+config MOUSE_BCM5974
+	tristate "Apple USB BCM5974 Multitouch trackpad support"
+	depends on USB_ARCH_HAS_HCD
+	select USB
+	help
+	  Say Y here if you have an Apple USB BCM5974 Multitouch
+	  trackpad.
+
+          The BCM5974 is the multitouch trackpad found in the Macbook
+          Air (JAN2008) and Macbook Pro Penryn (FEB2008) laptops.
+
+          It is also found in the IPhone (2007) and Ipod Touch (2008).
+
+	  This driver provides multitouch functionality together with
+          the synaptics X11 driver.
+
+          The interface is currently identical to the appletouch interface,
+          for further information, see
+          <file:Documentation/input/appletouch.txt>.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called bcm5974.
+
 config MOUSE_INPORT
 	tristate "InPort/MS/ATIXL busmouse"
 	depends on ISA
drivers/input/mouse/Makefile +1 -0
index 9e6e363..d4d2025 100644
@@ -6,6 +6,7 @@
 
 obj-$(CONFIG_MOUSE_AMIGA)	+= amimouse.o
 obj-$(CONFIG_MOUSE_APPLETOUCH)	+= appletouch.o
+obj-$(CONFIG_MOUSE_BCM5974)	+= bcm5974.o
 obj-$(CONFIG_MOUSE_ATARI)	+= atarimouse.o
 obj-$(CONFIG_MOUSE_RISCPC)	+= rpcmouse.o
 obj-$(CONFIG_MOUSE_INPORT)	+= inport.o
drivers/input/mouse/bcm5974.c +667 -0

667 lines not on this page · raw message

#1 lore raw
Quoted 2 lines

Subject: [PATCH 001/002] linux-input: bcm5974-0.31: fixed resource leak, removed work struct, device data struct introduced

hm, I wonder where [002/002] went.

Please copy the USB list on USB patches.

Quoted 4 lines · On Sat, 28 Jun 2008 14:54:20 +0200 Henrik Rydberg <[email protected]> wrote:

BCM5974: This driver adds support for the multitouch trackpad on the new Apple Macbook Air and Macbook Pro Penryn laptops. It replaces the appletouch driver on those computers, and integrates well with the synaptics driver of the Xorg system.

- erk, the driver uses two-spaces for indenting all over the place. Mayeb the email client mangled it in imaginative ways, but it _looks_ to be intentional.

If so, please don't do that. Kernel code uses hard tabs at 8-cols-per-tab for indenting.

drivers/input/mouse/Kconfig config MOUSE_APPLETOUCH · line 136

Quoted 4 lines
drivers/input/mouse/Kconfig +4 -0
+config MOUSE_BCM5974
+	tristate "Apple USB BCM5974 Multitouch trackpad support"
+	depends on USB_ARCH_HAS_HCD
+	select USB

selecting USB here seems like a bad idea, although I note that several other drivers had bad ideas. `depends on' would be better, IMO.

Quoted 36 lines
drivers/input/mouse/Kconfig +19 -0
+	help
+	  Say Y here if you have an Apple USB BCM5974 Multitouch
+	  trackpad.
+
+          The BCM5974 is the multitouch trackpad found in the Macbook
+          Air (JAN2008) and Macbook Pro Penryn (FEB2008) laptops.
+
+          It is also found in the IPhone (2007) and Ipod Touch (2008).
+
+	  This driver provides multitouch functionality together with
+          the synaptics X11 driver.
+
+          The interface is currently identical to the appletouch interface,
+          for further information, see
+          <file:Documentation/input/appletouch.txt>.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called bcm5974.
+
 config MOUSE_INPORT
 	tristate "InPort/MS/ATIXL busmouse"
 	depends on ISA

diff -puN drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad drivers/input/mouse/Makefile

drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +1 -0
@@ -6,6 +6,7 @@
 
 obj-$(CONFIG_MOUSE_AMIGA)	+= amimouse.o
 obj-$(CONFIG_MOUSE_APPLETOUCH)	+= appletouch.o
+obj-$(CONFIG_MOUSE_BCM5974)	+= bcm5974.o
 obj-$(CONFIG_MOUSE_ATARI)	+= atarimouse.o
 obj-$(CONFIG_MOUSE_RISCPC)	+= rpcmouse.o
 obj-$(CONFIG_MOUSE_INPORT)	+= inport.o
 
...
 

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+static inline
+const struct atp_config_t *atp_product_config(struct usb_device *udev)
+{
+  u16 id = le16_to_cpu(udev->descriptor.idProduct);
+  const struct atp_config_t *config;
+  for (config = atp_config_table; config->ansi; ++config)
+    if (config->ansi == id || config->iso == id || config->jis == id)
+      return config;
+  return atp_config_table;
+}

This is waaaaaaay too big for inlining.

Quoted 46 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +46 -0
+/* Wellspring initialization constants */
+#define ATP_WELLSPRING_MODE_READ_REQUEST_ID   1
+#define ATP_WELLSPRING_MODE_WRITE_REQUEST_ID  9
+#define ATP_WELLSPRING_MODE_REQUEST_VALUE     0x300
+#define ATP_WELLSPRING_MODE_REQUEST_INDEX     0
+#define ATP_WELLSPRING_MODE_VENDOR_VALUE_1    0x01
+#define ATP_WELLSPRING_MODE_VENDOR_VALUE_2    0x05
+
+#define dprintk(format, a...) \
+  { if (debug) printk(KERN_DEBUG format, ##a); }
+
+MODULE_AUTHOR("Henrik Rydberg");
+MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver");
+MODULE_LICENSE("GPL");
+
+static int debug = 1;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Activate debugging output");
+
+static int atp_wellspring_init(struct usb_device *udev)
+{
+  const struct atp_config_t *cfg = atp_product_config(udev);
+  char *data = kmalloc(8, GFP_DMA);
+  int size;
+
+  /* reset button endpoint */
+  if (usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+		      USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
+		      0, cfg->bt_ep, NULL, 0, 5000)) {
+    err("Could not reset button endpoint");
+    goto error;
+  }
+
+  /* reset trackpad endpoint */
+  if (usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+		      USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
+		      0, cfg->tp_ep, NULL, 0, 5000)) {
+    err("Could not reset trackpad endpoint");
+    goto error;
+  }
+
+  /* read configuration */
+  size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+			 ATP_WELLSPRING_MODE_READ_REQUEST_ID,
+			 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+			 ATP_WELLSPRING_MODE_REQUEST_VALUE,

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+			 ATP_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
+
+  if (size != 8) {
+    err("Could not do mode read request from device (Wellspring Raw mode)");
+    goto error;
+  }
+
+  /* apply the mode switch */
+  data[0] = ATP_WELLSPRING_MODE_VENDOR_VALUE_1;
+  data[1] = ATP_WELLSPRING_MODE_VENDOR_VALUE_2;

This will crash the kernel if the kmalloc() failed. And kmalloc(GFP_DMA) can easily fail.

Do we really need memory from the GFP_DMA region for this driver? It would be terribly old-fashioned.

I dunno what USB driver normally use for their dma memory. Perhaps dma_alloc_coherent()?

Quoted 29 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +29 -0
+  /* write configuration */
+  size = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+			 ATP_WELLSPRING_MODE_WRITE_REQUEST_ID,
+			 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+			 ATP_WELLSPRING_MODE_REQUEST_VALUE,
+			 ATP_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
+
+  if (size != 8) {
+    err("Could not do mode write request to device (Wellspring Raw mode)");
+    goto error;
+  }
+
+  kfree(data);
+  return 0;
+
+ error:
+  kfree(data);
+  return -EIO;
+}
+
+/* Structure to hold all of our device specific stuff */
+struct atp {
+  char			phys[64];
+  struct usb_device    *udev;	      /* usb device */
+  struct input_dev     *input;	      /* input dev */
+  struct atp_config_t	cfg;	      /* device configuration */
+  unsigned		open;	      /* non-zero if opened */
+  struct urb	       *bt_urb;	      /* button usb request block */
+  signed char	       *bt_data;      /* button transferred data */

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+  unsigned		bt_valid;     /* are the button sensors valid ? */
+  unsigned		bt_state;     /* current button state */
+  struct urb	       *tp_urb;	      /* trackpad usb request block */
+  signed char	       *tp_data;      /* trackpad transferred data */
+  unsigned		tp_valid;     /* are the trackpad sensors valid ? */
+};
+
+static inline int raw2int(__le16 x)
+{
+  return (short)le16_to_cpu(x);

Given that this function returns signed 32-bit, I'd worry about what it does when it is presented with 0xffff. otoh, perhaps you indeed intended to handle negative 16-bit quantities in that fashion, which would make sense.

drivers/input/mouse/Makefile

Quoted 6 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +6 -0
+}
+
+static inline int int2scale(const struct atp_params_t *p, int x)
+{
+  return ((p->max-p->min)*x)/(p->devmax-p->devmin);
+}

Is there any way in which this can get a divide-by-zero?

drivers/input/mouse/Makefile

Quoted 6 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +6 -0
+/**
+ * all value ranges, both device and logical, are assumed to be [a,b).
+ */
+static inline int int2bound(const struct atp_params_t *p, int x)
+{
+  int s = p->min+int2scale(p, x);

Please put a space around the operators in expressions like this.

Quoted 1 line

+ return s < p->min?p->min:s >= p->max?p->max-1:s;

That's just unreadable. Please simplify it.

drivers/input/mouse/Makefile

Quoted 3 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +3 -0
+}
+
+/**

This leadin is exclusively used to identify a kerneldoc-style comment.

Quoted 5 lines

+ * check quality of reading.
+ * -1: bad data
+ * 0: ignore this reading
+ * 1: good reading
+ */

But this is not a kerneldoc comment. Please remove all the incorrect /** instances.

Quoted 23 lines

...

drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +20 -0
+/**
+ * convert raw data to synaptics sensor output.
+ * returns the number of fingers on the trackpad,
+ * or a negative number in vase of bad data.
+ */
+static int compute_movement(int *abs_x, int *abs_y,
+			    int *rel_x, int *rel_y,
+			    int *pressure,
+			    struct atp_config_t *cfg,
+			    const unsigned char *data, int size)
+{
+  const int nfinger = (size-26)/28;
+  const struct tp_data_t *tp = (struct tp_data_t *) data;
+
+  if (nfinger) {
+    *abs_x = int2bound(&cfg->x, raw2int(tp->finger->abs_x) - cfg->x.devmin);
+    *abs_y = int2bound(&cfg->y, cfg->y.devmax - raw2int(tp->finger->abs_y));
+    *rel_x = int2scale(&cfg->x, raw2int(tp->finger->rel_x));
+    *rel_y = int2scale(&cfg->y, -raw2int(tp->finger->rel_y));
+    *pressure = int2bound(&cfg->p, raw2int(tp->finger->force_major));

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+  } else {
+    *abs_x = 0;
+    *abs_y = 0;
+    *rel_x = 0;
+    *rel_y = 0;
+    *pressure = 0;
+  }
+
+  /* report zero fingers for zero pressure */
+  return *pressure > 0?nfinger:0;

Normal style is

	return *pressure > 0 ? nfinger : 0;

(lots of other places)

Quoted 42 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +42 -0
+}
+
+static void atp_button(struct urb *urb)
+{
+  struct atp *dev = urb->context;
+  const unsigned char *data = dev->bt_data;
+  const int size = dev->bt_urb->actual_length;
+  int button = 0, retval;
+
+  switch (urb->status) {
+  case 0:
+    /* success */
+    break;
+  case -EOVERFLOW:
+  case -ECONNRESET:
+  case -ENOENT:
+  case -ESHUTDOWN:
+    /* This urb is terminated, clean up */
+    dbg("%s - urb shutting down with status: %d",
+	__func__, urb->status);
+    return;
+  default:
+    dbg("%s - nonzero urb status received: %d",
+	__func__, urb->status);
+    goto exit;
+  }
+
+  /* first sample data ignored */
+  if (!dev->bt_valid) {
+    dev->bt_valid = 1;
+    goto exit;
+  }
+
+  /* drop incomplete datasets */
+  if (size != 4) {
+    dprintk("bcm5974: incomplete button package (first byte: %d, length: %d)\n",
+	    (int)data[0], size);
+    goto exit;
+  }
+
+  button = data[1];
+

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+  /* only report button state changes */
+  if (button != dev->bt_state) {
+    input_report_key(dev->input, BTN_LEFT, button);
+    input_sync(dev->input);
+  }
+
+  dev->bt_state = button;
+
+ exit:
+  retval = usb_submit_urb(dev->bt_urb, GFP_ATOMIC);

GFP_ATOMIC is a red flag. Is this quite unrelaible allocation mode really needed here?

Quoted 63 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +63 -0
+  if (retval) {
+    err("%s - button usb_submit_urb failed with result %d",
+	__func__, retval);
+  }
+}
+
+static void atp_trackpad(struct urb *urb)
+{
+  struct atp *dev = urb->context;
+  int abs_x, abs_y, rel_x, rel_y, pressure;
+  int quality, nfinger, retval;
+
+  switch (urb->status) {
+  case 0:
+    /* success */
+    break;
+  case -EOVERFLOW:
+  case -ECONNRESET:
+  case -ENOENT:
+  case -ESHUTDOWN:
+    /* This urb is terminated, clean up */
+    dbg("%s - urb shutting down with status: %d",
+	__func__, urb->status);
+    return;
+  default:
+    dbg("%s - nonzero urb status received: %d",
+	__func__, urb->status);
+    goto exit;
+  }
+
+  /* first sample data ignored */
+  if (!dev->tp_valid) {
+    dev->tp_valid = 1;
+    goto exit;
+  }
+
+  /* determine quality of reading */
+  quality = compute_quality(dev->tp_data, dev->tp_urb->actual_length);
+
+  /* drop incomplete datasets */
+  if (quality < 0) {
+    dprintk("bcm5974: incomplete trackpad package "
+	    "(first byte: %d, length: %d)\n",
+	    (int)dev->tp_data[0], dev->tp_urb->actual_length);
+    goto exit;
+  }
+
+  /* drop poor quality readings */
+  if (quality == 0)
+    goto exit;
+
+  nfinger = compute_movement(&abs_x, &abs_y, &rel_x, &rel_y, &pressure,
+			     &dev->cfg,
+			     dev->tp_data, dev->tp_urb->actual_length);
+
+  if (debug > 1) {
+    printk(KERN_DEBUG "bcm5974: x: %04d y: %04d dx: %3d dy: %3d p: %3d\n",
+	   abs_x, abs_y, rel_x, rel_y, pressure);
+  }
+
+  /* input_report_key(dev->input,BTN_TOUCH,pressure>dev->cfg.p.fuzz); */
+  input_report_abs(dev->input, ABS_PRESSURE, pressure);
+  input_report_abs(dev->input, ABS_X, abs_x);

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+  input_report_abs(dev->input, ABS_Y, abs_y);
+  /* input_report_rel(dev->input, REL_X, rel_x); */
+  /* input_report_rel(dev->input, REL_Y, rel_y); */
+  input_report_key(dev->input, BTN_TOOL_FINGER, nfinger == 1);
+  input_report_key(dev->input, BTN_TOOL_DOUBLETAP, nfinger == 2);
+  input_report_key(dev->input, BTN_TOOL_TRIPLETAP, nfinger > 2);
+  input_sync(dev->input);
+
+ exit:
+  retval = usb_submit_urb(dev->tp_urb, GFP_ATOMIC);

ditto.

Quoted 5 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +5 -0
+  if (retval) {
+    err("%s - trackpad usb_submit_urb failed with result %d",
+	__func__, retval);
+  }
+}

drivers/input/mouse/Makefile

Quoted 10 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +10 -0
+
+static int atp_open(struct input_dev *input)
+{
+  struct atp *dev = input_get_drvdata(input);
+
+  if (usb_submit_urb(dev->bt_urb, GFP_ATOMIC))
+    goto error;
+
+  if (usb_submit_urb(dev->tp_urb, GFP_ATOMIC))
+    goto err_free_bt_urb;

etc.

Quoted 12 lines
drivers/input/mouse/Makefile renamed from drivers/input/mouse/Makefile~input-support-for-bcm5974-multitouch-trackpad +9 -0
+  dev->open = 1;
+  return 0;
+
+ err_free_bt_urb:
+  usb_free_urb(dev->bt_urb);
+ error:
+  return -EIO;
+}
+
 
...
#2 lore raw
Quoted 2 lines · Andrew Morton

I dunno what USB driver normally use for their dma memory.  Perhaps dma_alloc_coherent()?

kmalloc() as a rule ... dma_alloc_coherent() only makes sense if the buffer gets reused enough that the dma mapping ops (or as I think of them, cache maintainence ops) really hurt.

- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 5 lines · On Tue, 1 Jul 2008 20:04:16 -0700 David Brownell <[email protected]> wrote:
Quoted 2 lines · Andrew Morton

I dunno what USB driver normally use for their dma memory. __Perhaps dma_alloc_coherent()?

kmalloc() as a rule ...

kmalloc(GFP_DMA)? Hopefully not...

Quoted 5 lines

dma_alloc_coherent() only makes sense if
the buffer gets reused enough that the dma mapping ops (or as I think of them, cache maintainence ops) really hurt.

- Dave

#4 lore raw
Quoted 6 lines · Andrew Morton
Quoted 4 lines
Quoted 2 lines

I dunno what USB driver normally use for their dma memory. __Perhaps dma_alloc_coherent()?

kmalloc() as a rule ...

kmalloc(GFP_DMA)?  Hopefully not...

Right. Does anything except parport need that any more? Precious little ISA stuff does DMA.

USB should never use GFP_DMA.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Andrew Morton
Quoted 3 lines · Andrew Morton
Quoted 1 line

Subject: [PATCH 001/002] linux-input: bcm5974-0.31: fixed resource leak, removed work struct, device data struct introduced

hm, I wonder where [002/002] went.

Thank you very much for your comments, I will return shortly with a new version. I did not fully grasp, from reading Documentation/SubmitPatches, how the numbering in the subject should work; when I submit my new version in reply to your mail, should I submit a complete patch against the vanilla kernel, with number 001/003?

Best Regards,
Henrik Rydberg

#6 lore raw
Quoted 11 lines · On Wed, 02 Jul 2008 09:46:39 +0200 Henrik Rydberg…
Quoted 3 lines · Andrew Morton
Quoted 1 line

Subject: [PATCH 001/002] linux-input: bcm5974-0.31: fixed resource leak, removed work struct, device data struct introduced

hm, I wonder where [002/002] went.

Thank you very much for your comments, I will return shortly with a new version. I did not fully grasp, from reading Documentation/SubmitPatches, how the numbering in the subject should work; when I submit my new version in reply to your mail, should I submit a complete patch against the vanilla kernel, with number 001/003?

no....

The sequence numbering is only used when you're sending two or more patches at the same time. It is used so that the recipient can work out what order they are to be applied in (they can get reordered in flight) and so that the recipient can verify that none were missed.

So for a single patch, don't include it at all.

Also, it is better to prepare 2.6.27 patches against linux-next, as that is the candidate 2.6.27 tree. But in the case of a brand new driver it doesn't matter a lot. Unless you're using some interface which we've gone and changed, but that's fairly uncommon.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 14 lines · On Wed, 2 Jul 2008 00:53:55 -0700 Andrew Morton wrote:
Quoted 11 lines · On Wed, 02 Jul 2008 09:46:39 +0200 Henrik Rydberg…
Quoted 3 lines · Andrew Morton
Quoted 1 line

Subject: [PATCH 001/002] linux-input: bcm5974-0.31: fixed resource leak, removed work struct, device data struct introduced

hm, I wonder where [002/002] went.

Thank you very much for your comments, I will return shortly with a new version. I did not fully grasp, from reading Documentation/SubmitPatches, how the numbering in the subject should work; when I submit my new version in reply to your mail, should I submit a complete patch against the vanilla kernel, with number 001/003?

Quoted 3 lines

no....

The sequence numbering is only used when you're sending two or more

related, dependent,

Quoted 5 lines

patches at the same time. It is used so that the recipient can work out what order they are to be applied in (they can get reordered in flight) and so that the recipient can verify that none were missed.

So for a single patch, don't include it at all.

For multiple unrelated patches, sequence numbering could even be confusing to recipients. Could make them think that they missed some patch(es) when they didn't.

Quoted 4 lines

Also, it is better to prepare 2.6.27 patches against linux-next, as that is the candidate 2.6.27 tree. But in the case of a brand new driver it doesn't matter a lot. Unless you're using some interface which we've gone and changed, but that's fairly uncommon.

---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
In reply to Andrew Morton
Quoted 9 lines · Andrew Morton
Quoted 9 lines
drivers/input/mouse/bcm5974.c +9 -0
+  }
+
+  button = data[1];
+
+  /* only report button state changes */
+  if (button != dev->bt_state) {
+    input_report_key(dev->input, BTN_LEFT, button);
+    input_sync(dev->input);
+  }
Quoted 8 lines

drivers/input/mouse/bcm5974.c line 372

Quoted 5 lines
drivers/input/mouse/bcm5974.c +5 -0
+
+  dev->bt_state = button;
+
+ exit:
+  retval = usb_submit_urb(dev->bt_urb, GFP_ATOMIC);

GFP_ATOMIC is a red flag. Is this quite unrelaible allocation mode really needed here?

Being new to kernel work, I rely a lot on how other drivers work. However, doing some reading, these are my observations:

* The URB works in interrupt mode.

* The call to usb_submit_urb above is within a completion handler.

* From what I read on kerneltrap (2.6.22), such URBs should be resubmitted using the ATOMIC method. Maybe this changed, I could not tell.

* Personally, I am starting to worry about concurrency races, with the two URBs writing to the same input device. I suppose it depends on whether they are issued on the same interrupt or not? Spin locks?

Best regards,
Henrik Rydberg