From patchwork Thu Jul 5 11:14:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frieder Schrempf X-Patchwork-Id: 939862 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="co63W/iV"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=as-electronics.de header.i=@as-electronics.de header.b="h/CTDbCm"; 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 41LwMM0yX1z9s3C for ; Thu, 5 Jul 2018 21:18:07 +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=5go4xYJ9nolya3tnC+qT0DDP0JgamgVtZAwmRPUs8TM=; b=co63W/iVM6G1IRLgVyYFtQQjs6 ZuReICywPHbW0nvuvW+Tt9dqByQ02uo/Qyjp9AFB1FXPmmJx+onvEpuduJSH4d4hCR2YkvmAtrO9S lXP3RdtDhV2T5hXHgnMlysA5dPTK5XAcg8p/Pg3/pJPBYMF2Dp4zp4pH1QwgqxZmeWcBKSlhxvdvJ 9WbkzYd3oFI0RIOrPqyokJCinZsvrFCM0Ro2n0DMmEZNsjPHnO9iQc1eSVK9DD6BsjIRFPJOr5cLU 5Ycz31MOLtVZzp6WnbPTOvKJAsi847HV9dmwn8CkVXEKFCAinhnZhoWhHRz66Mr3rZsZzeRH4M7b9 ps2J3l5g==; 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 1fb2Gq-00018O-1n; Thu, 05 Jul 2018 11:17:56 +0000 Received: from mo6-p05-ob.smtp.rzone.de ([2a01:238:20a:202:5305::3]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fb2Gg-00010j-Cq for linux-mtd@lists.infradead.org; Thu, 05 Jul 2018 11:17:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1530789451; 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=tZCaPM+ETK/jVFWKAexZNweKjFocXwoGR7nnTUtOZMM=; b=h/CTDbCmcQrIkI7rM00CETtP9I1WXHNihiyJLv0ZzMG+TS+ABHdPSgYftbEBrs2DpB BgqYKDQsCCr1mYGUgKZKza7W628wMKNDFNI3gIp981mOsyN5rPW7eVIskvIlF8MWIi6u fWT324YNbwKxW9VdKo4kgzGopJ5p88cGRmzYDDUSP/aV340d0JyXNYhVbDihvVFBJb7I puyKvSutic3pvFlX5Jv3nhQWTax2bm2OOPKcLSUH+lOCxCuhar5fIAbFV+exeVyG5KoP LCzv9EFBuC2Ljsou3WFpczut9y9K+I0NxMLR9gUlLVbCYMtqmNKl2bja6sGUd7o3/aRB TZAw== X-RZG-AUTH: ":LX8JdEmkW/4tAFwMkcNJIloh1hrA5u3owhPk7bdT5Fx22AatU+eLaHfutoZdl+X9BETxn4/4+IVqx+daE87UU5bgm7XHzClQnm8VxHglxo5wj3H1fls=" X-RZG-CLASS-ID: mo05 Received: from fs-work.fritz.box by smtp.strato.de (RZmta 43.12 AUTH) with ESMTPSA id a0925bu65BH04i1 (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); Thu, 5 Jul 2018 13:17:00 +0200 (CEST) From: Frieder Schrempf To: linux-mtd@lists.infradead.org, boris.brezillon@bootlin.com, linux-spi@vger.kernel.org Subject: [PATCH v2 01/12] spi: spi-mem: Extend the SPI mem interface to set a custom memory name Date: Thu, 5 Jul 2018 13:14:57 +0200 Message-Id: <1530789310-16254-2-git-send-email-frieder.schrempf@exceet.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530789310-16254-1-git-send-email-frieder.schrempf@exceet.de> References: <1530789310-16254-1-git-send-email-frieder.schrempf@exceet.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180705_041747_309072_8AE8C3E8 X-CRM114-Status: GOOD ( 15.01 ) 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:3 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 , shawnguo@kernel.org, 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 --- Changes in v2: ============== * Add a name field to struct spi_mem and fill it while probing drivers/spi/spi-mem.c | 30 ++++++++++++++++++++++++++++++ include/linux/spi/spi-mem.h | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 990770d..048101c 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -311,6 +311,26 @@ 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) +{ + return mem->name; +} +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 @@ -344,6 +364,7 @@ static inline struct spi_mem_driver *to_spi_mem_drv(struct device_driver *drv) static int spi_mem_probe(struct spi_device *spi) { struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver); + struct spi_controller *ctlr = spi->controller; struct spi_mem *mem; mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL); @@ -351,6 +372,15 @@ static int spi_mem_probe(struct spi_device *spi) return -ENOMEM; mem->spi = spi; + + if (ctlr->mem_ops && ctlr->mem_ops->get_name) + mem->name = ctlr->mem_ops->get_name(mem); + else + mem->name = dev_name(&spi->dev); + + if (IS_ERR_OR_NULL(mem->name)) + return PTR_ERR(mem->name); + spi_set_drvdata(spi, mem); return memdrv->probe(mem); diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index 4fa34a2..c3f82d1 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -124,7 +124,8 @@ struct spi_mem_op { /** * struct spi_mem - describes a SPI memory device * @spi: the underlying SPI device - * @drvpriv: spi_mem_drviver private data + * @drvpriv: spi_mem_driver private data + * @name: name of the SPI memory device * * Extra information that describe the SPI memory device and may be needed by * the controller to properly handle this device should be placed here. @@ -135,6 +136,7 @@ struct spi_mem_op { struct spi_mem { struct spi_device *spi; void *drvpriv; + char *name; }; /** @@ -178,6 +180,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 +239,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);