From patchwork Mon Dec 31 11:09:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1921191 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A2AB73FC66 for ; Mon, 31 Dec 2012 11:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751939Ab2LaLLI (ORCPT ); Mon, 31 Dec 2012 06:11:08 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:55518 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525Ab2LaLJn (ORCPT ); Mon, 31 Dec 2012 06:09:43 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id qBVB9gTB009617; Mon, 31 Dec 2012 05:09:42 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id qBVB9gR9006755; Mon, 31 Dec 2012 05:09:42 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Mon, 31 Dec 2012 05:09:41 -0600 Received: from barack.emea.dhcp.ti.com (barack.emea.dhcp.ti.com [137.167.125.64]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id qBVB9W3Z030265; Mon, 31 Dec 2012 05:09:40 -0600 From: Peter Ujfalusi To: Samuel Ortiz CC: , , Tero Kristo Subject: [PATCH 07/10] mfd: twl-core: Move 'inuse' check early at probe time Date: Mon, 31 Dec 2012 12:09:28 +0100 Message-ID: <1356952171-6109-8-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1356952171-6109-1-git-send-email-peter.ujfalusi@ti.com> References: <1356952171-6109-1-git-send-email-peter.ujfalusi@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org We can fail earlier in case multiple instance of the twl-core is tried to be loaded. The twl-core by design only supports one instance. Signed-off-by: Peter Ujfalusi --- drivers/mfd/twl-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 547fed5..1827088 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -1170,6 +1170,12 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) return -EINVAL; } + if (inuse) { + dev_dbg(&client->dev, "only one instance of %s allowed\n", + DRIVER_NAME); + return -EBUSY; + } + pdev = platform_device_alloc(DRIVER_NAME, -1); if (!pdev) { dev_err(&client->dev, "can't alloc pdev\n"); @@ -1188,12 +1194,6 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) goto free; } - if (inuse) { - dev_dbg(&client->dev, "driver is already in use\n"); - status = -EBUSY; - goto free; - } - if ((id->driver_data) & TWL6030_CLASS) { twl_id = TWL6030_CLASS_ID; twl_map = &twl6030_map[0];