From patchwork Wed Oct 3 19:38:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978500 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fm4YINaN"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uRee/Yup"; 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 42QRDp5BKVz9s8J for ; Thu, 4 Oct 2018 05:39:54 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=4Wc6vjD76yZT+Gdlfhw7imCKusLQEnNKVi2fq5fRJBs=; b=fm4YINaN7Bgztk S98EAYvOoXpGnNsbojKf2KuCONUpyvcXr7afGrKZkGQzaM02WMkh9W3C2kTGdkb8CjI04rvuoJRcR 4SUGmqyDUIYcuS/VtD7dDxsjkMqYkVv29otI7OgqxuwFUPa23LIeAQSBltNMDHo6Iy0skizFZjLrO 4cpoSGWt6DHBWNpU7N2EI1zElGDrs/OUKzVS2DwL7E22dEU1nivO91cUlzEJn1uylh4qZG+0hfKZP cVURZ6WwFPhpcwmiCBCVW/2khDsu6RkHoqYQVgd1FYguzJXek/nCuOpX4wdHEnlDRc0xEjV+8HQe/ aHlIE43iUtAQ9Phi+HTg==; 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 1g7mzm-00048V-9j; Wed, 03 Oct 2018 19:39:42 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzJ-0003gG-PI for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:23 +0000 Received: by mail-ed1-x541.google.com with SMTP id z21-v6so2010992edb.11 for ; Wed, 03 Oct 2018 12:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=07UVT8AT/WIvxk7YqGQ2CULDktLqJYK6DbMGdKzq18o=; b=uRee/Yupj1+ZPGRaxOK2b8xZbnlW4WyQn8krI9eQW/rrerl/CfSaUPYUMF8nT/tmz+ Ar1XEJSIZThRU1VbhNQ0em0qEC+8W4awQTOT1ytQYJgNvvH6uLT5yg1mto0zM9vIbmKF C4kGDaeYyRvIlsRlyONL4+OGEwtxKD105MTRm1tqvSe7ik4YTjZSP+EfhxcoJRWVUf6N Y/ez55i9NqbW7NjhtUOhfoA6x4Nk3FfhXVgKMchf0uwaGw0t6sEtzkd350UmvocD81Fd Q4+10gTghEK2Ql/pOpExDCkoxkxyX4LN9NVkCxItb7D4qmEBCBJfbjnPgOT3ouRv6nCo lDaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=07UVT8AT/WIvxk7YqGQ2CULDktLqJYK6DbMGdKzq18o=; b=XXSokfDDItaMVxfUADdA+SZ4rU3Xqs5y9jfpttjvl2B+5+nPZzOsmM9NSpekr7wS9O TAVyplFaHrpISywm9YTEvomZaGxDWnZ9y0iyDQhSCUAdxjRyX13eKDNcYCIS8hvcBmoO 5Voq9Opv1blt0sRo9CVRDvNhoYIVEg0F//hiu/FiZKjMvSAvRGz3eVYMlYHFMwZBcfsD NOO+ozjlpa24z2eZN9DUqMxuqDdPnZn7iiyxb4OeWk440T5rKxWDMmyV0BG1VJfJdein Aq8wHwzSTzhB6gP0x/2ExZYbYlcUSoleFjOn7YnRkDmttTyGuU7gVhFoqztUBh/CKLSN wjPA== X-Gm-Message-State: ABuFfojytF5pSHQfMowfbgP/bbCeZNBVWNo2uWgxatYrWgsE7j4IcVn1 WAq00Hx2EFZsMfxx3qprfaw= X-Google-Smtp-Source: ACcGV61MxhDUVN6Mdt+0+VX0V9mRPjvMR7fRrSMKvaLzHTcDN/QVpmI49XCd8IAcMCo1WRtvxbRouA== X-Received: by 2002:aa7:c406:: with SMTP id j6-v6mr4404678edq.134.1538595541851; Wed, 03 Oct 2018 12:39:01 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:00 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 1/8] mtd: maps: gpio-addr-flash: Replace custom printk Date: Wed, 3 Oct 2018 21:38:52 +0200 Message-Id: <20181003193859.23928-1-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123913_871188_B57E1699 X-CRM114-Status: GOOD ( 14.04 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use preferred print methods dev_* Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/gpio-addr-flash.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 9d9723693217..17be47f72973 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -25,11 +25,7 @@ #include #include -#define pr_devinit(fmt, args...) \ - ({ static const char __fmt[] = fmt; printk(__fmt, ## args); }) - #define DRIVER_NAME "gpio-addr-flash" -#define PFX DRIVER_NAME ": " /** * struct async_state - keep GPIO flash state @@ -250,7 +246,7 @@ static int gpio_flash_probe(struct platform_device *pdev) i = 0; do { if (gpio_request(state->gpio_addrs[i], DRIVER_NAME)) { - pr_devinit(KERN_ERR PFX "failed to request gpio %d\n", + dev_err(&pdev->dev, "failed to request gpio %d\n", state->gpio_addrs[i]); while (i--) gpio_free(state->gpio_addrs[i]); @@ -260,8 +256,8 @@ static int gpio_flash_probe(struct platform_device *pdev) gpio_direction_output(state->gpio_addrs[i], 0); } while (++i < state->gpio_count); - pr_devinit(KERN_NOTICE PFX "probing %d-bit flash bus\n", - state->map.bankwidth * 8); + dev_notice(&pdev->dev, "probing %d-bit flash bus\n", + state->map.bankwidth * 8); state->mtd = do_map_probe(memory->name, &state->map); if (!state->mtd) { for (i = 0; i < state->gpio_count; ++i) From patchwork Wed Oct 3 19:38:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978506 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YriSLVt1"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lmuW2Nqx"; 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 42QRHH19s9z9s8J for ; Thu, 4 Oct 2018 05:42:03 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=AXJPxtuzdc5yXrju87EeIZL6vgZt1JMJy60IklfhY34=; b=YriSLVt1Rvv7RF Pykz9ogFBo2qeDE4+u3SBDaS9c6usD23vo4zX+fSfdUc1+U1jD6QzP7nNGf+AMdwzCZHbIXjgPWXR OEjN3dAoXb2IHlLPeYneBQQpWqGU7hm7tpdATxPFypP/zGMknWO/hlm/NLTa/A4ZvEPlToGsfGX0c iBO8APkh/jnttxs20c3KaFiQwWnXw8zAhfytqat/cBCNpkv7RTsgKpwg0fDytnRwbxISXo/pz2fqg /+vpxwhVp97jzmFad3T3pKbMUdCRdfEabFALo4x/Lbcbscdv9MQWfYGx/PeETJZQ5cOgjDtDUjTQT N3lXCerzn0yt6pbNoAXg==; 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 1g7n1p-0006Fn-68; Wed, 03 Oct 2018 19:41:49 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzL-0003gH-Ap for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:41 +0000 Received: by mail-ed1-x542.google.com with SMTP id a4-v6so6416493eds.10 for ; Wed, 03 Oct 2018 12:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PjA+sX8gLHXduyIAmFIqULLnywYjal55pxx0KrC3qkQ=; b=lmuW2Nqx4zU3tHrg3KDrrV6JiBwTzvLnnIUuMfjZuAetstjFjZ/pa4Zs+VF2kfjLk2 MrB4bG/3/nnDDY2J/LZhV4Oz66MqjspeHCxI6Ty/e4mpSu8SaqsYt2kFzYJW+oaNx0Ml YuPCuWsrsfSkq7mw7RgUqXs4t1SjPjQZkU9EW0bTFf/eGpjwZZlXlTM1FIHnIGSBXRGs LNgJUc0OXLT/AQ9PFqCom8lmerQXKVu6z1oAWOUtiJ7IGfh88Sy1CuzJzbdt7LTlLJRK 46htrVThir9Ue3lV2KFfScMnZ1eWlwKPPwpSHZXzlaW6DKsHCJywhdUI/D5baWJBpvRR vgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PjA+sX8gLHXduyIAmFIqULLnywYjal55pxx0KrC3qkQ=; b=c7sIBrf2U7oUo8wjK9UtOgr56jSgKnionvt5nE2RI1VYDtLBiLZav5XCUleXnextz6 MJYu5KZb3dSyvBz6sQ9ZrNGhHYSDKkQc8DzMXN0N41qhREG0rvP9wTSZCOb3lokzGIR5 2l5GU9/D3Ul0gZhKsthbWfK2wXDsiQUQfXfiYrhW+zD9jHqclMVnzxFhgWnBLfOtvyhM 7lVh8vfc/1boNTU20sfVs3gPUDq4AN/LS0/myU6KB5SZuMU+bQJf7Y8ocloiBGRH8tAI 2CtRU9v1Yn6tEle+g90t07YI+cBdt2kUU48Y3Wsctot8Qmvlw/HBv4eUq4MjStLmOO+6 q6PA== X-Gm-Message-State: ABuFfojjzJ4fgeTJt9BJg3cuQzdrQtpPykZ/o4tTPgZnIfwumJEBFW3g o3z5VXHGTSgdeli07TS0RjU= X-Google-Smtp-Source: ACcGV602M5OgJQcBMW0nF7AeLzSZA/hqlCIQTavWYFDGBQIa6g3prLN6Rs9XnR734e/NuBXiyl7Q8g== X-Received: by 2002:a50:8d1b:: with SMTP id s27-v6mr4319626eds.107.1538595543543; Wed, 03 Oct 2018 12:39:03 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:02 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 2/8] mtd: maps: gpio-addr-flash: Fix ioremapped size Date: Wed, 3 Oct 2018 21:38:53 +0200 Message-Id: <20181003193859.23928-2-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123915_398994_4A6A794F X-CRM114-Status: GOOD ( 15.45 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:542 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado , stable@vger.kernel.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We should only iomap the area of the chip that is memory mapped. Otherwise we could be mapping devices beyond the memory space or that belong to other devices. Signed-off-by: Ricardo Ribalda Delgado Fixes: ebd71e3a4861 ("mtd: maps: gpio-addr-flash: fix warnings and make more portable") Cc: --- drivers/mtd/maps/gpio-addr-flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 17be47f72973..6de16e81994c 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -234,7 +234,7 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.copy_to = gf_copy_to; state->map.bankwidth = pdata->width; state->map.size = state->win_size * (1 << state->gpio_count); - state->map.virt = ioremap_nocache(memory->start, state->map.size); + state->map.virt = ioremap_nocache(memory->start, state->win_size); if (!state->map.virt) return -ENOMEM; From patchwork Wed Oct 3 19:38:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978501 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AiCs4UNZ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XfvOGDgV"; 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 42QRFk3jbrz9s7W for ; Thu, 4 Oct 2018 05:40:42 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=1qPeNPXdJqOPfZYsG3Tq7ws4d5hm6akGro6il7eRRY4=; b=AiCs4UNZHBIV4P xu3oTdLjEUumIoCJxHrvJyZo7fdBWyVulR5Odtv8RncQhwM9+alahoedYVjy0aQ8oP82H2XGy9BXd TTrBDoXvzcywpoRp2HrlpXt7OKEx+nDw/yRUuCUY8kmfmTkahTDU32RNgQH9bYfHq8AjdWTDlFC4f Q7UdoeApOsXLspcYmq1OukqvYkT7F1EjDGFMFvWk5AiHfMT6m92j/FemQ0WXJZLaRz28n7XxHlgai D7YpzSfYTarA+QGKubsDw2ojnzHl3u/Wy998JmiKZfEVzrziPWKDUmeOrDq2mOPNHGfcyQWlpAi0W MvDjmRH/sFAGwSjd2Jug==; 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 1g7n0V-0005Jw-BJ; Wed, 03 Oct 2018 19:40:27 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzJ-0003gI-PV for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:26 +0000 Received: by mail-ed1-x541.google.com with SMTP id g26-v6so6463788edp.0 for ; Wed, 03 Oct 2018 12:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hZUbn50UsHuR5ct+6gyJtPRAN067Ky0FADOBnmfRKwk=; b=XfvOGDgVDnLcs/IOZQoaIjspO/jdgu0VXcHCSb/NfZyJ6gUALMY21KoSfkSKfLP87y TZTHfLzMKYwq70iB4pcbufv2tXbjsieshc31Je/enNmfxUwJLcU4/6r7TFRgUbwAtFo6 xfClP5QflIjCmvwa2N0FwXlkW+1MGd4KJmTzlT5dioChjzBgjouctW5KFvMbe/sFlAZz GeNqxfc+fytHL9BCRtDbQY8wqf0YjJ31cYO9wfJoUvACMQEStVh63GzaEagCQsaWawUX S98CaGXyy28obSY2z5owgOwU1XxhONBm/xNzVGKBfHPqcOJ015jlkNJ80pjYx4C48KXh iUXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hZUbn50UsHuR5ct+6gyJtPRAN067Ky0FADOBnmfRKwk=; b=Y9qaG1UvxjYHwfgRdoqGpNWpxsh4pfbkq1RFGS5qM5PehFt4p1CEj78XXPkuTmp5Wb v3mUcws0iQO6FIiKeptDtn2F34GUEsCD2kwD0lKrrKthQ8ZaI5Mv63/Gg+cmMDfGOhj/ IiArT38V3JuxkOVnmBUUTuW25S2ueeP4j0Us4hNRead/QUygICideymt2mBcz/2LURy8 /A8fTNrqBHLW2KgJbTEE3wA3onN0Y/OvAYbMYIEiHHcwQnUbt4hcfYRz8BbnDlSWzOBx jn7DN6LNt0IsKae24xhXPeTAm/KPas3vqO0RtHuRskkdrtpE9FZCij6+G9umDJkwc3Mk vyFQ== X-Gm-Message-State: ABuFfojMw343XGnQNOr79vjAuJ1qgQXZ+AysJje/jB/RIk6fkKc4CKXm iJ5OlhlJ0sMeaP2E+x3olP0= X-Google-Smtp-Source: ACcGV605BhK38pwwP7PTKy74FZNewQxPiUagHNwacKxE7pu7dJedW2iJKh/f2zXpGC9KevpkzuCpeg== X-Received: by 2002:a17:906:e0d5:: with SMTP id gl21-v6mr3364691ejb.92.1538595545425; Wed, 03 Oct 2018 12:39:05 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:03 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 3/8] mtd: maps: gpio-addr-flash: Use devm_* functions Date: Wed, 3 Oct 2018 21:38:54 +0200 Message-Id: <20181003193859.23928-3-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123913_869294_DA6D2777 X-CRM114-Status: GOOD ( 15.22 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org By using devm functions we can make the code cleaner. Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/gpio-addr-flash.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 6de16e81994c..84404dcc7824 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -213,7 +213,7 @@ static int gpio_flash_probe(struct platform_device *pdev) return -EINVAL; arr_size = sizeof(int) * gpios->end; - state = kzalloc(sizeof(*state) + arr_size, GFP_KERNEL); + state = devm_kzalloc(&pdev->dev, sizeof(*state) + arr_size, GFP_KERNEL); if (!state) return -ENOMEM; @@ -234,9 +234,9 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.copy_to = gf_copy_to; state->map.bankwidth = pdata->width; state->map.size = state->win_size * (1 << state->gpio_count); - state->map.virt = ioremap_nocache(memory->start, state->win_size); - if (!state->map.virt) - return -ENOMEM; + state->map.virt = devm_ioremap_resource(&pdev->dev, memory); + if (IS_ERR(state->map.virt)) + return PTR_ERR(state->map.virt); state->map.phys = NO_XIP; state->map.map_priv_1 = (unsigned long)state; @@ -245,12 +245,10 @@ static int gpio_flash_probe(struct platform_device *pdev) i = 0; do { - if (gpio_request(state->gpio_addrs[i], DRIVER_NAME)) { + if (devm_gpio_request(&pdev->dev, state->gpio_addrs[i], + DRIVER_NAME)) { dev_err(&pdev->dev, "failed to request gpio %d\n", state->gpio_addrs[i]); - while (i--) - gpio_free(state->gpio_addrs[i]); - kfree(state); return -EBUSY; } gpio_direction_output(state->gpio_addrs[i], 0); @@ -259,12 +257,8 @@ static int gpio_flash_probe(struct platform_device *pdev) dev_notice(&pdev->dev, "probing %d-bit flash bus\n", state->map.bankwidth * 8); state->mtd = do_map_probe(memory->name, &state->map); - if (!state->mtd) { - for (i = 0; i < state->gpio_count; ++i) - gpio_free(state->gpio_addrs[i]); - kfree(state); + if (!state->mtd) return -ENXIO; - } state->mtd->dev.parent = &pdev->dev; mtd_device_parse_register(state->mtd, part_probe_types, NULL, @@ -276,13 +270,9 @@ static int gpio_flash_probe(struct platform_device *pdev) static int gpio_flash_remove(struct platform_device *pdev) { struct async_state *state = platform_get_drvdata(pdev); - size_t i = 0; - do { - gpio_free(state->gpio_addrs[i]); - } while (++i < state->gpio_count); + mtd_device_unregister(state->mtd); map_destroy(state->mtd); - kfree(state); return 0; } From patchwork Wed Oct 3 19:38:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978518 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AbHwwifa"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WHcKmzmD"; 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 42QRXk2Nnvz9s8J for ; Thu, 4 Oct 2018 05:53:39 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=eKNkiQowufmiEwIJsU9LphoNRTEn2OqcjO8A83A093A=; b=AbHwwifao5RyXO 9FciGnywDVsWz0unJ1RHqIaWvzVk9Cww6XbMX+VfBKu42cO8OLy2+1Ey16bXDAQDdLIrrjYZCpV4z bkyHnH+eTeGvfRTMIxd3RKphv1i6IvRc+ZJAno6AqKQAgZD9AQTfQPL+vI4rBvuHcz8xTQfnHHv3I niSGhqtZR8KaZ9PaVBtPopxW9GMMybXeR5wP4WbFA2e5ZI2mj7E9J5XG0OsCojvgYU0Ce4R4X3d9m 8K2IgjCR3szd8KMWOifscHXhwM/+183nnZqy/l234ro0cp1KwLsGco7ZeE5eYektHEpxwRCCPcEjo 9ZSWCRJQs1zXe3142Kgw==; 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 1g7nD5-0002em-CK; Wed, 03 Oct 2018 19:53:27 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzJ-0003hR-Ox for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:46 +0000 Received: by mail-ed1-x541.google.com with SMTP id y19-v6so6457171edd.2 for ; Wed, 03 Oct 2018 12:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ls+XcqdmHnBV0GS3bS8NGlkMVyhd9AxDVYAww4RmSug=; b=WHcKmzmDc1eR3RjHo6WRbNx1WahwoWFYxfdR/EAPsjAvZdgQK30Jn2K6iYwm8/ZwUu Ysjc6p/M9vtJZPEMu6m7fae1L2ZjSr+63ZqyylwfKxJuEmvWjlvrRbtIoIQsLxlvUYr6 mrrmsMv7w5FYbBYA8o9SaMkZiTK+urlxxJasdJIZUrPrk9TdM2BsqDKJ8w8EMIfPzuGp UENODJIf9Tq3Onw1ZPGGsKvs8g8RpfI3Me266/xolz8LWut1a+z89Yna8Lvn25VKmnkw dqhfjDJNxB8QSdZpFOAnEGCkqsgnmWIvTl357e8bd9kCuEmflEfxMhjULXopfOj66W2/ clmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ls+XcqdmHnBV0GS3bS8NGlkMVyhd9AxDVYAww4RmSug=; b=iQkURbS0uB2cLX3Lwy4yujxrIro7bBBgaEg4Rw9lxAzQGawHf+I0FLKoN9I1hCbXJu fo8q699mnaAU40WfIfR5gNYd21LvTugavLq5BcdqA2Y7dIlMRUrT7ljSEXPY9CD07pgb dSUwfvsIMbPzYq/8QAGkan4KP4BOSrRxNgclhKmPdqyvQosDo1dLHHtnGQIyYo3kL1p1 s7bZIhC8dFHmhxF49DDEE1BXFbBDJIHUfwOZ7VJfKMog5on5CJTmvR4PIgGmL9Fjs1Fa Eb3qwLFJoL/7tJsIisfXIIR4oFpVqfIQ2Yt3Vj8JqGn79mXtJ21PbbIiO3SG8xUMejm3 UUNw== X-Gm-Message-State: ABuFfoiDFOrYStGC89H2Sdlf+wCkd1GC19hm1fdpGckKkR1fylQPEsWL 34rTQs8a8xBYLiG02oZpU+libxe6 X-Google-Smtp-Source: ACcGV60qLuMeQd0jrz3dwBeC7nnCqWdbPynRwlfpRr90F4M/84UhsI8upFvo/4iiTF5AV16WGkzgiQ== X-Received: by 2002:a17:906:95da:: with SMTP id n26-v6mr3239995ejy.205.1538595547282; Wed, 03 Oct 2018 12:39:07 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:05 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 4/8] mtd: maps: gpio-addr-flash: Use order insted of size Date: Wed, 3 Oct 2018 21:38:55 +0200 Message-Id: <20181003193859.23928-4-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123913_905463_02BA6DB9 X-CRM114-Status: GOOD ( 17.43 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org By using the order of the window instead of the size, we can replace a lot of expensive division and modulus on the code with simple bit operations. Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/gpio-addr-flash.c | 39 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 84404dcc7824..89cc8cce161b 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -25,6 +25,8 @@ #include #include +#define win_mask(x) ((BIT(x)) - 1) + #define DRIVER_NAME "gpio-addr-flash" /** @@ -34,7 +36,7 @@ * @gpio_count: number of GPIOs used to address * @gpio_addrs: array of GPIOs to twiddle * @gpio_values: cached GPIO values - * @win_size: dedicated memory size (if no GPIOs) + * @win_order: dedicated memory size (if no GPIOs) */ struct async_state { struct mtd_info *mtd; @@ -42,7 +44,7 @@ struct async_state { size_t gpio_count; unsigned *gpio_addrs; int *gpio_values; - unsigned long win_size; + unsigned int win_order; }; #define gf_map_info_to_state(mi) ((struct async_state *)(mi)->map_priv_1) @@ -60,7 +62,8 @@ static void gf_set_gpios(struct async_state *state, unsigned long ofs) { size_t i = 0; int value; - ofs /= state->win_size; + + ofs >>= state->win_order; do { value = ofs & (1 << i); if (state->gpio_values[i] != value) { @@ -83,7 +86,7 @@ static map_word gf_read(struct map_info *map, unsigned long ofs) gf_set_gpios(state, ofs); - word = readw(map->virt + (ofs % state->win_size)); + word = readw(map->virt + (ofs & win_mask(state->win_order))); test.x[0] = word; return test; } @@ -105,14 +108,14 @@ static void gf_copy_from(struct map_info *map, void *to, unsigned long from, ssi int this_len; while (len) { - if ((from % state->win_size) + len > state->win_size) - this_len = state->win_size - (from % state->win_size); - else - this_len = len; + this_len = from & win_mask(state->win_order); + this_len = BIT(state->win_order) - this_len; + this_len = min_t(int, len, this_len); gf_set_gpios(state, from); - memcpy_fromio(to, map->virt + (from % state->win_size), - this_len); + memcpy_fromio(to, + map->virt + (from & win_mask(state->win_order)), + this_len); len -= this_len; from += this_len; to += this_len; @@ -132,7 +135,7 @@ static void gf_write(struct map_info *map, map_word d1, unsigned long ofs) gf_set_gpios(state, ofs); d = d1.x[0]; - writew(d, map->virt + (ofs % state->win_size)); + writew(d, map->virt + (ofs & win_mask(state->win_order))); } /** @@ -152,13 +155,13 @@ static void gf_copy_to(struct map_info *map, unsigned long to, int this_len; while (len) { - if ((to % state->win_size) + len > state->win_size) - this_len = state->win_size - (to % state->win_size); - else - this_len = len; + this_len = to & win_mask(state->win_order); + this_len = BIT(state->win_order) - this_len; + this_len = min_t(int, len, this_len); gf_set_gpios(state, to); - memcpy_toio(map->virt + (to % state->win_size), from, len); + memcpy_toio(map->virt + (to & win_mask(state->win_order)), + from, len); len -= this_len; to += this_len; @@ -224,7 +227,7 @@ static int gpio_flash_probe(struct platform_device *pdev) state->gpio_count = gpios->end; state->gpio_addrs = (void *)(unsigned long)gpios->start; state->gpio_values = (void *)(state + 1); - state->win_size = resource_size(memory); + state->win_order = get_bitmask_order(resource_size(memory)) - 1; memset(state->gpio_values, 0xff, arr_size); state->map.name = DRIVER_NAME; @@ -233,7 +236,7 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.write = gf_write; state->map.copy_to = gf_copy_to; state->map.bankwidth = pdata->width; - state->map.size = state->win_size * (1 << state->gpio_count); + state->map.size = BIT(state->win_order + state->gpio_count); state->map.virt = devm_ioremap_resource(&pdev->dev, memory); if (IS_ERR(state->map.virt)) return PTR_ERR(state->map.virt); From patchwork Wed Oct 3 19:38:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978505 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gebzfhLX"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WF7AzKxA"; 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 42QRGV4QX8z9s7W for ; Thu, 4 Oct 2018 05:41:22 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=/YjdfbO7W8wMwtbE+SIH6aeIfdxwXLVyO7YmbzDgY2c=; b=gebzfhLX2Ullq9 +Hqt2cG65DJerjOHzntxORoe/J36FRoPW7C184BplODAtqerBEImgUP4sY/gGDzQFcGXkHVj5sClB tKzvyPyBNe+3sWh36GtKP/h/iLZip2hHRyaUS/x8H2y+YCkSImMH33N7BtwuQp2uFdBGXlRDQUc+m tYvBJ0yrZKKDbO/olB5RwWS/tTEke4ezsdz0FLvCHd2k+aECPnRIIGdW5ZDi9/ht/HcG+i/o6eeEq 4G8zaoLIxrvQ2KtJHYrBTX0OAb0DewWuvxexXFDavVRgSdzqAuc3KzabeztAo/vAhg6EZ3Y+W9ypt ewHbs95ZMaaBNmi7L6Vw==; 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 1g7n1D-0005ze-Ln; Wed, 03 Oct 2018 19:41:11 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzJ-0003lQ-PW for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:40 +0000 Received: by mail-ed1-x541.google.com with SMTP id q19-v6so6468886edr.1 for ; Wed, 03 Oct 2018 12:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zPXLWgPAM9TKQD8PmLyfoPaLlJmlL7ExTK2t4PzAkrc=; b=WF7AzKxAHmVg15NjPolfwQE6JFnpO4j0FXA1sBmAriTLE5SHA+HLC0KSB8wl8wl2jg 15Ewc7v9sxanVs3vuc8/iz64MbP2rYzjwkOZXgR9FLOX5itNo//pMI8gS0mu6Ww4hjQk cQLBmv95XznI3VlXM7pkVni96JpiAt6H/qTBIvoHbNt5CxyplWxoi0XyU0yKY+1IpyP0 uJyFliagf2xtDdvjEjTfb2BrrsfVnyIu9aL3V6dkHlSDVmFikhBtcchmpVS/HqFjBBmS uTXFvWDVYUtOrZz1Ks1e/M+Mhqwn1FPIbTpieAdp1dH8aPlLn3ibS5NP0MLDmduYeLeZ 6+gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zPXLWgPAM9TKQD8PmLyfoPaLlJmlL7ExTK2t4PzAkrc=; b=GopzUkcBJ6IZ1FWXjjfR4qorLzX5DSLtsWGKBYoBEqsId7/KSmPQtzgKhQn75Y+Qby 936WZf5YZ7t4CAe5w72o2PkuNMU3G20t/WkLKKK3QVYp1HG2ZHu/wtsZPy1Wi8kv0Tl6 80yae1wnHln7BeL6hGsScNneuKtNKQEcC9xIcBHcNJwqUJWjo14OiushrvR5m70gYiuI qvB4vwR/RLMCqxvE7nNKmPzhdudButwSMO3RS2cjEKArSmzeH6wPQ7JiN3Yv/Wto/Twc IVIk4G4aD4BVbmZpS8tv+yrlszQI7oEgyY4LATqPEhyY7mWapd4QLcB3xSyZRc1+riiK r1Eg== X-Gm-Message-State: ABuFfojuefNSrUlSQwtmN/Aq3BVLdDv23hAXAuzqO/EnMYXujOeNoJDn fsjNiRlDbVikuiurmQs8Z60= X-Google-Smtp-Source: ACcGV63mIaLRnWLzFzN7ZdLVqEIp7IZj6dG1qVQgRdbkYx947rO/v8gZXpjcWpwpu4GGAaY1q/XZYA== X-Received: by 2002:aa7:d4c7:: with SMTP id t7-v6mr4213737edr.256.1538595549107; Wed, 03 Oct 2018 12:39:09 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:07 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 5/8] mtd: maps: gpio-addr-flash: Replace array with an integer Date: Wed, 3 Oct 2018 21:38:56 +0200 Message-Id: <20181003193859.23928-5-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123913_891094_A7175434 X-CRM114-Status: GOOD ( 18.24 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org By replacing the array with an integer we can avoid completely the bit comparison loop if the value has not changed (by far the most common case). Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/gpio-addr-flash.c | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 89cc8cce161b..47b12a6fead4 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -43,7 +43,7 @@ struct async_state { struct map_info map; size_t gpio_count; unsigned *gpio_addrs; - int *gpio_values; + unsigned int gpio_values; unsigned int win_order; }; #define gf_map_info_to_state(mi) ((struct async_state *)(mi)->map_priv_1) @@ -55,22 +55,25 @@ struct async_state { * * Rather than call the GPIO framework every time, cache the last-programmed * value. This speeds up sequential accesses (which are by far the most common - * type). We rely on the GPIO framework to treat non-zero value as high so - * that we don't have to normalize the bits. + * type). */ static void gf_set_gpios(struct async_state *state, unsigned long ofs) { - size_t i = 0; - int value; + int i; ofs >>= state->win_order; - do { - value = ofs & (1 << i); - if (state->gpio_values[i] != value) { - gpio_set_value(state->gpio_addrs[i], value); - state->gpio_values[i] = value; - } - } while (++i < state->gpio_count); + + if (ofs == state->gpio_values) + return; + + for (i = 0; i < state->gpio_count; i++) { + if ((ofs & BIT(i)) == (state->gpio_values & BIT(i))) + continue; + + gpio_set_value(state->gpio_addrs[i], !!(ofs & BIT(i))); + } + + state->gpio_values = ofs; } /** @@ -202,7 +205,7 @@ static const char * const part_probe_types[] = { */ static int gpio_flash_probe(struct platform_device *pdev) { - size_t i, arr_size; + size_t i; struct physmap_flash_data *pdata; struct resource *memory; struct resource *gpios; @@ -215,8 +218,7 @@ static int gpio_flash_probe(struct platform_device *pdev) if (!memory || !gpios || !gpios->end) return -EINVAL; - arr_size = sizeof(int) * gpios->end; - state = devm_kzalloc(&pdev->dev, sizeof(*state) + arr_size, GFP_KERNEL); + state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; @@ -226,9 +228,7 @@ static int gpio_flash_probe(struct platform_device *pdev) */ state->gpio_count = gpios->end; state->gpio_addrs = (void *)(unsigned long)gpios->start; - state->gpio_values = (void *)(state + 1); state->win_order = get_bitmask_order(resource_size(memory)) - 1; - memset(state->gpio_values, 0xff, arr_size); state->map.name = DRIVER_NAME; state->map.read = gf_read; From patchwork Wed Oct 3 19:38:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978508 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pIkrPHdQ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OMuoRPGc"; 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 42QRKH4cs1z9s8J for ; Thu, 4 Oct 2018 05:43:47 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=GMlbGlx4HAW/9eb5ghAqMfndMPn0BRFiKth2UDMD2WQ=; b=pIkrPHdQ+oCVYL mmeZ6Ng753zUqjwDf3rDEcXQRxVWE8G8oVLsjPuXkyCfITR90FDxXLnjaVY5iyZhmMilIgFhiTYes 6Vh8vd34YmJ61rlulw/c4avJ26bCQs74b6kdD6MQnoYtsYjFzub4OfPT3gZTfWntbjStKVtkGDlGO Qs0W4uZbjwOenneswF7sA1gA+R/L/XWH0jbMCfm906BmeEMi49X0F7YZRw+MEO2NmZT6a0y5gqxOj ABtNZxhu8agLKJrxlJeAm8ScLGE0v6icpb2DuT0LOYrKJ+11GBB+zpK0YR8vv9PJGWJbvP+Q1slbd mSY5bH3iVA0twHndRYRg==; 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 1g7n3V-0006wV-8G; Wed, 03 Oct 2018 19:43:33 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzS-0003pQ-LW for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:47 +0000 Received: by mail-ed1-x544.google.com with SMTP id v18-v6so5365370edq.12 for ; Wed, 03 Oct 2018 12:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DnDkdVlT4uEmccUEt9jQFZdRTiIQUnmLL0jvRMKg+cQ=; b=OMuoRPGcGpz8FkPZUZD3n2l6dG+9sat0wpTlDPyQbOzaV6hxR5SsKZzOdDGV/BCZIj fE0GjLFZqq6GAKRZWbc85enJQ1GE4QPjUYTpY8dXUqU+q2PdYyRnv6X2ssC+pZw1RrpR ac4lEYB4sSXt21a7Py7YxI6y0TTGmnMmmuTWBeHIkpA3IrYlcAv3vZ4VEQ47KxNk1t9n myexaSNdudU+NmBzM0M3BupfkNLiR+rr3dll1GWLXfqDJVsy/tKd8mxq/UrHkbl4V+Jl MaUfZJWT5nK1+SF6HACeBc4iLHtStwj7bykDFtJVGjoLmye2g6J6rtWUpkChB1QQpAgs y1aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DnDkdVlT4uEmccUEt9jQFZdRTiIQUnmLL0jvRMKg+cQ=; b=UkTx9FJJf4aElWkyhbj9kcF5uo1qxkxmD0YgtXaBtmPj7VadZi++Q/Dmi8zWl2kOgo wF1KvLgoxxXakuhxUeyH0RtTKzc4IMhqdFs3pWhr05Y7jR3mLgD6IneqiKwmi6YgKdEr dpAbmfwbfKp1F5OqhNBC6m066zUbQKT3ESXYdGR03K1jqHgefHe5kss7cLT3Jlo9mP6c cJdrAYGpK0SH35Jlfb2gmhfFj43qFYqoKBoAqhi8sNDmzaUo1PucBeGbn6b6LXI/24Q0 m6bB0S2lOabF6XasXeg8JYijRgnmHRiIp3vrtlG0tzBNWL/Bj4FsSvG+cp+7oaMsBlXD LWmg== X-Gm-Message-State: ABuFfoi72OYV4jygB2bbAWcmkQzSwp9oF060Dh6f9a+XlIpKryZmHat6 dE8pK/+0gdFs5s70dYcFceA= X-Google-Smtp-Source: ACcGV6075GGpNBx0WHCsskTfNRNm+H7LahjdxVToWrd5kMhEN6wzyk46yLBX12xo/TZn+14PLhIxYQ== X-Received: by 2002:a17:906:344b:: with SMTP id d11-v6mr3402240ejb.130.1538595550814; Wed, 03 Oct 2018 12:39:10 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:09 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 6/8] mtd: maps: gpio-addr-flash: Convert to gpiod Date: Wed, 3 Oct 2018 21:38:57 +0200 Message-Id: <20181003193859.23928-6-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123922_736319_F147C2F7 X-CRM114-Status: GOOD ( 19.03 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Convert from legacy gpio API to gpiod. Board files will have to use gpiod_lookup_tables. Signed-off-by: Ricardo Ribalda Delgado Suggested-by: Boris Brezillon --- drivers/mtd/maps/gpio-addr-flash.c | 52 +++++++++++------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 47b12a6fead4..9e370e3158cd 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -33,16 +34,14 @@ * struct async_state - keep GPIO flash state * @mtd: MTD state for this mapping * @map: MTD map state for this flash - * @gpio_count: number of GPIOs used to address - * @gpio_addrs: array of GPIOs to twiddle + * @gpios: Struct containing the array of GPIO descriptors * @gpio_values: cached GPIO values * @win_order: dedicated memory size (if no GPIOs) */ struct async_state { struct mtd_info *mtd; struct map_info map; - size_t gpio_count; - unsigned *gpio_addrs; + struct gpio_descs *gpios; unsigned int gpio_values; unsigned int win_order; }; @@ -66,11 +65,11 @@ static void gf_set_gpios(struct async_state *state, unsigned long ofs) if (ofs == state->gpio_values) return; - for (i = 0; i < state->gpio_count; i++) { + for (i = 0; i < state->gpios->ndescs; i++) { if ((ofs & BIT(i)) == (state->gpio_values & BIT(i))) continue; - gpio_set_value(state->gpio_addrs[i], !!(ofs & BIT(i))); + gpiod_set_value(state->gpios->desc[i], !!(ofs & BIT(i))); } state->gpio_values = ofs; @@ -182,18 +181,19 @@ static const char * const part_probe_types[] = { * The platform resource layout expected looks something like: * struct mtd_partition partitions[] = { ... }; * struct physmap_flash_data flash_data = { ... }; - * unsigned flash_gpios[] = { GPIO_XX, GPIO_XX, ... }; + * static struct gpiod_lookup_table addr_flash_gpios = { + * .dev_id = "gpio-addr-flash.0", + * .table = { .... ); + * }; + * gpiod_add_lookup_table(&addr_flash_gpios); + * * struct resource flash_resource[] = { * { * .name = "cfi_probe", * .start = 0x20000000, * .end = 0x201fffff, * .flags = IORESOURCE_MEM, - * }, { - * .start = (unsigned long)flash_gpios, - * .end = ARRAY_SIZE(flash_gpios), - * .flags = IORESOURCE_IRQ, - * } + * }, * }; * struct platform_device flash_device = { * .name = "gpio-addr-flash", @@ -205,29 +205,24 @@ static const char * const part_probe_types[] = { */ static int gpio_flash_probe(struct platform_device *pdev) { - size_t i; struct physmap_flash_data *pdata; struct resource *memory; - struct resource *gpios; struct async_state *state; pdata = dev_get_platdata(&pdev->dev); memory = platform_get_resource(pdev, IORESOURCE_MEM, 0); - gpios = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!memory || !gpios || !gpios->end) + if (!memory) return -EINVAL; state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; - /* - * We cast start/end to known types in the boards file, so cast - * away their pointer types here to the known types (gpios->xxx). - */ - state->gpio_count = gpios->end; - state->gpio_addrs = (void *)(unsigned long)gpios->start; + state->gpios = devm_gpiod_get_array(&pdev->dev, NULL, GPIOD_OUT_LOW); + if (IS_ERR(state->gpios)) + return PTR_ERR(state->gpios); + state->win_order = get_bitmask_order(resource_size(memory)) - 1; state->map.name = DRIVER_NAME; @@ -236,7 +231,7 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.write = gf_write; state->map.copy_to = gf_copy_to; state->map.bankwidth = pdata->width; - state->map.size = BIT(state->win_order + state->gpio_count); + state->map.size = BIT(state->win_order + state->gpios->ndescs); state->map.virt = devm_ioremap_resource(&pdev->dev, memory); if (IS_ERR(state->map.virt)) return PTR_ERR(state->map.virt); @@ -246,17 +241,6 @@ static int gpio_flash_probe(struct platform_device *pdev) platform_set_drvdata(pdev, state); - i = 0; - do { - if (devm_gpio_request(&pdev->dev, state->gpio_addrs[i], - DRIVER_NAME)) { - dev_err(&pdev->dev, "failed to request gpio %d\n", - state->gpio_addrs[i]); - return -EBUSY; - } - gpio_direction_output(state->gpio_addrs[i], 0); - } while (++i < state->gpio_count); - dev_notice(&pdev->dev, "probing %d-bit flash bus\n", state->map.bankwidth * 8); state->mtd = do_map_probe(memory->name, &state->map); From patchwork Wed Oct 3 19:38:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978517 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MGHRjAPB"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qSWWASSe"; 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 42QRXk2Nljz9s7W for ; Thu, 4 Oct 2018 05:53:39 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=erbPYFNAyJN3bmaTPfZMTQYlGPqky9ISQ5IJniRkTas=; b=MGHRjAPBAc1YWr DWK/XF3FaemCfsaG+Ec3Dg5aSEwGmpZJInvNPc6J0LIuN5a4RCYN3j+jB0bMhlvL4Ol+ZNFTrG7Na RDWuoyCVYQ8ufn7RoMAOJVeSWPgSVMSrSDjCBbMzI0MeqiPBSrAvB3ZpmDM3QXm501erwlMjgwky/ YbOJn+uxhH9Z24eNayjaLDWseoZK4Nhdi+dSAGpL6rEOBndba18ylhyBuCKtCusiTEBTFNRKrDZup bcwKETEzbUITrb1R3ShCgXuPe3OBFHZjkm3Xyz+gimTPCKpW8N+G01bD/DFKd+qSo5MEX/eKPjvI8 xd2Eb6NuPSjw5zxMNKkQ==; 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 1g7nD4-0002ef-Rn; Wed, 03 Oct 2018 19:53:26 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzS-0003rb-LZ for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:41 +0000 Received: by mail-ed1-x544.google.com with SMTP id h4-v6so6426767edi.6 for ; Wed, 03 Oct 2018 12:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EUdiv3GxcKIGRchs0tikWhabjt2xJ5EVou+ayt6rXzE=; b=qSWWASSedwNTvf4cXruRNmwqRV5s9Pos2P66j+SdUqiqAjtfA0OWX9/tzuCumUDe0w ro03gJzfo3bAAdhBt2d9OaI6AX3eMl9lRbHr73oWwRDV2JE1M/q5ymohBIromZFuGkm5 CAYLo/rA0usRaBrn/3Nm9Ecgv6CCv3TIjjiKkPtfZ3xDAnnJ5WOX52Xw3sNC08eOmSEW NNKOcVRfVu09Tr7tuRmNtFNyxw4qS1DI0cIpZMdgAwFXUP20nIRYpMCO2W+fhWoBsIld HV5JDJH6JehWdTz7SOt48ok9ETZRx1IOoVO7sgdaaZg6vDLEt/N9Lmr7bzaKmbbBE5/1 z+mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EUdiv3GxcKIGRchs0tikWhabjt2xJ5EVou+ayt6rXzE=; b=a2SwuAolceh3UxXliwjKLqB7SRe2rbRojbjmjvCI7v9yYWkq+xuWKpUGVXMK0AsUwA Wziv06Vgv06M7D0jRaQzI0a7HYacwwXwD1nA5oABgJ1oDNvMHQXVTMtwRm2Hk8SBqgkU UGuUAf75r1iw33jyE3h7GXgj7ufAAzfloKubUIRSa3x+RTO9SfA4kAsbUkhWwLy5+y0W m/sZrr9OFPqAFmJIWqc9/xOjw4bUR7EM8NrxyTxRNoBVQMbdRcti3zMc1iZSL39mBH92 aWhRbhE1AQhoODTXiMu6Rtqg5CHDvbYwVpVqso2DNxXtAT/h0fy70PLo9Q9m7uGH0tbC Tqaw== X-Gm-Message-State: ABuFfohdiY6b1cPrX633mJVZvoYrdWL3l11C3euDaobR8D5a1T5uHPQH 15M4MRuWT6H/aILRVgMfp48zUiQc X-Google-Smtp-Source: ACcGV6125Uz8ifFRRuu+yBVLw3QDZH8ZrmLMErmL1j9qxy14pBPquBD4vc8gcsNixbGxPLK7iSylpQ== X-Received: by 2002:a17:906:b01:: with SMTP id u1-v6mr3428970ejg.124.1538595553273; Wed, 03 Oct 2018 12:39:13 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:11 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 7/8] dt-binding: mtd: Document gpio-addr-flash Date: Wed, 3 Oct 2018 21:38:58 +0200 Message-Id: <20181003193859.23928-7-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123922_755380_766B7260 X-CRM114-Status: GOOD ( 18.06 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado , devicetree@vger.kernel.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add documentation for gpio-addr-flash. This binding allow creating flash devices that are paged using GPIOs. Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: Ricardo Ribalda Delgado --- .../bindings/mtd/gpio-addr-flash.txt | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/gpio-addr-flash.txt diff --git a/Documentation/devicetree/bindings/mtd/gpio-addr-flash.txt b/Documentation/devicetree/bindings/mtd/gpio-addr-flash.txt new file mode 100644 index 000000000000..5006a26e1753 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/gpio-addr-flash.txt @@ -0,0 +1,54 @@ +Memory Mapped flash with some address lines addressed using GPIOs + +Handle the case where a flash device is mostly addressed using physical +line and supplemented by GPIOs. This way you can hook up say a 8MiB flash +to a 2MiB memory range and use the GPIOs to select a particular range. + + - compatible : "cfi-gpio-addr-flash" + - reg : Address range of the mtd chip that is memory mapped, this is, + on the previous example 2MiB. + - bank-width : Width (in bytes) of the bank. Equal to the + device width times the number of interleaved chips. + - gpios: List of GPIO specifiers that will be used to address the MSBs address + lines. The order goes from LSB to MSB. + - probe-type : (optional) "cfi_probe", "jedec_probe". How the mtd chip + is going to be probed. If omitted, assumed to be equal to "cfi_probe". + - #address-cells, #size-cells : Must be present if the device has + sub-nodes representing partitions (see below). In this case + both #address-cells and #size-cells must be equal to 1. + +The device tree may optionally contain sub-nodes describing partitions of the +address space. Check partition.txt for more details. + +Example: + + flash@300000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "cfi-gpio-addr-flash"; + bank-width = <2>; + reg = < 0x00300000 0x00200000 >; + gpios = <&gpio_0 3 0>, <&gpio_0 4 0>; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = < 0x0 0x200000 >; + label = "Golden Bitstream"; + }; + partition@200000 { + reg = < 0x200000 0x200000 >; + label = "User Bitstream"; + }; + partition@400000 { + reg = < 0x400000 0x200000 >; + label = "V4L Controls"; + }; + partition@600000 { + reg = < 0x600000 0x200000 >; + label = "Production Data"; + }; + } + } ; From patchwork Wed Oct 3 19:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978510 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C/l2Bmgo"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JsgHgBey"; 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 42QRL55LfBz9s7W for ; Thu, 4 Oct 2018 05:44:29 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=7gonvhReehfBNJzvD/GNHQc5yGDwX8Xa2KsZ3R3qdlM=; b=C/l2Bmgo1bMXMH sZQC9Hbur6cPJ85T9XAb8uSrFkuJ0AZk8ELMT6QPPp/5CcsN1iEJGWU7cbdc5w27SXNnyVkU2vkTy f/KgZs0h6jZ2A0inH7DfB4mu18Cb93HFucSjvt/3LccFWcXb5Iv2W9N98sm+rJIRy9T9NaFJz4XE+ +WczbUu/LI8NxJkV3kf3ptKRV+y8RZIxpOEjAHLgyYzvhSOGLSmeRjnGhG867iZl4KYUyL/HXFQor QdbbC6ysFNkug7xXW5WvZxLMFfL8boU94ZqcPK0v21Dh5dGpPyBqtFUM2Wdx9NL7F8hZhM+pG/ZOa PORFTwVW5jVw8sa6GIrQ==; 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 1g7n4E-0007Du-66; Wed, 03 Oct 2018 19:44:18 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7mzS-0003tR-NZ for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 19:39:59 +0000 Received: by mail-ed1-x544.google.com with SMTP id q19-v6so6469194edr.1 for ; Wed, 03 Oct 2018 12:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KOAyhQZ1kpINFprCvoK5uIYCA/Vz9KwRzR3zRWEAurw=; b=JsgHgBey89jArTKnLa7apugLwk9m+e+IHoQnZVpkLYEpydSYwCgSDCwiz+qMKZikhZ nVMGdGwytlUkziJD5f6iXLPDq4PwvHWO3Rag1e+WveBgxCpp04m06cqoyecFU5R92/4h h/34siZKzTrs3h/u4bx8RZfMy9+3Vbjk0ihnDQi+3dXxlgw+iQYnxSJgpmc0E7xLjweP ZPnGV9bMVHYikDzSEHvoD/0IdlB/vswAyJBhg/nUQPPgo72LUehjDkNlnJRN9jpCykz2 5ilnw4q8XFLSgcg22LR8hlEGhe97OiN1u9omxPwp0Q50LunknmEqjWsT5k76kpWC8Rdh p2ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KOAyhQZ1kpINFprCvoK5uIYCA/Vz9KwRzR3zRWEAurw=; b=sY1RpTk8WQraG7jEDkTopQ7KyoBBLATJk5W5OWV5nwJDwz+2eM3LEL36RVvvhAIf0w V5o0tnCsaw4/kdsQGHjzLrB+so8yPSEPKWB9020VaF6F8F4pJBwNlNsz5IQj+QPdp89F isvhPcfpaF+ThyFww1aE0tyBaMM1tjPiySBGLMkFtpUfEVJ0ywipyS3boAoKcEfuPeEM e3FPmK65X8ocgA5lgMbcww+evy6fe+qtyoSiL2PU53v5Nnm9RH/uQPAgfQizeYmv1mdx fpWyf85ojglbnUP1SXwrBdIdfnfyJ5kpht66lRMKCfdQSDtJkG45ZWfVVfNCtCus04Co 7CWg== X-Gm-Message-State: ABuFfohST+bs+yNy5WOOLnAYQJ2WJGV0CI2aaDBb7Km0eQ3OrBeZA1l1 a41wJk/pogI+aZkHM+e7soQPn/E+ X-Google-Smtp-Source: ACcGV62aIpF9hYseQ8f72T4GjQMMy3kbAcqWoRxiS7BZ1CHc3fFuS5wkxxFSyG/LXpnKghWjkCL7ew== X-Received: by 2002:a17:906:1e45:: with SMTP id i5-v6mr3460567ejj.146.1538595555505; Wed, 03 Oct 2018 12:39:15 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id b49-v6sm765263eda.70.2018.10.03.12.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 12:39:14 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v5 8/8] mtd: maps: gpio-addr-flash: Add support for device-tree devices Date: Wed, 3 Oct 2018 21:38:59 +0200 Message-Id: <20181003193859.23928-8-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003193859.23928-1-ricardo.ribalda@gmail.com> References: <20181003193859.23928-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_123922_871670_3ECE0F8D X-CRM114-Status: GOOD ( 18.81 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.0 SPF_PASS SPF: sender 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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Allow creating gpio-addr-flash via device-tree and not just via platform data. Option parsing has been moved to separated functions. Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 9e370e3158cd..1be2df81087a 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -7,6 +7,7 @@ * * Copyright © 2000 Nicolas Pitre * Copyright © 2005-2009 Analog Devices Inc. + * Copyright © 2018 Ricardo Ribalda * * Enter bugs at http://blackfin.uclinux.org/ * @@ -171,8 +172,67 @@ static void gf_copy_to(struct map_info *map, unsigned long to, } } -static const char * const part_probe_types[] = { - "cmdlinepart", "RedBoot", NULL }; +static int gf_bankwidth(struct platform_device *pdev) +{ + struct device_node *dn; + int ret; + u32 bankwidth; + + dn = pdev->dev.of_node; + if (!dn) { + struct physmap_flash_data *pdata; + + pdata = dev_get_platdata(&pdev->dev); + return pdata->width; + } + + ret = of_property_read_u32(dn, "bank-width", &bankwidth); + if (ret) { + dev_err(&pdev->dev, "failed to get bank-width\n"); + return -EINVAL; + } + + return bankwidth; +} + +static const char *gf_probe_type(struct platform_device *pdev) +{ + struct device_node *dn; + struct resource *memory; + const char *of_probe; + + dn = pdev->dev.of_node; + if (!dn) { + memory = platform_get_resource(pdev, IORESOURCE_MEM, 0); + return memory->name; + } + + of_probe = of_get_property(dn, "probe-type", NULL); + if (of_probe) + return of_probe; + + return "cfi_probe"; +} + +static void gf_device_parse_register(struct platform_device *pdev, + struct async_state *state) +{ + static const char * const part_probe_types[] = { + "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL }; + struct device_node *dn; + + dn = pdev->dev.of_node; + if (!dn) { + struct physmap_flash_data *pdata; + + pdata = dev_get_platdata(&pdev->dev); + mtd_device_parse_register(state->mtd, part_probe_types, NULL, + pdata->parts, pdata->nr_parts); + return; + } + + mtd_device_parse_register(state->mtd, part_probe_types, NULL, NULL, 0); +} /** * gpio_flash_probe() - setup a mapping for a GPIO assisted flash @@ -208,6 +268,7 @@ static int gpio_flash_probe(struct platform_device *pdev) struct physmap_flash_data *pdata; struct resource *memory; struct async_state *state; + int ret; pdata = dev_get_platdata(&pdev->dev); memory = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -215,9 +276,15 @@ static int gpio_flash_probe(struct platform_device *pdev) if (!memory) return -EINVAL; + if (!is_power_of_2(resource_size(memory))) { + dev_err(&pdev->dev, "Window size must be aligned\n"); + return -EIO; + } + state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; + platform_set_drvdata(pdev, state); state->gpios = devm_gpiod_get_array(&pdev->dev, NULL, GPIOD_OUT_LOW); if (IS_ERR(state->gpios)) @@ -230,7 +297,12 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.copy_from = gf_copy_from; state->map.write = gf_write; state->map.copy_to = gf_copy_to; - state->map.bankwidth = pdata->width; + + ret = gf_bankwidth(pdev); + if (ret < 0) + return ret; + state->map.bankwidth = ret; + state->map.size = BIT(state->win_order + state->gpios->ndescs); state->map.virt = devm_ioremap_resource(&pdev->dev, memory); if (IS_ERR(state->map.virt)) @@ -239,17 +311,15 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.phys = NO_XIP; state->map.map_priv_1 = (unsigned long)state; - platform_set_drvdata(pdev, state); - dev_notice(&pdev->dev, "probing %d-bit flash bus\n", state->map.bankwidth * 8); - state->mtd = do_map_probe(memory->name, &state->map); + state->mtd = do_map_probe(gf_probe_type(pdev), &state->map); if (!state->mtd) return -ENXIO; state->mtd->dev.parent = &pdev->dev; + mtd_set_of_node(state->mtd, pdev->dev.of_node); - mtd_device_parse_register(state->mtd, part_probe_types, NULL, - pdata->parts, pdata->nr_parts); + gf_device_parse_register(pdev, state); return 0; } @@ -263,11 +333,20 @@ static int gpio_flash_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id gpio_flash_match[] = { + { + .compatible = "cfi-gpio-addr-flash", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, gpio_flash_match); + static struct platform_driver gpio_flash_driver = { .probe = gpio_flash_probe, .remove = gpio_flash_remove, .driver = { .name = DRIVER_NAME, + .of_match_table = gpio_flash_match, }, };