From patchwork Mon Oct 30 18:48:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 117499 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp2987204edm; Mon, 30 Oct 2017 11:50:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QDrEHlMLrh2xroGhE1otsugXqqZoX7tg3erKs/Gvv6/sVKZ2MtNhddV+eRAEa7GhWP1657 X-Received: by 10.99.119.199 with SMTP id s190mr8672718pgc.110.1509389438032; Mon, 30 Oct 2017 11:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509389438; cv=none; d=google.com; s=arc-20160816; b=i5DiLbCLI/1k9Lc65Jmv6ukhbTN93ewMJFdWkhoy3dLhTfKhJ8ZcoUeW/cGJV+8CYs 7euAdivs/31OB27V12ZKeMouFkw+xiAf15sKBgsZVMac/EKXK/nIsSOGLOvpoLEJNPJ7 YgNJhT8mg5TcWkHEI40PAn0OvTFk96Kii3f7BSP4FyrGUxYAfMvTIF0TbWuL7MhY/JF6 nmNpOQVHwS1LAk2IpZGuGeKNClxqHqYYxi1uw5NWpNDtHA9HOeHeGrA4SmpHlqoCVZ6S ojxUpenMhMj/ptSnHT/Z5j2FbVDFIN6JdH8OBC21f2TuAlJNvKrImadOgZO7fwC3MgpO IlWw== 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=cUjyH3chgT4Rb6Y4ozsXtlh5RbiPSHt7GGpCF23O24U=; b=t093sBRxXKsYLgafulEkIw9SNef9jby6GUzCfVM5KRrgVrMIjFQKXrukH8Q28ul9Sx mF74ZV3srVSvoM9uyfHABV6DSftJ1KSFlbS7PcvNMIxcAaeltWtYrEMkMtcgRXuahezU PcIUDxykBN88+kHxax5A6Ghy6oacewtJldTjyVczA0gE106aFA6xp9n2AzCS4LOq6BNt Hu9gPGM2AhTZqn4RYCFhMW6AwK9Hu7IChlscoxnaHzGVnwSmZ96wUDzBo2pYptfHwk8J 40AcmSjK4VIeTkAWZXvk8GnEB/XY2Y+iJFt7czjNG01oBJoJaGZJeq2QadD9CXBG6t9Q eyoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=S+KAuzKD; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=SvdWYPZt; 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 d2si10434111pgp.817.2017.10.30.11.50.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 11:50:38 -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=S+KAuzKD; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=SvdWYPZt; 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=cUjyH3chgT4Rb6Y4ozsXtlh5RbiPSHt7GGpCF23O24U=; b=S+KAuzKDsvvdHehi4gbWEMJF8Z KBsy1QPYiHPD1Qz2uu8OEs975zyu1TXiTeBYr2XcMqcD/RyXi7gg/RGq73zDhrwHE1lUFq1Icc/yE fR6ODhluVyIbsfVJwtMoZswRuUrnPkcIeX97wAx2keaHjp4rTf5VkSZGvi4OebRVfhiaWRfCRhRtX Cl5+WExso0hmg8Muc4FGmk3X7PVkxZY/Ib3F2HB87rWATuJC/CTuQy8FToptmbQDXWfG1/5DfJCXY 2D0v5dshmLtKmPk7M4W421771i0JG73mWxY6ifA242Me6tYP8K+EYOhyAA3QLYuaJqGESgqHJFxV6 4ouBUSwQ==; 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 1e9F8n-0002IL-0l; Mon, 30 Oct 2017 18:50:29 +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 1e9F7M-0000Ma-DH for linux-mtd@lists.infradead.org; Mon, 30 Oct 2017 18:49:06 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 232FFA1E0C; Mon, 30 Oct 2017 14:48:38 -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=Z41H 0cMybL2ws8vzsqddQzpBN9c=; b=SvdWYPZtUrj7Ue0OpTjqox2Xnk8B7gj21onw 5h6scmous0wy5yW4gXKQOWAT9tHEnbKtxXmgn1fwpd932FJdIWNVqP5C9JO8q4WS pDpUufrlJGHQLZkoY3NJ+HEgBUrVYLYsi6HV9+cJ5Q1oqlJ7gbdtWJXEBS5iaisv vlpH0ig= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 1AD04A1E0A; Mon, 30 Oct 2017 14:48:38 -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 95C2EA1E04; Mon, 30 Oct 2017 14:48:37 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id BB91B2DA01CE; Mon, 30 Oct 2017 14:48:36 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v3 1/5] MTD: mtdram: properly handle the phys argument in the point method Date: Mon, 30 Oct 2017 14:48:29 -0400 Message-Id: <20171030184833.20709-2-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171030184833.20709-1-nicolas.pitre@linaro.org> References: <20171030184833.20709-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F08E4ABA-BDA2-11E7-B572-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_114900_703771_E0E7FAF3 X-CRM114-Status: GOOD ( 15.01 ) 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 Acked-by: Boris Brezillon --- 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 Mon Oct 30 18:48:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 117498 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2926675qgn; Mon, 30 Oct 2017 11:50:11 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q97uwFQAb+pGvbov5bkkaAL3KdnQxJskTcbBTGgC9pQ1jqytaPmCiH3VJJox9bXfawYRce X-Received: by 10.101.65.198 with SMTP id b6mr8442910pgq.136.1509389411388; Mon, 30 Oct 2017 11:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509389411; cv=none; d=google.com; s=arc-20160816; b=h8lW89A++snD7AoA9SZKoPyea3QXmlhnftBxsVi+WfXBDjxfddFyejQzj9w0TbyK9p FnNJkaZOfd+QqxUkf6VQOXrHPNA1hzcZMQwsG7h3hr+ChJlItK3/v18LKTAgw/vWTLV3 2wp56GasMOM5QOHGsXt2esvzwYplgR1jjw2LdSvgIQSfBz+2b964WpnOzcQNvkSKkEA6 FdrfDQ+YM3Re8btyGoVQuU3yVl6sQ6gdR+ahRvn3dYfn8Nb1emMUKkAqTqBjwwWwRyEd viiKhPuKEPLXg9DFMbNqer2ZmEdDAAokhbzD0V6HzcTz2cxwePYR+oyDrZT0b0SWG9hQ 7MIw== 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=c/L4yoxcuKGT44Idg1WrrwrESl8yKqnS1u0GM2BeWZU=; b=dz+uwH0aJtEbWoLHjsSLBlZqut/EtJN6C3znERYCn7vT6h1nCGjZGnPUQY97dU2ymD Yn5BKxUYEzRiy8YlqJ6El6uOuuGU4f45ZRokNCoFJoTPLCCttOUYJorevZoUbcNG0oJH LP8mZTvZyHNm+WCmybrHlTaHGIBq+6k/XppkGrQczMeB4bmCe678WPZSh4MiFdiTNb+5 3n4XiQNxqDFWUR1uufkwsZU5LLYxSWSbhQquWN+evF2qPGwJzo5OagIR/+1LL6DIgoJ4 R6Q+nK3ePFYqInCWjzzBR0m0Qk2VMLtt93aQ52ecWiOe0JnR17YX5JrRURDK85SlSftg Phdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=YLCTlntu; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=JZCk7ZNj; 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 n8si10644841pgs.144.2017.10.30.11.50.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 11:50:11 -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=YLCTlntu; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=JZCk7ZNj; 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=c/L4yoxcuKGT44Idg1WrrwrESl8yKqnS1u0GM2BeWZU=; b=YLCTlntu+qrOA2cgr8YeORuGFy 3UHbRGL7+nwREPXLZ5YepnAjqsFLeckXnUvOebPLeYvnztnQuNJncCurOQtstLY+p8Mue5Tz+Zyik WZbjUDpnsilyDPg/waYNX3TOH/ENQ9O+ARgHvUpV0cR9RiyjkwUohZb+5UvMkhRs66WNm7TBZpcaL rqmtQzpPG4UH9N1gvboHAmLtV7UGUR7P2uRpmU9i5m94P0m8/thmscGPReJAH4OMDc7aB36310SHt QVv1WC6hmdB7IOxurcxM2goCb2HPMkG+dUJVPpWb7/FZHc5aXIXHe+W7weLT+Ldz2f9CbMx11bIMO dXoK3mWA==; 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 1e9F8R-00017E-Ll; Mon, 30 Oct 2017 18:50:07 +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 1e9F7M-0000MZ-DK for linux-mtd@lists.infradead.org; Mon, 30 Oct 2017 18:49:05 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 1B9A6A1E0B; Mon, 30 Oct 2017 14:48:38 -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=VKjL lwjI731NZIA7rGd/r3q5h4g=; b=JZCk7ZNjWN9KCafDAULeHTvYZN2KQBSG3WA1 ltlGOC70MIuohvpS6qvdEURBJxwJppKEZOKmlBgwQJnpdooK7wfzhKN4kTdGKXgL MXkJZYcW77tk9cltUDs7Fjb/e3lCKCCVKRZ//7GptVDa06yGu7JUmOv3PgGGuxxz ZO4JFLc= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 12F9CA1E08; Mon, 30 Oct 2017 14:48:38 -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 9B782A1E05; Mon, 30 Oct 2017 14:48:37 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id C4C2A2DA0529; Mon, 30 Oct 2017 14:48:36 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v3 2/5] MTD: chips/map_ram.c: implement point and unpoint methods Date: Mon, 30 Oct 2017 14:48:30 -0400 Message-Id: <20171030184833.20709-3-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171030184833.20709-1-nicolas.pitre@linaro.org> References: <20171030184833.20709-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F0920150-BDA2-11E7-AF85-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_114900_681516_E2D921C5 X-CRM114-Status: GOOD ( 11.86 ) 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 This will allow for the removal of the get_unmapped_area method later. Signed-off-by: Nicolas Pitre Reviewed-by: Richard Weinberger Acked-by: Boris Brezillon --- 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 Mon Oct 30 18:48:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 117500 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp2987548edm; Mon, 30 Oct 2017 11:51:00 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RwhSDvc3x1jdZzQSBAxJTbAPw1bH53RXmkwNVyKBAG4i7Tj1b14anEwhTvPebjW3jNa/6C X-Received: by 10.159.194.204 with SMTP id u12mr8031174plz.401.1509389460785; Mon, 30 Oct 2017 11:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509389460; cv=none; d=google.com; s=arc-20160816; b=cTU8+4zqopQLRhzgw0ZJViAwNZ8qI8NCLq653LupSRNsv0ww1WLtLQcYLJChmRU5Lp eDdaj7tAldnzaoRgUj1B0aX3axM09VYVjIRavxz0eVgrgy9VjHi4ITSyciSJ8Q2h6Tjw xv73tLjJjV2zzHYEsHt+2J7+0Qw29oxYRLEXjxYS4E2nucadFVmvd/CQZD+42J12tZJ7 GSvf4rnb+XPnKRBACE1DsbVIMmtyTHpAD2w1VZBu+mrnumrJNufP7c1KB/2uB3U5T+0O 2DfkvrEt9gCWUAeOMnqtxZurR2CBT1hgnuWGzU7CigyQmfF06nVZjwX+K6MLy5+RHFJ8 qSjQ== 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=0EfIN55V7zl+4Jx2yQuBCpFG8mARzHzNwj7krUzyaUI=; b=sUo+JKMSOlnTcV+GKswkzai1nsDNL6HOcOu58MM9YfenNSTu7zuFcBCvpMWVEC0jd7 2mByDnsJKCQ+hvLNiyoRUtsx+S5N36dt3kEcr5ya6+4Cd45ypXxr7BUa0EMNKoldCj3g O72JtNFyTOkoP+TzJZR8vQTKpabXIuHBft5woN+w78weCLYGSw0cOCI1qX513Ak/m5Ep oSa8RgyS9BkAAGN65q4WgQ2gahLW6JO+q9YRbZSaTUgAC1nYTZk+bwghcVCi+L0RPGqx O/PKnGFGKf8kB4SzD/slHG1e9Dv10j7RPjOLbeVwQh9fDOTjeGGTl4ynf3sjLt1RSMMQ jHAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=I2QSZNz/; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=pDCpKDJ5; 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 g67si4791764pgc.614.2017.10.30.11.51.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 11:51:00 -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=I2QSZNz/; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=pDCpKDJ5; 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=0EfIN55V7zl+4Jx2yQuBCpFG8mARzHzNwj7krUzyaUI=; b=I2QSZNz/Llp6RncDINdNgx0wFP d+evqIBZ0m6BfH46mKU0a4SDX85TNZdAwxy3KuGSbRt3C5f3wvphWnIH7eI78D4Wp/m4bSdm0vV/3 WewWzZGSHommSNdnIi790voERkTDdba9gKKXpDbvd4c6VXCs+yPxynWPJEWHXT/XUpH4I0Uor/iB8 dOfSzk5Y9hR/0a6rDR9KOjgt8FZb9UCfCqqSUlnJetaT9LiRlmsXg/eZ9hDxJh0OVpb4xM+XPeW+3 0o0I35WcQM0fkFQHeuxS3fg57zRBvhZmgzUdn03ADM0ZA/xvr/1fkAXZlWM0JEZG+iZvZIxwFpdh+ U88z79pw==; 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 1e9F94-0002XM-EG; Mon, 30 Oct 2017 18:50:46 +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 1e9F7M-0000MY-DE for linux-mtd@lists.infradead.org; Mon, 30 Oct 2017 18:49:06 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 68B37A1E0F; Mon, 30 Oct 2017 14:48:38 -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=dSGy LMtCEZHgxRxB7BoMQsLs8FU=; b=pDCpKDJ5fq+yYDLd3u/qdZc9lkqHNA39mtys +hDLYuSbwVDQgDbP9mxmzQxmaOs9VzowLFfPzV4AyyC0b22NcFTrEy74b5p0lHb4 jOnsFxeeIXg6BVhALgaRaBNM4qSFs3fr60bPHTS94tWxtqp9NmSj/2KS6I4aLWOw 9dtyInk= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 612FAA1E0E; Mon, 30 Oct 2017 14:48:38 -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 BBB85A1E06; Mon, 30 Oct 2017 14:48:37 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id DB3372DA059F; Mon, 30 Oct 2017 14:48:36 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v3 3/5] MTD: chips/map_rom.c: implement point and unpoint methods Date: Mon, 30 Oct 2017 14:48:31 -0400 Message-Id: <20171030184833.20709-4-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171030184833.20709-1-nicolas.pitre@linaro.org> References: <20171030184833.20709-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F0A5845A-BDA2-11E7-948D-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_114900_674632_66F62BBF X-CRM114-Status: GOOD ( 11.87 ) 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 This will allow for the removal of the get_unmapped_area method later. Signed-off-by: Nicolas Pitre Acked-by: Boris Brezillon Tested-by: Chris Brandt --- 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 Mon Oct 30 18:48:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 117496 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2925707qgn; Mon, 30 Oct 2017 11:49:14 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TlpYh755U1qBbocYn/+4m7fI96t9UTYQErJHkeGL9UnoSJ/GXNLow6KMbpmke4fBQwEgUB X-Received: by 10.99.124.27 with SMTP id x27mr8615650pgc.304.1509389354168; Mon, 30 Oct 2017 11:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509389354; cv=none; d=google.com; s=arc-20160816; b=fyxrxlaffe8dMBNPQgzckQs8410ECegw1JbE/yg6QQA3We5KwLntrUHfHCTHbE5fFU 2lHRVNohHdQ4jRa2S83M2Ee8LU6geos0Eb4+ArLuTEKyzt8i1TyX5bSd1ueg4jtYamd4 syai3uaw6aCX9ZrkJSF16YcHibDEyG5by3lVPWtaRFEe2gHpore2Jvv/f5TqXxlHE/Os C121nYmPWd8i8uE12vGe1hXenJa6RHKK76GyQFKsUIJTaY3jAjP9TQZN9EhYO7yBua3N 98UJnKARpoLN7nZaIFLGctrQZX/ON5BK/r7j99bsCGKvI6sPBmr6/QH/v8fIov24z4CW ueLg== 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=5V/6TMGGJ6qBtPSoEbZdlfmsS9ZVlekUmy92NTGScwI=; b=tPPEflSvDW4zVVK+MaaByj2iBnqw/nb6XNwmY+9/XiiU6qpyXz76g2QFiczMbVe/5e iy1e3UG6AQuKr1tamB85C1Su+JRXC3UaKfrRH+Yocl0kXFrvPs6AnXNRGmjxWzp4Va+y ULzByIm8Gg9O82qE9LsOJvZi7fEesFkzhQFvQZXUODGI9/+3jk/lE6fKLRTNlA7HpeZS avRETSNhxPzNlOJU9d1iQP6Jz7afBhpMefuUWctRybmP81Fz+6p2hu3Dh+/xXfrQ5tOX 4srzqHETp/OJor8TLyWCOA9nl5sHqpQZo7/G9LbmBLtsWfI14INFiWUggHEkwxlvpJ4W /INg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=m2aO79SM; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=NMNOQa8C; 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 q2si9637666plh.626.2017.10.30.11.49.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 11:49:14 -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=m2aO79SM; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=NMNOQa8C; 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=5V/6TMGGJ6qBtPSoEbZdlfmsS9ZVlekUmy92NTGScwI=; b=m2aO79SM8loHIsR1+92RXCnkbT P+61WTSfRxEfE+onMoujIuLObSJjgRyUAyIxPjej3FtTSP+CPkuq14zW8vq8Vx+ygxWJRWv2ajqh9 CjoWae6zxLJEjAxthHocQvDktVk6/cgUx4z/hgelR1F4WceC/vP8bRiKb3FlBrvoo64ZvYPon7d40 kZ+1dewfJFzgahWp6qHq3BVHvp9bOl9MGyWhjMSpIxDIPQ/Wdc4pR/J+5Itoy5J3u02igtYagDUyU ebnNxb+tSRLwqJQhUvLBqAvKwt8bliugni4iuH3++ASwmIMpMHY62gN7CouwrAutpe/b+LxnGKs3L nNGusiHA==; 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 1e9F7R-0000OW-6w; Mon, 30 Oct 2017 18:49:05 +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 1e9F7M-0000Mc-Dh for linux-mtd@lists.infradead.org; Mon, 30 Oct 2017 18:49:03 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 49406A0964; Mon, 30 Oct 2017 14:48:38 -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=nxy9 k56DospvRzVcZd0b3nTEIL0=; b=NMNOQa8CnTRoZ4SM/9zVE33aRs/MJbpTlrOv zTpUhQw+ZFbhGalkkCpSHg1WZo90MFZMAzRBdZGsC6MfhZ7SyFhPOn/Mzz7cC5EB Dgtvv7GzRTD7XydIv+njVeZjlRDv2yiv2enlpDPLE0/cSmd3qR4ZqorYUO2vKOJw nU5gySc= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 41E76A0963; Mon, 30 Oct 2017 14:48:38 -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 C2554A095F; Mon, 30 Oct 2017 14:48:37 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 01B1B2DA0619; Mon, 30 Oct 2017 14:48:37 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v3 4/5] MTD: implement mtd_get_unmapped_area() using the point method Date: Mon, 30 Oct 2017 14:48:32 -0400 Message-Id: <20171030184833.20709-5-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171030184833.20709-1-nicolas.pitre@linaro.org> References: <20171030184833.20709-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F0AA693E-BDA2-11E7-BB1B-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_114900_693788_DD87DFD7 X-CRM114-Status: GOOD ( 13.33 ) 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 Acked-by: Boris Brezillon --- 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 Mon Oct 30 18:48:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 117501 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp2987809edm; Mon, 30 Oct 2017 11:51:16 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Sr4GkR8d97s+MtCHTreUdAbqMMY0At3jXuaRUdYrC6cG1t1py9woxqso5xlzlTwwKUjYh3 X-Received: by 10.84.137.129 with SMTP id 1mr1085847pln.67.1509389476654; Mon, 30 Oct 2017 11:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509389476; cv=none; d=google.com; s=arc-20160816; b=UE74gc6S/NTU7MjEBaVVPUsORrvEYDbVFnZf/24e1w5ZucpVD8jOIIlrBJ87FPJrvP 3DvK7tkWDi5w1fe7PgeTgd7h8H2997eQ4SqGeiMA5hNpMhvJB9nLrEbblDvb1bzmuBw/ uaG7MPUYul7fON3r4/A6ATnfwoUGaKXXEnN7b1impN2eVwjKDodUOhPMUiXcOGtJ68L2 ygNquaEshRsMgGyiFUViMm7kg9KksOToAWUtvek0CtkSI+g74KbAYJEbkGRa9xt15pwk XC4z29zgbp1xQJmMnuQlY3Lg0VMC/XKptNCzCQWrPzGhLpq34EnMrTUtRwyA2wdK+Tcs aWlg== 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=KLUitJnQDcSoGvyx7bn0xZdDQ1LwNk63h1g9su1vuUQ=; b=IahUmfZghJmDAfdQa/G/BXm3oZ0w++W27vYkxMYnLsGcnFcnwffoQGbH6JU1MnU7nk 3iKvJT923XMEP/grKO1qpNZnNi7P4NINgPQwXujLKDXHyloL+I00rVjU5X7PXDcNC+Yc db4iQXTG11L1wSVQhfVvuPqL6aIxhttR295gJ4NozVoq+LCMSp4Ydmd7cXD6lb44M/bD ehnn5307fNLbFp9gjIgeIWuqJOeibeoq6qcJRCvc25ilKGCqxXlhatBBmgGznqQpUw6z ENLRsz4tp4H7aSnLuo5tClFLeOXQyyDrP3XGIrA3PlVvO66yesK9X+WKGwIGCWHvsE8K jhFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=fFGXPhvw; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=l4bOysPB; 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 c78si11500665pfd.293.2017.10.30.11.51.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 11:51:16 -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=fFGXPhvw; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=l4bOysPB; 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=KLUitJnQDcSoGvyx7bn0xZdDQ1LwNk63h1g9su1vuUQ=; b=fFGXPhvwG4Tyb6MMG92/BiqE9J 9BMwnpHdtEVGMtZLOBNFq23iRnKtAjSUUQSfec3hD36+LojlKTa0rdAzIu8RrRByzkNFMu6ve0Jgv eCYmB6ME4fwmqs/SdM4S7gAyqWTRYzoL65Xq9eg8Wp+5pEUjoEOk1+swPwz3/FVHy3V52hHwBqkxO BcwyQ9kwTp1O4SymV7VDJm9hCm1zhMutmq+YVkkqw7R6FFPeYEy84yNopdcvELSVQJh6717TyTh4B yQsGqv4a19p9YgBJ3G/PXNaV9cnmhN8/7nSX6Q4AfpWmo5JCsB3ZGu94dRmh0XiV0gAwfQcoHEqY1 uqAvR+2g==; 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 1e9F9Q-0002pf-7x; Mon, 30 Oct 2017 18:51:08 +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 1e9F7M-0000Md-DD for linux-mtd@lists.infradead.org; Mon, 30 Oct 2017 18:49:06 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 212B2A1E13; Mon, 30 Oct 2017 14:48:39 -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=yWMt +koRs01yy/xue3R3IvdvAcI=; b=l4bOysPBRIchIcT9aS5CObDlyV8cPbJX8RM2 37Yim1LRyGFAItW7BBaqbzFxmNboGvQ1FZxPqymALL8dMPS8ieKTn5Olb9GINybd 4Zc3j7qRS3TyDJbrlICat/3qCp8FiLzlJxIFcyiFgkD1wBVM5bMFBxyAcGZGlesP MxABZiY= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 17633A1E11; Mon, 30 Oct 2017 14:48:39 -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 95F2BA1E10; Mon, 30 Oct 2017 14:48:38 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 0CC5A2DA06E6; Mon, 30 Oct 2017 14:48:37 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v3 5/5] MTD: remove the get_unmapped_area method Date: Mon, 30 Oct 2017 14:48:33 -0400 Message-Id: <20171030184833.20709-6-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171030184833.20709-1-nicolas.pitre@linaro.org> References: <20171030184833.20709-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F126CBF0-BDA2-11E7-B204-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_114900_663501_66CE4902 X-CRM114-Status: GOOD ( 16.91 ) 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 Acked-by: Boris Brezillon Tested-by: Chris Brandt --- 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,