Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp983905rdb; Fri, 2 Feb 2024 09:43:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5lJgA68fIHpN7aEK/WhtEiVeh3RVb8yQsXSGEbzxT8q7gcccH/7pvuu+ns6fkTRJKHE5N X-Received: by 2002:a05:620a:444b:b0:785:5fde:bf32 with SMTP id w11-20020a05620a444b00b007855fdebf32mr415714qkp.68.1706895781351; Fri, 02 Feb 2024 09:43:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706895781; cv=pass; d=google.com; s=arc-20160816; b=rAw18u2ny6PO9G6U/tJJh1u8o1SLFCLrOj0YpHO4C2o4tP6G4YI/F0v1ohGhd1Nb33 uzwNxRaubL39I06RY/xmrl0eA4k7I0dMYGPO7+e/oP8xlS0lFnXDcAXijHusrkJ0aURo QE5/hTThjzSkbAaJYfk12PHvZf4T8MDHXPC6KOW71DxJBBBzprvysrf0v02yegAf+BMu ZEsGc2CDtyUOQHcC3lZ0VxWpv+vZfv37wYDzBPpna6HBmuIqlf/HtAA0PnlyQ6TfBYxz qQBMp1mLugxP4lKmPkzOO+FgU+YJgjwFajT9h7Z96jH9vzADKrl9rfcKYE6xpaEGpcTf +dWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=lxj2OxF2tKrpIUq+UtFX2EYPlsFE5Q6qUnNhW/MIt3w=; fh=QBIM0LxwMxn4DXWau4vlYcH+J7ESCXZPsKYdcWG2fdA=; b=Z+xK7aUjmve9zFu3DGesD1xAZ1nxHW2UHflmuRL3n0q0pBOObJiJJ+bTXZJImzt1it ZgRoOimd3sp4/oYGSF1ZpSzKMDiYvcawcwDcgIdleyDlp1hORkdywJDt75NX/f1EDXsi +CgJL77+yjXKI+ZMObcZrT8MPjGkYUUABI0gc1BgdrypiALY+5ad9wm+VVliB5GBmIcn gcY4vP1tjawFx3rjeo2VFzYHtaeGbxwanGrjJcsNJ1n9Qldq8LtLdY2WxGm6yMLByEkz fg/1K5q/LePptfgflCr9K/cF2GVXCQGEDWT5Lz6VbJYAzGmvlC4mBzuL7zrNApVoMC4s 67nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qdj16sLU; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-50253-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCXuSvUMH5GYwnelrVELu+drV1BpY2RhPoxlihsAtaf3czENGuzoIOYfyHRu7V7++40QkY9eCq40fXmbRpA0x+zCHVa2VdljgyFtPVI7VQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v20-20020a05620a091400b007832f29a421si2368337qkv.361.2024.02.02.09.43.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 09:43:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50253-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qdj16sLU; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-50253-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F27011C25383 for ; Fri, 2 Feb 2024 17:43:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CFD614C5AD; Fri, 2 Feb 2024 17:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qdj16sLU" Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75A2A14AD2F for ; Fri, 2 Feb 2024 17:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706895706; cv=none; b=iwTIu7Udf1C8XcyIn2WO64mw4+3OJihrYg1EyMbCSkjwwwKHufEiyxOIgWoty066KCIfmT52nSEisiAmkhE4cf5WsCWNPpkLR/jrVKOjASu+s3lafV5s60N2ISnRrIPc3xlE1uRWhdary4dWK4TTF+gC1Mhv8NEnJ4OezyK9/Js= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706895706; c=relaxed/simple; bh=eu87qWyaCqCwnJ2sVE3adNP4GW3OSLM7PQC7Mv20M54=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uYfvMF1Dg3rlCxCsVlQ03l5pqDmR5iSUQermdcehvrX6dXCaclntIwDEu6hip8x+e45nEe+uPC1vRPQa89Hn3+N1ucj1EX0S+/89LA1NWn0AFMMXiWhwiO43l7WDEuFKSE6ZaSbH9z9NHRUMpaG9qDEz3dsvB8Sn2UuLaqMT4XA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Qdj16sLU; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6041c7aa418so19993347b3.3 for ; Fri, 02 Feb 2024 09:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706895703; x=1707500503; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lxj2OxF2tKrpIUq+UtFX2EYPlsFE5Q6qUnNhW/MIt3w=; b=Qdj16sLU9H9ljl2jwX+fQhhDY5X6JydV/fCOGN55bQ48i1rfSACdGkMq0JYNdjiJfZ yFGiA4KW3TggLF1zmqCOduCfCb21KjTXzJQ/kCNYljgypWP/fGyaROE5WS4Sp611MWqY q+6OKpCd0JBKsL+kTi7ffthXUOEQ6gfkgIiqHp4NuoVymSEMYV3jW1xFNNdooBI6Vs8r HnI43k2yUpR1yWYraRULZPTV2e85cytSjWXSUfqITGrJ75hK7h0Gh8QebGOujOjXEUhM wFZvUUU6lOO2dmEkPQKCelJL0k71LPvtx8cqUx0j3QGh7xlgboXu6vI3xt/6bi2Wfaba 3GUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706895703; x=1707500503; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lxj2OxF2tKrpIUq+UtFX2EYPlsFE5Q6qUnNhW/MIt3w=; b=icd/fWMomwPUWCetBSDnfw2QEht8p5RRCeoJSXGRirOjE8qAuvCATQXaLJmr0nm6JA x8Nmr+f7kpOsaAh8RmOuFVWZOWa7FoXRbkC5UPRtAnQlIeFyDadZ5tHeudD9gT1Ztvog ZlADJRk7Cn3iKOFM71taV3Z48UlWel/gCqh1JRniCdRJcjaVtlZad17Tw+2N0fReM1bu l4inUzNa/D6I2XZ9TeaVu5GQPFGQuQSHPxbXlKjJhy55CjQEr51/BMu3e/nzsltxHfYY raNuCQ0r/d5v2fqNkewTzqy5QoYzL/rvaoPmZWzjMwikFSDucf89pjaAQYlwGANujyS0 PyJw== X-Gm-Message-State: AOJu0Yzl8kDGuIXhvuRCTw1QeaXJV+C6fy9x1bWyzPCtJEzedXDp//YY J3dFG8g6yzB5vo59YrkvU81FeuZGnrUoCdo7t4moQzO5VM9nEyIiUzBjporVo86d7y5g0r92xO0 n0nhFMkDycxAYnZXQ1wFCJiGTlNfazzDSaPkLZw== X-Received: by 2002:a0d:d8d2:0:b0:5ff:53db:6b71 with SMTP id a201-20020a0dd8d2000000b005ff53db6b71mr9197451ywe.26.1706895703473; Fri, 02 Feb 2024 09:41:43 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Linus Walleij Date: Fri, 2 Feb 2024 18:41:31 +0100 Message-ID: Subject: Re: [PATCH 2/2] regulator: gpio: Correct default GPIO state to LOW To: Geert Uytterhoeven Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marek Szyprowski , devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 1, 2024 at 4:58=E2=80=AFPM Geert Uytterhoeven wrote: > According to the GPIO regulator DT bindings[1], the default GPIO state > is LOW. However, the driver defaults to HIGH. > > Before the conversion to descriptors in commit d6cd33ad71029a3f > ("regulator: gpio: Convert to use descriptors"), the default state used > by the driver was rather ill-defined, too: > - If the "gpio-states" property was missing or empty, the default was > low, matching the bindings. > - If the "gpio-states" property was present, the default for missing > entries was the value of the last present entry. > > Fix this by making the driver adhere to the DT bindings, i.e. default to > LOW. > > [1] Documentation/devicetree/bindings/regulator/gpio-regulator.yaml > > Signed-off-by: Geert Uytterhoeven It's closer to the spec, but Mark's pick, anyway: Acked-by: Linus Walleij But on the subject, the bindings say this: + gpios-states: + description: | + On operating systems, that don't support reading back gpio values in + output mode (most notably linux), this array provides the state of G= PIO + pins set when requesting them from the gpio controller. Systems, tha= t are + capable of preserving state when requesting the lines, are free to i= gnore + this property. Actually, Linux can read back the value just fine in output mode, so what about just ignoring the property and update the document to stop saying that about Linux? See drivers/gpiolib.c: static int gpio_chip_get_value(struct gpio_chip *gc, const struct gpio_desc *desc) { return gc->get ? gc->get(gc, gpio_chip_hwgpio(desc)) : -EIO; } static int gpiod_get_raw_value_commit(const struct gpio_desc *desc) { struct gpio_chip *gc; int value; gc =3D desc->gdev->chip; value =3D gpio_chip_get_value(gc, desc); value =3D value < 0 ? value : !!value; trace_gpio_value(desc_to_gpio(desc), 1, value); return value; } int gpiod_get_value(const struct gpio_desc *desc) { int value; VALIDATE_DESC(desc); /* Should be using gpiod_get_value_cansleep() */ WARN_ON(desc->gdev->chip->can_sleep); value =3D gpiod_get_raw_value_commit(desc); if (value < 0) return value; if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) value =3D !value; return value; } None of this path excludes lines in output mode... If individual drivers don't support it, it's either because: 1. The driver is buggy (such as not implementing .get() and should be fixed. 2. The hardware is actually incapable of reading the value in output mode. 3. Reading the value hardware register is bogus when the line is in output mode. All these are driver issues and have nothing to do with Linux per se. Yours, Linus Walleij