From patchwork Thu Sep 23 14:14:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 202122 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8NEFHkM015330 for ; Thu, 23 Sep 2010 14:15:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755407Ab0IWOOs (ORCPT ); Thu, 23 Sep 2010 10:14:48 -0400 Received: from hapkido.dreamhost.com ([66.33.216.122]:58069 "EHLO hapkido.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755372Ab0IWOOs (ORCPT ); Thu, 23 Sep 2010 10:14:48 -0400 Received: from homiemail-a2.g.dreamhost.com (caiajhbdcagg.dreamhost.com [208.97.132.66]) by hapkido.dreamhost.com (Postfix) with ESMTP id 8E8AE17A9F7 for ; Thu, 23 Sep 2010 07:14:47 -0700 (PDT) Received: from homiemail-a2.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a2.g.dreamhost.com (Postfix) with ESMTP id 7746B280069; Thu, 23 Sep 2010 07:14:13 -0700 (PDT) Received: from [192.168.1.104] (unknown [201.223.201.241]) (Authenticated sender: smtp@zesaurus.cl) by homiemail-a2.g.dreamhost.com (Postfix) with ESMTPA id 282EC280063; Thu, 23 Sep 2010 07:14:11 -0700 (PDT) Subject: [PATCH] input: for best practices, return -ENOMEM instead of -1 when returning on mem allocation errors From: Davidlohr Bueso Reply-To: dave@gnu.org To: dmitry.torokhov@gmail.com, dtor@mail.ru Cc: LKML , linux-input@vger.kernel.org Date: Thu, 23 Sep 2010 10:14:05 -0400 Message-ID: <1285251245.2127.4.camel@cowboy> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Sep 2010 14:15:17 +0000 (UTC) diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c index bf170f6..f459471 100644 --- a/drivers/input/misc/powermate.c +++ b/drivers/input/misc/powermate.c @@ -280,7 +280,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev pm->configcr = kmalloc(sizeof(*(pm->configcr)), GFP_KERNEL); if (!pm->configcr) - return -1; + return -ENOMEM; return 0; } diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 4831120..04d9bf3 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -699,7 +699,7 @@ int elantech_init(struct psmouse *psmouse) psmouse->private = etd = kzalloc(sizeof(struct elantech_data), GFP_KERNEL); if (!etd) - return -1; + return -ENOMEM; etd->parity[0] = 1; for (i = 1; i < 256; i++) diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 96b70a4..a79bc36 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -731,7 +731,7 @@ int synaptics_init(struct psmouse *psmouse) psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL); if (!priv) - return -1; + return -ENOMEM; psmouse_reset(psmouse); diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 0643e49..54b2fa8 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c @@ -303,7 +303,7 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); if (!psmouse->private) - return -1; + return -ENOMEM; psmouse->vendor = "IBM"; psmouse->name = "TrackPoint";