From patchwork Fri Jun 14 17:54:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166890 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352846ilk; Fri, 14 Jun 2019 10:55:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXtHFUB9zVDdsVAxxrM4CpMmKQvEZFhqcKUIu5mGCXIHKKWjdL4/BzHM1UWne9aXNdiaJl X-Received: by 2002:a17:90a:8d0d:: with SMTP id c13mr11803188pjo.137.1560534918986; Fri, 14 Jun 2019 10:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534918; cv=none; d=google.com; s=arc-20160816; b=L1J64z6F1PFKH+RNLUObqPIRqh8dmp78Tb9GFCTxeP1Uj/HTA1GG2epaLSuLsKwvfr tQ94HfvUKFBdApkph1vcijLsNOWhOJzraYV+2UaH7dPe6xTT2Y9U9v1PCthUQ6TRq57L wr647MYG7dHk/SV0xWvRqdIWUOXmFJYr/2t00hAE+o6PaAzASHFnnq2BjPRQJUuf6+r+ blozest42vbBSgzR6pWcQ4lvtGuP258S0gvScvm83jI2iet0l0A/3A2sWH6Xh1DfwlEs KHekOj4i3fgE+PiLfy+Sq4NASt0SXkLkus9jRKKr8VGI7uuFfi5xnFsqUixzLKZw/0Hq PxCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=c9o3GtHO217nUgCv6NA4hyWW1vCgV80gFdh2FfcxvOo=; b=Q/vjxH5pC5nwv2U/t0DbFNCnpbDYbwZUMuVAgPZ2kkeuRRVCoXJuSRFu2DkllcnrTd TUf7dEB5ATXLID8a512f3WT+wunwBpDHmQhgF2uOJ6EX6MTjGQltN2DSAUJAzrogrmIj vegsi0T/RiKk+ShGwYziHsziEMyfh8WZJO4J9UtuF4mVRoac5WZzfDZttHIWpG4eU6za xAIJ2Sj6pAuY9i5C6biyNCvZIc4EKi1f55AkprCEojwNYHEaLnGVCoW3KN2Rl7VSzqlg KDAm8w2lnH1LCuhe0/MuhJzOg3cR7feUo/2T3eHUrAK4mjxMSRvImW1MVSyjjXhHUZXO ULaA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.18; Fri, 14 Jun 2019 10:55:18 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbfFNRzS (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:18 -0400 Received: from foss.arm.com ([217.140.110.172]:39574 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbfFNRzQ (ORCPT ); Fri, 14 Jun 2019 13:55:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2E6AD6E; Fri, 14 Jun 2019 10:55:15 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2CF1C3F718; Fri, 14 Jun 2019 10:55:15 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com Subject: [PATCH v2 16/28] drivers: Introduce class_find_device_by_acpi_dev() helper Date: Fri, 14 Jun 2019 18:54:11 +0100 Message-Id: <1560534863-15115-17-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to class_find_device() to search for a device by the ACPI COMPANION device, reusing the generic match function. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- include/linux/device.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.7.4 diff --git a/include/linux/device.h b/include/linux/device.h index 2effcc2..b1b8c90 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -534,6 +534,27 @@ static inline struct device *class_find_device_by_devt(struct class *class, return class_find_device(class, NULL, &devt, device_match_devt); } +#ifdef CONFIG_ACPI +struct acpi_device; +/** + * class_find_device_by_acpi_dev : device iterator for locating a particular + * device matching the ACPI_COMPANION device. + * @class: class type + * @adev: ACPI_COMPANION device to match. + */ +static inline struct device * +class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev) +{ + return class_find_device(class, NULL, adev, device_match_acpi_dev); +} +#else +static inline struct device * +class_find_device_by_acpi_dev(struct class *class, const void *adev) +{ + return NULL; +} +#endif + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr,