Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp949042ybm; Wed, 22 May 2019 14:30:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+OcVlRMXg9xLu6uZQwEW0Pscne7eoszGAr1pwXSO2VBrnB1PGZJbA74XNvGxk9SHCXZ1u X-Received: by 2002:aa7:9203:: with SMTP id 3mr99467569pfo.123.1558560603747; Wed, 22 May 2019 14:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558560603; cv=none; d=google.com; s=arc-20160816; b=Ruy9ejIYjGyoFEfiEcIO/VY6n9dSe26W2HG/qBmbvFIQZfNHEpgnsK0QL5f6JSgh3t oNBNUmt8BB/biV1+SJ0biC3jJwdhkTwNvORPkUu0FJH7aGo5XrEgTxNqPfcPvbGQDcZu ESPusTkSpqvoqD8bIYygjTiUyYaHAh9AyoqLbDekGeJfxp/bGZy3Z0qQLTTMN71Z3uRS fc50qrQuell2LXolKi6xYMyShPZjZsoz6H9wruPDWmEnSnAR++9lVS+RYgUKLfXvS6WO bxlp5Fw0qdwwD3UVNKonNtJs1aZQWA6dfKwVd33U4Ox+Nz109EdajNVxu5Y1rRJ2GHu7 yu6g== 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=gPM/jVZtGO2/RgT9Pi90b9WxpAcXAmjN4dUeTd5rlc0=; b=FDcpMRi8gkOP16Olwex00Vg0HExWgCFhDGWgMVPlI76LNeuhgxu4R5cjPi4ksy8cZD vws/uMR5/mYX52Fjgovz5RtQZ9L4XUX+VXQ+0BfPFMBwIxuvfLBKPGLK7a3n5oskZAPj jt0cMYTvPHw5SXPmaKOTx9CQKfudsr5dDC+Sv9l13yTMFvDDXMwkmaAkENb9qJvkRzgN n+GXP+NU80gKs33iUvOEepAr3It1VRPXkJJq8JmmXvE5SeIKeD5QH2tAd2UBAZmZ01ry NRDcNvH5zpZEKSRK4TowzNxuM53gFYzkg2gctU2dyS7Ao4DHsoQMU6v5xEUOhngvGSCd ZnSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l4uVaRKK; 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 d125si31417081pfd.257.2019.05.22.14.29.47; Wed, 22 May 2019 14:30:03 -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=l4uVaRKK; 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 S1730150AbfEVV1D (ORCPT + 99 others); Wed, 22 May 2019 17:27:03 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44938 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728761AbfEVV1D (ORCPT ); Wed, 22 May 2019 17:27:03 -0400 Received: by mail-wr1-f67.google.com with SMTP id w13so3868464wru.11 for ; Wed, 22 May 2019 14:27:01 -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=gPM/jVZtGO2/RgT9Pi90b9WxpAcXAmjN4dUeTd5rlc0=; b=l4uVaRKKyhOj6q8UAKaPAPsHBuT94pMVw7A9dKSHMy5YOm42zxlYYfjLIYzck9FmTv fzTQOPjh2PkrGZikx2x296/rTWPPbh5GdpImItlwd8d8xkJVIkSc5JhMDe6HrLbw09JS 4449DXkARWg8JSqIZ1Fpl2wqzyES7uNfiuw2sJSoN9fTdGkPXQQXro/H6NC+C6hfA14R OTw+sEBZJugdPZN3U2nQRSZRQCaThk+ZSwC2oLi6P+xt+u8pSfwrs5GbPoPkUe+YZbd/ GfL8QZDRP+sqalPutnO63lgpRrwiFFM5nRk8+6Veu30Olh8zHQU0IOF04BK7Y1jo/Q1R HNOw== 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=gPM/jVZtGO2/RgT9Pi90b9WxpAcXAmjN4dUeTd5rlc0=; b=dpAwotq0l8OLn2ewgTbhNhDZEV+NFf7O24vf+HvABeoWtvdwaZ1tnmN8JTId3FTSL5 FEDdzciTaRpAuAPMf4NKkX+f68WfI4IWsaH03bfKF/IHVJYlwo1p3vogkaMkJYVm68pR QP8S55/xoMM9RVl5HyVgNR7PIaXJEi/7RHbJgYvebAQEYP0infFmmHQ6k1gAUK5ymMQM tQw7s6CndKA80z+zzUqapJca1WsYh7o9Wduze/tRNDCrrghtkFJkXV8cGsRDiOk2h/SP tLx7MHNN+W4qe7Y7y+HLpf5Okhpsv4EBnyAnXjy7UjgBCq9VgF50Ca5kCry8O1Gm4s5X QJnQ== X-Gm-Message-State: APjAAAV9PawT+TOzY9HqS/+JxsDSuFWzAyqGd2PPhoSfNjBw4liLobC5 cUYqE/mUowUgl1v3eLjGQSgL8L7yeK1efMxOePVUJXWk5b4= X-Received: by 2002:adf:db81:: with SMTP id u1mr27305113wri.296.1558560420784; Wed, 22 May 2019 14:27:00 -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: <0c59bcd6c866429cb9727f787b7f61ce@svr-chch-ex1.atlnz.lc> From: Richard Weinberger Date: Wed, 22 May 2019 23:26:48 +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: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. If the loop and return code handling in __concat_xxlock() can take care of that, awesome. Then all you need is giving it a better name. :-) -- Thanks, //richard