From patchwork Thu Oct 4 13:01:01 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: 978870 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="c7E4F7j5"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KZlKOwwR"; 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 42QtM82zsVz9sBq for ; Thu, 4 Oct 2018 23:01:56 +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=KiaF5/PgiN1os2HaR8/OFO4TCFKXRJxLHB5h38fGQFU=; b=c7E4F7j5XRDfpi d8tD0+h9ventHOeoisb+tZfHhReUOkrFxUVs6C0aXqLLPMV8XQxtc4vZA5a3kkcQ239So3OIUUbOy KLCj5dqIgWlw+rEaXRH4kMEgqdT4yHMES6xaDvKeUGWxijxXyWPlGv5hOb4m3usU4+acHShqb5X60 qIusjah/yoQqulcT34USvcjV01QbLAgaprnacNxCy+K304jw6oWk/6pNE6tKYi7PByEjAqnVkqgph i9xhg0o240mt3aIUs9C/O8iW025TfbUEbSphG+VNKA2XWv5hBkEh7jExbo5Z0wzhRXWOX0CMe9yOP Hqhnu+Y7pOj8kilcJw6g==; 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 1g83GA-0007e8-Gi; Thu, 04 Oct 2018 13:01:42 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83G6-0007cu-0K for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:01:40 +0000 Received: by mail-lj1-x244.google.com with SMTP id r8-v6so8256566ljc.10 for ; Thu, 04 Oct 2018 06:01:26 -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=cvOv02cS/5OY9CZqapWCURdGssdE7v3kGqWHFy7Kk5o=; b=KZlKOwwRo46FGX9QRU+hK+LGur1TFD1Z+EQhgdREcLXDqvlDXAZFne2y1oHKsfO35R XIq7vmcKyzTkfzJqzLd9Yj9brPOFIs4oZyQdAtWwK0L+ZE/yuKx5Ix1HNyDucuCUTGba SMXZmWbMOFXtcn+QfXFDlOlW1lvTSCw6idDkY2XsBoDiXKSk8LTZ7rgE0WXDuxRgWgFI nHVRWBwX52Drh7/I6Jy/22ZbMaeKWih2gzqpFqdxe37LH4xF6OOZy7bi3LRBe7pIAJmC CmW1nGTfVcz3kH0o6j9xnXSvq+B0I6tTvWnZ2Z8xyfBsJKFfKBVr3N5JT3naFVwBcbd4 iLIg== 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=cvOv02cS/5OY9CZqapWCURdGssdE7v3kGqWHFy7Kk5o=; b=uCqo1neAQepq7tbfq6ylCJZiGnZOrWRXKC4MvMnq68ErFN1Tqm9AIuuHRAWRqrptU+ +BMJ1cVNWBmxt+sxxiLXpsvlUo46JA6Wi2yXgZR8gw26FNu9pXowU5sbZnRK3cYcHhj1 xTDfwQvA0ROzE0zufli5z3Ys8T7dDrJRQAZcAQaNA/kbGRzjLC1tTvPwZPtqrQgIImxj BiqygJ/6qW3jcGwGxEOOZJ4ETA/jX+eQGe2aSgG2Mn33HIkDUHuLu0ex1jGCFZDKTkyP yDXbfXLwPxngoXwXdx141EUqw/mssRfOHzXqPKnocvklBPnMjR/L347x0BYcmVcZeu4m dRKg== X-Gm-Message-State: ABuFfoiZwtFl9GJP2s4KrwyBITN8rynhL2oqT335AMehgyOUd4QymjEW cNVCmJwW1SnRJSAsfIvTvFU= X-Google-Smtp-Source: ACcGV61tPqzvUEnswTuaKqF+ARYJftjZcVL60D0v6XrgpPtgEpRxakaXp7CPRc0XoOIFfyUa+DFtNA== X-Received: by 2002:a2e:3006:: with SMTP id w6-v6mr1462771ljw.146.1538658083264; Thu, 04 Oct 2018 06:01:23 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:22 -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 v6 01/10] mtd: physmap_of: Release resources on error Date: Thu, 4 Oct 2018 15:01:01 +0200 Message-Id: <20181004130110.8496-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-20181004_060138_095885_74F4DCBC X-CRM114-Status: GOOD ( 15.19 ) 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:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org During probe, if there was an error the memory region and the memory map were not properly released. This can lead a system unusable if deferred probe is in use. Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/physmap_of_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/maps/physmap_of_core.c b/drivers/mtd/maps/physmap_of_core.c index 4129535b8e46..062add8b3a6e 100644 --- a/drivers/mtd/maps/physmap_of_core.c +++ b/drivers/mtd/maps/physmap_of_core.c @@ -241,10 +241,10 @@ static int of_flash_probe(struct platform_device *dev) err = of_flash_probe_gemini(dev, dp, &info->list[i].map); if (err) - goto err_out; + goto err_out_release; err = of_flash_probe_versatile(dev, dp, &info->list[i].map); if (err) - goto err_out; + goto err_out_release; err = -ENOMEM; info->list[i].map.virt = ioremap(info->list[i].map.phys, @@ -252,7 +252,7 @@ static int of_flash_probe(struct platform_device *dev) if (!info->list[i].map.virt) { dev_err(&dev->dev, "Failed to ioremap() flash" " region\n"); - goto err_out; + goto err_out_release; } simple_map_init(&info->list[i].map); @@ -290,7 +290,7 @@ static int of_flash_probe(struct platform_device *dev) err = -ENXIO; if (!info->list[i].mtd) { dev_err(&dev->dev, "do_map_probe() failed\n"); - goto err_out; + goto err_out_iounmap; } else { info->list_size++; } @@ -329,6 +329,10 @@ static int of_flash_probe(struct platform_device *dev) return 0; +err_out_iounmap: + iounmap(info->list[i].map.virt); +err_out_release: + release_mem_region(res.start, resource_size(&res)); err_out: kfree(mtd_list); err_flash_remove: From patchwork Thu Oct 4 13:01:02 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: 978898 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="eyFV+fRg"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gVnGhdz5"; 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 42QtrL5tXCz9s8T for ; Thu, 4 Oct 2018 23:23:46 +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=Nx81LN+slXm5C0UMlL+VVunNyQNQGjo1wt1LQw/Z5rc=; b=eyFV+fRgZB4Loo pqIsuKHYGejYRkO4xuINfWBfTrTl68Vvwdwsal8HrnAmU2+B4IYBfiJ1F7OG2KtfOyyg5QQmreN+M LZ3bgXt488L1yrbqn/RlU2hF+4cATEdL/JeawStUqUihOa0C+XREBk+KZhKfGTS5E7uBY5Y8N1Lbz ldICjlj3X0rpZN34IZxEXRjmBHltFCI1UQMKkaf82yQ3l6qXmHQ0EoUIL3ItHvXRuV1XXChT4FMs7 vMBAs1lxYlBlyTcyjsaFpIafRyw/pzQ8SR1Itj4kLIRMWlvKi685yuoNvunTLcuZv1J7NN9/rYKwx IWI3q4tJKa7f0VB0shCQ==; 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 1g83bP-00035Y-1j; Thu, 04 Oct 2018 13:23:39 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83G9-0007d3-HN for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:01:44 +0000 Received: by mail-lj1-x242.google.com with SMTP id z21-v6so8306951ljz.0 for ; Thu, 04 Oct 2018 06:01:31 -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=ZtPppqn0cObkHfFqeBrroPaPD+bDud26pGAf+e3d480=; b=gVnGhdz5rRnqns1IeCrrykSU1dGUv5BbH7cz4Lca+1Lwr8v5uYGWH17mZroSeIkczQ SvEJOoVzF5ZtHqQuNBISKy4Yf/u1xPgSO8+3YkztmEgh8G1Pb80x/Jz0vDrc5/wcOf/5 uJ7mPAT3D+FIpyg6kKtwA/s8/ICdAavPKc1SgSQzdx5iV2CEXFmcCbMXK8KaetQFOSkj HHu9QLWdWtmgRtCfRsnQJhy2binTxpqAfsXW/g6GxofMJzIS7HzD2Yanhj1jIZ3u9ews 5vXDIJTQ4pYOWS7r1gkmuSn5o8hKQhv9fMafHAbmfLjaB+qwK/kGTACMvknFID4RV6ek +flw== 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=ZtPppqn0cObkHfFqeBrroPaPD+bDud26pGAf+e3d480=; b=l8XQ7UmCO3fr1lYGD0NcjDa0CNzimebJCqz7fBrK/dJacXmcqADmeBBk9MQ8ESVXRD 8tzkfokQpiah1gXa8fj56nxQihBlkETz2aX68M/EvZrnXKS8nmE6LIQEVJrT8UAQzH+J 5WYV+lOO9pSsd21M7EftC73zjFMiuYq8SoECapp0JDR20+NiUk7MBmTnyWoyDSHCwCoy JKMpT/j3mu0NHkyJ/3h3LnmR4m1Hcyct2bv9mOSD4ovrlYJ6xOaPlDajO7LW5rHz1/k7 SgK1viYNVi2byPW5VpOwUo0tMwqj6KeMUiZp5jmV9caCIVIDC65t98tXEodzlOaka37M HVTw== X-Gm-Message-State: ABuFfogNjPEKjy0ttcOgPPRuCYqPXxamDD5KujPDtRr53CH/WNJNUC6g x0toHEcnsS8HOFVJWJACmrM= X-Google-Smtp-Source: ACcGV60FvoXuq7WLemLa+Yt5oJNrO/91NoFrZa3ddgSHkEl7JYXjqVYspBDq85k4qq/vIMYfBsq0XQ== X-Received: by 2002:a2e:7e07:: with SMTP id z7-v6mr4202020ljc.84.1538658084848; Thu, 04 Oct 2018 06:01:24 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:23 -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 v6 02/10] mtd: physmap_of: Remove unused struct of_device_id Date: Thu, 4 Oct 2018 15:01:02 +0200 Message-Id: <20181004130110.8496-2-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060141_588673_19A6A954 X-CRM114-Status: GOOD ( 13.15 ) 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:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This struct does not seem to be used anywhere on the code Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/physmap_of_gemini.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/mtd/maps/physmap_of_gemini.c b/drivers/mtd/maps/physmap_of_gemini.c index 830b1b7e702b..9df62ca721d5 100644 --- a/drivers/mtd/maps/physmap_of_gemini.c +++ b/drivers/mtd/maps/physmap_of_gemini.c @@ -44,11 +44,6 @@ #define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */ -static const struct of_device_id syscon_match[] = { - { .compatible = "cortina,gemini-syscon" }, - { }, -}; - int of_flash_probe_gemini(struct platform_device *pdev, struct device_node *np, struct map_info *map) From patchwork Thu Oct 4 13:01:03 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: 978871 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="lM5qSK3s"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N/rqbKWO"; 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 42QtMl1Q8Jz9s5c for ; Thu, 4 Oct 2018 23:02:27 +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=4Wc6vjD76yZT+Gdlfhw7imCKusLQEnNKVi2fq5fRJBs=; b=lM5qSK3s7oz2qR L0LuWjULigd2Bz1R8ts1y5XtrO3+aSg71ivfe7icUkjJBQr66A6dPr535KRhxSjoDy+eiL7U/tjRU qX1R/04A3ksGbwkKGNjHZpoNeu/CbxyXT/IXIBVkHxVlGZc/KNRcs7Hg7rCN8ecKVu7iyw49uUkdC J96EpN2ly1G8rYaZ8tw+qtRAYMv16VjrCJ8/nIm3tblcg4ZsglGXofK6osUPK6N3Y7/rwznViD7RB Rg7W4LU0iU2Q/OFXCv5/r50c8EnuMafzP0LKgpDEyqNyLEf61BgtIXWy2B5rnsPzit2iuIfb76JAL b/ZCN7Yao10tRQ1iaMpg==; 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 1g83Gc-0007rD-VV; Thu, 04 Oct 2018 13:02:11 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83G6-0007d5-0E for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:01:43 +0000 Received: by mail-lj1-x244.google.com with SMTP id r83-v6so8287241ljr.7 for ; Thu, 04 Oct 2018 06:01:33 -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=07UVT8AT/WIvxk7YqGQ2CULDktLqJYK6DbMGdKzq18o=; b=N/rqbKWOjv4JZB2KzozopLDsUfVYb2X7N+HYHiYIL9sCkIp/UBzjQwlbOhIW5PQAvE 1qsRUxPIMoYtRXpYKCuoRjBJkhakRjr5qzxhP5MUramb0rcVo/9TxWq138GcSLblYzZ+ s/QNuTvOqYFpqtPgZ/FlmC56A6yM5YLCpIJEUGsKlx4FE+SDn+Zxy0j1JM9a4gRvLRW0 bWi+smC3xkcD9PB+u8WitHxyO/HwWi5XkYnirDTV5CthLdhV6P5VFpEIWTrKgB0qp5uV GP/3UoHf5ioxuXosjfUcxFVNDYNaaVxgTdZyJsT/RagOyCy8TPoDvEWaIad9oAMW/j+D /OcQ== 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=07UVT8AT/WIvxk7YqGQ2CULDktLqJYK6DbMGdKzq18o=; b=DKL0mRXfGq+cjBUc49VCjsqJhx7VHjxkcTT0V7r7UROg4OJ3D3bTzlH+pLZ0BHVRmq oof33F2x7PDa4augg9jUxTpJ0sE+nRziFIBL0jEhX0pukL5n/+tMMTu+T8qLNisCzITt OqQcozRxTWZyvtgyIXCZefl3mCdnyILycTwdMqoUmYnqezYKRCR2loAfsE2EXYFY3jhs k52n5gfAR0MWg4LWUzwXmCV2YY7hbpH6KsmJ3fRpZfbxAEdQoG0x/HEBqystBGMwTWsU u1q1n1rrtpV3vne4ksXBCwcWlCo2epzD0WTqCj5ruw/oDSx41WRiCGtmcc6Z5xFXrhsD ypDQ== X-Gm-Message-State: ABuFfoif8hENMO6I8Plz8Db0E2CK7HH5a5WuXdVQgJVG4/IywncHbfoK CJG08x4MvtbIxgwGuyeiiHo= X-Google-Smtp-Source: ACcGV63YpbB3H7z/WHChEGvBSmPLyEzmsEEMfZK7GaCwK7YSjv4FDXJMYT+wIl1nOfKViZ+/0qtayA== X-Received: by 2002:a2e:5859:: with SMTP id x25-v6mr3012996ljd.7.1538658086969; Thu, 04 Oct 2018 06:01:26 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:25 -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 v6 03/10] mtd: maps: gpio-addr-flash: Replace custom printk Date: Thu, 4 Oct 2018 15:01:03 +0200 Message-Id: <20181004130110.8496-3-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060138_084303_C03A24DB X-CRM114-Status: GOOD ( 14.27 ) 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:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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 Thu Oct 4 13:01:04 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: 978874 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="gsyk2RNs"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DaC08QwA"; 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 42QtQX6RPKz9s8J for ; Thu, 4 Oct 2018 23:04:52 +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=gsyk2RNs3dQrtt swJ1pMuIR0az8d6fq5kMiHXV0fijAS0E16wrb8G4r1m1wtBeP7/enbdGUHtZpo5PeUonoOHsaKt0F w9PQE8LPgmCOp/3MPfLsslPwZlUSQgOa29+knwOXk7vJ1nfM4BtSN8XhXphkLeVeQU/nRFv6wL5Qn WGNFujBiJ8FTIMIS4I6A+K1EwmUuvgg+9TdWRP0dsQJGAvwiVlTMsRrPHNmLkwrL1Z1tnDPlgOLHR 1gQTZafV/mzkFxwBZKcLIeaA5q5AFG4hrXKtWoS7Y9pm3U0MJSFIP2bAqdCBLp4GgNPEjN9aX7ypU orfiM8o07yN8Bqf5KJ1g==; 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 1g83J3-0000Yb-A3; Thu, 04 Oct 2018 13:04:41 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83GB-0007d4-Fr for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:02:00 +0000 Received: by mail-lj1-x241.google.com with SMTP id r8-v6so8256832ljc.10 for ; Thu, 04 Oct 2018 06:01:31 -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=DaC08QwAwE2cTfCAxrM3F28jYNckLgd4bT6mvCs6SzyUnE4Z+snHTMWUQyBVzz824t yFGiDNK4pL5N545rt2WiyO3uEQKEE63uQFYHakxUF0jDDcbxsHhZd3bmOc+0W5VWToQg 4Nhom2t70glWhW8zmlkPmZ9zXWr9jvgJ2SWRxhE1+PuGzpqv9fwMmModxGj4rEApomQc XWILzzApBGS2doFsZk7W3/RNfFFatADTGCbnXOuoyd6VBKIKpay14f/qdsm0VRiTipnp Ncwlfv38+s1MjdU9a7OiN0EqofBFeFpZNo1Zi+VJU8Lt4ElV1U6S4Q5XNGd1Z+w+SN17 1rQQ== 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=Gvbl+fOFfLX5sm0t6zRO2XPwhkXyKJrB0hsIz3B2KTPxB9A0u+Y7L56PXYr0iSWVhL miw7gmCiePHk+0YtB6Uhjb58QUMFaTv2+Ut0xeRmWNZ2H/53QiCBWWiFS/KvvWwvas+E r9BEd0s51em9eClJvIeHKuRDobmu8PJRz/vMG0k9CndA7fl/DvMtlJvdLSJ/ISPBQXs9 QzDFlRp6KyvgOGO6UTZg3+gJQ7XRxAZp+BYlLgtxoqh48kbk77exhlRLcEEuTb7W/eDl hcox6drvx5C9YdtuYuV/6zFJ19HDDlCHf/4bcqmMildB5JbaDgVB5pC7ww0bMIGypeOy 2B0A== X-Gm-Message-State: ABuFfoi6Xm+97AViS7yY3VyowBd7qIxeCQLB5fwD/WAnnlgucVVYzuUN /pe8DUwy7zX3Rb9Dt/hWGQM= X-Google-Smtp-Source: ACcGV63otuM/988L9WVIeBq2XXb69tMNyC4D3iy2/jVGNACq1D9+NGbP1hYxpHGJVJyvjNLRWtkscQ== X-Received: by 2002:a2e:3918:: with SMTP id g24-v6mr4093315lja.113.1538658088406; Thu, 04 Oct 2018 06:01:28 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:27 -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 v6 04/10] mtd: maps: gpio-addr-flash: Fix ioremapped size Date: Thu, 4 Oct 2018 15:01:04 +0200 Message-Id: <20181004130110.8496-4-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060143_543316_E9A2F0E9 X-CRM114-Status: GOOD ( 14.96 ) 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:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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 Thu Oct 4 13:01:05 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: 978873 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="oMefXha5"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TzK6udkx"; 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 42QtPw0ypdz9s5c for ; Thu, 4 Oct 2018 23:04:20 +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=oMefXha5PxFS5D MRz4OOBp8of3tyYqOmoCwd4KDxNiavFJBYm4hjeH2BkopuKLVjpVzfGhur0RNBtFZw26fJfNdaCO5 w1OIMjTh2sZZAtrtG/AGP7TjwSbXSIw6fLi/BTwY/iO/OqW0ZXFVtZBGnOGBJbDFgb4hDiQw9RqgL SchMpNkQEVE5wNDJfqHg+jNP//bVj1250WvFW7wRk5G+junRGZLjtNg2PUYUUr+CYsOL7BFMR4bhp y003Y/oiWRgQVdwpbw+22V74qBQRANSEj3Q+M+h1yxqXGFRyDdW7NOiFKshQ6j2RF4Fh1f0UpPMf1 EuPihgfPUkvPNjcmlxVA==; 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 1g83IU-0000Jk-31; Thu, 04 Oct 2018 13:04:06 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83GD-0007d6-P7 for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:01:59 +0000 Received: by mail-lf1-x144.google.com with SMTP id t22-v6so6708802lfb.7 for ; Thu, 04 Oct 2018 06:01:35 -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=TzK6udkx40T+yB4Jkdo3zG+dO3MlND4TaMmjCwny6HA9wgto/bQwMu7PEj/az/SB0Y cPV0NWqbGj37xNVZSpgpxPkKtoWihf2BP6Ds1ZZGD9xH91Z7KeRR+J1JUlvNim6qyr8f uIF79i81cN+917iD+EIthwt0dqJd70JVVaF4hKpxZaSqxSYvvlRG7TovePFISdJWPn1z Vj1NonbiUNPvzFssshuDlhcaovLZkcMDlCnbAiNcTVcIS/zf8OmmcHSgQjJ9jJaI1q0O ooWl6rv9BFyWrv+FeiPBVXnWMzFeh2PcyBYcSfdzfNyAj8V8l3vxqvjPRuabE+4apQUB t5+A== 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=aaMOxDGdRx/oTYA79DFGfIR8CGd7eUoojR190FdiDR9/gBvulnxLp/OMWj0rbTVN1m sUnZ4aiKK2HagBOoKtskDnhRv+sLNtMknx85jqCCcG22YLCVe+hyMmQ9sCuIP7mNf/jQ t6SAmtC5Ekgaq+BPAMqyZnG/j77wV/ZtwmLQ+zSyXSSndWMjEWMvxFfddahK2PCwYhIa Oh8hyiectqtyN+27u3fSmnq/8xJ0w88wvBE2qa3MvzMO5R8inCygYFmZrtkqOMffkhkG J1eK7zkvP/gALSxuTjiGABMtsYxJCzHVm8lCF924MNbzWogRG+y6XUUKSy9+4AlGAKEA o3ig== X-Gm-Message-State: ABuFfog0NfmW47lJLGU9ib7puFcLruz9v9wBqHogUGJJnarM4t/nk+zj MuCEgKiRKou0t2/6pXq2WN8= X-Google-Smtp-Source: ACcGV62EXxBxEjJhkLlaL9KwOnTOCd06JwT+hbfkdE0xbcZ1ii6X/Y/CEBWq83IWgObXCoRMYusoaw== X-Received: by 2002:a19:a686:: with SMTP id p128-v6mr3742306lfe.42.1538658090417; Thu, 04 Oct 2018 06:01:30 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:28 -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 v6 05/10] mtd: maps: gpio-addr-flash: Use devm_* functions Date: Thu, 4 Oct 2018 15:01:05 +0200 Message-Id: <20181004130110.8496-5-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060145_890890_BE3ECFA6 X-CRM114-Status: GOOD ( 15.12 ) 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:144 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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 Thu Oct 4 13:01:06 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: 978899 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="n/0hzYSJ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ijf9zYL3"; 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 42QtrM26Rsz9s7W for ; Thu, 4 Oct 2018 23:23: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=eKNkiQowufmiEwIJsU9LphoNRTEn2OqcjO8A83A093A=; b=n/0hzYSJOm7SOR o+7XEVjItJUIaKiu2jFK87eYvL61gqrbINOg1GSe/h9fMFjO63dCd0oxS4szswwo0bFopkpGSqtqc eudxUg5OkUqMbEJNq93Ht6+NwlWkx1GF6AA9VURdR0e7gh8T3MTCYqfghvj81F9CBEbgdBZz3I8NW zEiJj+DN+JI1cJUVk8wCj6LKQuLXg+q4fUpnbO1qy1F9HMd0ITrxdlx6rDskoo2udqdpcyFNhoU3K BHI5YDAJQqLoyzJr4XLT5TD7awkCE29DNdqB5HEvEUa8UxueV3e6Ky6b0Z4TR3DXuI3uZJ1knGsct bjGLiW6nCbdXmQVGCsBw==; 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 1g83bP-00035g-89; Thu, 04 Oct 2018 13:23:39 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83G9-0007d7-HQ for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:01:59 +0000 Received: by mail-lj1-x242.google.com with SMTP id u21-v6so8274899lja.8 for ; Thu, 04 Oct 2018 06:01:34 -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=Ijf9zYL3MFNaHgaweolUADpB/K+9rJBQBRFxNcEdcJQCM/gavBMNeg+2FCGIoDSLwj ndLdTD3MPu4zLCWDDRT4OZ03UqHrTluFZR0aHGaloTji5FAri9CXbzLt6EZs0rY9AwmS Su+wxZ1J3m826dfdo09HBv0OwFpsz3qJygGNw3eNe5vXeiBiRSdcCFGfsPn18JY0IviI rj1G1/1zd7DhUKi1LS4cH04ofjLcqY9RCzKkGxSm+ryOjgeIBYg9DU1nedKxqp73GBA0 6979isa99VCHEH9m8JgQOoj7IUD36gDuOcGXb1ak5yjTJSdVfMBgWX10RDkBqduy4Sjm l3tA== 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=DTBeb+WWIPJd5pnfCQxxxcr4X2p/qDcGf6W04xZSM+496wKEKZVbTKng2fEWZAM1d8 yyyJEoL6khSVICEiwXVLNlEwZP/zIPPxqUI6w8eBHoj3r/kXiexAbypky/P+bu0I9CcZ FjQEyYo0Xgk4vV0B5wSnwjx0bdIF7l0hgq+93rbMl0/ZLEW6ktM3EHMRxsWD5k8+Y0YI B4PvDfTjuZXUHrS7BGmpydWE6A9ltd0PgnHHY+tk17nM/Z8uTqyXYxAAHZxUWn3z0uzT E2OC0PDYeL1TMDnWab12G/q3lpBV0E5OZkLmjUEFR4DStCxAc+nSfWPGoQe+1qHnXAf1 JPRQ== X-Gm-Message-State: ABuFfojI82E6DEaOkYZLcQqcrZwQj9rh6oSq534t+EFwIqirZx3S/2dC rgSUZSWA37OWVqy2DdS5g3I= X-Google-Smtp-Source: ACcGV62omxlHhpDgQYBF3w8cxv32S0xsiQXbLFRgjAP6Dwr4tukEoz6yrex+JNuFbyEarRspIuHCBQ== X-Received: by 2002:a2e:1615:: with SMTP id w21-v6mr4193211ljd.33.1538658091919; Thu, 04 Oct 2018 06:01:31 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:30 -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 v6 06/10] mtd: maps: gpio-addr-flash: Use order insted of size Date: Thu, 4 Oct 2018 15:01:06 +0200 Message-Id: <20181004130110.8496-6-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060141_610582_8EE72C2A X-CRM114-Status: GOOD ( 17.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:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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 Thu Oct 4 13:01:07 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: 978875 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="bpU5qUOq"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="blfNUV8L"; 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 42QtRZ6C2pz9s5c for ; Thu, 4 Oct 2018 23:05:46 +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=bpU5qUOqILSWL/ m6yaSdoHczz9QLKH/iQ77Qa3u4AobKosqBkUQH4EzKe2Brz81GP0BDvssvvjedQ22pYPT9Eie+bgc bw9aaisjr65rWls6Q/9qdyiFGJpjBDwQ1izlVpctoKRyswcuSuuq+Zd8a28PGmXqCMLQ1ae0x9KwM 3rSZ3yWyjBHTG9id7L2cTqa7KbnBj8Oe3445MbLcWDFBD9nlv5qCp4jCuHr/qO1Yuo2ZefCCcDDQz AFiLCEIBtrwa0KYA44ePMpnkJZv9YBY3yuTft9whprnhRL2KrWYLG8Uz3e3qxkUimJ7STJJ07QQKL wJBnuXGfQqQ7GvUSb2xA==; 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 1g83Js-000212-Vx; Thu, 04 Oct 2018 13:05:33 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83GE-0007d8-Ui for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:02:04 +0000 Received: by mail-lf1-x143.google.com with SMTP id t22-v6so6708982lfb.7 for ; Thu, 04 Oct 2018 06:01:36 -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=blfNUV8Li7VdqR7yIcIf84B8bEzopdp6zO2+jdYMtxaUWeE7vPvRwfRC1XZyR+EdlM Ji+D2LCET+bp//Ij4ln9k5E97+2Frp+5i/7xNuHiEnBdGQTzy7oFelCamYNnudUUJycY vduc0vY3MypB4oRiB18EG/p8eKzVRdvWmQNNDbGvDdZeciSCObexH3xCSfcFAhqKLh5x k5JR3HAlvoznDl20rZJDh9hhSH4HQgJOsWt6c+lwIJFDpVZGWXy5bYqRX8hZkc5HFs5R NEM3gsbxV5FQLGBATofBbMagLoWvO7077Qvm3X/lz7KSIKaKbWbaGF9Zyc0vE+Btc8gy pGqg== 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=QLsNuIQkxvnW3XuUngFJTo9DZow8aKIo+p/jAcGaVYiaIpqbADYVXSFRHqwHf1zArv zGs5BXT6L55bQ7s1ma7WIlMihzYlxsASiPZyOFKO1W4BXuybkVrgV0Old3SWv9hHrtQF zJs6gLK2IjfkeIRUdgjsOZvyJNk6MzfthWTM4JcHfUJnq106AfR//U1nBRHBtafNcnBE gZZYFr4U0PTGBIAAzbCi+OFTosyGDDoEOSuw7YcajFWCmgcVXyTnGAApSOZPjU2WKFk/ fudpwbabVyfqfe15iMch6oFVTL3mX98dfij65ZZdC5THWWahxSIhUn/eeF3BHRABW+/X ZMPA== X-Gm-Message-State: ABuFfogjlaASD5LNyqC2vhQ4Zlxfi6lKjB/9FwF8gtvhNyFsI/iGBhgK lLwzsnhyUViAo1xJO1+NAwQ= X-Google-Smtp-Source: ACcGV609Jy+l/OyYktqEvlJthDghglfBx6OE1g1UivdMySWUnjLRyZDbcjD1CE0nHb+QjUMtNKUH8Q== X-Received: by 2002:a19:964e:: with SMTP id y75-v6mr3763927lfd.58.1538658094203; Thu, 04 Oct 2018 06:01:34 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:32 -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 v6 07/10] mtd: maps: gpio-addr-flash: Replace array with an integer Date: Thu, 4 Oct 2018 15:01:07 +0200 Message-Id: <20181004130110.8496-7-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060147_015312_A3275116 X-CRM114-Status: GOOD ( 17.74 ) 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:143 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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 Thu Oct 4 13:01:08 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: 978900 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="eRSEs0Px"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nwK0R2OZ"; 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 42QtrS4dg3z9s8J for ; Thu, 4 Oct 2018 23:23:52 +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=zwkRVUh/mniGgxYdUj6WxL7Y5v0SFRw4JAF2JVllR8I=; b=eRSEs0Pxswmmtv QLc1bVHqUz4jV+c1Kwwv70ffyG2tfvQKvrSFngXPW1syNwvwm+gwfR2PVjSRL8b2jbNb2MOHjbDKF 37yo582kJqsiMjrNfQyGh3qYJhHphsdEWf5Jw/Sdytno7H890ujMeSVq6e+2pScNlUAAISxrgmo9X JzyE+IPso7OyxvvidZflZJBRU3dIwZlmw0FlFi7+NPu0r58Fq1+MIpbni5fIb3j/vxVX251qywvjh JP7iPiD7fAeTIn99FeMvGjq+v2FJ6XYnXSjESRRgpodeBIiv2FTQo4w6FZ9nNjAnA++H3oQj642pu qYlSesHwS7KmipyRjpSg==; 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 1g83bQ-000364-H1; Thu, 04 Oct 2018 13:23:40 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83GI-0007d9-N0 for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:02:25 +0000 Received: by mail-lf1-x142.google.com with SMTP id r191-v6so6724598lff.2 for ; Thu, 04 Oct 2018 06:01:39 -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=t04/5xTYqJKjawPYGYipOMCnPHvhrwprfxMj3JMdytY=; b=nwK0R2OZSH5UwBEsGTDz2oT3Btz/yRnkX9VTpHuhJGNn4Tt5zkXj0nb2wJ8aFo4ovG FmTUjuQu+6PN37LR5phe790zzKjkxT9TEeEcova6fEuV+i98v+19wAZfudwXMYdyTH5k g3H0F8e1HQWOcfG7GO6PgvguzjjZWEZ3QG6Fp57HnbW2k4/k6EPc3sfS1R+Dqrv72z8d nqan44CBVi7Ny+OUu9ITvY1BXbX3q8gONXz/JCTX5Cv9xd32jlyLmuqLrWzwBf7E1szO 5/q7ZxEjcobfWP0qdOXcrb5SvgLP2zv7YkPDDBFexVeYilLlhNamtUh6bOsPpnYtvkVX qasA== 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=t04/5xTYqJKjawPYGYipOMCnPHvhrwprfxMj3JMdytY=; b=CLS3xR076j+ERvYVRJJ8AxqXYaKSGk/K3UObnVEU+h5oi/JNvyAyGVunMWrrxQTboz rFhynCKyJi5nHAQMXSHhfz65E0XFkFU2zAS3Ar7SzVH07TqzecpytRnbKwWqt2D9S7x1 45bcV+jSAgaYGSSAmbKtR1ja28EjpvgSszrJQiIKSIWAuLQup3m4OUXfX8u8KA+lI23n wCICwv4rNJWHKaRSgJdEfUm3m829Nbruza1WqmT8u4b4+M2b+cy7oPoI6dFMSvrNQ4FH 7W41XFMRosV3Z2Zl+EE/tXYDNGmMdKdS15cIOQCBz0mRdi89b7aXYxOUY4rPZ9nxXO3G JZQA== X-Gm-Message-State: ABuFfoh2by5dOPikKRHymWsR3USmwErT5/07X/4z3cRYlfaQuL2ahCcX rsd6KoE4DyOHL1mZDcrF2Yc= X-Google-Smtp-Source: ACcGV61Z9+/eV4GeTsovZKdvE4zFKkssJHGGnj3psbDp3UKITW8OsC7yCqq/sDl8MyY7VL528hBNhg== X-Received: by 2002:a19:518a:: with SMTP id g10-v6mr4039220lfl.63.1538658095799; Thu, 04 Oct 2018 06:01:35 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:34 -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 v6 08/10] mtd: maps: gpio-addr-flash: Convert to gpiod Date: Thu, 4 Oct 2018 15:01:08 +0200 Message-Id: <20181004130110.8496-8-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060150_790881_49B27387 X-CRM114-Status: GOOD ( 18.44 ) 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:142 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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 | 55 ++++++++++++------------------ 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 47b12a6fead4..a20e85aa770e 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,22 @@ 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 = { + * GPIO_LOOKUP_IDX("gpio.0", 15, "addr", 0, GPIO_ACTIVE_HIGH), + * GPIO_LOOKUP_IDX("gpio.0", 16, "addr", 1, GPIO_ACTIVE_HIGH), + * ); + * }; + * 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 +208,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, "addr", 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 +234,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 +244,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 Thu Oct 4 13:01:09 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: 978876 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="bNBUyzCv"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b9PRGK3b"; 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 42QtSF2lGWz9s8J for ; Thu, 4 Oct 2018 23:06:21 +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=oFnutza/njPeOjqrAnuxz+cMQqOte2sMfk+HmLV0h4E=; b=bNBUyzCv64hF/9 AjJb/iIAiNNfC0EHV6LRgJYnNhpBDgUd3PKk7WhAbBzXrmSrOcahFoeZ1iPXs6VSrKNgcs6indi/n EcVRoOv0kY3RP/SYnQg+fhpceJ9ZybrkEnuL1voOxHX6JvtBHrFsUm7WE04pjGYjx5AsxsxKclPWk 8A2PVwHt/7AXudlULgUP25k4X7+HTywZSOUqp3FgO67FNtXHEZYFhOnE6PgJ6CYJeKtke347AaDrX 6jHNgT87ulIZ3VX6jkhCMKTVEf81sm6mlSQgKzCaFzS0vXKJrm/70UFMDjxakFrRVIiW8vn1E/6An Mk/IvXYbdEgiBDnEwVZw==; 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 1g83KT-0002Kg-A1; Thu, 04 Oct 2018 13:06:09 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83GJ-0007db-C4 for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:02:21 +0000 Received: by mail-lj1-x243.google.com with SMTP id 203-v6so8253692ljj.13 for ; Thu, 04 Oct 2018 06:01:41 -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=Mi6p39XaHpJHZl8Psk/3hUmWx8Q0ifFV62Ay17By3MI=; b=b9PRGK3b6u6qCq5THocpUE7EBH0SUn1Hc4xTjgPfhR6TdeSxv+5tnKh2Icj+5sQ7LA /Heu9YYXJ09g2k3tfcyfv+pat5tN97U4sqxFtOYXtNgNZh9I9ckhe+ov4fugtkOD0x2j oDEB6+IkyoIUmaCJ92ZeQphaiQ/n+a1fCsjaz9i4SFbmLMZDoHwvQav7Pgy27HWLbZTj pczJQGG9c9O3Gh08fKl3oTJOczK/6YMJyoTBUjk1pZzt3pBriBitCdudG9op/qs/wpVV Ie716RKY6iitdlV8KeoG3wDkXCATphU0OdOXBF1KKotHVOBvUAhW69962BISpSb0UTDy jeVg== 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=Mi6p39XaHpJHZl8Psk/3hUmWx8Q0ifFV62Ay17By3MI=; b=CROdvCOqo8v7e1l5MIaUMTqgZ57Izf2tTp5UB2jL0+KeuUALDNHI4wpqRL88JDZvlR qCc9sQ9jLDXRSmc5farddGvuk1RRR9MuEy4T6/nvakQoSeQf2sDiOW/bbg3KFeBtg0JX jzJ1gWK+ZQPeJ+tIeJHIL+m9QuXZK/0hrMJmsIqwmTESohnZpaU6awUyO78PDEOrjcxX zGCNzXIav2YvmNV5ulzV9v9D64jL8LHxfyMSpT7zzkc0tniYlZO14zhFvbKr7EieNzvl dlz/I+qBRFRFu9AXjHg8pvCHX2CC7x0pEf1zn2iC1UMcKGF6L/480Jq1+Sfxj0yO8p6S XOcw== X-Gm-Message-State: ABuFfojxQm1boxngU4un6CUc0LIpgOwL9P2GHuLy1RfqMK3wP6t39jxk igmwWOvw5HwQrOuLY3Dem+s= X-Google-Smtp-Source: ACcGV623ANedVX89vhJ9HLENZPxY512+1oNqKT/gmpn89kzpDDtSF1m2fM6WcXy0Wmsey2FdvT5ngg== X-Received: by 2002:a2e:3101:: with SMTP id x1-v6mr1966794ljx.83.1538658097885; Thu, 04 Oct 2018 06:01:37 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:36 -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 v6 09/10] dt-binding: mtd: Document gpio-addr-flash Date: Thu, 4 Oct 2018 15:01:09 +0200 Message-Id: <20181004130110.8496-9-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060151_445993_3091ACC9 X-CRM114-Status: GOOD ( 16.74 ) 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:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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/mtd,gpio-addr-flash.txt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/mtd,gpio-addr-flash.txt diff --git a/Documentation/devicetree/bindings/mtd/mtd,gpio-addr-flash.txt b/Documentation/devicetree/bindings/mtd/mtd,gpio-addr-flash.txt new file mode 100644 index 000000000000..304a33880f9e --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/mtd,gpio-addr-flash.txt @@ -0,0 +1,25 @@ +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 : must be "mtd,gpio-addr-flash", "cfi-flash"; + - reg : Address range of the mtd chip that is memory mapped, this is, + on the previous example 2MiB. + - addr-gpios: List of GPIO specifiers that will be used to address the MSBs + address lines. The order goes from LSB to MSB. + +For the rest of the properties, see mtd-physmap.txt. + +The device tree may optionally contain sub-nodes describing partitions of the +address space. Check partition.txt for more details. + +Example: + + flash@300000 { + compatible = "mtd,gpio-addr-flash", "cfi-flash"; + bank-width = <2>; + reg = < 0x00300000 0x00200000 >; + addr-gpios = <&gpio_0 3 0>, <&gpio_0 4 0>; + } ; From patchwork Thu Oct 4 13:01:10 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: 978879 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="qzkC5UwB"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gvRF2GUO"; 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 42QtTZ42Xwz9s5c for ; Thu, 4 Oct 2018 23:07:30 +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=rNt01/MzH/p6TmMoP/G+9uH8OkB6QeY4E0JAZW5LONQ=; b=qzkC5UwBaUKWJc JT/rs7Ix3VN5sC9HxjGj7M4rHenQq4O6lrt1wLX+Qva3VI8PbigmqPo94FzIpjFF3ps2ylX9FA84S 46de+ln67evVWYdorDOEKZAzvRHHM1JX0rjDx0b832Csbr2ReVCPOJEcJLiKMvGwmlIlNQPGxmsbU i1lIiwoNo0bPTjRQCTc3LHiHvFA1804xwWi9vFFV9Ye2rnz7S+22vfTJFCAyYiJQvBCfLgU/UoYsv u7xqeKRBN7gFqNUJ84JDctZboA8Ei9Ti2E48+T0cyXPPppOKBr0c6J3i8L8cEju5oJbzwJCYQ4YT7 Ksc5jRVdpPbjQOeC6kPw==; 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 1g83LY-0002mq-SJ; Thu, 04 Oct 2018 13:07:16 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83GL-0007dh-KN for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:02:33 +0000 Received: by mail-lj1-x241.google.com with SMTP id f8-v6so8307209ljk.1 for ; Thu, 04 Oct 2018 06:01:43 -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=PHQLBfV+yfk3eYHXazJUVHPKq/BnSdiyfyS6/G9izco=; b=gvRF2GUOUGY1LCejxNnxrNqRPwqM9c4nPMyo4L153JtPbon3RvbQpdt2te1CcC229I CgYWalhTe1CfzEL411QYSkYhR5TVx+hF5va3d2Sim0vH+I3IyTiC4Jdsa3CFCNtEkAh3 SGZLtB3e1487mE9g+LMycsOsD/SM444PCX092N8FBLZkXoy2vyRi8ffUEL2vGE2xdfzW VZq3gnvoXwbLDE5BcGGwkHMOxSheuv6T/Ht6KYHhsMAS4ppYVA1g8r8O/RRVNQhf9i2i 9O57/1j635LljEbapGMocqgj1kMdy1Nj5rTvrylkkC2ItsijKT1pWL4y+jliFaYhVpw0 o/cg== 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=PHQLBfV+yfk3eYHXazJUVHPKq/BnSdiyfyS6/G9izco=; b=j965mElBruGa0Kd9AQEcfGEgaPAdjWj5HgR70hdwvXmPCHWf9VbKrdoRBQcjWOg+YJ 30SjB/0JzSrQyQy3/7LzlcYfsKuqrL1xt7OzlwmDvLujoFOikZ0dc7nD63nNedK+GQU7 uM87+2EDNtOsRAiei7N+RelSK3j46xzpnkehe+dEtLFxUDmIh1rlq9U58MuxEsAPjf4B rDmxLgOH3c/ejewxFGROUp0pINyqdKW8inKgDTvwLNzvTImThQBMx2GynLHx+1F7wKJM QYeuqn7I2BQ3Gek4Wmmiw1zCsIiYN1pTtjYbCFmSJlqf79WtXRbVvGE4ofkS9nnXaMnL qVYw== X-Gm-Message-State: ABuFfohzA0sPDo0MlROCt97hZisP03azJ5mLBiRfFPQgAV/WDq05ETWW rOZubi/wByi8/vPI4I7PRL8= X-Google-Smtp-Source: ACcGV63/e0l2F+urYHzklIkwOZg4CfGhDn7umQtndhXvfaCQH48zDChsmZrxv2BGGs+Ps4OswtpjLg== X-Received: by 2002:a2e:1642:: with SMTP id 2-v6mr4216219ljw.56.1538658099664; Thu, 04 Oct 2018 06:01:39 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a1-v6sm421415lfk.63.2018.10.04.06.01.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:01:38 -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 v6 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices Date: Thu, 4 Oct 2018 15:01:10 +0200 Message-Id: <20181004130110.8496-10-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004130110.8496-1-ricardo.ribalda@gmail.com> References: <20181004130110.8496-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-20181004_060153_746376_194DF363 X-CRM114-Status: GOOD ( 23.67 ) 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:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: 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. Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity. Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/Kconfig | 8 +++ drivers/mtd/maps/Makefile | 3 +- drivers/mtd/maps/gpio-addr-flash.c | 91 ++++++++++++++++++------------ drivers/mtd/maps/gpio-addr-flash.h | 31 ++++++++++ drivers/mtd/maps/physmap_of_core.c | 7 +++ drivers/mtd/maps/physmap_of_gpio.c | 24 ++++++++ 6 files changed, 127 insertions(+), 37 deletions(-) create mode 100644 drivers/mtd/maps/gpio-addr-flash.h create mode 100644 drivers/mtd/maps/physmap_of_gpio.c diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index afb36bff13a7..427143d42168 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig @@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI platforms, some detection and setting up parallel mode on the external interface. +config MTD_PHYSMAP_OF_GPIO + bool "GPIO-assisted OF-based physical memory map handling" + depends on MTD_PHYSMAP_OF + depends on MTD_GPIO_ADDR + help + This provides some extra DT physmap parsing for flashes that are + partially physically addressed and assisted by GPIOs. + config MTD_PMC_MSP_EVM tristate "CFI Flash device mapped on PMC-Sierra MSP" depends on PMC_MSP && MTD_CFI diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index 51acf1fec19b..c232ccf05bee 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_MTD_PHYSMAP) += physmap.o physmap_of-objs-y += physmap_of_core.o physmap_of-objs-$(CONFIG_MTD_PHYSMAP_OF_VERSATILE) += physmap_of_versatile.o physmap_of-objs-$(CONFIG_MTD_PHYSMAP_OF_GEMINI) += physmap_of_gemini.o +physmap_of-objs-$(CONFIG_MTD_PHYSMAP_OF_GPIO) += physmap_of_gpio.o physmap_of-objs := $(physmap_of-objs-y) obj-$(CONFIG_MTD_PHYSMAP_OF) += physmap_of.o obj-$(CONFIG_MTD_PISMO) += pismo.o @@ -44,6 +45,6 @@ obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o obj-$(CONFIG_MTD_VMU) += vmu-flash.o -obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o +obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o obj-$(CONFIG_MTD_LATCH_ADDR) += latch-addr-flash.o obj-$(CONFIG_MTD_LANTIQ) += lantiq-flash.o diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index a20e85aa770e..7837fc7b8de8 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -25,25 +25,25 @@ #include #include #include +#include "gpio-addr-flash.h" #define win_mask(x) ((BIT(x)) - 1) #define DRIVER_NAME "gpio-addr-flash" +#define gf_map_info_to_state(mi) ((struct async_state *)(mi)->map_priv_1) + /** - * struct async_state - keep GPIO flash state + * struct async_state_pdev - Async state platform device * @mtd: MTD state for this mapping * @map: MTD map state for this flash * @gpios: Struct containing the array of GPIO descriptors - * @gpio_values: cached GPIO values - * @win_order: dedicated memory size (if no GPIOs) + * @state: GPIO flash state */ -struct async_state { +struct async_state_pdev { struct mtd_info *mtd; struct map_info map; - struct gpio_descs *gpios; - unsigned int gpio_values; - unsigned int win_order; + struct async_state state; }; #define gf_map_info_to_state(mi) ((struct async_state *)(mi)->map_priv_1) @@ -174,6 +174,31 @@ static void gf_copy_to(struct map_info *map, unsigned long to, static const char * const part_probe_types[] = { "cmdlinepart", "RedBoot", NULL }; +int gpio_flash_probe_common(struct device *dev, struct async_state *state, + struct map_info *map) +{ + if (!is_power_of_2(map->size)) { + dev_err(dev, "Window size must be aligned\n"); + return -EIO; + } + + state->gpios = devm_gpiod_get_array(dev, "addr", GPIOD_OUT_LOW); + if (IS_ERR(state->gpios)) + return PTR_ERR(state->gpios); + + state->win_order = get_bitmask_order(map->size) - 1; + map->read = gf_read; + map->copy_from = gf_copy_from; + map->write = gf_write; + map->copy_to = gf_copy_to; + map->size = BIT(state->win_order + state->gpios->ndescs); + map->phys = NO_XIP; + map->map_priv_1 = (unsigned long)state; + + return 0; +} +EXPORT_SYMBOL(gpio_flash_probe_common); + /** * gpio_flash_probe() - setup a mapping for a GPIO assisted flash * @pdev: platform device @@ -210,7 +235,8 @@ static int gpio_flash_probe(struct platform_device *pdev) { struct physmap_flash_data *pdata; struct resource *memory; - struct async_state *state; + struct async_state_pdev *state_pdev; + int ret; pdata = dev_get_platdata(&pdev->dev); memory = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -218,40 +244,33 @@ static int gpio_flash_probe(struct platform_device *pdev) if (!memory) return -EINVAL; - state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL); - if (!state) + state_pdev = devm_kzalloc(&pdev->dev, sizeof(*state_pdev), GFP_KERNEL); + if (!state_pdev) return -ENOMEM; - state->gpios = devm_gpiod_get_array(&pdev->dev, "addr", GPIOD_OUT_LOW); - if (IS_ERR(state->gpios)) - return PTR_ERR(state->gpios); - - state->win_order = get_bitmask_order(resource_size(memory)) - 1; + state_pdev->map.virt = devm_ioremap_resource(&pdev->dev, memory); + if (IS_ERR(state_pdev->map.virt)) + return PTR_ERR(state_pdev->map.virt); - state->map.name = DRIVER_NAME; - state->map.read = gf_read; - state->map.copy_from = gf_copy_from; - 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->gpios->ndescs); - state->map.virt = devm_ioremap_resource(&pdev->dev, memory); - if (IS_ERR(state->map.virt)) - return PTR_ERR(state->map.virt); + state_pdev->map.name = DRIVER_NAME; + state_pdev->map.bankwidth = pdata->width; + state_pdev->map.size = resource_size(memory); - state->map.phys = NO_XIP; - state->map.map_priv_1 = (unsigned long)state; + ret = gpio_flash_probe_common(&pdev->dev, &state_pdev->state, + &state_pdev->map); + if (ret) + return ret; - platform_set_drvdata(pdev, state); + platform_set_drvdata(pdev, state_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) + state_pdev->map.bankwidth * 8); + state_pdev->mtd = do_map_probe(memory->name, &state_pdev->map); + if (!state_pdev->mtd) return -ENXIO; - state->mtd->dev.parent = &pdev->dev; + state_pdev->mtd->dev.parent = &pdev->dev; - mtd_device_parse_register(state->mtd, part_probe_types, NULL, + mtd_device_parse_register(state_pdev->mtd, part_probe_types, NULL, pdata->parts, pdata->nr_parts); return 0; @@ -259,10 +278,10 @@ 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); + struct async_state_pdev *state_pdev = platform_get_drvdata(pdev); - mtd_device_unregister(state->mtd); - map_destroy(state->mtd); + mtd_device_unregister(state_pdev->mtd); + map_destroy(state_pdev->mtd); return 0; } diff --git a/drivers/mtd/maps/gpio-addr-flash.h b/drivers/mtd/maps/gpio-addr-flash.h new file mode 100644 index 000000000000..46d97a8031eb --- /dev/null +++ b/drivers/mtd/maps/gpio-addr-flash.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include + +/** + * struct async_state - keep GPIO flash state + * @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 gpio_descs *gpios; + unsigned int gpio_values; + unsigned int win_order; +}; + +int gpio_flash_probe_common(struct device *dev, + struct async_state *state, + struct map_info *map); + +#ifdef CONFIG_MTD_PHYSMAP_OF_GPIO +int of_flash_probe_gpio(struct platform_device *pdev, struct device_node *np, + struct map_info *map); +#else +static inline +int of_flash_probe_gpio(struct platform_device *pdev, struct device_node *np, + struct map_info *map) +{ + return 0; +} +#endif diff --git a/drivers/mtd/maps/physmap_of_core.c b/drivers/mtd/maps/physmap_of_core.c index 062add8b3a6e..19a300232969 100644 --- a/drivers/mtd/maps/physmap_of_core.c +++ b/drivers/mtd/maps/physmap_of_core.c @@ -27,6 +27,7 @@ #include #include "physmap_of_gemini.h" #include "physmap_of_versatile.h" +#include "gpio-addr-flash.h" struct of_flash_list { struct mtd_info *mtd; @@ -257,6 +258,12 @@ static int of_flash_probe(struct platform_device *dev) simple_map_init(&info->list[i].map); + err = of_flash_probe_gpio(dev, dp, &info->list[i].map); + if (err){ + iounmap(info->list[i].map.virt); + goto err_out; + } + /* * On some platforms (e.g. MPC5200) a direct 1:1 mapping * may cause problems with JFFS2 usage, as the local bus (LPB) diff --git a/drivers/mtd/maps/physmap_of_gpio.c b/drivers/mtd/maps/physmap_of_gpio.c new file mode 100644 index 000000000000..97e02737ed67 --- /dev/null +++ b/drivers/mtd/maps/physmap_of_gpio.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2018 Qtechnology A/S + * + * Ricardo Ribalda + * + */ +#include +#include "gpio-addr-flash.h" + +int of_flash_probe_gpio(struct platform_device *pdev, struct device_node *np, + struct map_info *map) +{ + struct async_state *state; + + if (!of_device_is_compatible(np, "mtd,gpio-addr-flash")) + return 0; + + state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + return gpio_flash_probe_common(&pdev->dev, state, map); +}