Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp955678ybm; Wed, 22 May 2019 14:37:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDZ0amn+Z/4ARsQjehuGsPlZ7Vz7x1T0k7aGXJvB6Q1vK4uVqxfzhyAGQLiFJXN8K34a/v X-Received: by 2002:a17:902:24e:: with SMTP id 72mr46949205plc.168.1558561036456; Wed, 22 May 2019 14:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558561036; cv=none; d=google.com; s=arc-20160816; b=X2lYmndXMQAuFq3TUJ2ZGSNwbJ1Aa8YNuTwrMSOZyxl68e609/+ye3vcbH5W++otyK /hTl6QW7kqDgbFGK/vx3TpvWHtFdp/KbEcqNefMfeKN9u1PDO2LEgMEphrtzv6iJhPrR HKwyVGIUyE7M6Nb+XT10Q+zRVizZky7KqX4663Yx2fIf5DIMtgOJJDSCSwVEw5/8VwhT /GogndyVsS7UMhVdwzrn17Rc5rtliZREx3AxdRpuCPLXUTdUO32ZGjY+OOnTtoAPHp5n hugWIZVZZszTIAH86exscZ9G/lOEX+OHspPjU5yLBGCNxA+HaTuYjhPCehoodY1UhGB0 8Pfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=CB47ddRrKNWzkvlQMhShBURKZepRSv/MUuWiHjNrhfA=; b=WToSdLMx9Vf516FPMHchttPIpYr7qCXrjWXFkCsqg+x731e23obozjm2l0Ej/ZYnm/ Bu/ota3G3Ch+uWFCAi3E+Sy93gh8jYGZwa38bonQQUYRL+93rLSjWS0fgsA0aI5LMbkx yqDmOPto+H6JDTkzbE4es3R6Vz2VCDOgUTXoGCi1mh7tFXY/f94tw3UVi72Z062zMrnp FkvF2T2FGbr0JvZ2/0CLgKKOJGg0hXnR6L0dN6UUKKhzHekQJnnQ7HRW1AhP0nxjt1q6 Daun7iL70ntfwDAO5vGGa/1qwIwd1awFsG0Y/2I3e8mgBDrgDdNR/iec507bJMD4ybOf 7SYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VixhObCS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si27300506plb.30.2019.05.22.14.37.01; Wed, 22 May 2019 14:37:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VixhObCS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730120AbfEVVfb (ORCPT + 99 others); Wed, 22 May 2019 17:35:31 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42880 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729691AbfEVVfb (ORCPT ); Wed, 22 May 2019 17:35:31 -0400 Received: by mail-wr1-f68.google.com with SMTP id l2so3899784wrb.9 for ; Wed, 22 May 2019 14:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CB47ddRrKNWzkvlQMhShBURKZepRSv/MUuWiHjNrhfA=; b=VixhObCSPbWyKqLO1CMmQvg2SVLU6ChlVUtMUAF1lP4n2Nn4PM/AAenNz1sRbSWpvi bCb3FHCGyTmwCRzy88Je5DbLF4WfH6xMTHIObnbLMTnY0OCIEz4PuVNiPtMAw9e2CeHZ 7aksMNx3MDFrvNGSh9hjfNT4ouy9uLzmHR8VeRyU4JKylcuW2ByOpdBFyFQjn61sDc2R AozjR1dBbvnGfPrZBw2r6TmGy3oTutj/hfw1NgfoHA7sLvp5PUuCNqE7k93J407Tg/EW HKT2THdPzBPRkizuRovFB+O+D1w+Tjn8WT+A7RMt278syNd2ag7WFBPAmRKeGbrrGlU2 fzNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CB47ddRrKNWzkvlQMhShBURKZepRSv/MUuWiHjNrhfA=; b=E5nA/Y0ae3SlugvH5TqELm9szyn9baSjpalge+bU9+HERmN2JmO8Ozlm4FZzwWZvMV TZ0Ds3t+U+FI5LUPz7puxD/o3+oZiFHSeiRMlTFNDVwfKNreuGnRG2PzlUyXIY0+KhPM TNSF8vAiJWvR/Cnvy0ZgnAnuyqHYM/UXWrOlwQweL6dd9JnEMMcJOEcduWcl4nvqYoX3 L4HDnh6fJWGK8Er9iieXb8eKkFcA33q1DJ0G0dEnAZmet3zIAI5iLGPKufAOEa2cw4VY iz/5hVF/70vXH25poTMrBH6tS/cl3HDhnX20BYYOiXtxQXdO0bz8MWikCQITRzCYOJ0F jt7w== X-Gm-Message-State: APjAAAUAq3Xcx/+w5g0oYP+6uHqhCtFhT15KMMC/ZpysVoCDOg+aMcCX Kqyizqgbs1UqyGHF6FxKQl/Dw+47QP+/H66dDko= X-Received: by 2002:a5d:69cf:: with SMTP id s15mr44438901wrw.75.1558560929456; Wed, 22 May 2019 14:35:29 -0700 (PDT) MIME-Version: 1.0 References: <20190522000753.13300-1-chris.packham@alliedtelesis.co.nz> <20190522000753.13300-2-chris.packham@alliedtelesis.co.nz> <0c59bcd6c866429cb9727f787b7f61ce@svr-chch-ex1.atlnz.lc> In-Reply-To: From: Richard Weinberger Date: Wed, 22 May 2019 23:35:18 +0200 Message-ID: Subject: Re: [PATCH 2/2] mtd: concat: implement _is_locked mtd operation To: Chris Packham Cc: David Woodhouse , Brian Norris , Marek Vasut , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , "linux-mtd@lists.infradead.org" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 22, 2019 at 11:26 PM Richard Weinberger wrote: > > On Wed, May 22, 2019 at 11:06 PM Chris Packham > wrote: > > > > On 23/05/19 8:44 AM, Richard Weinberger wrote: > > > On Wed, May 22, 2019 at 2:08 AM Chris Packham > > > wrote: > > >> > > >> Add an implementation of the _is_locked operation for concatenated mtd > > >> devices. As with concat_lock/concat_unlock this can simply use the > > >> common helper and pass mtd_is_locked as the operation. > > >> > > >> Signed-off-by: Chris Packham > > >> --- > > >> drivers/mtd/mtdconcat.c | 6 ++++++ > > >> 1 file changed, 6 insertions(+) > > >> > > >> diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c > > >> index 9514cd2db63c..0e919f3423af 100644 > > >> --- a/drivers/mtd/mtdconcat.c > > >> +++ b/drivers/mtd/mtdconcat.c > > >> @@ -496,6 +496,11 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) > > >> return __concat_xxlock(mtd, ofs, len, mtd_unlock); > > >> } > > >> > > >> +static int concat_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) > > >> +{ > > >> + return __concat_xxlock(mtd, ofs, len, mtd_is_locked); > > >> +} > > > > > > Hmm, here you start abusing your own new API. :( > > > > Abusing because xxlock is a poor choice of name? I initially had a third > > copy of the logic from lock/unlock which is what lead me to do the > > cleanup first. mtd_lock(), mtd_unlock() and mtd_is_locked() all work the > > same way namely given an offset and a length either lock, unlock or > > return the status of the len/erasesz blocks at ofs. > > Well, for unlock/lock it is just a loop which applies an operation to > a given range on all submtds. > But as soon an operation returns non-zero, the loop stops and returns > that error. > This makes sense for unlock/lock. > > Now you abuse this as "apply a random mtd operation to a given range". > So, giving it a proper name is the first step. Step two is figuring > for what kind > of mtd operations it makes sense and is correct. > > > > > > > Did you verify that the unlock/lock-functions deal correctly with all > > > semantics from mtd_is_locked? > > > i.e. mtd_is_locked() with len = 0 returns 1 for spi-nor. > > > > > > > I believe so. I've only got access to a parallel NOR flash system that > > uses concatenation and that seems sane (is mtdconcat able to work with > > spi memories?). The concat_is_locked() should just reflect what the > > underlying mtd device driver returns. > > mtdconcat *should* work with any mtd. But I never used it much, I see > it more as legacy > code. > > What happens if one submtd is locked and another not? > Does concat_is_locked() return something sane then? > I'd expect it to return true if at least one submtd is locked and 0 > of no submtd is locked. BTW: Meant overlapping requests. If it targets always only one submtd, it is easy. -- Thanks, //richard