From patchwork Mon Oct 12 15:01:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 529154 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 958131402B2 for ; Tue, 13 Oct 2015 02:04:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28F474B949; Mon, 12 Oct 2015 17:03:23 +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 HcYxAfpaIrCQ; Mon, 12 Oct 2015 17:03:22 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6678B4B8D5; Mon, 12 Oct 2015 17:03:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6A0E44B8B1 for ; Mon, 12 Oct 2015 17:03:12 +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 9b4LAX4auocb for ; Mon, 12 Oct 2015 17:03:12 +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-f65.google.com (mail-pa0-f65.google.com [209.85.220.65]) by theia.denx.de (Postfix) with ESMTPS id 6AE5B4B93B for ; Mon, 12 Oct 2015 17:03:05 +0200 (CEST) Received: by palb17 with SMTP id b17so19239708pal.2 for ; Mon, 12 Oct 2015 08:03:04 -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=+npwcmFPMl4UjKshrjUBonV425MqBV0OlOfOJp+noZc=; b=G685GyoztTnBYDWKaNLnuVkItlPr1NwmJTlOLjUw7LvecO2mzuYTNJjZ5okerZSpwf BB5ws5akq6VE1JIZUwrRa0YmYY2sMiNpeIK62d9ZeC7+p++k9b24oqkBfedW/nNZPHbR jvAnzPL1Mtxdjkg0bVtyrmmTZIaBru9CDVBkHxNVA0KMkt6XprQrm5Y7bJb7qtjoUt/X z8bcgUAdv9qnh/MjTTA+gIV+1Qt+OmDYfyKyqWLWNUFHv0TJMOpmA/1zg2Ijgz1XHdMs oCnVBzZB3pB5FvZfjSF9piNPRzndPUzNqeaWPwdtx2BnDr+9ysZncDDp/KfAs51hjYj2 khXQ== X-Received: by 10.68.168.226 with SMTP id zz2mr34859644pbb.8.1444662184179; Mon, 12 Oct 2015 08:03:04 -0700 (PDT) Received: from Jubuntu.amcc.com ([182.73.239.130]) by smtp.gmail.com with ESMTPSA id qy5sm18924909pbb.16.2015.10.12.08.02.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 08:03:02 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Mon, 12 Oct 2015 20:31:08 +0530 Message-Id: <1444662074-2424-16-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444662074-2424-1-git-send-email-jteki@openedev.com> References: <1444662074-2424-1-git-send-email-jteki@openedev.com> Cc: fabio.estevam@freescale.com, Marek Vasut , qiwang@micron.com, Tom Rini , Michal Simek , Siva Durga Prasad Paladugu , frankliu@micron.com, Jagan Teki Subject: [U-Boot] [PATCH v4 15/21] sf: Use flash function pointers in dm_spi_flash_ops 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" flash operations are defined as static and reuse them with function-pointers so call them with generic function pounters instead of calling like normal functions. Signed-off-by: Jagan Teki --- Changes for v4, v3, v2: - none drivers/mtd/spi/sf_ops.c | 2 -- drivers/mtd/spi/sf_probe.c | 15 +++------------ include/spi_flash.h | 13 ------------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 97e644d..f63ce7a 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -761,7 +761,6 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash) flash->dual_flash = flash->spi->option; /* Assign spi_flash ops */ -#ifndef CONFIG_DM_SPI_FLASH flash->write = spi_flash_cmd_write_ops; #if defined(CONFIG_SPI_FLASH_SST) if (params->flags & SST_WR) @@ -776,7 +775,6 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash) #endif flash->erase = spi_flash_cmd_erase_ops; flash->read = spi_flash_cmd_read_ops; -#endif /* Compute the flash size */ flash->shift = (flash->dual_flash & SF_DUAL_PARALLEL_FLASH) ? 1 : 0; diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index a712792..e2dac7e 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -120,7 +120,7 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len, { struct spi_flash *flash = dev_get_uclass_priv(dev); - return spi_flash_cmd_read_ops(flash, offset, len, buf); + return flash->read(flash, offset, len, buf); } int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len, @@ -128,23 +128,14 @@ int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len, { struct spi_flash *flash = dev_get_uclass_priv(dev); -#if defined(CONFIG_SPI_FLASH_SST) - if (flash->flags & SNOR_F_SST_WR) { - if (flash->spi->op_mode_tx & SPI_OPM_TX_BP) - return sst_write_bp(flash, offset, len, buf); - else - return sst_write_wp(flash, offset, len, buf); - } -#endif - - return spi_flash_cmd_write_ops(flash, offset, len, buf); + return flash->write(flash, offset, len, buf); } int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len) { struct spi_flash *flash = dev_get_uclass_priv(dev); - return spi_flash_cmd_erase_ops(flash, offset, len); + return flash->erase(flash, offset, len); } int spi_flash_std_probe(struct udevice *dev) diff --git a/include/spi_flash.h b/include/spi_flash.h index 4312d3d..0732172 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -87,23 +87,10 @@ struct spi_flash { u8 dummy_byte; void *memory_map; -#ifndef CONFIG_DM_SPI_FLASH - /* - * These are not strictly needed for driver model, but keep them here - * while the transition is in progress. - * - * Normally each driver would provide its own operations, but for - * SPI flash most chips use the same algorithms. One approach is - * to create a 'common' SPI flash device which knows how to talk - * to most devices, and then allow other drivers to be used instead - * if required, perhaps with a way of scanning through the list to - * find the driver that matches the device. - */ int (*read)(struct spi_flash *flash, u32 offset, size_t len, void *buf); int (*write)(struct spi_flash *flash, u32 offset, size_t len, const void *buf); int (*erase)(struct spi_flash *flash, u32 offset, size_t len); -#endif }; struct dm_spi_flash_ops {