lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <MN2PR08MB5951A1DDC80445E917EAA32DB8140@MN2PR08MB5951.namprd08.prod.outlook.com>
Date:   Mon, 3 Jun 2019 12:43:23 +0000
From:   "Shivamurthy Shastri (sshivamurthy)" <sshivamurthy@...ron.com>
To:     Miquel Raynal <miquel.raynal@...tlin.com>,
        Richard Weinberger <richard@....at>,
        David Woodhouse <dwmw2@...radead.org>,
        Brian Norris <computersforpeace@...il.com>,
        Marek Vasut <marek.vasut@...il.com>,
        Vignesh Raghavendra <vigneshr@...com>,
        Boris Brezillon <bbrezillon@...nel.org>,
        Yixun Lan <yixun.lan@...ogic.com>,
        Lucas Stach <dev@...xeye.de>,
        Anders Roxell <anders.roxell@...aro.org>,
        Stefan Agner <stefan@...er.ch>,
        Marcel Ziswiler <marcel.ziswiler@...adex.com>,
        "Bean Huo (beanhuo)" <beanhuo@...ron.com>,
        Paul Cercueil <paul@...pouillou.net>,
        Frieder Schrempf <frieder.schrempf@...tron.de>,
        Chuanhong Guo <gch981213@...il.com>,
        "linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v3 01/12] mtd: rawnand: turn nand_onfi_detect to use
 nand_device

It is necessary to turn nand_onfi_detect to use nand_device structure,
to make ONFI related codes generic for all NAND devices.

Signed-off-by: Shivamurthy Shastri <sshivamurthy@...ron.com>
---
 drivers/mtd/nand/raw/internals.h | 2 +-
 drivers/mtd/nand/raw/nand_base.c | 2 +-
 drivers/mtd/nand/raw/nand_onfi.c | 8 +++++---
 include/linux/mtd/rawnand.h      | 5 +++++
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/raw/internals.h b/drivers/mtd/nand/raw/internals.h
index cba6fe7dd8c4..4dc9ae108fa1 100644
--- a/drivers/mtd/nand/raw/internals.h
+++ b/drivers/mtd/nand/raw/internals.h
@@ -141,7 +141,7 @@ int nand_legacy_check_hooks(struct nand_chip *chip);
 
 /* ONFI functions */
 u16 onfi_crc16(u16 crc, u8 const *p, size_t len);
-int nand_onfi_detect(struct nand_chip *chip);
+int nand_onfi_detect(struct nand_device *base);
 
 /* JEDEC functions */
 int nand_jedec_detect(struct nand_chip *chip);
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 6ecd1c496ce3..96a93481420f 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4737,7 +4737,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
 
 	if (!type->name || !type->pagesize) {
 		/* Check if the chip is ONFI compliant */
-		ret = nand_onfi_detect(chip);
+		ret = nand_onfi_detect(&chip->base);
 		if (ret < 0)
 			return ret;
 		else if (ret)
diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c
index 0b879bd0a68c..e20b60b8dd93 100644
--- a/drivers/mtd/nand/raw/nand_onfi.c
+++ b/drivers/mtd/nand/raw/nand_onfi.c
@@ -13,6 +13,7 @@
  */
 
 #include <linux/slab.h>
+#include <linux/mtd/nand.h>
 
 #include "internals.h"
 
@@ -137,9 +138,10 @@ static void nand_bit_wise_majority(const void **srcbufs,
 /*
  * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise.
  */
-int nand_onfi_detect(struct nand_chip *chip)
+int nand_onfi_detect(struct nand_device *base)
 {
-	struct mtd_info *mtd = nand_to_mtd(chip);
+	struct nand_chip *chip = device_to_nand(base);
+	struct mtd_info *mtd = &base->mtd;
 	struct nand_memory_organization *memorg;
 	struct nand_onfi_params *p;
 	struct onfi_params *onfi;
@@ -147,7 +149,7 @@ int nand_onfi_detect(struct nand_chip *chip)
 	char id[4];
 	int i, ret, val;
 
-	memorg = nanddev_get_memorg(&chip->base);
+	memorg = nanddev_get_memorg(base);
 
 	/* Try ONFI for unknown chip or LP */
 	ret = nand_readid_op(chip, 0x20, id, sizeof(id));
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index f5bb6f11c36b..87282beee008 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -1154,6 +1154,11 @@ static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip)
 	return &chip->base.mtd;
 }
 
+static inline struct nand_chip *device_to_nand(struct nand_device *base)
+{
+	return container_of(base, struct nand_chip, base);
+}
+
 static inline void *nand_get_controller_data(struct nand_chip *chip)
 {
 	return chip->priv;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ