From patchwork Mon Jun 3 15:49:54 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: 165617 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4644533ili; Mon, 3 Jun 2019 08:51:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHXmiZSZ1Z6RJg125bmoZFoh9357kNfe2RbSWkag/5ucvpNxoS+9z+G4QydezMmU1RVHh0 X-Received: by 2002:a63:e616:: with SMTP id g22mr30411137pgh.61.1559577106161; Mon, 03 Jun 2019 08:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559577106; cv=none; d=google.com; s=arc-20160816; b=p7fPx4udrF74PerLlRV53K9pNcPF2qkZMukWgDNIiXqXTg5jiJYDlkl+a8ZpxCv4Rf 3b7EjvFbIsEitBfJi9lgHv4lzRqZ5o+znADSBXI9Eb77BtWc/jPMeH8frpc8XO51vUA4 SOMTJK8/d4TNOr9OJEi5gMf26gEgQK2fjPNHhtyVsE1NRffeqj06r41Lc9GJx1PcnVor fFSExxHrzcxZNy11nXDVLmnkyXi3Pi36uQlFwKXrj8xLsbpqkMAP6IGGkTApuOnJiVpo VyWMP3syOgeitWn6qYiD8FMQ7w08OIf0dlgUxIOKZj2qItDBx6Xx7BpP0ilNetCABAPk mz0A== 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=zmXZa2q3AZMEPh9RGYa+UwIAdiJW6+y7+BWrXktHK44=; b=qEIeRL+brf6QzAHD7vCiaK8gm1Z7giluqYx1Iya3fh/UwwLFn1AwCvB4Yh6x/3xbnS kHHKfLTwGEkHpg08D+8VtaqwIccmBn29Ku24M3+25aimDLyVZ9NY1ARPolFTVb7VPIeA uM7S2BkyK3Lcw+IO0QvtVJ3IxEbbVk6H+3po8KXXrogdzfXasE4HLmLFRRy3ItnkzNWc ZzvUQCBZur0Ffg3O5rDTDe1WuNRRvEH9QgetBq8M7LZoK2LnHaOchyQKHYCE/+VuB7z7 kpYe9k1Ltj8tbptRbHeLwPKKNZC40NBYdkDlP68EX9x/6GRpmjApp7IGInyJw1dsCg5E 01sg== 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 n2si13824126pgq.129.2019.06.03.08.51.45; Mon, 03 Jun 2019 08:51:46 -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 S1729370AbfFCPvp (ORCPT + 30 others); Mon, 3 Jun 2019 11:51:45 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53816 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729282AbfFCPvm (ORCPT ); Mon, 3 Jun 2019 11:51:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E50551A25; Mon, 3 Jun 2019 08:51:41 -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 04E1A3F246; Mon, 3 Jun 2019 08:51:40 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com Subject: [RFC PATCH 28/57] drivers: class: Add variants of class_find_device() Date: Mon, 3 Jun 2019 16:49:54 +0100 Message-Id: <1559577023-558-29-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559577023-558-1-git-send-email-suzuki.poulose@arm.com> References: <1559577023-558-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 Similar to the bus_find_device_by_*() helpers add wrappers for class_find_device() to find devices by generic attributes. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- include/linux/device.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) -- 2.7.4 diff --git a/include/linux/device.h b/include/linux/device.h index e8d1267..1945c3d 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -528,6 +528,64 @@ extern int class_for_each_device(struct class *class, struct device *start, extern struct device *class_find_device(struct class *class, struct device *start, const void *data, int (*match)(struct device *, const void *)); +/** + * class_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @class: the class we're iterating + * @start: Device to begin with + * @name: name of the device to match + * + * This is similar to the class_find_device() above, but it handles searching + * by a name automatically. + */ +static inline struct device *class_find_device_by_name(struct class *class, + struct device *start, + const void *name) +{ + return class_find_device(class, start, name, device_match_name); +} + +/** + * class_find_device_by_devt - device iterator for locating a particular device + * by devt. + * @class: the class we're iterating + * @start: Device to begin with + * @devt: devt of the device to match + */ +static inline struct device *class_find_device_by_devt(struct class *class, + struct device *start, + dev_t devt) +{ + return class_find_device(class, start, &devt, device_match_devt); +} + +/** + * class_find_device_by_of_node - device iterator for locating a particular device + * by of_node. + * @class: the class we're iterating + * @start: Device to begin with + * @np: of_node of the device to match + */ +static inline struct device *class_find_device_by_of_node(struct class *class, + struct device *start, + struct device_node *np) +{ + return class_find_device(class, start, np, device_match_of_node); +} + +/** + * class_find_device_by_fwnode - device iterator for locating a particular device + * by fwnode. + * @class: the class we're iterating + * @start: Device to begin with + * @fwnode: fwnode of the device to match + */ +static inline struct device *class_find_device_by_fwnode(struct class *class, + struct device *start, + struct fwnode_handle *fwnode) +{ + return class_find_device(class, start, fwnode, device_match_fwnode); +} struct class_attribute { struct attribute attr;