Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp756692pxb; Wed, 29 Sep 2021 09:04:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZBr2QhH0dbDnW3rkrMWWMk+EQW7EPQWmqeRsl4pfW+A+OZGy7HcK4uIx+Ot/VaWr7Yt9I X-Received: by 2002:a17:90b:3e82:: with SMTP id rj2mr760724pjb.72.1632931461872; Wed, 29 Sep 2021 09:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632931461; cv=none; d=google.com; s=arc-20160816; b=jcQoSVoJkZR/NYMXzO2KfNkdu4AS2TzS169yjkMWv7laEKzU8ODbKws2IcpcU9Hl1K u+glT8Ue/tjW+GJwll2vKxQrOGzzDEGZmYCZ2IRJMjX8gOOeyLkjEwTfghBSR5qEgNWp 6kDptmsLDFqnbpZ7ocDNgVl5TCa+hTrePk/3jDTscAfj4Y3h9AL3vy57myDFF10NrBNd 6dudhV+8p4uGNstCpO0Nm1l7Gp40GctLeNVEGxMMMplmt7FIRDMTiqIJBijWMIRPeixf b1uCkfEAMocRCL0CGJLgjpyDJUaOdN3cyOR7GIHaATQgKsUxTdUGjxOvVtulgXwVUj44 t/YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=66gYmi6lBmPZ/L17dKFHsrbn1XPIQIpAT7gJwo79Q+8=; b=bBzmysoQcaevfYkIeM3ewwovGEEiSr9p/uP2PpIze6z/QCUc96bRtsudneJ/4ql2f2 NvAWJuBKfMtjl7z/AycoI9dwK3FKKVXVfWbGzy0Zxqwgm+trt5bIUTee7Cu3N6Z95PX0 NmnplcJccvTD+k8ZLR18lHwERgAzGU2xtiZ2SvsccBnsEmv+PyphaD/p1RDsqQ5W3sCc +s5qBD65hIoCX8eVg7su1ApXovMF+MPvdybu94mjXeu03SHsnbdGEPquTISH2/rgzZhD wMxc97qnI+UKySgAK1y61z0KJobLNEU0u9E3k8RHvx/piuHKmrb/5ZmTgtDlHjGosbK0 E/Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjG61cqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u70si252950pfc.245.2021.09.29.09.04.08; Wed, 29 Sep 2021 09:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjG61cqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343816AbhI2Px0 (ORCPT + 99 others); Wed, 29 Sep 2021 11:53:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:47014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245740AbhI2PxP (ORCPT ); Wed, 29 Sep 2021 11:53:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0AAF060FA0; Wed, 29 Sep 2021 15:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632930694; bh=1Dcwft/d81SvmPwSaeSbXxkBB01iAeQr8xtz4Jq1N5Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PjG61cqAVPxwm53h4hF3QoYL4gUx7M+I887ql8PonN79fa1wQN0pZQ2hGJFG2DSjd gAxP8rahuVoFDV+ya2F0RdNsIDqF/r50M2x4Ho16ogPLaWF5TaSbO9foddNQIReI95 8EE5Gp8ztIouy9iQR+AGxxLrcnEqg4Hp9GKRQc+PZmvuk/g8wIVydHyLNGL2tjNGWV nOS1Wkx/+UbHys0AgFYM56pgIWCzzjyfJLWoS+ixMCjXg8DLPOS1hCFRh5W4WjhieE gtMYJYUYG6bVfQqx4ji8cz58vbJ7NXvAEj6rLSa5u1wi9Gqrc8JzdxPzgTbqqiI55e bXZs3hICIZBNg== Received: by mail-ed1-f51.google.com with SMTP id v18so10233619edc.11; Wed, 29 Sep 2021 08:51:33 -0700 (PDT) X-Gm-Message-State: AOAM533XmUpTjivXci8lmiyY9RX0DtuUuu7ER0BWBs29ysh3RJbz0zAB /0xGLpiQeXESK+IqVP1bI9o/U4P1AKhA/o/ZCQ== X-Received: by 2002:a17:906:a294:: with SMTP id i20mr511335ejz.128.1632930610672; Wed, 29 Sep 2021 08:50:10 -0700 (PDT) MIME-Version: 1.0 References: <20210929115409.21254-1-zev@bewilderbeest.net> <20210929115409.21254-2-zev@bewilderbeest.net> In-Reply-To: <20210929115409.21254-2-zev@bewilderbeest.net> From: Rob Herring Date: Wed, 29 Sep 2021 10:49:58 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/6] of: base: Add function to check for status = "reserved" To: Zev Weiss Cc: OpenBMC Maillist , Greg Kroah-Hartman , Jeremy Kerr , Joel Stanley , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Frank Rowand , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 6:54 AM Zev Weiss wrote: > > Per v0.3 of the Devicetree Specification [0]: > > Indicates that the device is operational, but should not be used. > Typically this is used for devices that are controlled by another > software component, such as platform firmware. > > One use-case for this is in OpenBMC, where certain devices (such as a > BIOS flash chip) may be shared by the host and the BMC, but cannot be > accessed by the BMC during its usual boot-time device probing, because > they require additional (potentially elaborate) coordination with the > host to arbitrate which processor is controlling the device. > > Devices marked with this status should thus be instantiated, but not > have a driver bound to them or be otherwise touched. > > [0] https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf > > Signed-off-by: Zev Weiss > --- > drivers/of/base.c | 53 +++++++++++++++++++++++++++++++++++++++------- > include/linux/of.h | 6 ++++++ > 2 files changed, 51 insertions(+), 8 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index f720c0d246f2..c5cc178fc6bd 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -579,14 +579,18 @@ int of_machine_is_compatible(const char *compat) > EXPORT_SYMBOL(of_machine_is_compatible); > > /** > - * __of_device_is_available - check if a device is available for use > + * __of_device_check_status - check if a device's status matches a particular string > * > - * @device: Node to check for availability, with locks already held > + * @device: Node to check status of, with locks already held > + * @val: Status string to check for > + * @alt: Optional alternate status string to check for (NULL to check only @val) > + * @dflt: default to return if status property absent > * > - * Return: True if the status property is absent or set to "okay" or "ok", > - * false otherwise > + * Return: True if status property exists and matches either @val or @alt. > + * @dflt if status property is absent. False otherwise. > */ > -static bool __of_device_is_available(const struct device_node *device) > +static bool __of_device_check_status(const struct device_node *device, const char *val, > + const char *alt, bool dflt) How about val==NULL means available/okay and then you can get rid of alt and dflt. Otherwise, I'd simply not try to share the implementation here and just add of_device_is_reserved(). Rob