Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp975515imu; Fri, 9 Nov 2018 08:58:55 -0800 (PST) X-Google-Smtp-Source: AJdET5f7mljUSaA1BWj0R8mDO6FkhEbXZCDd7kWYeShIcvJ2VSwjw3lkNR9vlWk3B8doISB1YvtW X-Received: by 2002:a17:902:4827:: with SMTP id s36-v6mr9368991pld.226.1541782735847; Fri, 09 Nov 2018 08:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541782735; cv=none; d=google.com; s=arc-20160816; b=uz6QeI/Qfv7U3j4vwapqdIEPASUFEnrF2h9gcxpGzqIKG38mO9bW4PMwXZnQJQfCiD n/62KLGYhjqNzEfgRNhLBs8Rpf6jN6D828MTdDbNxgpcTsokqaeQJ36h5PgnbsKdyVm3 HPlFTHMriYOFxjjkjCJkG5ayHDzbctsS7eiUtikzDFNzqi0+WxMbKwWyWBH6i0yOQWrN nEH1mOLp/N9QG3a6FkktR3Up1H1CeYWS/gVSajfgi+qFOg5cjkGy31forcu7Ejuitu7R wQDvaatX+ucFKe6AD9UGIV+WeZW+TYrldFvcadTICsXNjaS4Yiz1HqZC1J8sa9k4Igb/ mt2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=pBBSzEe9gydsLeyDawc+cy8G49k0qpYgoa87pCEfNS4=; b=j7RD3UE8e01Nn1JM3rdAsEEl/62xO4adx96WQ3M1267FCmMH1RkdwcUd1ib2zyVuL3 hF0Ij1usVjKfcH7RDi2OmySYnOqjwwtIusr+R2fIMkvElDUjb6zsuMFyrV230BTBfPds 7lL7HRRjvW4/OkJ/fOW4btnjMuXaITB2udzJpr325Vn3K2l5tFEXoTeXAi5FIK9vsOv+ fxetJs+mo94VwY2bGwkhq1HPzEYDmjd2T29Va4p1RmjLlTI7yHlDi2oKgwdWI+vvCJNi JE7MjKmLuCY6lm3RZs7GAhePv3Ulf8aHoJwOEL+MsJ3WyaBhpP1N5MLGt+PQp5gCidK2 ZPug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchiptechnology.onmicrosoft.com header.s=selector1-microchiptechnology-onmicrosoft-com header.b=0B9CcOvf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p76-v6si8732375pfj.244.2018.11.09.08.58.36; Fri, 09 Nov 2018 08:58:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microchiptechnology.onmicrosoft.com header.s=selector1-microchiptechnology-onmicrosoft-com header.b=0B9CcOvf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbeKJCiS (ORCPT + 99 others); Fri, 9 Nov 2018 21:38:18 -0500 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:35767 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbeKJCiQ (ORCPT ); Fri, 9 Nov 2018 21:38:16 -0500 X-IronPort-AV: E=Sophos;i="5.54,483,1534834800"; d="scan'208";a="22610343" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Nov 2018 09:56:51 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.105) with Microsoft SMTP Server (TLS) id 14.3.352.0; Fri, 9 Nov 2018 09:56:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pBBSzEe9gydsLeyDawc+cy8G49k0qpYgoa87pCEfNS4=; b=0B9CcOvfFPJyR3KDxeytfhicRS3Ts9GF23vw5/1p/jprrtt1qaWDWHPEnwtfmk9sWlB67ABdanQ0rDcn6jC+ZQaHeMTpi2PAZ+dxkrxLM6XZoKweFjrejsvfSDWM9CPLcp8JnuDlHupx92WYXvAd5p36X1vpYQ+tOulgP9vg+p8= Received: from BN6PR11MB1842.namprd11.prod.outlook.com (10.175.99.146) by BN6PR11MB1905.namprd11.prod.outlook.com (10.175.100.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Fri, 9 Nov 2018 16:56:48 +0000 Received: from BN6PR11MB1842.namprd11.prod.outlook.com ([fe80::11b7:21db:803a:7cfa]) by BN6PR11MB1842.namprd11.prod.outlook.com ([fe80::11b7:21db:803a:7cfa%5]) with mapi id 15.20.1294.034; Fri, 9 Nov 2018 16:56:48 +0000 From: To: , , , , CC: , , , , Subject: [PATCH v2 1/5] mtd: spi-nor: don't drop sfdp data if optional parsers fail Thread-Topic: [PATCH v2 1/5] mtd: spi-nor: don't drop sfdp data if optional parsers fail Thread-Index: AQHUeE00AxQBHvrBzkKb1srph+UtJg== Date: Fri, 9 Nov 2018 16:56:48 +0000 Message-ID: <20181109165644.30534-2-tudor.ambarus@microchip.com> References: <20181109165644.30534-1-tudor.ambarus@microchip.com> In-Reply-To: <20181109165644.30534-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR07CA0231.eurprd07.prod.outlook.com (2603:10a6:802:58::34) To BN6PR11MB1842.namprd11.prod.outlook.com (2603:10b6:404:103::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tudor.Ambarus@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR11MB1905;6:X6S7o0/mx1ak3AXtlzbNJ0okp4THbuPR4Yl+eIPxBIWyAP56z+o62LM9OyIWXfByxQMWvEKY89E20dWPwvZJr3gE/ldm4wyiD6WRPowVFlOKVZcAFMP8I16nRFqAgv8Tg2ItxUfJmhEs0II7bIRVH/YfTcHe30aD0yp8ko+cZtCDyjYV4UnRD4pteJoQFN1B9sTwe+c63qKqSVvlTOrHN9U5uV5nFxmV2yQPTtNuGAkNvS5joTP84u68I2HiMD0fmid1qAD8/1DHc6fdNPbrcv1SNhJNoGBY8XIudll8e1ooy0oHwD8EvOTu4dNVtoxnMMWYoSnQsgMSOO7qk/+I5OqDfp7Nt14HhA+Zr4Weu9YLAu5Ff5cwidhUYZ0yHypZnsh+cjCVpcTRfSRk+UrEWD7HFgZom/9AWT7bebRIe7p77KrYe+yGoRKs6tNfQe+/5FNGuKZYArBgi93jDjelsQ==;5:kfQ5XVFdQcmy9UNpHzboHpGCmYvxnsPzWb5N3t3ba2TxmcXUuyjSeWZjmj3pDP4PGQq8fS/d+r1l/lSfF68j0vhmhGbzTmfsJeODOmTWPSMJdYzclSpOkV0UZrhBWz1IXlPmEpGvfwzWMHWfMmQr6/osNo/hQbilGm02F/58G8w=;7:qa8aHhpyernTJ5m3HQ7Urb43XkIxptYp0oLUaOTDX6k7Q1zTYUpfcvKnLHIMgDfIQLyV7EpVv2JB0Gn6Nr8SS8TpBs3f0EIh/vKnfVN5qbB45dl8yE1krE1UidoKVWmJU5mAekhN6dOK2yuTITUM+w== x-ms-office365-filtering-correlation-id: eee4182f-ab9d-445d-1450-08d6466456bc x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BN6PR11MB1905; x-ms-traffictypediagnostic: BN6PR11MB1905: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231382)(944501410)(52105095)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:BN6PR11MB1905;BCL:0;PCL:0;RULEID:;SRVR:BN6PR11MB1905; x-forefront-prvs: 08512C5403 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(376002)(39860400002)(346002)(136003)(189003)(199004)(6486002)(8936002)(68736007)(3846002)(81156014)(486006)(8676002)(316002)(71190400001)(2616005)(110136005)(6116002)(11346002)(14444005)(256004)(86362001)(66066001)(2201001)(39060400002)(186003)(446003)(102836004)(54906003)(71200400001)(7736002)(305945005)(14454004)(81166006)(6436002)(5660300001)(2501003)(97736004)(26005)(2906002)(1076002)(476003)(72206003)(76176011)(4326008)(99286004)(6512007)(52116002)(478600001)(386003)(2900100001)(105586002)(25786009)(106356001)(107886003)(6506007)(53936002)(36756003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1905;H:BN6PR11MB1842.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: VzEtzmAmIJvKeBK0mCrCt4BRezl2MuVbyvL1nUY7M6u0glGry/s0qHgx/mm72OnUb+ypUQxnVQ0MRiKlIPif0p+P3Pqo8a4c+nqmNX9Lc9PpNHr9zClTGI++/pFJCOSMLBgWRQhR+TvJnQHGV5o9DNm1SU/DEsR8zrpJB9QDt9kSp5q03nJG/R3iCgKKkHOT5MmtG62HMgdVtgQBtya0UaYa7qaSvslODbNVVLYm9KnUDH5/79FiDvrAiih+NnqYeMVEgcWnlMhIodCyzFcycp+NjHNl3NGK0v6fGYaNMao5FWMKi5pfGAXmvOxZzPUDf3f7K8Cibl8vnVkYxsnAXD1gWfyw7tBXhvtoDmBEHJs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: eee4182f-ab9d-445d-1450-08d6466456bc X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2018 16:56:48.7446 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1905 X-OriginatorOrg: microchip.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org JESD216C states that just the Basic Flash Parameter Table is mandatory. Already defined (or future) additional parameter headers and tables are optional. Don't drop already collected sfdp data in case an optional table parser fails. In case of failing, each optional parser is responsible to roll back to the previously known spi_nor data. Fixes: b038e8e3be72 ("mtd: spi-nor: parse SFDP Sector Map Parameter Table") Reported-by: Yogesh Gaur Suggested-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- v2: update Fixes tag to point to correct commit drivers/mtd/spi-nor/spi-nor.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 4a96ee719e5a..2cdf96013689 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -3130,7 +3130,7 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, if (err) goto exit; =20 - /* Parse other parameter headers. */ + /* Parse optional parameter tables. */ for (i =3D 0; i < header.nph; i++) { param_header =3D ¶m_headers[i]; =20 @@ -3143,8 +3143,17 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, break; } =20 - if (err) - goto exit; + if (err) { + dev_warn(dev, "Failed to parse optional parameter table: %04x\n", + SFDP_PARAM_HEADER_ID(param_header)); + /* + * Let's not drop all information we extracted so far + * if optional table parsers fail. In case of failing, + * each optional parser is responsible to roll back to + * the previously known spi_nor data. + */ + err =3D 0; + } } =20 exit: --=20 2.9.4