From patchwork Tue Oct 17 15:28:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 116129 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1364019edb; Tue, 17 Oct 2017 08:32:23 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDxTx4y0GfG171g6T5ciKzmIgh2XWxLv2hSO1n9a5rHgJrYh1sfdnvlpVZ1CiBGK24LRF+E X-Received: by 10.101.88.140 with SMTP id d12mr10116641pgu.166.1508254225710; Tue, 17 Oct 2017 08:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254225; cv=none; d=google.com; s=arc-20160816; b=WqqVwiYQCqj7z7u0kTfDhPoKFQ1vcBK6rwRuzQLMNVvYCnsYxIed0h+oSQbok+nm7s WpGuhq8A9lXzsGSqVJUWZnIu+yCZCgxMHELT1fZTJ7H1evQ708Dp5G/IyMykod/RqKN0 HusTwd/Gt/P1dh4kMCGILBcvOiJZgi66e+d30LzHEzAo3Hic1DeajH4AOdWuRFJOwMUD mpMAzZJ2xTbydqibS8M/B9zwkJGYhZNZ5w8jSVt81atDB3/jiEf7Sal6eEuEXZi6NYyX iMkJpVfq7x9S/vEAb6pXyH3Po3yFhKrtfHy83xOZivm2Amej+pdamgtLl/pzXzA2nMR/ iF3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature:arc-authentication-results; bh=139YtR3FX8aeLbyoft8YGRMEU1lDVmdWF9uNuO5iHHY=; b=D/LDp0D2/6HB6AiGV57O6k/YsvUcROG+9oVnv5YF9mAfPn4DyrWswbSbg/qcyc/Dk2 8YAoICIi91KiCycMQCkxVMHyjyBmZy77Rmmu9oTXliCJYWyU3n7XCH5O5PRP4+4itPO4 TD0hq7KoGiqwUs17uQ3j+8v3Jkqwl/j2/MvnhPKzoH7kN/oqGDMIWGQiTOQn6sonRlRw sRmX5xU4SX/AgKrib9UmksmUVs6DKTHfFkQeSAK5i8jQ3wMoDcq97GaVyfani80XI0e4 Wtc7SmF3z6k1JqV1tVDLVmRHdYmsMNRwJax3hazILHL8mjpEqUmFxml+KmhCQmrQu9KI pK+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=CZrpDmqm; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=D5EphJPu; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id a61si4446653plc.827.2017.10.17.08.30.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:30:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=CZrpDmqm; dkim=neutral (body hash did not verify) header.i=@pobox.com header.s=sasl header.b=D5EphJPu; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=139YtR3FX8aeLbyoft8YGRMEU1lDVmdWF9uNuO5iHHY=; b=CZrpDmqm0vnp20Rf7UGZQrz97J AKsvcdlblQzLRbAmA2hwvILe43AbJcgY4dBMa7VpbbwAXWUj/Sm2AUqCkDb8Lb4J0SntZv7Jjjdpc cmPhGEeUGkIUdecEBqxBIBtTh7/HK3tY9PMyZKVyWDrA1yXE97YQulT+3SE3kzqUQAKnADx5+eeQf pByy4JganEHZiFIfyIP45qRlwv0q5TwJ5gztBCuMdoDdGfH/AMSkmKA2lpQ3k7xSS3aXVBADB/bQk d3hisTM6y9s9qTvwk9wPaLmpCleIHK1J4XZCMIdGDCtt4WrGmcGRFwex+g018qSy6QdMOHk68OgB9 gEL+4r7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tov-0005hp-D9; Tue, 17 Oct 2017 15:30:17 +0000 Received: from pb-smtp1.pobox.com ([64.147.108.70] helo=sasl.smtp.pobox.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Tnc-0004BY-LI for linux-mtd@lists.infradead.org; Tue, 17 Oct 2017 15:29:02 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id A56D4927BD; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=ykzb un+akuqes7UP1UaiPDJIE4A=; b=D5EphJPuP6JDUUoYqEmP2VYgFEkClprLimpv nXhuvwCTh3IJh9PD+Hl7nVJZUihnjFxnIwz6FUS1WSu1qpuOijLplgcUPZJfpvfo CecHL2gI2+C6Xnm4axKZ4bbjnrDgji4SQhpQHhzcOx2F5cMKzqWUzIgv4AYEEXoS 7wp+cnM= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 9DBBC927BC; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from yoda.home (unknown [137.175.234.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 2EF7A927B3; Tue, 17 Oct 2017 11:28:33 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 57F642DA0625; Tue, 17 Oct 2017 11:28:32 -0400 (EDT) From: Nicolas Pitre To: Boris Brezillon , Richard Weinberger Subject: [PATCH v2 4/5] MTD: implement mtd_get_unmapped_area() using the point method Date: Tue, 17 Oct 2017 11:28:25 -0400 Message-Id: <20171017152826.11658-5-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171017152826.11658-1-nicolas.pitre@linaro.org> References: <20171017152826.11658-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: D5FE549A-B34F-11E7-A1E2-8EF31968708C-78420484!pb-smtp1.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_082856_986624_7561C8ED X-CRM114-Status: GOOD ( 13.04 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [64.147.108.70 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , linux-mtd@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The mtd->_point method is a superset of mtd->_get_unmapped_area. Especially in the NOR flash case, the point method ensures the flash memory is in array (data) mode and that it will stay that way which is precisely what callers of mtd_get_unmapped_area() would expect. Implement mtd_get_unmapped_area() in terms of mtd->_point now that all drivers that provided a _get_unmapped_area method also have the _point method implemented. Signed-off-by: Nicolas Pitre Reviewed-by: Richard Weinberger --- drivers/mtd/mtdcore.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index e7ea842ba3..ecb0380158 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -1022,11 +1022,18 @@ EXPORT_SYMBOL_GPL(mtd_unpoint); unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags) { - if (!mtd->_get_unmapped_area) - return -EOPNOTSUPP; - if (offset >= mtd->size || len > mtd->size - offset) - return -EINVAL; - return mtd->_get_unmapped_area(mtd, len, offset, flags); + size_t retlen; + void *virt; + int ret; + + ret = mtd_point(mtd, offset, len, &retlen, &virt, NULL); + if (ret) + return ret; + if (retlen != len) { + mtd_unpoint(mtd, offset, retlen); + return -ENOSYS; + } + return (unsigned long)virt; } EXPORT_SYMBOL_GPL(mtd_get_unmapped_area);