From patchwork Wed Jun 5 15:13:47 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: 165898 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7485885ili; Wed, 5 Jun 2019 08:14:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqySW9kgBvpesYMbld5KHaCme9sCY+uRCyVKQQJQn27KRYS0IczBsRR3kIpvF5LQyQh7avic X-Received: by 2002:a65:5c88:: with SMTP id a8mr5046409pgt.388.1559747699560; Wed, 05 Jun 2019 08:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559747699; cv=none; d=google.com; s=arc-20160816; b=ozt7UrIjSrH2/tGLQUuHaBGdwJqcKR8ByQQSFwFfWQX6XA0h1Y9QCZlqMgaOmXOJbb gXIKx9sL6mN7Rr1MTbgs2QfUmLVVx4yYqUq5LAjVEraNrsMMxgz0krhEUbTs7u3cZJGV yISE6jbyohiOUA3PRyAUjkrcMV+TfYUiAFpUbwtJbiJZJhna3pNnl4GCt+LqwJchYtZA wPd0k+sz3wfiMRYJhiI9sipI/1y0e/mJxJdmOZDcKIp6WCwx7xl+3v4RIyiL01unncfs PccOdBfyWR8KwiPWUXopbFllOuEqyGAB8XwNS26KD92sxGsMR8+lW8AIzxjOAOzfXOTJ LwNw== 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=mP7zfy1xi+SVNeGAYbDyltHY1erTbof0kYSDqRYw+0s=; b=j4rOwc5t0axx44IVzBJVBWFN6cOEg3fAcbcjXBGc89TFGtWPj1LFNI/+HDifnIO4x5 zbUNMHlfhO9AsfOBBiNzQp/nDfmQJ9DLIUxIyU3/CM37sEcSBzK50zPypTqN/I0tALTG /suG4A2p36KlXp+/UiV8vfUUyTmfxSaxvdf34sOpf8iQoaTbxAnbqD+SNFc/uKnR2V7j 4M/IKl9yXKMQCjodE3F+CL+2D/UZ0aNzYn9n+tqNbuepje+/jBJ6VT5/iq5F2Hr/plfo Qm5wSNEEMjp76F1kpWbASk1ZSSBTdCYT7rAQWX4CvjynEIdUGX/1KPr5wlcr8elac/Ty HaMg== 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 h68si26807792pgc.270.2019.06.05.08.14.59; Wed, 05 Jun 2019 08:14:59 -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 S1728627AbfFEPOy (ORCPT + 30 others); Wed, 5 Jun 2019 11:14:54 -0400 Received: from foss.arm.com ([217.140.101.70]:33540 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbfFEPOw (ORCPT ); Wed, 5 Jun 2019 11:14:52 -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 71BF615A2; Wed, 5 Jun 2019 08:14:52 -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 91E053F246; Wed, 5 Jun 2019 08:14:47 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alessandro Zummo , Alexander Aring , Alexander Shishkin , Alexandre Belloni , Andrew Lunn , Arnd Bergmann , Dan Murphy , "David S. Miller" , Florian Fainelli , Harald Freudenberger , Heikki Krogerus , Heiko Carstens , Heiner Kallweit , Jacek Anaszewski , Jiri Slaby , Liam Girdwood , linux-leds@vger.kernel.org, linux-rtc@vger.kernel.org, linux-usb@vger.kernel.org, linux-wpan@vger.kernel.org, Mark Brown , Maxime Coquelin , Pavel Machek , Peter Rosin , Stefan Schmidt , Tomas Winkler , "Rafael J. Wysocki" Subject: [PATCH 10/13] drivers: Introduce variants of class_find_device() Date: Wed, 5 Jun 2019 16:13:47 +0100 Message-Id: <1559747630-28065-11-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559747630-28065-1-git-send-email-suzuki.poulose@arm.com> References: <1559747630-28065-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 Now that we have generic helpers to match various generic device attributes, provide wrappers to the class_find_device() to lookup devices by individual properties. The new wrappers except the lookup by devt, drops the "start" device pointer as none of the existing users need it and the attributes are usually unique. The idea is to stop the proliferation of custom match functions to do generic attribute matching. So now we have : class_find_device_by_name class_find_device_by_of_node class_find_device_by_fwnode class_find_device_by_devt Cc: Alessandro Zummo Cc: Alexander Aring Cc: Alexander Shishkin Cc: Alexandre Belloni Cc: Andrew Lunn Cc: Arnd Bergmann Cc: Dan Murphy Cc: "David S. Miller" Cc: Florian Fainelli Cc: Greg Kroah-Hartman Cc: Harald Freudenberger Cc: Heikki Krogerus Cc: Heiko Carstens Cc: Heiner Kallweit Cc: Jacek Anaszewski Cc: Jiri Slaby Cc: Liam Girdwood Cc: linux-leds@vger.kernel.org Cc: linux-rtc@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: linux-wpan@vger.kernel.org Cc: Mark Brown Cc: Maxime Coquelin Cc: Pavel Machek Cc: Peter Rosin Cc: Stefan Schmidt Cc: Tomas Winkler Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- include/linux/device.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) -- 2.7.4 diff --git a/include/linux/device.h b/include/linux/device.h index 8c8727b..4396edc 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -474,6 +474,57 @@ 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: class type + * @name: name of the device to match + */ +static inline struct device *class_find_device_by_name(struct class *class, + const char *name) +{ + return class_find_device(class, NULL, name, device_match_name); +} + +/** + * class_find_device_by_of_node : device iterator for locating a particular device + * matching the of_node. + * @class: class type + * @np: of_node of the device to match. + */ +static inline struct device * +class_find_device_by_of_node(struct class *class, const struct device_node *np) +{ + return class_find_device(class, NULL, np, device_match_of_node); +} + +/** + * class_find_device_by_fwnode : device iterator for locating a particular device + * matching the fwnode. + * @class: class type + * @fwnode: fwnode of the device to match. + */ +static inline struct device * +class_find_device_by_fwnode(struct class *class, + const struct fwnode_handle *fwnode) +{ + return class_find_device(class, NULL, fwnode, device_match_fwnode); +} + +/** + * class_find_device_by_devt : device iterator for locating a particular device + * matching the device type. + * @class: class type + * @start: device to start search from + * @devt: device type 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); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr,