From patchwork Thu Aug 28 13:14:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 36201 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E1E02054F for ; Thu, 28 Aug 2014 13:14:46 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp18sf7699900obc.1 for ; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=o1BZsj7jHpFUFu9XK3nA4zeZL6dYwmY2z6c+sd18KRE=; b=RHIxc/jRGOkItzUJIPTO38QYhhJYdjQ3KENd8J7XxTY3DWIMhtcP3eGI8dtH/uLLw1 N+p49a9qGvYR6dFJaZi5htqZS7xn+vQbm4lTyNFVgcg1+kBfWzh4SepphFhW2kzPYHmF jUf3osM1xjkZ3dHc5sH2d4ZIfP4VjLh9bxGIwTH3hoUkb89YgMpMNfrYZPt69mP/y5dQ FYiJyh684kuGf4slcnF6P0JzPqPJqDOZH5145B4lrqFrz2HucdcULro9J1jjmC1Lzl/I nrEl/UL3fnKifgVCWeai4gK1DzqjicOLSip7zmxNiurRkSvgkATvbEzFNgcHcPmn27uH Yc3g== X-Gm-Message-State: ALoCoQna4QzaOU7Yb9gq9fq8U7Dspm2CXnyRjSJEB2ywAdcUnDTBebzucyVHovv2ajHbIoFg4OL1 X-Received: by 10.182.142.5 with SMTP id rs5mr1885347obb.15.1409231685788; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.48 with SMTP id m45ls573596qgd.18.gmail; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) X-Received: by 10.221.28.67 with SMTP id rt3mr91304vcb.78.1409231685708; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id yv8si3373308vcb.5.2014.08.28.06.14.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 06:14:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id im17so778479vcb.27 for ; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr358637vdb.95.1409231685609; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp234663vcb; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) X-Received: by 10.42.83.81 with SMTP id g17mr4321401icl.45.1409231685062; Thu, 28 Aug 2014 06:14:45 -0700 (PDT) Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com [209.85.223.178]) by mx.google.com with ESMTPS id ct19si4007217icb.96.2014.08.28.06.14.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 06:14:45 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.178 as permitted sender) client-ip=209.85.223.178; Received: by mail-ie0-f178.google.com with SMTP id at1so924704iec.9 for ; Thu, 28 Aug 2014 06:14:44 -0700 (PDT) X-Received: by 10.50.28.75 with SMTP id z11mr37899058igg.11.1409231684808; Thu, 28 Aug 2014 06:14:44 -0700 (PDT) Received: from localhost.localdomain (host86-152-0-170.range86-152.btcentralplus.com. [86.152.0.170]) by mx.google.com with ESMTPSA id w8sm16633672igl.13.2014.08.28.06.14.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Aug 2014 06:14:44 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Lee Jones Subject: [PATCH 09/11] mfd: pcf50633: Check return value of platform_device_add() Date: Thu, 28 Aug 2014 14:14:15 +0100 Message-Id: <1409231657-18294-9-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409231657-18294-1-git-send-email-lee.jones@linaro.org> References: <1409231657-18294-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The return value of platform_device_add() is checked after every other use throughout the kernel. We're also sliding in another cheeky dev_err() => dev_warn() change as we're not actually erroring out here, rather reporting the fact that something's gone wrong, but carrying on regardless. Signed-off-by: Lee Jones --- drivers/mfd/pcf50633-core.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index c87f7a0..e15c060 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -195,8 +195,9 @@ static int pcf50633_probe(struct i2c_client *client, const struct i2c_device_id *ids) { struct pcf50633 *pcf; + struct platform_device *pdev; struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev); - int i, ret; + int i, j, ret; int version, variant; if (!client->irq) { @@ -243,9 +244,6 @@ static int pcf50633_probe(struct i2c_client *client, for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { - struct platform_device *pdev; - int j; - pdev = platform_device_alloc("pcf50633-regulator", i); if (!pdev) return -ENOMEM; @@ -253,25 +251,31 @@ static int pcf50633_probe(struct i2c_client *client, pdev->dev.parent = pcf->dev; ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], sizeof(pdata->reg_init_data[i])); - if (ret) { - platform_device_put(pdev); - for (j = 0; j < i; j++) - platform_device_put(pcf->regulator_pdev[j]); - return ret; - } - pcf->regulator_pdev[i] = pdev; + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; - platform_device_add(pdev); + pcf->regulator_pdev[i] = pdev; } ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); if (ret) - dev_err(pcf->dev, "error creating sysfs entries\n"); + dev_warn(pcf->dev, "error creating sysfs entries\n"); if (pdata->probe_done) pdata->probe_done(pcf); return 0; + +err: + platform_device_put(pdev); + for (j = 0; j < i; j++) + platform_device_put(pcf->regulator_pdev[j]); + + return ret; } static int pcf50633_remove(struct i2c_client *client)