From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759332Ab0CMVgI (ORCPT ); Sat, 13 Mar 2010 16:36:08 -0500 Received: from netrider.rowland.org ([192.131.102.5]:38693 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1759309Ab0CMVgA (ORCPT ); Sat, 13 Mar 2010 16:36:00 -0500 Date: Sat, 13 Mar 2010 16:35:59 -0500 (EST) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Bruno =?UTF-8?B?UHLDqW1vbnQ=?= cc: Jiri Kosina , , , , "Rick L. Vinyard Jr." , Nicu Pavel Subject: Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device In-Reply-To: <20100313203953.0f3436b3@neptune.home> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 13 Mar 2010, Bruno [UTF-8] Prémont wrote: > Is something like below acceptable? (from error handling point of view > it makes no difference...) > > Thanks, > Bruno > > file: drivers/hid/hid-core.c > > int hid_add_device(struct hid_device *hdev) > { > static atomic_t id = ATOMIC_INIT(0); > int ret; > > if (WARN_ON(hdev->status & HID_STAT_ADDED)) > return -EBUSY; > > /* we need to kill them here, otherwise they will stay allocated to > * wait for coming driver */ > if (hid_ignore(hdev)) > return -ENODEV; > > /* XXX hack, any other cleaner solution after the driver core > * is converted to allow more than 20 bytes as the device name? */ > dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, > hdev->vendor, hdev->product, atomic_inc_return(&id)); > > + hid_debug_register(hdev, dev_name(&hdev->dev)); > ret = device_add(&hdev->dev); > if (!ret) > hdev->status |= HID_STAT_ADDED; > > - hid_debug_register(hdev, dev_name(&hdev->dev)); > > return ret; > } If the device_add() fails, you should undo the hid_debug_register() call. Alan Stern From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Stern Subject: Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device Date: Sat, 13 Mar 2010 16:35:59 -0500 (EST) Message-ID: References: <20100313203953.0f3436b3@neptune.home> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from netrider.rowland.org ([192.131.102.5]:35185 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1759303Ab0CMVgA (ORCPT ); Sat, 13 Mar 2010 16:36:00 -0500 In-Reply-To: <20100313203953.0f3436b3@neptune.home> Sender: linux-input-owner@vger.kernel.org List-Id: linux-input@vger.kernel.org To: Bruno =?UTF-8?B?UHLDqW1vbnQ=?= Cc: Jiri Kosina , linux-input@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Rick L. Vinyard Jr." , Nicu Pavel On Sat, 13 Mar 2010, Bruno [UTF-8] Pr=C3=A9mont wrote: > Is something like below acceptable? (from error handling point of vie= w > it makes no difference...) >=20 > Thanks, > Bruno >=20 > file: drivers/hid/hid-core.c >=20 > int hid_add_device(struct hid_device *hdev) > { > static atomic_t id =3D ATOMIC_INIT(0); > int ret; > =20 > if (WARN_ON(hdev->status & HID_STAT_ADDED)) > return -EBUSY; > =20 > /* we need to kill them here, otherwise they will stay alloc= ated to > * wait for coming driver */ > if (hid_ignore(hdev)) > return -ENODEV; > =20 > /* XXX hack, any other cleaner solution after the driver cor= e > * is converted to allow more than 20 bytes as the device na= me? */ > dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, > hdev->vendor, hdev->product, atomic_inc_return(= &id)); > =20 > + hid_debug_register(hdev, dev_name(&hdev->dev)); > ret =3D device_add(&hdev->dev); > if (!ret) > hdev->status |=3D HID_STAT_ADDED; > =20 > - hid_debug_register(hdev, dev_name(&hdev->dev)); > =20 > return ret; > } If the device_add() fails, you should undo the hid_debug_register()=20 call. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-input" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html