From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEF61C4338F for ; Tue, 17 Aug 2021 12:24:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F9F361029 for ; Tue, 17 Aug 2021 12:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F9F361029 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zMebKTJIWRe1NARYmgoJxfM/vDgttyD0JQxKxZikY5A=; b=wLmup4XT5p4bMB Ip8kwUN8VZESXjb5d6X4n5XrSwgHY+0OiqZpPeazElg2tGb4TQriGzNegnMKQP/uQOo+kuNtL5JAp T+NB9cy9VSznQ/jVY3o0PAczMXsV7NeEWkXuZKBvKSI5vmvKAm8GHd1+BAZKgcOxIp/BOfxVZnEJY IzVoiAcmqWWRFiaRlzt3mxXpG01jzThw1au+yvmRXqRVrl+LEcZZ9Z2QJF9jI7Qj+wjIUVl9oNdBg LR1dIe+hK5FI60YQwy8AljEl+O7PN+VLRBIZXHALlHIp6P/FIlxCdO2sz+yCdgRg2DWZNYUGmvhzk pVFJQlcMvzpOBvKb2Guw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFy8X-002RTD-R1; Tue, 17 Aug 2021 12:24:10 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFy8Q-002RQr-VL; Tue, 17 Aug 2021 12:24:06 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17HCNdmZ045966; Tue, 17 Aug 2021 07:23:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629203019; bh=GPT2jfXdRO+ck3NAbPAqN4ncf+/nYbhK4HzC5BzxzPE=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=A25YTZyo2WvBmmlyQRAofJ97mhPYL9F6f2apLTaT3AcA14VLMf3D9gnq/8k2FCX/z X1M1Yb4hR2OqYyrAfYmff9Vjng0WR/AWlBJLSaNJE/ZF3tSvEBdbFfLXVBz8WDBQ5t iUxVtSTdbiETiYG2vF82ko2K3SEaBSH26+6Uw9/Y= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17HCNdNl080673 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 17 Aug 2021 07:23:39 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 17 Aug 2021 07:23:39 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 17 Aug 2021 07:23:39 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17HCNcNp038863; Tue, 17 Aug 2021 07:23:39 -0500 Date: Tue, 17 Aug 2021 17:53:37 +0530 From: Pratyush Yadav To: Tudor Ambarus Subject: Re: [PATCH v2 20/35] mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor Message-ID: <20210817122335.ci6ntkhmx4b6my46@ti.com> References: <20210727045222.905056-1-tudor.ambarus@microchip.com> <20210727045222.905056-21-tudor.ambarus@microchip.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210727045222.905056-21-tudor.ambarus@microchip.com> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210817_052403_162342_BB341589 X-CRM114-Status: GOOD ( 17.41 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: macromorgan@hotmail.com, vigneshr@ti.com, jaimeliao@mxic.com.tw, richard@nod.at, esben@geanix.com, linux@rasmusvillemoes.dk, knaerzche@gmail.com, nicolas.ferre@microchip.com, michael@walle.cc, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, code@reto-schneider.ch, miquel.raynal@bootlin.com, heiko.thiery@gmail.com, sr@denx.de, mail@david-bauer.net, zhengxunli@mxic.com.tw Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On 27/07/21 07:52AM, Tudor Ambarus wrote: > Get the pointer to the containing struct spi_nor by using container_of. Please add an explanation on _why_ you are doing this. I suspect it would be something boring like "because mtd is embedded in nor, no need to use mtd->priv", but good to have it here regardless. > > Signed-off-by: Tudor Ambarus > --- > drivers/mtd/spi-nor/core.c | 1 - > drivers/mtd/spi-nor/core.h | 2 +- > 2 files changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > index 9885d434ea83..5c8cffb5e6f2 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -3175,7 +3175,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, > > if (!mtd->name) > mtd->name = dev_name(dev); > - mtd->priv = nor; > mtd->type = MTD_NORFLASH; > mtd->writesize = nor->params->writesize; > mtd->flags = MTD_CAP_NORFLASH; > diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h > index 987797a789c8..8fddc685d2d3 100644 > --- a/drivers/mtd/spi-nor/core.h > +++ b/drivers/mtd/spi-nor/core.h > @@ -557,7 +557,7 @@ void spi_nor_otp_init(struct spi_nor *nor); > > static struct spi_nor __maybe_unused *mtd_to_spi_nor(struct mtd_info *mtd) > { > - return mtd->priv; > + return container_of(mtd, struct spi_nor, mtd); > } > > static inline void snor_f_4b_opcodes(struct spi_nor *nor) > -- > 2.25.1 > -- Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/