From patchwork Thu Nov 26 12:04:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 549057 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8F2D7140307 for ; Thu, 26 Nov 2015 23:09:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7053F4BAE6; Thu, 26 Nov 2015 13:07:35 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h-tK9TimEgiq; Thu, 26 Nov 2015 13:07:35 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8E9034BAEA; Thu, 26 Nov 2015 13:07:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37C834B61D for ; Thu, 26 Nov 2015 13:06:26 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pOpUZVeMwo1J for ; Thu, 26 Nov 2015 13:06:26 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by theia.denx.de (Postfix) with ESMTPS id 878E84BA5C for ; Thu, 26 Nov 2015 13:06:21 +0100 (CET) Received: by pacdm15 with SMTP id dm15so85462515pac.3 for ; Thu, 26 Nov 2015 04:06:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PfZgHhum+0YJz7grB2dzPWUi90sVqUM5g9AvXhVo/gk=; b=UsWohyPudxdd3CnvFXz8CiZhFuVFkNuW+xICi8D7fsjuDq3k6vbj4B0nGtxXbQ+V71 FjrD5UExgMWGQPRIJ/C8PijJowNJS7Z2lFdGAHLwqPy8LSbNF8j1PXJrgvm3Inb5EXAI t7/htD6B7jTZjxMnZ1/LiyIrv1I7uEbhxz46p4s9pk/YdljzbBo8uPGMGGmjbYBB1hUl nKJwpmVnKRdGfc3ecuJmFy8wB/qhH9fqmcyv7h4QJBvtK+KHCHI50gqJoL65ZzQCCwf0 A7Dr8HRGN3vWy4UvtYL9ewGzMi5dmUzruKP4MNT4CToW0q/Fiymwh65E8IoMBIKBVOX3 uPsA== X-Received: by 10.66.121.4 with SMTP id lg4mr3321166pab.22.1448539579864; Thu, 26 Nov 2015 04:06:19 -0800 (PST) Received: from Jubuntu.amcc.com ([182.73.239.130]) by smtp.gmail.com with ESMTPSA id b15sm27201832pfj.7.2015.11.26.04.06.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Nov 2015 04:06:18 -0800 (PST) From: Jagan Teki To: u-boot@lists.denx.de Date: Thu, 26 Nov 2015 17:34:06 +0530 Message-Id: <1448539458-14306-23-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448539458-14306-1-git-send-email-jteki@openedev.com> References: <1448539458-14306-1-git-send-email-jteki@openedev.com> Cc: Tom Rini , Michal Simek , Jagan Teki , Stefan Roese Subject: [U-Boot] [PATCH v7 22/34] sf: Add MTD support for non-dm spi_flash interface X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds MTD support to non-dm spi_flash interface code. Reviewed-by: Heiko Schocher Signed-off-by: Jagan Teki --- drivers/mtd/spi/sf_probe.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index f882b3f..51a0c07 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -28,17 +28,24 @@ struct spi_flash_priv { #ifndef CONFIG_DM_SPI_FLASH struct spi_flash *spi_flash_probe_tail(struct spi_slave *bus) { + struct spi_flash_priv *priv; struct spi_flash *flash; int ret; - /* Allocate space if needed (not used by sf-uclass */ - flash = calloc(1, sizeof(*flash)); - if (!flash) { - debug("SF: Failed to allocate spi_flash\n"); + /* Allocate space if needed (not used by sf-uclass) */ + priv = calloc(1, sizeof(*priv)); + if (!priv) { + debug("SF: Failed to allocate spi_flash_priv\n"); return NULL; } + flash = &priv->flash; + flash->mtd = &priv->mtd; + flash->spi = bus; + flash->priv = priv; + + priv->mtd.priv = flash; /* Claim spi bus */ ret = spi_claim_bus(bus); @@ -51,19 +58,16 @@ struct spi_flash *spi_flash_probe_tail(struct spi_slave *bus) if (ret) goto err_scan; -#ifdef CONFIG_SPI_FLASH_MTD - ret = spi_flash_mtd_register(flash); + ret = add_mtd_device(&priv->mtd); if (ret) { printf("SF: failed to register mtd device: %d\n", ret); goto err_mtd; } -#endif + return flash; -#ifdef CONFIG_SPI_FLASH_MTD err_mtd: spi_free_slave(bus); -#endif err_scan: spi_release_bus(bus); err_claim: @@ -97,9 +101,7 @@ struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node, void spi_flash_free(struct spi_flash *flash) { -#ifdef CONFIG_SPI_FLASH_MTD - spi_flash_mtd_unregister(); -#endif + del_mtd_device(flash->mtd); spi_free_slave(flash->spi); free(flash); }