From patchwork Wed Jul 27 09:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2263 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 282E33F1F7 for ; Wed, 27 Jul 2022 11:37:55 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id sd24-20020a1709076e1800b0072b582293c2sf4895693ejc.0 for ; Wed, 27 Jul 2022 02:37:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914675; cv=pass; d=google.com; s=arc-20160816; b=GxS5/8UJ/fPZw0YYdsDy3oH+ZHmnMEtvYV7zqZuDeY2J0YspbXw6CYRjomk4KxbW1W naq1oXUbwjfl4EltIG4D56VBk2lE92CBbrfXhgfVaGuFHmxi7hsViecmqu51imEfWxJO lZNVDU4cVgvrvRAHKqzwO7u1Mm9daSs5EfFRtm9sDPkDwSysa4+fV7RYbrP0j3gUzwo2 09cjQf40jTUtsJThu+mUsFtfIxV6C6Drd6BTwNL3KFqhquvply47qTqJ8zaof0WNxeIz E6f2aCRlxuzTzXli1hf5XCbZRJRrMpt16fvKOeR7ZXbTkRLb/npcq8VQi+PYbVF98VEo oozQ== 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:to:from:dkim-signature; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=exP4TxS//h4HaRbb5MFp/papGoe/065KjxN1ts/II0D/fuonuBPRzkq1LrJ/INlDXM 9tS4BdXc1iFJ89xgp4DaRxMhOtUpPU4ta38aQufh+Lab6HSr4CUDghmUr/jRUU3RbpHL zS90XPjxg3Jp+WIeYK8nq5wvpI0Qs5OOJyGXUYZQ6nqyh/Yr3DM/7h1FJYnrGnOkcwMt 2o/8Rd0J9J3+tt9ulSbibyJ9U3nqmQx65z7xpgmiFojxv9zF5ypeswGkOdjWCUIu7Nc5 n/2049RGTwLJaWTjXrUU/Tt0lcTgySYLduev7kAfEip6XDzCN+kHgCgpDJNDD/abOV8p 5qJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O2y1jS1V; 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: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=JqWB07uH7112FUaRMy8PdvsnOhfiuXk3rv6Kfqfxr6JOt1ic742YfZ53uszNN/KvsZ cl63ioIzJUXjV8PjD7n8xW7rohsRJBtoaCuMiCxRKKttXot4zfKYJeNXhHVuPcZ2NLB+ Ja6m/vn6OttmsSVIoaG1S5o9cihLPYagT9C9Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to: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=7f2mH1drEBrEteEYxfS05gZd17lt5YmYDobfRyjfvOItsTSW4GxR69TdAavXuw7aDJ mlN7k3+0Gvot469b+EhLgONPsnYwLbotu974aG83Q5/FpCkW1LA/F0tRQDmBHnpbaNaf UCpgi9UcQm2U91X/+ozJAArCVBzFiSkXdWvMJ2u4laA6Zs/Hby2SSTRIu0mDzHvUg5Hy k6hq07/vp/Ipel6JgSZCfTjZPLJ0a7TseesVATzaVUYqBUuLft3zbBnH8J56H7W1mdRj /KmQxpiVI0LauueiBLVNdeZj1svH6MNMTPlUo12ojgzIuCOfpMt/MyZ2v1Y/7cahxzTk VsTA== X-Gm-Message-State: AJIora8zy645KGqNMN70eTz6ZZLdZ/xdwZ0pwY0NmP2th31ajuFnE2Tq NWWHsazgKskJceJOL5tLlBja3zYk X-Google-Smtp-Source: AGRyM1uU29bisLxOZUZ1AXoZdzV3qJM6UC0GcbGhd4okIMmrdUMMceBiBcD8S8Nz7za4dgmvg8lh/Q== X-Received: by 2002:a17:907:6eac:b0:72b:4c75:28fb with SMTP id sh44-20020a1709076eac00b0072b4c7528fbmr17286372ejc.675.1658914674753; Wed, 27 Jul 2022 02:37:54 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:7256:b0:72f:6ce5:d858 with SMTP id n22-20020a170906725600b0072f6ce5d858ls1897460ejk.4.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) X-Received: by 2002:a17:906:7308:b0:72f:3294:8001 with SMTP id di8-20020a170906730800b0072f32948001mr16734616ejc.254.1658914673414; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914673; cv=none; d=google.com; s=arc-20160816; b=JHTfjweDH82ql/TqqHDVRS2+ZBg1eLHFvZqGsRHADLsKf61q/BGH1UK5hhi2GfRdKh cuCSYOfPcnqFwHT7kKWz0hE4KRufJHD7PsvM8SSlaXvC87I0oX0MQgX7M110vHVMYNVa ME5PcUhlPGCMfitGBlwVgRAGChiixAQzwX+cxJDvTBhs+d7pxV29ri3YGwYrNQ0redHX WsHksn11/aw4SvL1OgQzS7hm/+yjNYnCDpA3d2pdWszT72ibOtrUA5ggMGkeCDU8ibg4 xcFpbTZke7z0ea85oSw8ZJjfOzydF+zWvGrpNl2lAJb7M759M55sNl/fTAVjTKEYKCGN mSKw== 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:to:from:dkim-signature; bh=MNpcuzewDZbHWetPCMtSq+7NxdT3aCHxDyE39RwXta0=; b=XliI9QbZwvcS6RXWBrUSvH4WGQ+dlaTVFiaf8PQtb5Rc1dXSLmyUwTUcCx5GtiP0ZT PPEvDkziWHLfDUF3WmOdRyLgHB8zq/x4HJi6HOF1nPu/7sCmYAwNXX0yKMp8T6J5o4u/ +nGC7wKQOxcQL1J0qTmOTbPck/v+rAEVpmenREN4w1qafE4MBoz9nPwI6nBNicjv5rTV Xpkom/8Oh3DVqdBA0wvitccFgYklGzx0ksSgncABVwnra/Y4YbtjHmZeRxy0Z9OE4Oxn DpLDtUU6G6SN/Sq3yziAZK/hRkoKGd2/FQIQYRqlAsBGDNbwduzCQph7Prx8cQ5Ded2r FBMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O2y1jS1V; 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 z29-20020a50cd1d000000b0043a86563d8esor8141252edi.0.2022.07.27.02.37.53 for (Google Transport Security); Wed, 27 Jul 2022 02:37: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:aa7:d943:0:b0:43b:9010:9d86 with SMTP id l3-20020aa7d943000000b0043b90109d86mr22270988eds.34.1658914673048; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:52 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 2/7] mtd: nand: change return type of nand_get_flash_type() to int Date: Wed, 27 Jul 2022 11:37:43 +0200 Message-Id: <20220727093748.1415135-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-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=O2y1jS1V; 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);