From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 2BB77283FD4 for ; Wed, 29 Apr 2026 08:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777450717; cv=none; b=uUpielgWqSpU71DOrbhVbffRFIVmwL/faesi51lesXowcPR3CCbBTDf621P4EWYckqs4u+upfFkdnhRompIknhV9uakYhfSRJ5GxwqyT+qPe/6FpnYlGcgLUDM3swEUDySIzojkemECypUmgVDukN46Oyog/72MeXhhTcf8dkWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777450717; c=relaxed/simple; bh=ku5bsdX/4FzBHL9u0sgIjuIvSYMX50kBpWy6mJ7xq2M=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To; b=GXfdO+6OShQ522mzA6PU/OVPBoiddQ2kY1pGGw0oSY4ZXfp7OJ5wxQJkAzkFOSw1KMifFkZZKn1UdKnBfsjp3Am99gCbDuDh5scnt92E9OnPBP1WzJXGx+Bt60Ny21Rwp2HnT7LNr6o+TQfeJPaX3FP7iwUEaEz5+ozu5c3tP44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fairphone.com; spf=pass smtp.mailfrom=fairphone.com; dkim=pass (2048-bit key) header.d=fairphone.com header.i=@fairphone.com header.b=AeNWgMUQ; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fairphone.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fairphone.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fairphone.com header.i=@fairphone.com header.b="AeNWgMUQ" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-441209fb77eso339324f8f.1 for ; Wed, 29 Apr 2026 01:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1777450713; x=1778055513; darn=vger.kernel.org; h=to:from:subject:message-id:date:content-transfer-encoding :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UQY6rAmf59by2qCfkgOBHF4DNIvfx78JVnAi1xvtF5o=; b=AeNWgMUQIaYm7ladRjQ+NxjgfNeMpXlyyqNTVVYjipy5j1XMTDH7WIrIu7IWm+yXid uXCvtW6m3zM0DlcDN8E85bFFMuA/1fNHeMetSodLAvVPN/M/UD9TA7066Ju+BRTAFgP9 VivPnS+KHAjLrh739G98JLidqnVDqDrUY8AJJLWA4SJzMzrwM6EELAZZgiNL4/eJWJdE BrLJHYf4L/gGhVJFYz/5y8KNwkfcDwCsHzOIkqZV9zgdTYzNSWGhLOGsrrP088qxTJMF Tqb20+yrU39Kc16CMcnyUU2iza17W0A9BiS3i9lGe6ZIUXhmRjgVG+fHtpHJL/HX7hlH yd6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777450713; x=1778055513; h=to:from:subject:message-id:date:content-transfer-encoding :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UQY6rAmf59by2qCfkgOBHF4DNIvfx78JVnAi1xvtF5o=; b=VQjxMsJD8wiTw25O93ZS5d+Hms2F/N1mjbnQyRuTMgpsdYcW7XwXh6OUaKuekj5GJL wXisPL5loq9hXWVbvSZcHRlTWKE8BJ33y6LD93lL/+HXgtdhBOP2UpqtVICO3J5eUseK XkCpSUgHpKjHIvVSRZ9GmgSDGGDFmG2wPhWgCMLBhqBurKFby+3cl//tyxAvlRAc5j2E n+BCfQZYOK6zgR2Eo8JDZAm3grkJFSkSJPfZ+HhSuGW+R0xvX3rgvAd6SDm4RMzg33pl pBlqS0LCNOb3wex+sauDMeB2QX+CMkPshPMYQH/67S5xWwC3WsBeuuzOufbqIgnOfInq uJNw== X-Forwarded-Encrypted: i=1; AFNElJ9et0JnFyxihQf+IzgLN9cSJD/Ev5ah+jD/5zYdzFmYe094PyQQZPJ/p8lkv3G7wkG/QNP9A2+sDF8OBPY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6e04lvlm3qkQXxoVst/l4xpbvxKCI41eTLBx64I8AE/RqaRsg gPkERReud7BA7XVebJ+xo2SnEtM1cGVtwvHaDPNwglKeaVq39irZP7wTmc7xKteF6Ck= X-Gm-Gg: AeBDieuq3jmd3cLdxStpw/cqeyK+eKrfqmQ1sYQ5DtHAw3+sF6TAvBUbpaoGZ0zFNfU Xd2HO7ruUg4WqZE9di3OPHTkpqN9cEtpnTrZarN1ParerV2CoM4ioehheW1+HAIcZBXyZ+mlBed 2+RTj13Sk2yqR6oZCeWVK5R7QIkUHhHovJWVkTTld9/57coOZTbUPi0rJNw0qhbZS7Gi/zY92y1 4wObLmXS1TI0VqmGAXCibiomfkDgfX0c7O/jdlbdBuUZARIKU16lVzwneiC2ZyhJuCOlP5GXegb 6c7hkioULyEpwNvVvCEDAYqtbgGHOyXjSiqIbRQ6QXnoWvSn6SBLpNLCytTu5/6hoVhvVMsCLUV TunTWKzaQLKKmkkwe+Ha+klq03k3h7XstOlpAUvuwNI4JkW/H3HpQoPFoHLPTVJ/NNv06WLm5QC QQPhK0edGBEtHH7BPloIy2BjcO4L2fDlI2FbpSDWrL6JsLxim59JUg9GuwwhKKmrBraDq8N37aL Mz4/8KPqw== X-Received: by 2002:a5d:644b:0:b0:446:e2ba:45b with SMTP id ffacd0b85a97d-447a3eb8654mr2772070f8f.11.1777450713321; Wed, 29 Apr 2026 01:18:33 -0700 (PDT) Received: from localhost (046124192191.public.t-mobile.at. [46.124.192.191]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-447b7217b20sm3963375f8f.22.2026.04.29.01.18.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2026 01:18:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 29 Apr 2026 10:18:31 +0200 Message-Id: Subject: Unexpected behavior of of_regulator_get()? From: "Luca Weiss" To: "Liam Girdwood" , "Mark Brown" , , "Griffin Kroah-Hartman" X-Mailer: aerc 0.21.0-0-g5549850facc2 Hi Mark and Liam, My colleague Griffin is currently working on a patchset and while doing this we discovered some seemingly unexpected behavior with the of_regulator_get() family of functions. In a simplified version, we have this devicetree structure: gpio-keys { compatible =3D "gpio-keys"; event-hall-sensor { label =3D "Hall Effect Sensor"; vdd-supply =3D <&vreg_l10b>; }; key-volume-up { label =3D "Volume Up"; }; switch { label =3D "Switch"; }; }; Then on each subnode ("child") we call this function: devm_of_regulator_get_optional(dev, to_of_node(child), "vdd"); The expected behavior would be that for event-hall-sensor it sucessfully gets the vdd-supply, and for key-volume-up and switch it does not, and return -ENODEV. However we see that for every one of the 3 nodes it successfully gets the vdd-supply. Looking through the code this seems to be caused by of_get_regulator() first doing of_parse_phandle(node, prop_name, 0) which is checking on the node itself. But then if this does not succeed, it calls of_get_child_regulator(dev->of_node, prop_name) which goes through every child node of the top-level device (gpio-keys) until it finds a regulator. So this will find the vdd-supply of event-hall-sensor even for key-volume-up and switch. Going through the git history shows this commit from 2018 [0] which definitely has a different use-case in mind given the commit message so that very much seems like an unintentional side effect (not that I fully understand the addressed problem in the first place). [0] fe06051dbf8a ("regulator/of_get_regulator: add child path to find the r= egulator supplier") A workaround from the driver side would be to check for the presence of vdd-supply on the child (fwnode_property_present(child, "vdd-supply")) before trying to get a regulator but I feel like resolving this in the regulator core would be the better solution? Let me know your thoughts. Regards Luca