From patchwork Tue Oct 17 15:28:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 116126 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5034121qgn; Tue, 17 Oct 2017 08:29:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SZLH36/MWGb1y4//HTikj/5wO931GdsIMiBFwlfFx5J8It+aNVujlnUy37wSfyWxHzmMPw X-Received: by 10.84.129.2 with SMTP id 2mr2738638plb.270.1508254146375; Tue, 17 Oct 2017 08:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254146; cv=none; d=google.com; s=arc-20160816; b=kjPVA8A8UZzrAYNvicIONgBVN5BhlisFF50HKyy3BfuSsBcCZaLzwnPk9GE3o4YjGP a/z6pW9eCjYogF0Laz514uWN9bAqADXyeudpKFOQ23HgQ8vXWW1JaqGsNY2bSdKBBDQL jLUDquRscWy7lKG0rE4PVoQeFZsuaMw8n8NU0v2C3SAUina/4bUFSPm1xLPIQ9KH1xoS UVKzL7MkwpdQjQeSj2Cg3o528H+LJt7RGMEVW7Pbt3d5V8owK277o5U0mQZshHbVGa04 1nM4PlXOYrLD2UStkNk+BMZv0RzvMVZkkMJ1d0Ynl+Ruz1RLiAmLcNjTSzoDlHqz7XiC 3zdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature:arc-authentication-results; bh=3d6lJSoSBZdJ30DnE78iPQ9amcSDUUs4IxfNh+69OrE=; b=IJPv/rNefGIwaKjIHIZuTQBGuouPq2/kNOxIH1feYTh0darkgGcqfHFJ4tw4F97MLb d7wFh5RoHFkSMGP2+wkY2zfxLtCZyE0p3Wga3GcMD6H8bb4C3j6ps5ySXyUvMkVbmGFj 7w5T1qGBsHVS6vyycPrBnFMSMRUI26RRR2D4/QseeV9xQjysY4UUbe9DfAxOjN6zko4g RdMzZO73ipTR4I+p8fuMKjrBBWDZULRqumFq727DnBHrrP94dGDxGJxLW6YN7Hs37vht Y9yA7LHLES686GcjGFdbGF6QHEfw0hv6jrVEkhr+aO166MtUA/WhDR+AZOUSNZGXcSsq iFFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=sPUqNtXt; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=EM5iO1ti; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id b21si6336593pls.38.2017.10.17.08.29.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:29:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=sPUqNtXt; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=EM5iO1ti; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3d6lJSoSBZdJ30DnE78iPQ9amcSDUUs4IxfNh+69OrE=; b=sPUqNtXt0aK6QQqLkBjmyZt4Wv Mch9EukZDX1JAkjvQtj+eyoJ7Z8/gAZyPHb0liGH1aqYuhDMf0UrT9QJeGGZY9f/YUFgDm9hwyh// sXsIs5+CBix3RCEezb1ilVa0CypUM7MH76YeWbdjn2xj+ulbJVP6XRPEF0ekpCSPGrYShyb1vd4ep ZGlTKqKCIi8YnRrwRnCWCgUnt8UqTa+0tjFc4EkNzRiv2WelXqVREDzGYHwqaIQomgJE/QNYeceD1 sjGW9TEmVqt9rSx6+5l4mlCqsZxKlIIHDe/nmYn6N4AvD8frqIHq0kG3exT5gnB75WQYxKpssOWYF e70jU9BA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnh-0004Fw-89; Tue, 17 Oct 2017 15:29:01 +0000 Received: from pb-smtp2.pobox.com ([64.147.108.71] helo=sasl.smtp.pobox.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnc-0004BW-LT for linux-mtd@lists.infradead.org; Tue, 17 Oct 2017 15:28:59 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 516779A51A; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=ZrIW nK4TxYunlZZpIOgjiQnqXdg=; b=EM5iO1tiXRzG4pDm9otFiAnt8Ljs9RflP4cy GuPgqDfNXH7n85aurtB1F6nEUHOXkw4w7eOOIQ3FA2T9ny7lj9zae7gty3udfhNo yRAFdbdwlTO/sQMrkjj9iG45OPMTWs+y2XIi3FHJm+GpGfRn+2pwmXho1uSFDv3n 6iRYE/8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4A1889A519; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from yoda.home (unknown [137.175.234.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id C95279A517; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 07AC42DA023A; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v2 1/5] MTD: mtdram: properly handle the phys argument in the point method Date: Tue, 17 Oct 2017 11:28:22 -0400 Message-Id: <20171017152826.11658-2-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171017152826.11658-1-nicolas.pitre@linaro.org> References: <20171017152826.11658-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: D5C5B6EE-B34F-11E7-BCB2-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_082856_969260_835D0CB1 X-CRM114-Status: GOOD ( 14.72 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [64.147.108.71 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , linux-mtd@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org When the phys pointer is non null, the point method is expected to return the physical address for the pointed area. In the case of the mtdram driver we have to retrieve the physical address for the corresponding vmalloc area. However, there is no guarantee that the vmalloc area is made of physically contiguous pages. In that case we simply limit retlen to the actually contiguous pages. Signed-off-by: Nicolas Pitre Reviewed-by: Richard Weinberger --- drivers/mtd/devices/mtdram.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index cbd8547d7a..4418629e8d 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +70,27 @@ static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, { *virt = mtd->priv + from; *retlen = len; + + if (phys) { + /* limit retlen to the number of contiguous physical pages */ + unsigned long page_ofs = offset_in_page(*virt); + void *addr = *virt - page_ofs; + unsigned long pfn1, pfn0 = vmalloc_to_pfn(addr); + + *phys = __pfn_to_phys(pfn0) + page_ofs; + len += page_ofs; + while (len > PAGE_SIZE) { + len -= PAGE_SIZE; + addr += PAGE_SIZE; + pfn0++; + pfn1 = vmalloc_to_pfn(addr); + if (pfn1 != pfn0) { + *retlen = addr - *virt; + break; + } + } + } + return 0; } From patchwork Tue Oct 17 15:28:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 116130 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1364170edb; Tue, 17 Oct 2017 08:32:32 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SInkwWog1z7ar3AYlAXazjays1DPG2wXftQ2qHUGScLO/sv/ZffSuN5F3E+FZO/wWWQymt X-Received: by 10.84.140.131 with SMTP id 3mr5300174plt.67.1508254242168; Tue, 17 Oct 2017 08:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254242; cv=none; d=google.com; s=arc-20160816; b=0WIJ1Z8yE+H/7NvUQ/v1jD2OMr01I9k9h+sShEWLxCcmcJwD5xS6CjyLQlRHmxA+je Rsc5W28QfS7gltx7TpSoLMbOg/T22rsUoMgN+rJNs4C9q3fl4+2sRVe5//LCFFTyTr7a GqyeNJ/Bj3CS6e0aw92rNtbUdoOnIcPHPtOGykomTeUYCF4GA0rb0huzzIxx343q6EW+ k8xxhLZlIPvZGhOv9CWsOjfacaAzkJZRFaENjJ9Fg/LCvGeXpQqr1HEqFjl+acyqltdS yekatPmQY1cT9IAKm6FB44pbutiq8iiEGsf//EMBAio/MeZL2NcVV6c94Tedz8eAndoj KhZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature:arc-authentication-results; bh=3PawkdmItPU7sKa0Cd1ratTV4v3mJBS/pxbmr8ihog4=; b=NnDfr93R4zn6JufphvTnrE4goIrVrGrO7v/4gu6Clw5VUZVvhIqZgc8BGnG1efOVOW mgwaWZLEyH8lRlaDOR5HjTg7Xi6Zzkj2i85psq2A4K/FS1Is/oyW0YroOgd/CpTN4Ooe YT190wej5f587fj38N3vHA4cUHXneLN3XBNefkrLxUAz5Os1JD1I3qJ/KXD6ut5CkNTh 50GY0fSGhsyF4CjL+YoXPxtUd33Ix0Kat7YkXl6u5BKhysXAL1Usc/61OzLy2zt57LQ6 +MpgRLk3eM3m2OMAXrA8qFCj8YZlsFnX55xyMWkYW1o8fGaoT01aXgZatbuvbrKNylAO YVDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=OvjiwBd3; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=rNeRn3Xk; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id 205si6009588pfy.38.2017.10.17.08.30.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:30:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=OvjiwBd3; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=rNeRn3Xk; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3PawkdmItPU7sKa0Cd1ratTV4v3mJBS/pxbmr8ihog4=; b=OvjiwBd3zdN/jLnvAX+63+VgjS yCvlYwYQo+x8IXvXX/Cx1gjVLJQCu97TzWQCwzmAdUX8Wiuz20DINWKY/LYF28QfYWOwbaXGoQ8nq fwOvteWRPrR9/E8Vw2YcwQ55oVnv3dbxxNdjwm3c1Qg3rrtboZ/m6M1rWqq8M3JL9uRe+xsNHJEvx xLs+usmp2RRCnDvJvxmqzlquEeBooIEsUP1C5Jz5IkwkK2oOVw79sdjgtL8/jfTiIe0vR5w4mr9zH 0wlO76kqB7KgvTAE/mwWSQwkNUpoBDY4Ew7bSWDpC8ww/fcMPtF8Unl6SMQl2kf/KTHaSbtepwhkb g06EDhOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4TpD-0006cF-Kd; Tue, 17 Oct 2017 15:30:35 +0000 Received: from pb-smtp1.pobox.com ([64.147.108.70] helo=sasl.smtp.pobox.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnc-0004BX-L2 for linux-mtd@lists.infradead.org; Tue, 17 Oct 2017 15:29:02 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 7F2E3927BB; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=NlvM q6yDMX91HkPrlENCXV7XrEQ=; b=rNeRn3XkOqxuOE3TcIv8+Dws5zAkDD/4v8oD nvYaQhpdLb0jNGTErmO3waKNxphg19/uuRRdpub+AN/kI+C1WFfGe7CONa6rJLsU Kjjwuf6BdhKS8jTF/AV0T5QjZ4ahe9TLqPfdAvSo9I0AyJinZflXaw8/0dOElnUs 0NOrSjs= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 76AD4927BA; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from yoda.home (unknown [137.175.234.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 0732A927B0; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 1DD822DA0482; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v2 2/5] MTD: chips/map_ram.c: implement point and unpoint methods Date: Tue, 17 Oct 2017 11:28:23 -0400 Message-Id: <20171017152826.11658-3-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171017152826.11658-1-nicolas.pitre@linaro.org> References: <20171017152826.11658-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: D5E5D4F6-B34F-11E7-B4D6-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_082857_003482_C28E23D6 X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [64.147.108.70 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , linux-mtd@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Signed-off-by: Nicolas Pitre Reviewed-by: Richard Weinberger --- drivers/mtd/chips/map_ram.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index afb43d5e17..c3939dd230 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c @@ -22,6 +22,9 @@ static void mapram_nop (struct mtd_info *); static struct mtd_info *map_ram_probe(struct map_info *map); static unsigned long mapram_unmapped_area(struct mtd_info *, unsigned long, unsigned long, unsigned long); +static int mapram_point (struct mtd_info *mtd, loff_t from, size_t len, + size_t *retlen, void **virt, resource_size_t *phys); +static int mapram_unpoint(struct mtd_info *mtd, loff_t from, size_t len); static struct mtd_chip_driver mapram_chipdrv = { @@ -69,7 +72,9 @@ static struct mtd_info *map_ram_probe(struct map_info *map) mtd->_read = mapram_read; mtd->_write = mapram_write; mtd->_panic_write = mapram_write; + mtd->_point = mapram_point; mtd->_sync = mapram_nop; + mtd->_unpoint = mapram_unpoint; mtd->flags = MTD_CAP_RAM; mtd->writesize = 1; @@ -96,6 +101,25 @@ static unsigned long mapram_unmapped_area(struct mtd_info *mtd, return (unsigned long) map->virt + offset; } +static int mapram_point(struct mtd_info *mtd, loff_t from, size_t len, + size_t *retlen, void **virt, resource_size_t *phys) +{ + struct map_info *map = mtd->priv; + + if (!map->virt) + return -EINVAL; + *virt = map->virt + from; + if (phys) + *phys = map->phys + from; + *retlen = len; + return 0; +} + +static int mapram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) +{ + return 0; +} + static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { struct map_info *map = mtd->priv; From patchwork Tue Oct 17 15:28:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 116127 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5035058qgn; Tue, 17 Oct 2017 08:30:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDicSqzb/E5FNh6wM61NEvjxQy88GTP5Pev3FU6BmAU4ifDXC70oGoYNnFPhAOSRYGX1eIE X-Received: by 10.84.150.101 with SMTP id g92mr12597775plg.168.1508254204389; Tue, 17 Oct 2017 08:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254204; cv=none; d=google.com; s=arc-20160816; b=BGm/VN+q2DWILAwOrTbYBJVpLX7W20ERh2GNb8CVfGdS+8Xvc/AWbneU/2v1/YazZl zie358gYiXhet978ZzcjkJ9K830YXLNKDAUZ9nC8lZsiOPBzbI5eKbcxCXGpZOlKokbM vVTX8ayWdFU+DbWcv3TIIuJ20Izw1aWIKl+/er0zH8o9NeCZS4980ZrJg9cgGZG2cNra DMqt9ATyR+atADeh9VgV8Xtu7uGfaCzyLJBOl3e+cXRWj3IqUlnNhZjqyI2EjlFEvTC+ LCw1qW2WeXN8KpRpqkoJ+XmUxfVOrZVZ/ZFyfc4g56dffVbGzI2tUk++igCmGBUBo2UG hYgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature:arc-authentication-results; bh=kJgjE7UloDl4UbH0SHEuJW3Hhzq6nuwXDWu62PAhCKk=; b=M05y9u04aHh99Agy8TAoWVcCme40yCX+U4LiLe6UPL+W/lfWgDMsQHDaveo/7CwxOd Hocn/y33L/b9kErskNgzdjkFveBFiotZNYabfSq3lcT17VUItpa+T3igLpYifpY3ZRzn rJMKArUlHlaSpcqTGDzzesuNsxJalzwkQVGB7QgF+pRutiXUtxruarZGhuMc5z4HqZ0+ JvpiQeuTnBvxUqOK6g7L3cl1dYYk27caK2pnZYnHHk3VpOHeecL8Ij47xIOnw+AYw+zT mkTXJQPkv4UlQy4i6kO43hImka7TtYrCN/Pat7ndntjTivunrRNc8/8wmabLXrrCINBY BzHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=lCwT+NYY; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=KaTXR21S; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id m3si6272926pld.831.2017.10.17.08.30.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:30:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=lCwT+NYY; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=KaTXR21S; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kJgjE7UloDl4UbH0SHEuJW3Hhzq6nuwXDWu62PAhCKk=; b=lCwT+NYY0Ueew8XPjmZuNZonIR TT0+01+DUYc1Vhn46zS4vJUavdOKSQuKNY/iWS4ic1rFm0xQat1rM3T/74VN/Kbxh1Tj0bXf/c/3L DjGipAHBs9+z9ci05DkdTimIcTFS85HfoHpaujVJ3ogGFyzHZN6C+8fcPSCB1xmH6cxfvlG/pYV+P 6aQeXsMIHL6WnVigU0Pv/Xw3rHicr39bUYP+Y00MFHGiWemwZNvisb8iIDoxQZX3i42c298Y02Hxw GzHjp+TSt2lHGo7sK0iMnUDF6NnZXxvLyLXUxKe8AUp3207/V9QG/QW3DZ7FaUfW1V8Pips0fgp++ o2vwY1CQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4ToZ-0004T7-KA; Tue, 17 Oct 2017 15:29:55 +0000 Received: from pb-smtp2.pobox.com ([64.147.108.71] helo=sasl.smtp.pobox.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnc-0004BZ-L3 for linux-mtd@lists.infradead.org; Tue, 17 Oct 2017 15:28:59 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 76F899A51D; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=wQgk 6G6KtIZtuE3WTSSqIuK0mFY=; b=KaTXR21SBrCqHTBOPoiIfRx6xClGY5UWvh9v oco1idRvenma2zKI7+uxKyT939PgSUFdNbNqYPq/D48LrTAJUiWwnofEknSDJmgE Jpd4ldB+jwtyvK3yc2uxzckCpQOJ5zsifJXYmQ1t1KOj3U7ntpUnKPZ/PerDjDRF BwRyAow= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 6EB629A51C; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from yoda.home (unknown [137.175.234.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 07D899A518; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 447F52DA04ED; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v2 3/5] MTD: chips/map_rom.c: implement point and unpoint methods Date: Tue, 17 Oct 2017 11:28:24 -0400 Message-Id: <20171017152826.11658-4-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171017152826.11658-1-nicolas.pitre@linaro.org> References: <20171017152826.11658-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: D5E5715A-B34F-11E7-9DA7-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_082856_967066_21B832D1 X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [64.147.108.71 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , linux-mtd@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Signed-off-by: Nicolas Pitre --- drivers/mtd/chips/map_rom.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c index e67f73ab44..722afb1cf4 100644 --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c @@ -22,6 +22,10 @@ static struct mtd_info *map_rom_probe(struct map_info *map); static int maprom_erase (struct mtd_info *mtd, struct erase_info *info); static unsigned long maprom_unmapped_area(struct mtd_info *, unsigned long, unsigned long, unsigned long); +static int maprom_point (struct mtd_info *mtd, loff_t from, size_t len, + size_t *retlen, void **virt, resource_size_t *phys); +static int maprom_unpoint(struct mtd_info *mtd, loff_t from, size_t len); + static struct mtd_chip_driver maprom_chipdrv = { .probe = map_rom_probe, @@ -52,6 +56,8 @@ static struct mtd_info *map_rom_probe(struct map_info *map) mtd->type = MTD_ROM; mtd->size = map->size; mtd->_get_unmapped_area = maprom_unmapped_area; + mtd->_point = maprom_point; + mtd->_unpoint = maprom_unpoint; mtd->_read = maprom_read; mtd->_write = maprom_write; mtd->_sync = maprom_nop; @@ -78,6 +84,24 @@ static unsigned long maprom_unmapped_area(struct mtd_info *mtd, { struct map_info *map = mtd->priv; return (unsigned long) map->virt + offset; + +static int maprom_point(struct mtd_info *mtd, loff_t from, size_t len, + size_t *retlen, void **virt, resource_size_t *phys) +{ + struct map_info *map = mtd->priv; + + if (!map->virt) + return -EINVAL; + *virt = map->virt + from; + if (phys) + *phys = map->phys + from; + *retlen = len; + return 0; +} + +static int maprom_unpoint(struct mtd_info *mtd, loff_t from, size_t len) +{ + return 0; } static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) From patchwork Tue Oct 17 15:28:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 116129 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1364019edb; Tue, 17 Oct 2017 08:32:23 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDxTx4y0GfG171g6T5ciKzmIgh2XWxLv2hSO1n9a5rHgJrYh1sfdnvlpVZ1CiBGK24LRF+E X-Received: by 10.101.88.140 with SMTP id d12mr10116641pgu.166.1508254225710; Tue, 17 Oct 2017 08:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254225; cv=none; d=google.com; s=arc-20160816; b=WqqVwiYQCqj7z7u0kTfDhPoKFQ1vcBK6rwRuzQLMNVvYCnsYxIed0h+oSQbok+nm7s WpGuhq8A9lXzsGSqVJUWZnIu+yCZCgxMHELT1fZTJ7H1evQ708Dp5G/IyMykod/RqKN0 HusTwd/Gt/P1dh4kMCGILBcvOiJZgi66e+d30LzHEzAo3Hic1DeajH4AOdWuRFJOwMUD mpMAzZJ2xTbydqibS8M/B9zwkJGYhZNZ5w8jSVt81atDB3/jiEf7Sal6eEuEXZi6NYyX iMkJpVfq7x9S/vEAb6pXyH3Po3yFhKrtfHy83xOZivm2Amej+pdamgtLl/pzXzA2nMR/ iF3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature:arc-authentication-results; bh=139YtR3FX8aeLbyoft8YGRMEU1lDVmdWF9uNuO5iHHY=; b=D/LDp0D2/6HB6AiGV57O6k/YsvUcROG+9oVnv5YF9mAfPn4DyrWswbSbg/qcyc/Dk2 8YAoICIi91KiCycMQCkxVMHyjyBmZy77Rmmu9oTXliCJYWyU3n7XCH5O5PRP4+4itPO4 TD0hq7KoGiqwUs17uQ3j+8v3Jkqwl/j2/MvnhPKzoH7kN/oqGDMIWGQiTOQn6sonRlRw sRmX5xU4SX/AgKrib9UmksmUVs6DKTHfFkQeSAK5i8jQ3wMoDcq97GaVyfani80XI0e4 Wtc7SmF3z6k1JqV1tVDLVmRHdYmsMNRwJax3hazILHL8mjpEqUmFxml+KmhCQmrQu9KI pK+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=CZrpDmqm; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=D5EphJPu; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id a61si4446653plc.827.2017.10.17.08.30.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:30:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=CZrpDmqm; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=D5EphJPu; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=139YtR3FX8aeLbyoft8YGRMEU1lDVmdWF9uNuO5iHHY=; b=CZrpDmqm0vnp20Rf7UGZQrz97J AKsvcdlblQzLRbAmA2hwvILe43AbJcgY4dBMa7VpbbwAXWUj/Sm2AUqCkDb8Lb4J0SntZv7Jjjdpc cmPhGEeUGkIUdecEBqxBIBtTh7/HK3tY9PMyZKVyWDrA1yXE97YQulT+3SE3kzqUQAKnADx5+eeQf pByy4JganEHZiFIfyIP45qRlwv0q5TwJ5gztBCuMdoDdGfH/AMSkmKA2lpQ3k7xSS3aXVBADB/bQk d3hisTM6y9s9qTvwk9wPaLmpCleIHK1J4XZCMIdGDCtt4WrGmcGRFwex+g018qSy6QdMOHk68OgB9 gEL+4r7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tov-0005hp-D9; Tue, 17 Oct 2017 15:30:17 +0000 Received: from pb-smtp1.pobox.com ([64.147.108.70] helo=sasl.smtp.pobox.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnc-0004BY-LI for linux-mtd@lists.infradead.org; Tue, 17 Oct 2017 15:29:02 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id A56D4927BD; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=ykzb un+akuqes7UP1UaiPDJIE4A=; b=D5EphJPuP6JDUUoYqEmP2VYgFEkClprLimpv nXhuvwCTh3IJh9PD+Hl7nVJZUihnjFxnIwz6FUS1WSu1qpuOijLplgcUPZJfpvfo CecHL2gI2+C6Xnm4axKZ4bbjnrDgji4SQhpQHhzcOx2F5cMKzqWUzIgv4AYEEXoS 7wp+cnM= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 9DBBC927BC; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from yoda.home (unknown [137.175.234.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 2EF7A927B3; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 57F642DA0625; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v2 4/5] MTD: implement mtd_get_unmapped_area() using the point method Date: Tue, 17 Oct 2017 11:28:25 -0400 Message-Id: <20171017152826.11658-5-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171017152826.11658-1-nicolas.pitre@linaro.org> References: <20171017152826.11658-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: D5FE549A-B34F-11E7-A1E2-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_082856_986624_7561C8ED X-CRM114-Status: GOOD ( 13.04 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [64.147.108.70 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , linux-mtd@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The mtd->_point method is a superset of mtd->_get_unmapped_area. Especially in the NOR flash case, the point method ensures the flash memory is in array (data) mode and that it will stay that way which is precisely what callers of mtd_get_unmapped_area() would expect. Implement mtd_get_unmapped_area() in terms of mtd->_point now that all drivers that provided a _get_unmapped_area method also have the _point method implemented. Signed-off-by: Nicolas Pitre Reviewed-by: Richard Weinberger --- drivers/mtd/mtdcore.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index e7ea842ba3..ecb0380158 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -1022,11 +1022,18 @@ EXPORT_SYMBOL_GPL(mtd_unpoint); unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags) { - if (!mtd->_get_unmapped_area) - return -EOPNOTSUPP; - if (offset >= mtd->size || len > mtd->size - offset) - return -EINVAL; - return mtd->_get_unmapped_area(mtd, len, offset, flags); + size_t retlen; + void *virt; + int ret; + + ret = mtd_point(mtd, offset, len, &retlen, &virt, NULL); + if (ret) + return ret; + if (retlen != len) { + mtd_unpoint(mtd, offset, retlen); + return -ENOSYS; + } + return (unsigned long)virt; } EXPORT_SYMBOL_GPL(mtd_get_unmapped_area); From patchwork Tue Oct 17 15:28:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 116128 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5036635qgn; Tue, 17 Oct 2017 08:31:22 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAwwwhmy6NdYoh6FQST3bRjmFMDnZYb5KZ+YVav6Ll/EMQLCudXfWnKDPLtfP7R4MPMcqub X-Received: by 10.159.198.71 with SMTP id y7mr12155805plt.56.1508254282613; Tue, 17 Oct 2017 08:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254282; cv=none; d=google.com; s=arc-20160816; b=bWiJRehc60L2NKl0Ko5Pc63zEe6LMxe4/DkI+u2SNLDJIuglMf4yTZ5fiZlQlhNE0E NmpEFuXAbYYQsq2UMCpWZv6eL2h5MlNJm4MtTKIUb7DPP/exk8atjvR1vSP+d4gwNQiy 39AY5waM/42ClTftK+ZLackFoR8wLfhhRetqECNx1yod2hKGYHH3SEGTLrC7zLckN8pR T3KopmPgT5ulE8fPzMSbiM2T9D6Gc3Z1bwYxZyTTKhxKlk4HqUD6AuUbKtP+VXCMr0nl Vnqv2YX0IRXT7W/vYpbPmlkhH1XYtRhR1o3y07/QXkmaFJBKjUsL0TIDeGPfboemu+rk qXjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature:arc-authentication-results; bh=x8xo3A66jw8VM3seGob081I3DO364G1HuWGwERUHE/o=; b=FCebxL2AHxm3zYt1J0cOdNmzLCzBIN4ONHDXybpZrpG1gfP+pp9ByiX6G7mdX2KAUK 3dFg/lRIN4aHj4jc6LOZ4JtDVyt399FrtOmOJ6aD5qRTwJ92Qp1t3FxcoFblamQ8za/3 xTSUzhfOl1bcJmNfUp9Buwlisx9N1BT4LlB6NFWniL/HjZ0boL9/DGT5Y5SrQ5jiEnzH Olo3RFNDqVWK//nrmiZs8Ny552keLkX1nww/YBRmVoT58JuFHE4FxoyW0eSlIWeKc79G 3pN1Q+oGWkdBcFpSZegb6jpaY27vVT8cSGPKS9Dp1VOxDkptEXiEYx4SvEOFpNfo+NEQ pZ0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=eC19Ohwi; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=SboriUH4; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id w8si6247508plz.806.2017.10.17.08.31.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:31:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=eC19Ohwi; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=SboriUH4; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=x8xo3A66jw8VM3seGob081I3DO364G1HuWGwERUHE/o=; b=eC19OhwidSdtTsmB0YHcSqoVZ4 WuqN7v/TkEkHBYQ6GKoQJmV9TtLnksJ+BeODevMDv0vLRvpuh34Lsr5872MwqL7d9cO2hpPxXcWen D9qXc7nhklofElTRIYyByioeiZ/d4hNu76U5PbPi0ITPdQ45empObA3DKrTFFBplbSHBV1RNj/4cw aZYyOiVd7YwLlR+6QGAkiI/Y6HlIRaGbCwXQHHQQGPraKao4nHe8R8pJ/YFdjaVFWx/5TwySJqrBQ 6KvZVzAt4tdvWTDdRHYVDd8E7oxsMXQrWm+OmruJnhmKJUwuyuv7lqKl1gSmqBHb19ku3YpbmiPUe cokuQKXg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tpo-0007Im-3t; Tue, 17 Oct 2017 15:31:12 +0000 Received: from pb-smtp2.pobox.com ([64.147.108.71] helo=sasl.smtp.pobox.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnc-0004Bg-L4 for linux-mtd@lists.infradead.org; Tue, 17 Oct 2017 15:29:07 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 6E5819A520; Tue, 17 Oct 2017 11:28:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=DZj7 LT0wwu1lrJdScmUkoFa+v2I=; b=SboriUH48SY8e244FPRG83WfQk2Kq3rZitl9 CFKGg4fehWvn3BVkY4diY2P8S458wgR6kAlGiTqf958a7rvabx4i2xvRlaK9j7Z7 o5uqP9mA3wbimw8q4TNjnszKQe7gFU9McPiV2HnCBq5jLNZ/i5LME5cgIgNUL3lz uTGXitw= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 66FCB9A51F; Tue, 17 Oct 2017 11:28:34 -0400 (EDT) Received: from yoda.home (unknown [137.175.234.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id E130C9A51E; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 6E5372DA0661; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v2 5/5] MTD: remove the get_unmapped_area method Date: Tue, 17 Oct 2017 11:28:26 -0400 Message-Id: <20171017152826.11658-6-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171017152826.11658-1-nicolas.pitre@linaro.org> References: <20171017152826.11658-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: D66DC74E-B34F-11E7-8D2B-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_082856_997855_07FABB18 X-CRM114-Status: GOOD ( 16.71 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [64.147.108.71 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , linux-mtd@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org It is now unused. Signed-off-by: Nicolas Pitre Reviewed-by: Richard Weinberger --- drivers/mtd/chips/map_ram.c | 18 ------------------ drivers/mtd/chips/map_rom.c | 16 ---------------- drivers/mtd/devices/mtdram.c | 14 -------------- drivers/mtd/mtdconcat.c | 27 --------------------------- drivers/mtd/mtdpart.c | 14 -------------- include/linux/mtd/mtd.h | 4 ---- 6 files changed, 93 deletions(-) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index c3939dd230..1cd0fff0e9 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c @@ -20,8 +20,6 @@ static int mapram_write (struct mtd_info *, loff_t, size_t, size_t *, const u_ch static int mapram_erase (struct mtd_info *, struct erase_info *); static void mapram_nop (struct mtd_info *); static struct mtd_info *map_ram_probe(struct map_info *map); -static unsigned long mapram_unmapped_area(struct mtd_info *, unsigned long, - unsigned long, unsigned long); static int mapram_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys); static int mapram_unpoint(struct mtd_info *mtd, loff_t from, size_t len); @@ -68,7 +66,6 @@ static struct mtd_info *map_ram_probe(struct map_info *map) mtd->type = MTD_RAM; mtd->size = map->size; mtd->_erase = mapram_erase; - mtd->_get_unmapped_area = mapram_unmapped_area; mtd->_read = mapram_read; mtd->_write = mapram_write; mtd->_panic_write = mapram_write; @@ -86,21 +83,6 @@ static struct mtd_info *map_ram_probe(struct map_info *map) return mtd; } - -/* - * Allow NOMMU mmap() to directly map the device (if not NULL) - * - return the address to which the offset maps - * - return -ENOSYS to indicate refusal to do the mapping - */ -static unsigned long mapram_unmapped_area(struct mtd_info *mtd, - unsigned long len, - unsigned long offset, - unsigned long flags) -{ - struct map_info *map = mtd->priv; - return (unsigned long) map->virt + offset; -} - static int mapram_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys) { diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c index 722afb1cf4..20e3604b4d 100644 --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c @@ -20,8 +20,6 @@ static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_ch static void maprom_nop (struct mtd_info *); static struct mtd_info *map_rom_probe(struct map_info *map); static int maprom_erase (struct mtd_info *mtd, struct erase_info *info); -static unsigned long maprom_unmapped_area(struct mtd_info *, unsigned long, - unsigned long, unsigned long); static int maprom_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys); static int maprom_unpoint(struct mtd_info *mtd, loff_t from, size_t len); @@ -55,7 +53,6 @@ static struct mtd_info *map_rom_probe(struct map_info *map) mtd->name = map->name; mtd->type = MTD_ROM; mtd->size = map->size; - mtd->_get_unmapped_area = maprom_unmapped_area; mtd->_point = maprom_point; mtd->_unpoint = maprom_unpoint; mtd->_read = maprom_read; @@ -72,19 +69,6 @@ static struct mtd_info *map_rom_probe(struct map_info *map) } -/* - * Allow NOMMU mmap() to directly map the device (if not NULL) - * - return the address to which the offset maps - * - return -ENOSYS to indicate refusal to do the mapping - */ -static unsigned long maprom_unmapped_area(struct mtd_info *mtd, - unsigned long len, - unsigned long offset, - unsigned long flags) -{ - struct map_info *map = mtd->priv; - return (unsigned long) map->virt + offset; - static int maprom_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys) { diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index 4418629e8d..0bf4aeaf0c 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c @@ -99,19 +99,6 @@ static int ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) return 0; } -/* - * Allow NOMMU mmap() to directly map the device (if not NULL) - * - return the address to which the offset maps - * - return -ENOSYS to indicate refusal to do the mapping - */ -static unsigned long ram_get_unmapped_area(struct mtd_info *mtd, - unsigned long len, - unsigned long offset, - unsigned long flags) -{ - return (unsigned long) mtd->priv + offset; -} - static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { @@ -156,7 +143,6 @@ int mtdram_init_device(struct mtd_info *mtd, void *mapped_address, mtd->_erase = ram_erase; mtd->_point = ram_point; mtd->_unpoint = ram_unpoint; - mtd->_get_unmapped_area = ram_get_unmapped_area; mtd->_read = ram_read; mtd->_write = ram_write; diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index d573606b91..60bf53df54 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -644,32 +644,6 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs) } /* - * try to support NOMMU mmaps on concatenated devices - * - we don't support subdev spanning as we can't guarantee it'll work - */ -static unsigned long concat_get_unmapped_area(struct mtd_info *mtd, - unsigned long len, - unsigned long offset, - unsigned long flags) -{ - struct mtd_concat *concat = CONCAT(mtd); - int i; - - for (i = 0; i < concat->num_subdev; i++) { - struct mtd_info *subdev = concat->subdev[i]; - - if (offset >= subdev->size) { - offset -= subdev->size; - continue; - } - - return mtd_get_unmapped_area(subdev, len, offset, flags); - } - - return (unsigned long) -ENOSYS; -} - -/* * This function constructs a virtual MTD device by concatenating * num_devs MTD devices. A pointer to the new device object is * stored to *new_dev upon success. This function does _not_ @@ -790,7 +764,6 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c concat->mtd._unlock = concat_unlock; concat->mtd._suspend = concat_suspend; concat->mtd._resume = concat_resume; - concat->mtd._get_unmapped_area = concat_get_unmapped_area; /* * Combine the erase block size info of the subdevices: diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index a308e70739..be088bccd5 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -101,18 +101,6 @@ static int part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) return part->parent->_unpoint(part->parent, from + part->offset, len); } -static unsigned long part_get_unmapped_area(struct mtd_info *mtd, - unsigned long len, - unsigned long offset, - unsigned long flags) -{ - struct mtd_part *part = mtd_to_part(mtd); - - offset += part->offset; - return part->parent->_get_unmapped_area(part->parent, len, offset, - flags); -} - static int part_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { @@ -458,8 +446,6 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent, slave->mtd._unpoint = part_unpoint; } - if (parent->_get_unmapped_area) - slave->mtd._get_unmapped_area = part_get_unmapped_area; if (parent->_read_oob) slave->mtd._read_oob = part_read_oob; if (parent->_write_oob) diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 6cd0f6b765..0a0678a5e6 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -297,10 +297,6 @@ struct mtd_info { int (*_point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys); int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len); - unsigned long (*_get_unmapped_area) (struct mtd_info *mtd, - unsigned long len, - unsigned long offset, - unsigned long flags); int (*_read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,