From patchwork Thu Jul 28 17:17:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2283 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E27623F081 for ; Thu, 28 Jul 2022 19:17:54 +0200 (CEST) Received: by mail-wr1-f70.google.com with SMTP id w17-20020adfbad1000000b0021f0acd5398sf508897wrg.1 for ; Thu, 28 Jul 2022 10:17:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1659028674; cv=pass; d=google.com; s=arc-20160816; b=P9XltxT0UoK/L/IXid48ppK55PcIRX2Ws/3P/vhG8rEENK95fGyQWCjnMh4T7XpPaq BfGqi5KDZctCX1lnuf56wGRkm7ZtFoVnaqryHpUIAhXY33VOUYzgxdlXP8lb0HFo8eX5 aQGdx7dAHwAORK1QCJMi5emZXXJAUvOXe94n+TAsQFdw5VAenrfNBGlzWbYTA3mmyHBR D2DvNDS/lrfACZv2/xrXPlLeqz7spXdsHce040xu7IBL8UB6mOfoqs4pbwDa5fPQ/X86 Ha0kaq4JIAQhM3mwMtxiDReWcashkdpkXjBUStXpcuFmzd4rQTyqtOGGbWz+rpSIQwPH u3CQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=IGFjOGlVK9drLdzhOQp2DLLPcQHPqu0o4/ybgsnChF+3GDQv0LRQQyXVlBRETGSb3E XSHy8yNweponkJ8uN09B5vJiGwmGIQCuAelvjfclW1GlbrcdzjJGOORUq7BTqcfhj4kA /XBELzx5eWsLO+xaBaCIZLt9if1B+4ouJiiRTVGxJIUTFsA/5QLgkabCbBHB9Mogtr7S 2plOeTCqhnSXntfVcZBkIYd2w5KCDuWdFVQnyxWTXq72qFkBr6XKIIsY/BmHcs8v7v+A G9dXQ0/VlgoTGknAuDxnrTVhWrqZukdeAWXe2horeNnSVYfKvqf3nQ1hCWHZmgjecXBg 7Rjw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OYAjwTyQ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=JiX3l7BjqxyCgZFqdrqhGR1d6Shrq+j440e3p4zLb1RQKhu3u6h2HxZzxGCooNkqxj AgmlWTdUJW7mKhhwFr1ri7vTQtWAKuoFC/HaHNr1SNpYoM+sgKeJ2IJlltZs8+f5TQpU Y7CW9F6YERKYyYR+gDs4FH62f9O+QiRScRNgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=INwtyd/tGfeSOLeGQhDQovTBArBBelZCHItYMZiOdVyvlCDJapi6lAMaEPTP9dMPC+ QoLQtyd51ZqZxO0jU8fRM99lr+FvBshUNPQbMULZtq/IW+W0G7njB4QxVPkJoPBjE6pB HTrqKKqeXGL44Ne6sKNvuCRxcpHGDoZzbtHGgSS2k0cJtAUtewhOdV8vCMZlf7JZadt7 VNTaSbwenBzAN89ulaq9R3TDkfUuqHYsuPOrj8UXNm6Z/3QxkuHBgSleTPpERf6284Kv IgrjGaMIfoEAzzaF+HehlpM+isteo76wRttw181pynT1NZy3xr8s/SL/KHfWjFDJkq04 r/5g== X-Gm-Message-State: AJIora+X9cT+jJYgxTfiulzyHl5pJjBf53+lc28Owp+81HpdB2e3fqeW z9s6R9oSvSg9YG6uEVJv1HePimiL X-Google-Smtp-Source: AGRyM1sTNk74svUFkG+guNXKkqON+1+uIbTB2qf0Q3j6eYIUKeaz9PjpgjuKWMc6XwRDeR6KizF4eA== X-Received: by 2002:a5d:6d0e:0:b0:21e:fc95:3dfc with SMTP id e14-20020a5d6d0e000000b0021efc953dfcmr2570873wrq.112.1659028674630; Thu, 28 Jul 2022 10:17:54 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a1c:c902:0:b0:3a3:1227:ad91 with SMTP id f2-20020a1cc902000000b003a31227ad91ls842397wmb.1.-pod-control-gmail; Thu, 28 Jul 2022 10:17:53 -0700 (PDT) X-Received: by 2002:a05:600c:4f06:b0:3a3:2158:c5ed with SMTP id l6-20020a05600c4f0600b003a32158c5edmr256088wmq.103.1659028673279; Thu, 28 Jul 2022 10:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659028673; cv=none; d=google.com; s=arc-20160816; b=U45bENJ8CUm6dAOn8WDD+9IU2viyJFPDuxw/jDB5ubtIT9mpX4JknEtdchHkA87sDN z7w7cujtTia7H2RcgRi2Pni+ubiS0tkIIxNucy/GVv5hAag5IEnOIEFlnTr4MEs3h+BR BeAxL+Ncm9JdLEILNfOSeUOPJHoNzWurhMWoGG1DsjHkOxyBStwUxXNoiqu1DHBOmDEq KSwJe/bF6PHhbJBqsgdniU27QyuBsQATgDxsvvuUVEOU4WGroUtAK/RkvpuUBvf1L6Ym XeHNEbPF9JdL5M4jLSCFLfKQoBircMgwyseoB5NxKGdQbDMgj6x06MLrtiXcGE7AFWHH k9RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=MNpcuzewDZbHWetPCMtSq+7NxdT3aCHxDyE39RwXta0=; b=bt6aZonAFCRe5b3PIkUzamhO/SOdfugsUmfjYVjyh8p2TEKhvrfYgoCPzEfzV/3Afq AipmeN8EVyYxFCIq3+rTliYx7ZIXvUFccqXvZgDu5DkjLK3FR96M76b7BWn1OznWNnSS /TqwUlMuXewgDBKY3hWo+8umk/Ij8Z1G4SPSYEbEuEnBg8yOZpKZSavdPw+pHmaCUCC/ PgrgH2iazwwhrr65mSHjwgKT8xFM3zok223h46M3zJ7/SEWUwT28A3f8SgorzrbUk8Cm 13IGh4c3Gg7bTdXyykAWaQalaktqr35v7mScaDkvqYrHPQctyYxiMhlgcEG9N+fy+q+y JXBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OYAjwTyQ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id j2-20020a05600c410200b003a2fed12c14sor1408372wmi.25.2022.07.28.10.17.53 for (Google Transport Security); Thu, 28 Jul 2022 10:17:53 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:600c:5120:b0:3a3:2ae4:fb20 with SMTP id o32-20020a05600c512000b003a32ae4fb20mr251681wms.81.1659028672917; Thu, 28 Jul 2022 10:17:52 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.196.208.4]) by smtp.gmail.com with ESMTPSA id h3-20020a5d4fc3000000b0021eba590ad1sm1667850wrw.90.2022.07.28.10.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 10:17:52 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi , u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Tommaso Merciai , Weijie Gao , GSS_MTK_Uboot_upstream , Patrice Chotard , Wolfgang Denk , Simon Glass Subject: [PATCH 2/5] mtd: nand: change return type of nand_get_flash_type() to int Date: Thu, 28 Jul 2022 19:17:40 +0200 Message-Id: <20220728171744.1761739-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728171744.1761739-1-michael@amarulasolutions.com> References: <20220728171744.1761739-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OYAjwTyQ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream linux commit 4722c0e958e636. The returned "type" is never used in nand_scan_ident() and spl code Make nand_get_flash_type() simply return an integer value in order to avoid unnecessary ERR_PTR/PTR_ERR dance. Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mt7621_nand.c | 10 +++++----- drivers/mtd/nand/raw/mxs_nand_spl.c | 8 ++++---- drivers/mtd/nand/raw/nand_base.c | 28 +++++++++++++--------------- include/linux/mtd/rawnand.h | 5 ++--- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/nand/raw/mt7621_nand.c b/drivers/mtd/nand/raw/mt7621_nand.c index 9763ae6dc5..a4a0bce35d 100644 --- a/drivers/mtd/nand/raw/mt7621_nand.c +++ b/drivers/mtd/nand/raw/mt7621_nand.c @@ -1184,13 +1184,13 @@ int mt7621_nfc_spl_post_init(struct mt7621_nfc *nfc) { struct nand_chip *nand = &nfc->nand; int nand_maf_id, nand_dev_id; - struct nand_flash_dev *type; + int ret; - type = nand_get_flash_type(nand, &nand_maf_id, - &nand_dev_id, NULL); + ret = nand_get_flash_type(nand, &nand_maf_id, + &nand_dev_id, NULL); - if (IS_ERR(type)) - return PTR_ERR(type); + if (ret) + return ret; nand->numchips = 1; nand->mtd.size = nand->chipsize; diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 3daacbb330..773d375fc2 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -81,13 +81,13 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) { int nand_maf_id, nand_dev_id; struct nand_chip *chip = mtd_to_nand(mtd); - struct nand_flash_dev *type; + int ret; - type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); + ret = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); - if (IS_ERR(type)) { + if (ret) { chip->select_chip(mtd, -1); - return PTR_ERR(type); + return ret; } return 0; diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 9d8ccfda53..b4fa618dc4 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4276,9 +4276,8 @@ static const struct nand_manufacturer *nand_get_manufacturer_desc(u8 id) /* * Get the flash and manufacturer id and lookup if the type is supported. */ -struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, - int *dev_id, - struct nand_flash_dev *type) +int nand_get_flash_type(struct nand_chip *chip, int *maf_id, + int *dev_id, struct nand_flash_dev *type) { struct mtd_info *mtd = &chip->mtd; const struct nand_manufacturer *manufacturer_desc; @@ -4291,7 +4290,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, */ ret = nand_reset(chip, 0); if (ret) - return ERR_PTR(ret); + return ret; /* Select the device */ chip->select_chip(mtd, 0); @@ -4299,7 +4298,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, /* Send the command for reading device ID */ ret = nand_readid_op(chip, 0, id_data, 2); if (ret) - return ERR_PTR(ret); + return ret; /* Read manufacturer and device IDs */ *maf_id = id_data[0]; @@ -4315,12 +4314,12 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, /* Read entire ID string */ ret = nand_readid_op(chip, 0, id_data, 8); if (ret) - return ERR_PTR(ret); + return ret; if (id_data[0] != *maf_id || id_data[1] != *dev_id) { pr_info("second ID read did not match %02x,%02x against %02x,%02x\n", *maf_id, *dev_id, id_data[0], id_data[1]); - return ERR_PTR(-ENODEV); + return -ENODEV; } chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); @@ -4368,7 +4367,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, } if (!type->name) - return ERR_PTR(-ENODEV); + return -ENODEV; if (!mtd->name) mtd->name = type->name; @@ -4401,7 +4400,7 @@ ident_done: pr_warn("bus width %d instead %d bit\n", (chip->options & NAND_BUSWIDTH_16) ? 16 : 8, busw ? 16 : 8); - return ERR_PTR(-EINVAL); + return -EINVAL; } nand_decode_bbm_options(mtd, chip); @@ -4432,7 +4431,7 @@ ident_done: ret = nand_manufacturer_init(chip); if (ret) - return ERR_PTR(ret); + return ret; pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", *maf_id, *dev_id); @@ -4460,7 +4459,7 @@ ident_done: pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n", (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC", mtd->erasesize >> 10, mtd->writesize, mtd->oobsize); - return type; + return 0; } EXPORT_SYMBOL(nand_get_flash_type); @@ -4547,7 +4546,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, { int i, nand_maf_id, nand_dev_id; struct nand_chip *chip = mtd_to_nand(mtd); - struct nand_flash_dev *type; int ret; if (ofnode_valid(chip->flash_node)) { @@ -4560,14 +4558,14 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); /* Read the flash type */ - type = nand_get_flash_type(chip, &nand_maf_id, + ret = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, table); - if (IS_ERR(type)) { + if (ret) { if (!(chip->options & NAND_SCAN_SILENT_NODEV)) pr_warn("No NAND device found\n"); chip->select_chip(mtd, -1); - return PTR_ERR(type); + return ret; } /* Initialize the ->data_interface field. */ diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 8dc2d81dba..8178f36b49 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -29,9 +29,8 @@ struct nand_flash_dev; struct device_node; /* Get the flash and manufacturer id and lookup if the type is supported. */ -struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, - int *maf_id, int *dev_id, - struct nand_flash_dev *type); +int nand_get_flash_type(struct nand_chip *chip, int *maf_id, int *dev_id, + struct nand_flash_dev *type); /* Scan and identify a NAND device */ int nand_scan(struct mtd_info *mtd, int max_chips);