Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp399563imm; Fri, 31 Aug 2018 03:35:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYnWkRK+uTahznErtQwDnFwx6ZIjuqMblrES1eQyV5/amgmIDAeAK6zZ6Y1SJKmY7MSscJE X-Received: by 2002:a65:5189:: with SMTP id h9-v6mr13895062pgq.13.1535711732642; Fri, 31 Aug 2018 03:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535711732; cv=none; d=google.com; s=arc-20160816; b=V+vJj+6/wtW6arEFa8bwmHf+FgMEEbvu7aX6M2FAT/1GZbyWeX8kNHUXcQtgVxXBm6 AtuZtNq7FByhDgn+XeF8eIkgzeIx1Wf6cL/aYRs9GtHBatsxIUfBDQTLrJVToGeJA0y7 ITF9zB4KM6ZYZ+GEdiPrZowQNVJjPJgEF71+FqOcuymY9sBwVANWVJf45QnIxER7yvnd EA6KMQXk0xoah51rvHFFpxkI2hvJkxiCY2XgeGZvB/98cmsR8/C3bvWeptsNSo7RtabE HIC/awI2gjwTj3R93xl9ZQA5UiwmDU3HcMJs5vL2az6dgQ+N/tb4PvB14IZZJcwV9Ap3 hIKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kGHasaR5g3WpOQjTgENxMdhTIk7CmIBT1snjoOPzrJA=; b=suxZwfTLL9fGfcB/W3RW1Ipxt9Y85qYjwR4PzbLCXlAVPFc1GALbb0gwj9PaEL70aZ BPNpSNeYDWuOaytNv29BngGMHO35kMVni/aRwT9SIE5zzwGr9c1eX07gb3HTTF6cgQ81 D2/gLpi4KXrl8inaskL7TzhwVGHbVCTgnEtRB635uQkH2qZsjbF56mbmTZkEX/cNToig VBfNZ/3OSD13iwptnD6MF2VTqcBv6AjRaM6fO3p7x0xETLO+EBssZNOvbPYYkaelm1Dl CZJmjsPT9pF9yvb06tiZ5jBxaleO+g8dO0I4/uea0HCVPeKqNUXPbGtuZGdQw/WHTPBW 5YsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=MS97uu7N; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj4-v6si9161610plb.119.2018.08.31.03.35.17; Fri, 31 Aug 2018 03:35:32 -0700 (PDT) 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=@nxp.com header.s=selector1 header.b=MS97uu7N; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728334AbeHaOiy (ORCPT + 99 others); Fri, 31 Aug 2018 10:38:54 -0400 Received: from mail-eopbgr30057.outbound.protection.outlook.com ([40.107.3.57]:60224 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726493AbeHaOix (ORCPT ); Fri, 31 Aug 2018 10:38:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGHasaR5g3WpOQjTgENxMdhTIk7CmIBT1snjoOPzrJA=; b=MS97uu7N6CxIooUZfKz2UbYJVDdZPDzmFqKXO9za0cn8CezBIPFop/7RsK14OhocoqacvJNVVjeadoa/bvWCnpQyUvCtQNhI90TEmCmnbLP6+ClAxPevCxPTaYfRgYIo6sLO3q0AsmhAv0GaoeQQfI0J7jbh60Uw4rpcR4/s0Ig= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yogeshnarayan.gaur@nxp.com; Received: from idcbfarm.ap.freescale.net (14.143.30.134) by HE1PR04MB1034.eurprd04.prod.outlook.com (2a01:111:e400:581a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.16; Fri, 31 Aug 2018 10:31:54 +0000 From: Yogesh Gaur To: linux-mtd@lists.infradead.org, boris.brezillon@bootlin.com, marek.vasut@gmail.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: robh@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, computersforpeace@gmail.com, frieder.schrempf@exceet.de, linux-kernel@vger.kernel.org, Yogesh Gaur Subject: [PATCH 1/7] spi: add slave device size in spi_device struct Date: Fri, 31 Aug 2018 15:59:58 +0530 Message-Id: <1535711404-29528-2-git-send-email-yogeshnarayan.gaur@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535711404-29528-1-git-send-email-yogeshnarayan.gaur@nxp.com> References: <1535711404-29528-1-git-send-email-yogeshnarayan.gaur@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.143.30.134] X-ClientProxiedBy: SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) To HE1PR04MB1034.eurprd04.prod.outlook.com (2a01:111:e400:581a::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49757ddc-4756-4f89-c5ea-08d60f2cfbab X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:HE1PR04MB1034; X-Microsoft-Exchange-Diagnostics: 1;HE1PR04MB1034;3:UC9hQKX3ihY/+qKJ0Mw999baZzIssmO+7aBxugJtse/CRsfCN7p9bMEmhK2FJemca3SKb8KmovdnuEABwvLRlWU9ZZLvgDQ0RFIGVeu+qtHJ4ZTvxhFtFH/PQYYAFO+NHKmIS45xyRt4AebL2XFM47IAd7Qt7blWIh5Uk/LIzqfhzJC1hiPC5/KVFaA6p3eurfc921EA4bm2uh+TxQOlF1YESD/zBUzIKhXp8sVXGsj8bODdVQDEQGiXLYdTBzGK;25:F1crNceLY1S1+5mvcOYocKWJwMVK0mE52L3run10rO8BsXt9KGIYmfjt9SnaqfkgWebbe3xHiAUneAld9gtXVmb+oHCENXeAFVT7/2yZLgm7y40zvsn4dwiXgd66g/+jVsbDbXwkx4yjeNeIJNRnIOzKmjJWAMKSL8nXj671fyvqgKAtX+IQI9E3BZHPtga3NfqDUzOFJrHLrnqCafv19v/p4Kh/SHgtfqMWWcC2Vgl+0fyycFwLFSg+CW4+Okdsc8w6BvzxjmTzgh64ToJZiY2pom9l4UgKWY8n8DPlY5DFxZzOdMn7hbI7IoE9kf4U+0TrKq036J6lWGlrMWyDOA==;31:nl6qxbYjbm3XZv02osruH3LFSTcnJpCaTq8gQ9taqHAZQb3lA2c8hBARk5G6pMdAPPs0ynuXlAQviWm3bCuW9kzbijA1p6gIyC6TWmOtigE+8LTs/+A4j9P0SXCby229tOFve38dPIMO4d62tUhsY2hL2MJbfHjUaunqyM1sAy3hT8wam8z88CuX/A42GbUi6l8tIQW64OnONre0akJc6HkkmtJT+Ph/voc6iEvc7tE= X-MS-TrafficTypeDiagnostic: HE1PR04MB1034: X-Microsoft-Exchange-Diagnostics: 1;HE1PR04MB1034;20:0zjGdKr47bhau3okowKvDk53x6TMiyrEgq4rg0h8CJhf3VPVHGTsTOtiLRFcfYeEk6gaZF3xESLSPg0WpTOjdEPfOHgH4zuWTdHdGZ5Yw7pAk3nyAqXVsbcn1Gqe+EPZxoydh5etV79Cl5MjY3Pre8IRh4EqRXIRGaBJ3EP74igPPShmPAbehin9VBuZjvEOrcKtVQ/cgrUp/9TtUwj2JUgjhGAFblkuPQeo7iRwpddwCzvxCD5GZlhHuQF6dsxNyZQAZ2q6DeEzAyaja1UnhoxYvx5JT2VSpDkK0Q1BC/1o0PPxS78iP9g8rYEUN6EhQkQ85Gr13LEvTaJrL/1GKw2ERNsRkbID8RI1R1aVzqXncB9/O2HbnlD6HSCL59jPg54Y5NOjNYCRPhUkJkareZSi7d7QZHw/wcsNPK6N1Hr8bNA9/8ZyiZJtFe+dFiE+WvE5ov0QFj+X+8umDCtaLx0nldWw0gS+0y/8JgIE3qLwgb9cmrFqy8f9Mnvz8pId;4:vruKJuV1y6+ebkAMgTV4VAXICYUXKzOVdtClFJ6xO5CQ8fXHwSWt4yb0J1MhX8ZDOGJ2WBKIqwmT9DhKHvGkBLbeoilU3pfqm7Mi26A9pSC4pX4AiG68Zc7+WydkI5wOSV+YDp4fvYkE8eRpzjtlu6GeK8AN6v+DjNf95R2uCnwIz+/3zr1WwpXf3LKcILAo4dUpwVIT6nbpQtKbalcyiyHX3F1zmjW8DQ4YuDSa0vXw+sRU7eQMgib7gy7+FlkMQcIBWEiwG9X6GjPanXroGChNKd0QtaGNoQ86JAPJcPVkZUvNrS5rJexzBav4WUMh 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:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:HE1PR04MB1034;BCL:0;PCL:0;RULEID:;SRVR:HE1PR04MB1034; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(39850400004)(376002)(346002)(366004)(136003)(199004)(189003)(48376002)(7736002)(7416002)(8936002)(105586002)(5009440100003)(52116002)(106356001)(51416003)(55236004)(386003)(6506007)(81156014)(81166006)(76176011)(2906002)(86362001)(3846002)(186003)(50466002)(16526019)(6116002)(305945005)(26005)(6486002)(66066001)(47776003)(25786009)(36756003)(5660300001)(97736004)(8676002)(53936002)(6512007)(50226002)(14444005)(316002)(39060400002)(68736007)(486006)(4326008)(16586007)(11346002)(478600001)(446003)(2616005)(476003)(956004)(110426005);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR04MB1034;H:idcbfarm.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR04MB1034;23:li6vmjADdXr3zBWzy4CNL+uxONRwrmlLS6xAopXWY?= =?us-ascii?Q?+ESYc5Otk87hUDwp07TQ+XoSG4uSQnfRcwz6/4Olsr6Mi/7I2Z906CHkhb/b?= =?us-ascii?Q?maPmZKMxN10EQkMRux7cNd3uLop2In9upg8eoSJzof3B1FK4MNfkYXdI+ee/?= =?us-ascii?Q?2ka0BaDpE8iJjA5E8V2eEkJNqE+bUmgSU38MRuP8kj2UScvJL9VCk4be/o8d?= =?us-ascii?Q?hFZplSXBdfvMrYKUzp9TcpQamqADPdD8cTpCojQdYBxnIqcmusISQl2YEqw2?= =?us-ascii?Q?1BM6UoptfIZvsqVw2x17z/gIFxgNRuRporuB3Qq1xHaom3ys9U/PFhFo/hAe?= =?us-ascii?Q?Bon1oRH9mY5/ZZw8C3imO3he+v7zeq4oRYtmETSr2R8MBz00VufYxB+NPWt1?= =?us-ascii?Q?DguePDEuV1IEP7b2fl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Ii246K1575SesKJLKdfPSxF0e9ZUV3LE4UeHFHdBB56K+BfmjHZBf0BNTL2FdMpsqHUqEl/mdvSZhL0UIEfpSPvyWeQZ282HUZY7ZoB5nAHfb1FE/P3imBn7hcFcXG9BMOaAxsduZh5xAyqL3Ln87aN4cWC+quj4Qg/31RACsUoVnWh5soBiBF6KhYGRBmfOxSJz95dApGc7cI384Ey5VOY3H8uHNgpL6AlV7LhV+M4ISGrdtSQrucEI7s SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 10:31:54.9195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49757ddc-4756-4f89-c5ea-08d60f2cfbab X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1034 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add 'size' data variable in spi_device struct. This is to save the size of the connected slave device. After slave device scan, spi_nor_scan, size being assigned to this from MTD layer. SFDP read is being requested before completion of spi_nor_scan() routine, thus populate device size before making read request to the SPI controller. Signed-off-by: Yogesh Gaur --- drivers/mtd/devices/m25p80.c | 6 ++++++ drivers/mtd/spi-nor/spi-nor.c | 2 ++ include/linux/spi/spi.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index fe260cc..6c7ad86 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -124,6 +124,10 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, /* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8; + /* for case of SFDP header read commands, populate spi device size */ + if (flash->spimem->spi->size == 0) + flash->spimem->spi->size = nor->mtd.size; + while (remaining) { op.data.nbytes = remaining < UINT_MAX ? remaining : UINT_MAX; ret = spi_mem_adjust_op_size(flash->spimem, &op); @@ -215,6 +219,8 @@ static int m25p_probe(struct spi_mem *spimem) if (ret) return ret; + spi->size = nor->mtd.size; + return mtd_device_register(&nor->mtd, data ? data->parts : NULL, data ? data->nr_parts : 0); } diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 6042df8..b066bed 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2864,6 +2864,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, if (info->flags & SPI_S3AN) nor->flags |= SNOR_F_READY_XSR_RDY; + mtd->size = info->sector_size * info->n_sectors; + /* Parse the Serial Flash Discoverable Parameters table. */ ret = spi_nor_init_params(nor, info, ¶ms); if (ret) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index a64235e..558aeed 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -127,6 +127,7 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats, * for driver coldplugging, and in uevents used for hotplugging * @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when * not using a GPIO line) + * @size: size of the connected slave device * * @statistics: statistics for the spi_device * @@ -168,6 +169,7 @@ struct spi_device { void *controller_data; char modalias[SPI_NAME_SIZE]; int cs_gpio; /* chip select gpio */ + u32 size; /* size of slave device */ /* the statistics */ struct spi_statistics statistics; -- 2.7.4