From patchwork Thu Dec 10 07:59:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 7817221 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D18BDBEEE1 for ; Thu, 10 Dec 2015 08:24:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2BC72056C for ; Thu, 10 Dec 2015 08:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EECAE20396 for ; Thu, 10 Dec 2015 08:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754477AbbLJIBM (ORCPT ); Thu, 10 Dec 2015 03:01:12 -0500 Received: from down.free-electrons.com ([37.187.137.238]:51024 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754447AbbLJIBI (ORCPT ); Thu, 10 Dec 2015 03:01:08 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 6723822A; Thu, 10 Dec 2015 09:01:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (unknown [37.161.176.221]) by mail.free-electrons.com (Postfix) with ESMTPSA id D9F5C1B0C; Thu, 10 Dec 2015 09:00:58 +0100 (CET) From: Boris Brezillon To: David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Hartley Sweeten , Ryan Mallon , Shawn Guo , Sascha Hauer , Imre Kaloz , Krzysztof Halasa , Tony Lindgren , linux-omap@vger.kernel.org, Alexander Clouter , Thomas Petazzoni , Gregory CLEMENT , Jason Cooper , Sebastian Hesselbarth , Andrew Lunn , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Marek Vasut , Steven Miao , adi-buildroot-devel@lists.sourceforge.net, Mikael Starvik , Jesper Nilsson , linux-cris-kernel@axis.com, Josh Wu , Wan ZongShun , Ezequiel Garcia , Maxim Levitsky , Kukjin Kim , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , linux-sunxi@googlegroups.com, Stefan Agner , Greg Kroah-Hartman , devel@driverdev.osuosl.org, Boris Brezillon Subject: [PATCH v4 03/58] mtd: nand: nuc900: create and use mtd_to_nuc900() Date: Thu, 10 Dec 2015 08:59:47 +0100 Message-Id: <1449734442-18672-4-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449734442-18672-1-git-send-email-boris.brezillon@free-electrons.com> References: <1449734442-18672-1-git-send-email-boris.brezillon@free-electrons.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create and use mtd_to_nuc900() instead of direct container_of() calls. Signed-off-by: Boris Brezillon --- drivers/mtd/nand/nuc900_nand.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c index 8148cd6..65908c0 100644 --- a/drivers/mtd/nand/nuc900_nand.c +++ b/drivers/mtd/nand/nuc900_nand.c @@ -62,6 +62,11 @@ struct nuc900_nand { spinlock_t lock; }; +static inline struct nuc900_nand *mtd_to_nuc900(struct mtd_info *mtd) +{ + return container_of(mtd, struct nuc900_nand, mtd); +} + static const struct mtd_partition partitions[] = { { .name = "NAND FS 0", @@ -78,9 +83,7 @@ static const struct mtd_partition partitions[] = { static unsigned char nuc900_nand_read_byte(struct mtd_info *mtd) { unsigned char ret; - struct nuc900_nand *nand; - - nand = container_of(mtd, struct nuc900_nand, mtd); + struct nuc900_nand *nand = mtd_to_nuc900(mtd); ret = (unsigned char)read_data_reg(nand); @@ -91,9 +94,7 @@ static void nuc900_nand_read_buf(struct mtd_info *mtd, unsigned char *buf, int len) { int i; - struct nuc900_nand *nand; - - nand = container_of(mtd, struct nuc900_nand, mtd); + struct nuc900_nand *nand = mtd_to_nuc900(mtd); for (i = 0; i < len; i++) buf[i] = (unsigned char)read_data_reg(nand); @@ -103,9 +104,7 @@ static void nuc900_nand_write_buf(struct mtd_info *mtd, const unsigned char *buf, int len) { int i; - struct nuc900_nand *nand; - - nand = container_of(mtd, struct nuc900_nand, mtd); + struct nuc900_nand *nand = mtd_to_nuc900(mtd); for (i = 0; i < len; i++) write_data_reg(nand, buf[i]); @@ -124,11 +123,9 @@ static int nuc900_check_rb(struct nuc900_nand *nand) static int nuc900_nand_devready(struct mtd_info *mtd) { - struct nuc900_nand *nand; + struct nuc900_nand *nand = mtd_to_nuc900(mtd); int ready; - nand = container_of(mtd, struct nuc900_nand, mtd); - ready = (nuc900_check_rb(nand)) ? 1 : 0; return ready; } @@ -137,9 +134,7 @@ static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { register struct nand_chip *chip = mtd_to_nand(mtd); - struct nuc900_nand *nand; - - nand = container_of(mtd, struct nuc900_nand, mtd); + struct nuc900_nand *nand = mtd_to_nuc900(mtd); if (command == NAND_CMD_READOOB) { column += mtd->writesize;