From patchwork Wed May 30 13:14:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frieder Schrempf X-Patchwork-Id: 922795 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=exceet.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RTOCHJag"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=as-electronics.de header.i=@as-electronics.de header.b="nIYulWos"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40wrkG2ws7z9s01 for ; Wed, 30 May 2018 23:17:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HdmacrFD8/o6F3NavNBFtc1w1hAot5SDzZvbG5w5MJQ=; b=RTOCHJagFpURBCah50S1AYCsr9 SroWzfce+pYnahg2LMSApHlrWzMJkr+fnDCYHV2LoKz7B+CzAiDInntcpGJr0pOGuuXBxlgz3FqXq ZZ7YPToZaFFTZIGNCvCGfrdF7en+jk0mOgjvDZt+zIk22+S7zSMH0pIyR6tKZmFS7DnvygOH2y7Vw toOFTDx8Tk7MH8AwVGrcnUQ73ntGgGF8FEnSWhVXLMLiAlmkQkfsHQG8I4bdZ5zLIgBxvAGHaOl1z BHrr3PxfAunw6u4g+07cXt4U1NLHkaejBp/sCBNwXM8TQMwj8ArOfsjz1RsVSFsC72WcjAfdXQPV/ qg0y/18A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fO0yt-0001io-Ie; Wed, 30 May 2018 13:17:35 +0000 Received: from mo6-p05-ob.smtp.rzone.de ([2a01:238:20a:202:5305::10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fO0yT-0001WB-9l for linux-mtd@lists.infradead.org; Wed, 30 May 2018 13:17:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1527686217; s=strato-dkim-0002; d=as-electronics.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=XJnkbHO7zE+WZc2rmB8EKbKKKkzbn5h9YfvZCpOzqJM=; b=nIYulWosCgAR54DHHax+Q1QyFBu4UGDlueQ66h5bDlwpLR6lFqJtOHFTBpx+laDpU+ BY8AA16S/l8qglmMm75Kc+48PnAqzsbkORKVhLu2ao4QXZzgpeGD8Ts/Rg6h3/W5X+wb gX5pIba9YreVj4fuc8zHCkYeGhBQ/7wsBJ0B0ygf8gDZ0TJpMXFX46Bjga8H9H2yuRRZ vwXwQ9Y7NCfX3koiIBAfVXGv+lve+VXvOkEJ2M1z7R4ZRi7nM5wM2tsgZ28+Jp92OJlM eg73wIPzvdomkZ0a2YERMplGWsLoTyngDvHBP874OVFCDgvlyZYBplE1RdyXazb2Er5P 8iAg== X-RZG-AUTH: ":LX8JdEmkW/4tAFwMkcNJIloh1hrA5u3owhPk7bdT5Fx22AatU+eLaHfutoZdl+X9BETxn4/4+IVqx7oJE8yFU0CFyS7Uq+kmFDrWBCuLGqeCYZgEsPw=" X-RZG-CLASS-ID: mo05 Received: from fs-work.fritz.box by smtp.strato.de (RZmta 43.8 AUTH) with ESMTPSA id z034bcu4UDGXPOX (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 30 May 2018 15:16:33 +0200 (CEST) From: Frieder Schrempf To: linux-mtd@lists.infradead.org, boris.brezillon@bootlin.com, linux-spi@vger.kernel.org Subject: [PATCH 01/11] spi: spi-mem: Extend the SPI mem interface to set a custom memory name Date: Wed, 30 May 2018 15:14:30 +0200 Message-Id: <1527686082-15142-2-git-send-email-frieder.schrempf@exceet.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527686082-15142-1-git-send-email-frieder.schrempf@exceet.de> References: <1527686082-15142-1-git-send-email-frieder.schrempf@exceet.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180530_061709_494237_81C983B5 X-CRM114-Status: GOOD ( 12.26 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a01:238:20a:202:5305:0:0:10 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yogeshnarayan.gaur@nxp.com, richard@nod.at, prabhakar.kushwaha@nxp.com, Frieder Schrempf , linux-kernel@vger.kernel.org, marek.vasut@gmail.com, han.xu@nxp.com, broonie@kernel.org, miquel.raynal@bootlin.com, fabio.estevam@nxp.com, david.wolfe@nxp.com, computersforpeace@gmail.com, dwmw2@infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When porting (Q)SPI controller drivers from the MTD layer to the SPI layer, the naming scheme for the memory devices changes. To be able to keep compatibility with the old drivers naming scheme, a function is added to the SPI mem interface to let controller drivers set a custom name for the memory. Example for the FSL QSPI driver: Name with the old driver: 21e0000.qspi, or with multiple devices: 21e0000.qspi-0, 21e0000.qspi-1, ... Name with the new driver without spi_mem_get_name: spi4.0 Signed-off-by: Frieder Schrempf --- drivers/spi/spi-mem.c | 25 +++++++++++++++++++++++++ include/linux/spi/spi-mem.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 990770d..5e9af47 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -311,6 +311,31 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) EXPORT_SYMBOL_GPL(spi_mem_exec_op); /** + * spi_mem_get_name() - Let drivers using the SPI mem interface specify a + * custom name for the memory to avoid compatibility + * issues with ported drivers. + * @mem: the SPI memory + * + * When porting (Q)SPI controller drivers from the MTD layer to the SPI + * layer, the naming scheme for the memory devices changes. To be able to + * keep compatibility with the old drivers naming scheme, this function can + * be used to get a custom name from the controller driver. + * If no custom name is available, the name of the SPI device is returned. + * + * Return: a char array that contains the name for the flash memory + */ +const char *spi_mem_get_name(struct spi_mem *mem) +{ + struct spi_controller *ctlr = mem->spi->controller; + + if (ctlr->mem_ops && ctlr->mem_ops->get_name) + return ctlr->mem_ops->get_name(mem); + + return dev_name(&mem->spi->dev); +} +EXPORT_SYMBOL_GPL(spi_mem_get_name); + +/** * spi_mem_adjust_op_size() - Adjust the data size of a SPI mem operation to * match controller limitations * @mem: the SPI memory diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index 4fa34a2..f1912d3 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -178,6 +178,7 @@ struct spi_controller_mem_ops { const struct spi_mem_op *op); int (*exec_op)(struct spi_mem *mem, const struct spi_mem_op *op); + const char *(*get_name)(struct spi_mem *mem); }; /** @@ -236,6 +237,8 @@ bool spi_mem_supports_op(struct spi_mem *mem, int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op); +const char *spi_mem_get_name(struct spi_mem *mem); + int spi_mem_driver_register_with_owner(struct spi_mem_driver *drv, struct module *owner);