From patchwork Wed Oct 11 03:26:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 115484 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp273836qgn; Tue, 10 Oct 2017 20:27:23 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAJh/StD0uREp8uBRvdrGQdbYr92dqzmzm+CckWX/b326ySkxdxEBhpIqVmYO468htCQWcr X-Received: by 10.98.147.197 with SMTP id r66mr10044220pfk.20.1507692443285; Tue, 10 Oct 2017 20:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507692443; cv=none; d=google.com; s=arc-20160816; b=uUY2G3JA5ZkOOCxMjHhK/QBVzPBZFzMvXtJj+2EEW+eXLxAlStNVQIn/4GyLyrxAxw uFZr7mWMpyJPygQrBe25gTA+IK+ScR2/dupPpq6yH25lu/TRDIP9dOFwiLORh7hkLEEm F0ppV1Pyzcg/OLmoEfQmlJkxQJbEwizHybMSUK5nGinZDReX5l7G6KSADzoyO96gJHI/ zNr6S6oFyXw7sklTMNb4Ums8Fl7s2gBnFd3QB2b20hFZ2YW3imMKhOnzQyt7/t/3GoIG wULPRq66WeijP569Kt3q/B2Z8TieNwFZAeXT0DElLQ46b8rWAiL5k0vMfqaihwNCKgRJ kbBw== 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=4jzwR3JLURSybJH2QhcqCYc6waXm5uXamkb+cnrZoPM=; b=uxTfZxrPyaAMy8f7z6b9VSvvI+hUVZVqcgtCNpJHAFyvmq21sM3SAWiozgkr5HdpSs 0NpEnfLag08IyWZ/3KZsHEP78A9WC+xTO4NyiZHxuA2JXHjNyrWcih5+8nMAgYj4VT/k 067gfZAgFfFD16y/13+BM/UDTMb9zXfUxy/a6IF5DgaopoTkr/FlMsnvOjEy3P55kRjY bFmKSvKzCfC6ILQOmU3DSa+JbSylmGkidnAi9yFCNUZuuLV4aC89fA080eMd0L4qLqO+ vKEZhkZ0FvcVbzTrstBRl7DFwGvQhXxjObPLW9FjqXQFry7Q6EbvOI9Isz3Iv4oBhsfK n3zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=BvFZklk7; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=SMCrRGPN; 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 p4si9472457pgc.42.2017.10.10.20.27.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 20:27:23 -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=BvFZklk7; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=SMCrRGPN; 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=4jzwR3JLURSybJH2QhcqCYc6waXm5uXamkb+cnrZoPM=; b=BvFZklk79tiI4pUW4+HrnQzMiA gjNFVYUqd0K1yAFx0v+pwwbhFjcYCxjfIxSYXZ8WoURMG9qWPrekzchQxabrUDcwL0LUCGiy/IAG+ SNONUHs/nHfD7SE733Vi9ZSjkM5JoGcIF9NslqXxSGrkUjekyhYeFy0/9oVzRCiQq9v6o7/zaiw5G +92mP/G2gmDimI2uXYW6nKplh/qxRSfCRYCaGzoqvjYUvo1XeQAwjQeS+xh8jsOp3JBa4ipoPc8xD Ag406o0kKUhV7iHQrEFH4TC+GJRsKWJFpK3FZL+WgBQPxZsr4YKH7/Girr/a7izxe2i31nu9jiWex jhQob3gw==; 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 1e27fs-0002t8-NF; Wed, 11 Oct 2017 03:27:12 +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 1e27fZ-0002Ln-0G for linux-mtd@lists.infradead.org; Wed, 11 Oct 2017 03:26:56 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 9356C9F57C; Tue, 10 Oct 2017 23:26:26 -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=O9H5 MiUGdRQlUnrmeIrhsky8wrw=; b=SMCrRGPNs9njqCA5XUGhNk0eL0kkVBK3WaiI TLm83Sx7i4yr7TSorYKT2uktsGPYD5nbv/kZh+0IeNa1WqWEIs4YL0uHqvktk5fF EDqiMFnR/RnP0eQvkFmpDhpUDaN9tKNGebV8ntigb+qoCWs4bFMFYhJVwVfAn/3q iSf0OcQ= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 8AAAE9F578; Tue, 10 Oct 2017 23:26:26 -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 2631E9F575; Tue, 10 Oct 2017 23:26:26 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 5FAEF2DA0624; Tue, 10 Oct 2017 23:26:25 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon Subject: [PATCH 1/5] MTD: mtdram: properly handle the phys argument in the point method Date: Tue, 10 Oct 2017 23:26:17 -0400 Message-Id: <20171011032621.26979-2-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171011032621.26979-1-nicolas.pitre@linaro.org> References: <20171011032621.26979-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F696471A-AE33-11E7-A1A0-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171010_202653_261429_90452B24 X-CRM114-Status: GOOD ( 14.97 ) 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: 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 --- 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/ Reviewed-by: Richard Weinberger diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index cbd8547d7a..7dbee8e62f 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 = *virt - addr; + break; + } + } + } + return 0; } From patchwork Wed Oct 11 03:26:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 115486 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp274135qgn; Tue, 10 Oct 2017 20:27:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCcCU9QhAnwgnNPluGNNyTuOBMupMbpU7SX3/mdnB2bLe98sRIAAHrTrJ0BnDN2kw27GbKZ X-Received: by 10.99.123.22 with SMTP id w22mr14129248pgc.396.1507692473599; Tue, 10 Oct 2017 20:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507692473; cv=none; d=google.com; s=arc-20160816; b=KgdrAWKpYj44jD33/cgROXfsO4cnuUBUByMYuYc4H+TGuGqIKbGLDd2VNFlqfSnTEN YMMRaiQrrCUmYUTfMmWYwAA4g5JH+Yc2uVFitPgBRuDYZuIl6F4cM1qyAK7+zS7NFrC7 EpZqs5OKmqgmw3vJpgOj+Yhxj0d35nnoRpPfN2FrwcqjRIf8z2c6+w1xsx/HDUSYjBzA AG/Npe36Or8FPPEG7DliiX3vCCVgbqWlbo7ycgjdNX1V954AY+cP5nLoSOpJxX+EpbcD 606Rt4tsHT1gH836Z1qBaXWl10WXZ5l8oglZXtjqw6VOLmxPn4xyG0opMO9nvpmBEGBf r+Gg== 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=Tk+hKHKgJ40KflWolOfyr6j5Ti/te3SheEkYTcQi71g=; b=qKf0kiVgDcdAF2+WKpHJAnNZYFf11MFbs+9RoWixLhjB+GQU75aVTt/Mlm9utM1Qvt DewNZLVnIyltu5c7xKH5A5fJzqkDPPBY7Ua1UeeQeZvoimfUKScOcmkV244jfY0jJOdS jHpjH7lLnEUEjEwq3tjuhVAT8YeACnVc99hmFnW9qzDGY1mNsrIbDUv8KsSfMf5w2slT /NrNHsB0aBNjqqVGVazl9awvelHRxAySdBq2OW2M6SaXtobVq7WeMqgXuWlipSWSrozZ 4g+B9AFWJIndWm/hUIMDHDt5wIkkW3J9Apc/hgpm/X4+ZAbif7fjDabISnydt7ea713i ByVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=tieMCKt4; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=Kobpr3aY; 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 a61si9944187plc.827.2017.10.10.20.27.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 20:27:53 -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=tieMCKt4; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=Kobpr3aY; 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=Tk+hKHKgJ40KflWolOfyr6j5Ti/te3SheEkYTcQi71g=; b=tieMCKt41PzGB6K6ionsbhm8fk zkML6WJtet6swAFVgwO/W1TDl1Cmk5O0EhFd9hlQVcF0UnC8/W+vAwUVFjPNQsh5PB9+CA39D6WxW xBkBCfOmR0sgu4rOZfHYoz5wchV4oT7llRSAevUd5vg7dEE7+94FrF2w604wrJEfKVa6cnY+6/nsF wOZ9sGbaJjEYwcTIfGWghxTuE7UDO4pP+968FPdcySi9anpyL0Z7XY9kTzWAvp4Nz94vq0y/J9W7C EUZZMVXBIpOg5ZaGIuVf4lsgb8b5Gge9NfJvxnqZvoJiwsFbEzdk3MrFVuuRkRCX0eYm1v6ZPkr6x JT8gkemw==; 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 1e27gN-0003TB-Ou; Wed, 11 Oct 2017 03:27:43 +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 1e27fZ-0002Lq-0F for linux-mtd@lists.infradead.org; Wed, 11 Oct 2017 03:26:58 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 733FAA7284; Tue, 10 Oct 2017 23:26:27 -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=OCDL BXzYKcLXp8FBOd7Ct/lChD4=; b=Kobpr3aYbw+UNxZeuuuM1gqArc/q2XKq2ZDs uWhQ0rY2kkErJ8UmUvNCRTXvWjIE8B5+j3BhvcqWblfwA74U0JRcLulw7pHhglq2 i0zOIfCn7dwczGhjt/clWvVOJA74RTlSBli10S6tvRj7lE4BuYJ8FtAKn0JzpdLO WTeQy7A= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 6A39DA7283; Tue, 10 Oct 2017 23:26:27 -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 DBA46A7280; Tue, 10 Oct 2017 23:26:26 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 747802DA0631; Tue, 10 Oct 2017 23:26:25 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon Subject: [PATCH 2/5] MTD: chips/map_ram.c: implement point and unpoint methods Date: Tue, 10 Oct 2017 23:26:18 -0400 Message-Id: <20171011032621.26979-3-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171011032621.26979-1-nicolas.pitre@linaro.org> References: <20171011032621.26979-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F70831E0-AE33-11E7-92F3-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171010_202653_273777_40518482 X-CRM114-Status: GOOD ( 11.46 ) 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: 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_ram.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ Reviewed-by: Richard Weinberger 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 Wed Oct 11 03:26:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 115485 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp273930qgn; Tue, 10 Oct 2017 20:27:32 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBBMwLhlZtzJLXLubPyC5wYIyR0uYiT0hT5v2WENq4lQCH2lVGcxRn9YqLzh2ZS0tDb0Sf4 X-Received: by 10.98.13.8 with SMTP id v8mr15377082pfi.180.1507692451956; Tue, 10 Oct 2017 20:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507692451; cv=none; d=google.com; s=arc-20160816; b=U3slX490oIDjw2UPhcKaoQZNm9w9TNH+N7f1OD/wcgx0+/pj2aCTqtpq2biBS7Yeta 2V5PlzKR0pbIUz5Aq/bmtuDx0pt5g3NO43ouohuFz7CxvVrSmM9m5elMcgs3vAruL4na kfSFxiwVA6dt2f7hVG/aD4s20EuOzyCF+gq9i0Wef5Bh0sYd6y2w9QR1ST3Hm/agWSd1 CIGrbHDZ9/rF2r17A+Tf0f6X5CSTaC2AKAenL1PFWalC0QgXSk+yfNejHhiAMFz4hcED SH/zRHozpeRUxvTCLHsL7dsHr1qteW1/kuYkb95DQSxEmrO/lRlZ/aQeMZfy3/7rphFM KyFA== 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=o90iyB2PQiY765wSG08SUIta4sDzqmhoUpPGY2Ame58fccfmjNM+G5bRjjjd4SXx/K YzWyXdEQiNZMdj3jaTxA6x2v8l73ReH5usdvs5OmsgSaMB7yvwNiNsoe9GURCU4IyhFH ez3o1MJGe3shdGy7UB9BkZJ3HSUst2mYJ+XsAwAvRx4RnfvOS/Sm21lHq6Vnri3OBDB6 UE3zS8D4F1pAN+QADJ6vdbZ3h1dc2SaCuw3e2cvoqnyecFx65vuXq6F2M5Zo/rsSwJqT NXsFR5BplNLU8QLwqVTy9SlFL+dgmc3glTpF7/L73KjdwfxpB+hR4MDbs2Bk8GBnCgK5 /KAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=hXJFcYL6; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=FSAWz+K2; 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 x85si10165923pfk.613.2017.10.10.20.27.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 20:27:31 -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=hXJFcYL6; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=FSAWz+K2; 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=hXJFcYL6+FMDUYRmqQD/zKUCGD jW5p5eisJZ5m9Y36SK4WDi6LhE4VqQpLdHNVoSPl13Lc5LT51zpXx/Zx8TIpdulF14jcCFDgadqX9 vbMwmUu9wUpAb7Lt4p6cpEatuET+x6MnLG6RXcxYtJnrtzw5enWKaIHVeGH9QbICZ+qFjBxISjzGE 3ziaIGbV4Hb97wNg+4t8Hw6gcX7R2udn0PLpdPzuczIz4pl8+KrdPRPDYzGqd1/QMlYwJABZcLoba rJQWM7qtHkzRVIWmlt4nZ+U0gsF5e7NGzePuBc6Y1QyRTQsbz771uz7rsy7na59C2JAOebZl9Zh29 eFbm/OvA==; 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 1e27g7-0003BZ-OU; Wed, 11 Oct 2017 03:27:27 +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 1e27fZ-0002Lr-0G for linux-mtd@lists.infradead.org; Wed, 11 Oct 2017 03:26:58 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 8111DA7286; Tue, 10 Oct 2017 23:26:27 -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=FSAWz+K28+sQM3KDkpSrOrFOPiPeCvuh5/Wc stoZHVxvmXhXn6fdmYIBGEkyXKZXRwsfukUSFJ3u5qRpLxdH74HmvMEkHJvUJhuh 6m9d09VzNQ/mT1CXhl8XGLK0dIFUUNZsd975bKU2JQDycfd60BKgbGrIlvctaYg3 rCENDC8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 77706A7285; Tue, 10 Oct 2017 23:26:27 -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 DEC3EA7282; Tue, 10 Oct 2017 23:26:26 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 7FC302DA0660; Tue, 10 Oct 2017 23:26:25 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon Subject: [PATCH 3/5] MTD: chips/map_rom.c: implement point and unpoint methods Date: Tue, 10 Oct 2017 23:26:19 -0400 Message-Id: <20171011032621.26979-4-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171011032621.26979-1-nicolas.pitre@linaro.org> References: <20171011032621.26979-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F70A6618-AE33-11E7-8351-575F0C78B957-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171010_202653_263781_4ADB32E2 X-CRM114-Status: GOOD ( 11.47 ) 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: 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 Wed Oct 11 03:26:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 115483 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp273642qgn; Tue, 10 Oct 2017 20:27:03 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAzloHIsPsHhezMgTCMZYlzX5UmxnOu0o+I7XOUljX/X8glwmr2AM72+R+2LJDBKCGRidU0 X-Received: by 10.99.179.5 with SMTP id i5mr8663045pgf.199.1507692423077; Tue, 10 Oct 2017 20:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507692423; cv=none; d=google.com; s=arc-20160816; b=g9Ez8NBMvcD/UPWHLRWokkChoZWe05900S/Agzn4wy8pTcsrgtHSxgcGshNcZfv37e O/PTyn+XM7dPxClImdScMF6Wk5knl9aBeTqJi+WW/ysVHxYMG4u57qTa7t7X0YKOZbhV YNFGega3bRwGhW6boxnN+4Gv2QYWfkbOEsJTBbBxamZiPGqmZZnJeqN2/jT10PjFIf3b vBH8YFAq1cSlmt1QkI4vjLjWzyL6VFqeKh1P203jYZN98GhTe4EtXZNDWexZQ5DW7m8R co5nvcJz/yTt6Z9pBiHl57KMozGkI4SjW4X7Nd69ljHGcV5Oljbzem+J4tfL+mXZO+37 +5KQ== 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=2Aa5HSAmoL0leESGZppAd03c67g6Ayb0d168bRJyV7Y=; b=0O2VeR9TKt5lmaVQst+gjKbMTOzGOBTYO0Ko6lmcXivYGWYQYzCSfxZt55F/2+aL1G tE0qI5/4oeuQiaWBDZF/s2ubNoRbYVHI2vizr6D/DNmf40Wk2qKZDPKkA3rQxu+Wf51s Xh2h+Ie0RAhO83nR4V1pDSV80XtDtLIbny2IAtmUXpx3HiyQv7jMzo1cel9FnvTcgpTm 7hQt8nQrFUwLqLbpGv8IkzY8/RR+XB1V7Oce4mefH7aqSf0KTNT/xcVpYiTNRFw5V1nt qUb0jIp5d7/cVNOay7omhSfuMV3sa7NRjKXcJ7Sm0+j9bMOGnQo63WKRm7avM9WPRSO+ Cuww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=CAxyf1Q1; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=Z+BFQbBN; 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 b11si9426077pgq.114.2017.10.10.20.27.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 20:27:03 -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=CAxyf1Q1; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=Z+BFQbBN; 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=2Aa5HSAmoL0leESGZppAd03c67g6Ayb0d168bRJyV7Y=; b=CAxyf1Q1yZ5hnZy2FH3wxCXNcz ZQ95fFYlOdm4rZLXcKoFlegmRA+WG9JE7r34305FqNqWuNS58FlrNEBreK6/SyhZo8vQvb88jCNKp RL6ZcqvhUQLULn4VV7tB1H/ofYFPzQ/FgCh+rVG4vjxD1k0NFrIBSZDECzFQaNKcrgyCG0NRGCiPk 9FAE+dyVWgRhVs4yMpe1E7lY+JGhBoEo/68V9Mlm2X6hrXza++Lprk+nJs02jfInRPNpCNHetHs38 E8rR+2Zn45gV66hWWiqCyCVIcYJR4ahtYBB+BNaVDkMw6F0KajN4AgYGqnRu/cgmRwQLHYYYwqBEI vICfFyjg==; 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 1e27fe-0002eQ-6s; Wed, 11 Oct 2017 03:26:58 +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 1e27fZ-0002Lo-07 for linux-mtd@lists.infradead.org; Wed, 11 Oct 2017 03:26:56 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 999DB9F57E; Tue, 10 Oct 2017 23:26:26 -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=hGbJ c4gI/8wPLWyFmNzWSKyFsKk=; b=Z+BFQbBNpmVfoqmcfr7PjSOCQ/oWY/t6e4ZG rkk7OZFsXvqTkMtgIvrjkYvHz5ixtO/14nic5zUvrgdr/OJ5VMSIDnUgagzPdRMJ 7D10YJ57n8anIJBoABpy2k2zt15u7J/L3PoW//JKqws+gb6x+DqbUXvHQT8arDq5 HCAY6oY= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 913449F579; Tue, 10 Oct 2017 23:26:26 -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 30CBD9F577; Tue, 10 Oct 2017 23:26:26 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 8B0BC2DA0684; Tue, 10 Oct 2017 23:26:25 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon Subject: [PATCH 4/5] MTD: implement mtd_get_unmapped_area() using the point method Date: Tue, 10 Oct 2017 23:26:20 -0400 Message-Id: <20171011032621.26979-5-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171011032621.26979-1-nicolas.pitre@linaro.org> References: <20171011032621.26979-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F69D4984-AE33-11E7-9E0A-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171010_202653_253878_43517615 X-CRM114-Status: GOOD ( 13.39 ) 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: 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 --- 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/ Reviewed-by: Richard Weinberger 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 Wed Oct 11 03:26:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 115488 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp274455qgn; Tue, 10 Oct 2017 20:28:27 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCMJotMO4RZy4KnqOaC5nAkbxwPD32eJaSkZEwoAbsyY5rwsi+4lUycW/4VDzCLv1FIX1sZ X-Received: by 10.101.72.65 with SMTP id i1mr3459795pgs.436.1507692507676; Tue, 10 Oct 2017 20:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507692507; cv=none; d=google.com; s=arc-20160816; b=z847jiCSFUqxhzxsqn8Pomou6gHwVhPJv3Hyq933d3jBS3B/v/LNDEU8K6rQK6uN3/ 9QDWG+5vJkenXiTbEw3eZN7YPp1xRh4yVJjWL7yRA53pTrbqYnudaLZJD8ub4sGozPaT AdtdUA5PgRuMYCsP0UUPyl1i7FjnIrzSi8vZnBtbVHJQBt8f59/MMMtQn/OeBCgq7gqM 6/ZfavvZGeCMjkxZrKY3zn0h69hTgupY8eDar/wQMtAdpy31NjMk0kRNclkH8C7pX7qF RdPm0EcIxA+aYGUZorqBAC0fVodG6Rxqxb52QOXhCHiNW5jsncBBNqpcLCjrVNDNoTXr qjhQ== 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=3clWKHDelxdkYwvJG7wLcBu9YYVVsHW6J8BG0fjICZc=; b=WCNtGKseYzOHTH0YHVuH8HdLdAYV8kCywVm4fv+pOzS6bGmSKeSYBJdLVmvW2Eda6k 2XFbNEVS9rOQDWW5UNWLfuxmb0GW8ldw3iNUr0RiKf3/MrxWUhhvhqvrA5Pc8wuDaUBo I74+c4I3AEhKqhjfw3RVB3JgQcWt5+mxBTr4gRbzpfpSH1d9eceIAYez5GrCihekud6R VRSBZA9Q2AjAbG8zBe9X/b3vuoYzXJzKi5MouLTMQo3YPD8LkZbyLsg2PPa9nOV83RDI MR+UrVFDVCiLiRde9JwraqNRvlHrZolnoDygmr2G3wYFcOYIsiWKuEYiMqwOPjRABARV u/mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=sqfth2s9; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=TyPUIatS; 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 o33si10218003plb.17.2017.10.10.20.28.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 20:28:27 -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=sqfth2s9; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=TyPUIatS; 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=3clWKHDelxdkYwvJG7wLcBu9YYVVsHW6J8BG0fjICZc=; b=sqfth2s9GJcrQVXmpiLeLide0F KqTxtPXJX8xp/+gIbqFNZA5ci3yXFjXG+PJ8wJlPwxNbqc+NJxgBdGd9eFfUsS/tgiYqCBhlAXs4F ua2OLIoDtqBX7bOMvBUb6rntztOBv7QrG8LRpTrwa/eTAuqSOtCYpmD3NgL00ClmgwzK3GhGQkwyP IvmdLFCMcdt6TMKNxb4deo89KN8mk7VWPZ9b/AmR1JzQZXR6i9RO1BfhOMFJuBBlAR3Jh0v3hcMSw orvw2qjC0cSCrpNi2J2APxvIkpzq+ijBB04G33t64sZDLJShF+ETZirIj2VpjGcSGoYOlXwk/Zaut i4ixgg2g==; 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 1e27gv-00040n-SC; Wed, 11 Oct 2017 03:28: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 1e27fZ-0002Ls-0H for linux-mtd@lists.infradead.org; Wed, 11 Oct 2017 03:26:59 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 8C6C69F583; Tue, 10 Oct 2017 23:26:27 -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=92eu 5nwzoCZNlAL9zyDkjxCrL74=; b=TyPUIatSwZTNFnllm9JiGdQhkpH0bBBblCyl TC4BUO4OaJMMHCSRA8llweFDUh4qto27/U18MlwwgPK+rKSltvB3eZoNx+1stf1l I7NRMoiDei7obqmrCMvO/YbMTk2NA0tSoGD7kspBvCUZrqqmqW9cmW8ufwGlUonP nGygnaY= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 830B39F581; Tue, 10 Oct 2017 23:26:27 -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 0F7169F580; Tue, 10 Oct 2017 23:26:27 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 93D422DA06A7; Tue, 10 Oct 2017 23:26:25 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon Subject: [PATCH 5/5] MTD: remove the get_unmapped_area method Date: Tue, 10 Oct 2017 23:26:21 -0400 Message-Id: <20171011032621.26979-6-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171011032621.26979-1-nicolas.pitre@linaro.org> References: <20171011032621.26979-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: F720BBDE-AE33-11E7-95C6-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171010_202653_294474_BBB65F83 X-CRM114-Status: GOOD ( 17.27 ) 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: 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 --- 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/ Reviewed-by: Richard Weinberger 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 7dbee8e62f..d4c94bd46d 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,