From patchwork Mon Oct 12 19:54:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 529401 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 3344114027C for ; Tue, 13 Oct 2015 06:55:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7D4B4B8BD; Mon, 12 Oct 2015 21:55:38 +0200 (CEST) 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 YdRrm5weWASQ; Mon, 12 Oct 2015 21:55:38 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BB0934B866; Mon, 12 Oct 2015 21:55:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 89AED4B8D7 for ; Mon, 12 Oct 2015 21:55:26 +0200 (CEST) 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 qkPEW26JD5Wd for ; Mon, 12 Oct 2015 21:55:26 +0200 (CEST) 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-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by theia.denx.de (Postfix) with ESMTPS id 6A3CA4B8BB for ; Mon, 12 Oct 2015 21:55:16 +0200 (CEST) Received: by pabrc13 with SMTP id rc13so26961808pab.0 for ; Mon, 12 Oct 2015 12:55:15 -0700 (PDT) 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=THV/3Y9qr1eg/QcayquMJ+JKi9REpFCHYC/G9aqFbTA=; b=lrnZkOO8f3UeVKSNrBTTim65N/qO9Qx4yDrA1dUN/K4mPRqKaEdLqCeoZU/XvgIlKD 6rH8GfkY3WJGkYY6JJTE8Zubtf3rThb0tyeXxRnEJgrFdYgQPM+JjbCtB6anlBXzmbw8 D0RYa/mMfdtTOzFbdCOIY63G+s0L1N9gCZignpil//TpRDFzsHx9XhzXs+jQvgtUAkWm q7ffXWgqFu0LMhsVRIcqdmpzLQc4NX9eB3FlGsnhbsZT0gmSE5idudaKrQ2iuiTttura Ed+BWSOKXHt6/lV1NO/1eYh83Jf7RmlrDAay9W0w7hRXg56Los0jrZskIE5U/NdGLGeS Xo4w== X-Received: by 10.68.93.194 with SMTP id cw2mr36158981pbb.36.1444679715715; Mon, 12 Oct 2015 12:55:15 -0700 (PDT) Received: from localhost.localdomain ([123.236.183.133]) by smtp.gmail.com with ESMTPSA id g12sm4613845pat.36.2015.10.12.12.55.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 12:55:14 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Tue, 13 Oct 2015 01:24:12 +0530 Message-Id: <1444679655-30349-5-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444679655-30349-1-git-send-email-jteki@openedev.com> References: <1444679655-30349-1-git-send-email-jteki@openedev.com> Cc: Jagan Teki Subject: [U-Boot] [PATCH 5/8] 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. Signed-off-by: Jagan Teki Reviewed-by: Heiko Schocher --- 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 5e314e2..60abaf2 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -26,17 +26,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); @@ -49,19 +56,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: @@ -95,9 +99,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); }