Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp2764381qtf; Mon, 12 Jun 2023 09:41:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JSFV3raB9Zbxrq+dsQYCHXnN7oHzQdF0uBAmqN7Df/mQOHLyrWiaGSowSsAENfWKolQ+b X-Received: by 2002:a05:6a20:1004:b0:110:29b9:9652 with SMTP id gs4-20020a056a20100400b0011029b99652mr9022475pzc.56.1686588071751; Mon, 12 Jun 2023 09:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686588071; cv=none; d=google.com; s=arc-20160816; b=iLloOu2Xy1Me0GyzgGi0VyXME3nXVMyM0SHEYCDkFXATIvruCsjhLAShp8VMMuTl5y 7cV2WNG84Webur/noWd3YvqgUcmnhK9DV7DMup2piFU8KFh9N8Y+NPZC2q0nMe4KS35t 4yqG5wY8jYkGjjBTKdAQr8A7SsBJ14xSBZSDEvrPvB6zgbkhcLJUA3r01ajf7NsJxTM6 1eBwz/dl9lC45C9zfyQZZl/hHeQJEsa3BYRWZpF30piicQ/LOFhU2vDSbf50RF/mnfvN 3MTQFD9jB+QzHsYfZr4N0xlQOJYgJ+n0Me1wr7/+tePuCeUYGU4q7g/F54BWA/XNI/Ao 8iPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ItHLodkwYmdt6kbjC2UZXGm9eqteWuErs3uZxhRY9Xk=; b=t0g28Ql6/XBjJdtb7UnL5IMOXeXGL5uz0Jx+IWf6idAZqPo0Q31Lcvii4Bp9NYgb/q 3VbgzLIGe0ZUyzDiG55Xqv7B2bg3q0PfWnRlnnimLnwugT7BdZNUoHP+XXUOua6ANVdb NPCBXYaTnoQgc4VJ2wFqzY42vIZF4y1fMkjDUiFL7RYIyzVrA/VfLOGoZdAGQnDU945i R7KIx9dUsFbda9VvRfmilUNAz57MuAi0Zj6CH6ml4XbDU+q5mL3JcvEKQ5iiEE/ZZJ/G z607rFTZy8H3Fp7O9rUymM8C5xOku4I1ZJ3/FzR8YNapIohcFVsISaQNBp8lw0kAJAMZ JA8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nqpy6rdC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a637411000000b00545072f800fsi6872895pgc.320.2023.06.12.09.40.56; Mon, 12 Jun 2023 09:41:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nqpy6rdC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233706AbjFLQNM (ORCPT + 99 others); Mon, 12 Jun 2023 12:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233212AbjFLQM7 (ORCPT ); Mon, 12 Jun 2023 12:12:59 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A5DF9; Mon, 12 Jun 2023 09:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686586378; x=1718122378; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZVijZK/WZlyfY9LyKUl0qbhbQCVTQtvnKOYuW8Ncf/M=; b=nqpy6rdC0eIi7vJ1ryhlNpdtvlc//sSr5lyMLp3tfDTH+E1wLIhh1az6 m2fZ+f+QKiFBzfc+dtUVG94Rc24K8HeTvmwCPtHoJo6fSRp0mf51RUPkl /ZzcRMEirxTAmMSm+jxP9Oz+To1c3mKiFMeypvDwwqF0EFk/RFYbpixEj kRyA5B/sOwkUuD5CNZCYxLGwUuaViUh2ytiIiu686uH44muq3nOurHbae /WkIygervy21YZ5oR2fwBB6lKaHsKKaCXCN99Ax+WTaiEQpTK6Sa/KSJN BrW+WZ9Gk3GJFliZuEAuCedoDCsdCxGBSY1xfuNndfXpo9MDdnhD6O706 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="360572690" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="360572690" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 09:10:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="824031047" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="824031047" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 12 Jun 2023 09:10:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D20983B6; Mon, 12 Jun 2023 19:10:13 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Greg Kroah-Hartman , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Hans de Goede , Jens Axboe , Damien Le Moal , "Rafael J. Wysocki" , Len Brown , Daniel Scally , Heikki Krogerus , Sakari Ailus Subject: [PATCH v3 2/3] device property: Implement device_is_compatible() Date: Mon, 12 Jun 2023 19:10:10 +0300 Message-Id: <20230612161011.86871-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230612161011.86871-1-andriy.shevchenko@linux.intel.com> References: <20230612161011.86871-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some users want to use the struct device pointer to see if the device is compatible in terms of Open Firmware specifications, i.e. if it has a 'compatible' property and it matches to the given value. Provide inline helper for the users. Reviewed-by: Sakari Ailus Signed-off-by: Andy Shevchenko --- include/linux/property.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/property.h b/include/linux/property.h index 3df7e10156d8..0251138c7c88 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -90,6 +90,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char return fwnode_property_match_string(fwnode, "compatible", compat) >= 0; } +/** + * device_is_compatible - match 'compatible' property of the device with a given string + * @dev: Pointer to the struct device + * @compat: The string to match 'compatible' property with + * + * Returns: true if matches, otherwise false. + */ +static inline bool device_is_compatible(const struct device *dev, const char *compat) +{ + return fwnode_device_is_compatible(dev_fwnode(dev), compat); +} + int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, const char *prop, const char *nargs_prop, unsigned int nargs, unsigned int index, -- 2.40.0.1.gaa8946217a0b