From patchwork Mon Jun 1 21:10:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 479180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 27FB91412E1 for ; Tue, 2 Jun 2015 07:13:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YzX04-0008Tv-TL; Mon, 01 Jun 2015 21:12:00 +0000 Received: from mail.sigma-star.at ([95.130.255.111]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YzWzp-0008Dz-D8 for linux-mtd@lists.infradead.org; Mon, 01 Jun 2015 21:11:46 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.sigma-star.at (Postfix) with ESMTP id 8F2C216B4672; Mon, 1 Jun 2015 23:10:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at mail.sigma-star.at Received: from azrael.upc.at (chello213047235169.tirol.surfer.at [213.47.235.169]) by mail.sigma-star.at (Postfix) with ESMTPSA id B709B16B446D; Mon, 1 Jun 2015 23:10:56 +0200 (CEST) From: Richard Weinberger To: computersforpeace@gmail.com Subject: [PATCH 6/6] mtd: docg3: Don't do ERR_PTR(0) Date: Mon, 1 Jun 2015 23:10:54 +0200 Message-Id: <1433193054-26865-7-git-send-email-richard@nod.at> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1433193054-26865-1-git-send-email-richard@nod.at> References: <1433193054-26865-1-git-send-email-richard@nod.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150601_141145_686773_5C642167 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record Cc: Richard Weinberger , linux-mtd@lists.infradead.org, dwmw2@infradead.org, maximlevitsky@gmail.com, linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Don't return a obfuscated null pointer using ERR_PTR(0). If the no device is found clearly return -ENODEV. This makes the code more clear and matches the comment of doc_probe_device(). Signed-off-by: Richard Weinberger --- drivers/mtd/devices/docg3.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index 5e67b4a..630e29a 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c @@ -1902,7 +1902,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev) chip_id = doc_register_readw(docg3, DOC_CHIPID); chip_id_inv = doc_register_readw(docg3, DOC_CHIPID_INV); - ret = 0; + ret = -ENODEV; if (chip_id != (u16)(~chip_id_inv)) { goto nomem4; } @@ -2068,13 +2068,10 @@ static int __init docg3_probe(struct platform_device *pdev) mtd = doc_probe_device(cascade, floor, dev); if (IS_ERR(mtd)) { ret = PTR_ERR(mtd); - goto err_probe; - } - if (!mtd) { - if (floor == 0) - goto notfound; - else + if (ret == -ENODEV && floor == 0) continue; + else + goto err_probe; } cascade->floors[floor] = mtd; ret = mtd_device_parse_register(mtd, part_probes, NULL, NULL, @@ -2091,10 +2088,9 @@ static int __init docg3_probe(struct platform_device *pdev) doc_dbg_register(cascade->floors[0]->priv); return 0; -notfound: - ret = -ENODEV; - dev_info(dev, "No supported DiskOnChip found\n"); err_probe: + if (ret == -ENODEV) + dev_info(dev, "No supported DiskOnChip found\n"); free_bch(cascade->bch); for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) if (cascade->floors[floor])