Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp159481pja; Fri, 22 Nov 2019 04:51:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwXuaqXnKIVhHJyv6qA/UO+6rMDnTAiZc0dNtisHZfDHH+UXPDDObZX6EqKilRI44d5TqEv X-Received: by 2002:a17:906:69cb:: with SMTP id g11mr21786332ejs.328.1574427087732; Fri, 22 Nov 2019 04:51:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574427087; cv=none; d=google.com; s=arc-20160816; b=QNgDnrm2II1xfM5QdCtJ33ydoCJVaaXElr0gSjUhdrRzCMjswGH/y9ZgJohutpXQR4 HOsYy6EI8imsdJg72OAPTmUDK/TkSoEQB0RrR8dNc6YiJSt71vrcS5h58B4CSMvciwIR 7wJuvtHKr+h6gZPnGsrbvL1g4TzJXtaI56MRV5kmRQWgE9JPSUOvkfl6xKP6JfguVE7n KzA8YbM7swpPJJ49D4D0Q0lCt4FIi2ZdO6dmGA4LPX/wznpYFxtLTIj5YyuACeGNKLIY epa7/t1xHGvRzmtZBClaHGgucigdlGJxbcKI8oYHWVnFg41HgiTPxGUWgJsJBY/4dg3L GqYA== 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=cT3IohDx0JHZlkGP4CZFg3FyqkNQ1ycKB4FYfEK3fT0=; b=Z+6Gxvc9E7KHEt1CIa8FOncja76t/1BwusOROqaega6Mqj+kpT5mIv7C737idpxasm 9W+XnJiKg8itNK7OccZtpul8kHLYjDma8412Ha/mPt4agfGRKiXFsD32KgP0Q/wxKtdU G0oD5RptR399z8QGerXTZsAfckKFQ/QhkndbEZLzYFZRglkNRZ4Dabhxr19GzJaUBLEQ ejhP+s86PSHJYkvn0XkrqoPPlKFTJaWGMHOykk0ISWnpBgZgGVij3apSPaKsearYuOc8 9WkntJ1/yaX9zUN8F3cPGfl9ZUrHlB1/ni1VRklbYtJOTQf09g3B97iDSckSVcw2apmR Y7XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R08nHDFY; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c29si4438476edb.223.2019.11.22.04.51.03; Fri, 22 Nov 2019 04:51:27 -0800 (PST) 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=@linaro.org header.s=google header.b=R08nHDFY; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727705AbfKVMrZ (ORCPT + 99 others); Fri, 22 Nov 2019 07:47:25 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39725 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727571AbfKVMrY (ORCPT ); Fri, 22 Nov 2019 07:47:24 -0500 Received: by mail-lj1-f193.google.com with SMTP id p18so7224341ljc.6 for ; Fri, 22 Nov 2019 04:47:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cT3IohDx0JHZlkGP4CZFg3FyqkNQ1ycKB4FYfEK3fT0=; b=R08nHDFYlfWD1UbasbWcgbXF3HkurI/bX+33/EvmtGS69Ug6wVt6fV1YJEp0qv9qAk zjGS26ksb3CIAXusmn1BDgKNYCt36OLVm36WWqiY98Rn5KxohFnifc7aO2ltKk0aW1w2 uXnLddN3awhdM+McnPckBkeqdZ77OQWHKoj/0teqobq03TU6v1styfpeDLSS05Jf6ca0 7o3EB/mzSiZas8rRlo+tk/ZwfH9MJqgocDiTcPnOdD37CWaCFiVt7ZXo1TjHoEEvWbQr 704bY+A5zS/4YcA1mm/lM8f1evfc5XT9kxmEq1DfdTOgiBDBdi3ZuE0LG92RqfqGUk6h TmUg== 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=cT3IohDx0JHZlkGP4CZFg3FyqkNQ1ycKB4FYfEK3fT0=; b=Igykn3hTYw9WWn8Q6RSOT3cdJMx0YFKec7h78yDaZt2+v9G7NRj/m5soFA8BQWaG1B 4YEiwfLu3f1Ap3Ko/ETU+vk8b+oPKiaAjsSiZ6jjy1FBJMfcIGQ8FrU0zOOnrFmfjNpq 0i7+unrAePwVeG+/S08jsS58xzStEerMztX6vs8Qk2xlv5iGj1zQXxOh7N760TziboIj 9zqjDAtM51Y1tlhSBYlQAFdAnJEOkU45vcmkn289xxaSwXyjWnKH9nHG+GgqhXU+NchV 2CFWWb2lMZ62xKP1mwrxkgyJejps15U8MomIWnVvCONDhDQjZ8f3WPJrYp/17UOjMSIv aH7Q== X-Gm-Message-State: APjAAAU8TSoSE+/eS8427FLsQ3kHfkuc6GqUFmgMA04LrbDTljG9Gaxx v5lAC8dyaCoxDOu8wDPOpa7MIDIVqpl1O+UY4akl3w== X-Received: by 2002:a2e:8597:: with SMTP id b23mr12200230lji.218.1574426842056; Fri, 22 Nov 2019 04:47:22 -0800 (PST) MIME-Version: 1.0 References: <20191120142038.30746-1-ktouil@baylibre.com> <20191120142038.30746-3-ktouil@baylibre.com> In-Reply-To: <20191120142038.30746-3-ktouil@baylibre.com> From: Linus Walleij Date: Fri, 22 Nov 2019 13:47:10 +0100 Message-ID: Subject: Re: [PATCH 2/4] nvmem: add support for the write-protect pin To: Khouloud Touil Cc: Bartosz Golaszewski , Rob Herring , Mark Rutland , Srinivas Kandagatla , baylibre-upstreaming@groups.io, "linux-kernel@vger.kernel.org" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-i2c 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 Hi Khouloud, more comments! On Wed, Nov 20, 2019 at 3:21 PM Khouloud Touil wrote: > + if (nvmem->reg_write) { > + gpiod_set_value_cansleep(nvmem->wp_gpio, 0); > + ret = nvmem->reg_write(nvmem->priv, offset, val, bytes); > + gpiod_set_value_cansleep(nvmem->wp_gpio, 1); > + return ret; > + } Since I requested that the GPIO line shall be flagged as active low in the device tree, make sure to invert this and toss in a comment: /* * We assert and deassert the write protection GPIO line. * This line is often active low, but that semantic is handled * in gpiolib in respons to flags in the machine description, * such as the device tree or ACPI. */ gpiod_set_value_cansleep(nvmem->wp_gpio, 1); ret = nvmem->reg_write(nvmem->priv, offset, val, bytes); gpiod_set_value_cansleep(nvmem->wp_gpio, 0); > @@ -365,6 +372,15 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) > kfree(nvmem); > return ERR_PTR(rval); > } > + if (config->wp_gpio) > + nvmem->wp_gpio = config->wp_gpio; > + else > + nvmem->wp_gpio = gpiod_get_optional(config->dev, > + "wp", > + GPIOD_OUT_HIGH); GPIOD_OUT_LOW as it will be inverted. Apart from this I like the idea in this patch! Yours, Linus Walleij