Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0B83C3DA60 for ; Thu, 18 Jul 2024 08:36:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F39CE88B51; Thu, 18 Jul 2024 10:35:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=salutedevices.com header.i=@salutedevices.com header.b="ASSNWXQI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D057884AC; Thu, 18 Jul 2024 07:46:26 +0200 (CEST) Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2CC1F88A68 for ; Thu, 18 Jul 2024 07:46:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=avromanov@salutedevices.com Received: from p-infra-ksmg-sc-msk01.sberdevices.ru (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id B82D3100020; Thu, 18 Jul 2024 08:46:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru B82D3100020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1721281583; bh=JDelhVXodeE0FVE0h9jqMuwmNCSW24hIqfQ2KPgcans=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ASSNWXQIRiMUlr0zamN4ZAcVBYBlNDKZQogqscsfWfCX6chqS9OhB1AkoLse61Jdl EVruQAy0fvYEII7DsKNuiIiKLl7NJSOTxs/7ut6Hzaar16zadLLmqIuPjn47j0pty0 cJ+D2LuUfi0i9DhMcrfwfP745p4igHn264CKelQgQ/K8pR+mC6wLl8/wZ/7pHzsnrM AywpW/KnZPqukzEeFmHK1NbkopDkF9Uv9KCb47MCiAn/2qTfsGmydTb6GJhvVl9Pkb MS7ovDEjY6ctu+bfKFuDWwzkziXd7Ejy1/V2TcKIUQ+BMA7JF/1iM7FaDIpQ1cLfVB zQEGaZaLzltNQ== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 18 Jul 2024 08:46:23 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 18 Jul 2024 08:46:23 +0300 From: Alexey Romanov To: , , , , , , , , , , , , , , , CC: , , Alexey Romanov Subject: [PATCH v7 3/3] spinand: bind mtdblock Date: Thu, 18 Jul 2024 08:46:06 +0300 Message-ID: <20240718054606.799665-4-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718054606.799665-1-avromanov@salutedevices.com> References: <20240718054606.799665-1-avromanov@salutedevices.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 186573 [Jul 18 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: avromanov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 24 0.3.24 186c4d603b899ccfd4883d230c53f273b80e467f, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; salutedevices.com:7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/07/18 03:46:00 #26059015 X-KSMG-AntiVirus-Status: Clean, skipped X-Mailman-Approved-At: Thu, 18 Jul 2024 10:35:04 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Bind SPI-NAND driver to MTD block driver. Reviewed-by: Frieder Schrempf Signed-off-by: Alexey Romanov --- drivers/mtd/nand/spi/core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index ef50237f10..54a90ff295 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -33,6 +33,10 @@ #include #endif +struct spinand_plat { + struct mtd_info *mtd; +}; + /* SPI NAND index visible in MTD names */ static int spi_nand_idx; @@ -1172,12 +1176,25 @@ static void spinand_cleanup(struct spinand_device *spinand) kfree(spinand->scratchbuf); } +static int spinand_bind(struct udevice *dev) +{ + if (blk_enabled()) { + struct spinand_plat *plat = dev_get_plat(dev); + + if (CONFIG_IS_ENABLED(MTD_BLOCK)) + return mtd_bind(dev, &plat->mtd); + } + + return 0; +} + static int spinand_probe(struct udevice *dev) { struct spinand_device *spinand = dev_get_priv(dev); struct spi_slave *slave = dev_get_parent_priv(dev); struct mtd_info *mtd = dev_get_uclass_priv(dev); struct nand_device *nand = spinand_to_nand(spinand); + struct spinand_plat *plat = dev_get_plat(dev); int ret; #ifndef __UBOOT__ @@ -1217,6 +1234,8 @@ static int spinand_probe(struct udevice *dev) if (ret) goto err_spinand_cleanup; + plat->mtd = mtd; + return 0; err_spinand_cleanup: @@ -1286,4 +1305,6 @@ U_BOOT_DRIVER(spinand) = { .of_match = spinand_ids, .priv_auto = sizeof(struct spinand_device), .probe = spinand_probe, + .bind = spinand_bind, + .plat_auto = sizeof(struct spinand_plat), }; -- 2.34.1