From patchwork Fri Jun 14 17:54:01 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: 166881 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352584ilk; Fri, 14 Jun 2019 10:55:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ4Ma1/vglgaSnCwQ7Hjkqg9ILeBn9q8WrgCaIQKoHWuu6/g5D3VDc8k0mzBRs0yGp1Ekv X-Received: by 2002:a63:1919:: with SMTP id z25mr37594416pgl.440.1560534901813; Fri, 14 Jun 2019 10:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534901; cv=none; d=google.com; s=arc-20160816; b=d63qx6eeKlM0wNAjMrMpuMIXq5TdwGCY/DHeXbUHiVJqWbL3lYY69bqWZoKHqJGeu5 yVi4SGc+O/P/ECjPluqaJ5jYrYNlpeA0qn+cdh4le/+SkvIMpHhLGizBf+R+nKSJvf+b V1VT1TVsZeVj5heH3lvT40mIN+VZGlz3BgfTd0Bmk83qeWDRV4kDcI7pnjo7qN8FWLXK RV9PNplwZ4EfRYgj9Dx+RCnTz5PN/Z3gqdDz+0ScVOtYN/KnBAK70T749qN8NOL1KJ4x EdvhT/BJV1vFbI4iFbCeMDTB/BDsRzJcpcJFSflRt+/xZNLgfyZ7vT6WIwHbrdL253mx 0vYg== 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=Pi188EItlRZ4O9JGvL8x5kEaGLgBtARxNQtM7nqr+z4=; b=X4Heoh4oGK36Q/ntC3wVWZQMqfPcysz+tnFiGqiIqYz1OuTm3LEnojA6JgDbao5fdD LjYYc1C9Egd/ZPkqU5sxcFP36dgrWAl0krtxaXS4zM8JnvOkLSDs9XlgD5Qgntzkch+K J64xQRm1/BLAKyfWuVOeKKc0N2eJ3hgSRpPieTQNx+y8HmAI8aBgmx0NZDUnFtURV0+Z SWAVtrIlYJ2t3+vBHJtqK0YVP9pNuxbToJtsYEIE+IYM/b3DlxFPsFq07Fni0Q7xihYh jHk+/mpRTVawwlleQMbjvVFGQBYMAobgCwZB9qP+gqnJwyjqCpcGAc9y2xK0uNXtgLV7 6Tsw== 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 t14si3268706pgc.90.2019.06.14.10.55.01; Fri, 14 Jun 2019 10:55:01 -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 S1727405AbfFNRy7 (ORCPT + 17 others); Fri, 14 Jun 2019 13:54:59 -0400 Received: from foss.arm.com ([217.140.110.172]:39354 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfFNRy7 (ORCPT ); Fri, 14 Jun 2019 13:54:59 -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 EEF05346; Fri, 14 Jun 2019 10:54:57 -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 EF5FE3F718; Fri, 14 Jun 2019 10:54:53 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alan Tull , Andrew Lunn , Daniel Vetter , David Airlie , "David S. Miller" , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Florian Fainelli , Frank Rowand , Heiner Kallweit , Jiri Slaby , Jonathan Hunter , Lee Jones , Liam Girdwood , linux-fpga@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, Maarten Lankhorst , Mark Brown , Mathieu Poirier , Maxime Ripard , Moritz Fischer , Peter Rosin , Rob Herring , Srinivas Kandagatla , Thierry Reding , Thor Thayer , Wolfram Sang , Ulf Hansson , Joe Perches Subject: [PATCH v2 06/28] drivers: Add generic helper to match by of_node Date: Fri, 14 Jun 2019 18:54:01 +0100 Message-Id: <1560534863-15115-7-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 helper to match device by the of_node. This will be later used to provide wrappers to the device iterators for {bus/class/driver}_find_device(). Convert other users to reuse this new helper. Cc: Alan Tull Cc: Andrew Lunn Cc: Daniel Vetter Cc: David Airlie Cc: "David S. Miller" Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Florian Fainelli Cc: Frank Rowand Cc: Greg Kroah-Hartman Cc: Heiner Kallweit Cc: Jiri Slaby Cc: Jonathan Hunter Cc: Lee Jones Cc: Liam Girdwood Cc: linux-fpga@vger.kernel.org Cc: linux-i2c@vger.kernel.org Cc: linux-spi@vger.kernel.org Cc: Maarten Lankhorst Cc: Mark Brown Cc: Mathieu Poirier Cc: Maxime Ripard Cc: Moritz Fischer Cc: Peter Rosin Cc: Rob Herring Cc: Srinivas Kandagatla Cc: Thierry Reding Cc: Thor Thayer Cc: Wolfram Sang Cc: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman Cc: Ulf Hansson Cc: Joe Perches Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 6 ++++++ drivers/fpga/of-fpga-region.c | 7 +------ include/linux/device.h | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index fd7511e..9211908 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3328,3 +3328,9 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2) dev->of_node_reused = true; } EXPORT_SYMBOL_GPL(device_set_of_node_from_dev); + +int device_match_of_node(struct device *dev, const void *np) +{ + return dev->of_node == np; +} +EXPORT_SYMBOL_GPL(device_match_of_node); diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index 75f64ab..e405309 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -22,11 +22,6 @@ static const struct of_device_id fpga_region_of_match[] = { }; MODULE_DEVICE_TABLE(of, fpga_region_of_match); -static int fpga_region_of_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /** * of_fpga_region_find - find FPGA region * @np: device node of FPGA Region @@ -37,7 +32,7 @@ static int fpga_region_of_node_match(struct device *dev, const void *data) */ static struct fpga_region *of_fpga_region_find(struct device_node *np) { - return fpga_region_class_find(NULL, np, fpga_region_of_node_match); + return fpga_region_class_find(NULL, np, device_match_of_node); } /** diff --git a/include/linux/device.h b/include/linux/device.h index 4d7c881..7093085 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -163,6 +163,8 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter); void subsys_dev_iter_exit(struct subsys_dev_iter *iter); +int device_match_of_node(struct device *dev, const void *np); + int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); struct device *bus_find_device(struct bus_type *bus, struct device *start,