From patchwork Fri Jun 14 17:54:19 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: 166896 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353015ilk; Fri, 14 Jun 2019 10:55:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvjKrbiG8k9uJ8wBHZneucIrBXbIUntFZYSW2Hoz8gG7Th8CtlsHCY9x8rsXXpzW9t3vlo X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr92691003plh.338.1560534931366; Fri, 14 Jun 2019 10:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534931; cv=none; d=google.com; s=arc-20160816; b=D2OCcRB4Im3oynmo3EL3BVuUx/FyMJ9HBMzbjcocZYNzHPY1GISWWktHvm8GICaWsd xHgiydmkjzfcO5K1oc9RY7WmGukuLQLVUE6RTTjNuVRarjFgu9uof0Dxu5r3lpJCsl4A N8m9+Jpb73yvxAIG8XuhkzHETiRSWanfU/T6ZNVG3q09CI3jtNBozqIX93+M5+ziNJAS ya2itFYJlbGQ0631aJPc9WfDrPJttkkFdH8SQqrC8jV/61rhAnl1vwLPrynVAvHHGOnQ wrle6wX73Zn87DSHsOoX/Ty0M0brwFD50lF+Oh0xrh3rxnseRf22UdZciLna5GNWwqjR +Yhg== 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=lz4DU0OJwe3BiALHT7jkeYZIdJRvt6nZpNaxC/3oo5c=; b=VNXfDzPkVuwLCimGqxNN0rdoI/rSSv7WP7gHInCkf6/419a4axXPvR2IXzl86DmTll brH0lYB1dz8RE/eWOHUye8uJaiyGUWTjObziWJWlrxTZBGu3U5LIYi9JEiUjrYqh9mD0 HRiXoYhulUPCGWHtCBI7hh+ioaD8sqodfVUdiID+b/yJfupC6k/RFmyNkRtz+Oy5x5pR JFShR5TkM/TmVciR6tO6l/RyFudY+dJSy3LBDN4eiA5ANNuCaQ70ozgXh4XtZ/P/6sVq JvvpFRfdoTE7SsaLTZDTuB5ooqYCHXGfnKeunKKWkvMpwkVrTuaGf8NeyZwSbhGChU8F oPiQ== 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 f69si2888095pjg.43.2019.06.14.10.55.31; Fri, 14 Jun 2019 10:55:31 -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 S1727722AbfFNRz3 (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:29 -0400 Received: from foss.arm.com ([217.140.110.172]:39694 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727700AbfFNRz1 (ORCPT ); Fri, 14 Jun 2019 13:55:27 -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 67A60D6E; Fri, 14 Jun 2019 10:55:27 -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 64D113F718; Fri, 14 Jun 2019 10:55:26 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Will Deacon , Robin Murphy , Joerg Roedel Subject: [PATCH v2 24/28] drivers: Introduce driver_find_device_by_fwnode() helper Date: Fri, 14 Jun 2019 18:54:19 +0100 Message-Id: <1560534863-15115-25-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 driver_find_device() to search for a device by the fwnode pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Will Deacon Cc: Robin Murphy Cc: Joerg Roedel Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/iommu/arm-smmu-v3.c | 9 ++------- drivers/iommu/arm-smmu.c | 9 ++------- include/linux/device.h | 13 +++++++++++++ 3 files changed, 17 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index d787856..6b956a03 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2023,16 +2023,11 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) static struct platform_driver arm_smmu_driver; -static int arm_smmu_match_node(struct device *dev, const void *data) -{ - return dev->fwnode == data; -} - static struct arm_smmu_device *arm_smmu_get_by_fwnode(struct fwnode_handle *fwnode) { - struct device *dev = driver_find_device(&arm_smmu_driver.driver, NULL, - fwnode, arm_smmu_match_node); + struct device *dev = driver_find_device_by_fwnode(&arm_smmu_driver.driver, + fwnode); put_device(dev); return dev ? dev_get_drvdata(dev) : NULL; } diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 3af579a..0d63a9e 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1419,16 +1419,11 @@ static bool arm_smmu_capable(enum iommu_cap cap) } } -static int arm_smmu_match_node(struct device *dev, const void *data) -{ - return dev->fwnode == data; -} - static struct arm_smmu_device *arm_smmu_get_by_fwnode(struct fwnode_handle *fwnode) { - struct device *dev = driver_find_device(&arm_smmu_driver.driver, NULL, - fwnode, arm_smmu_match_node); + struct device *dev = driver_find_device_by_fwnode(&arm_smmu_driver.driver, + fwnode); put_device(dev); return dev ? dev_get_drvdata(dev) : NULL; } diff --git a/include/linux/device.h b/include/linux/device.h index f929671..2cf49f7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -450,6 +450,19 @@ driver_find_device_by_of_node(struct device_driver *drv, return driver_find_device(drv, NULL, np, device_match_of_node); } +/** + * driver_find_device_by_fwnode- device iterator for locating a particular device + * by fwnode pointer. + * @driver: the driver we're iterating + * @fwnode: fwnode pointer to match. + */ +static inline struct device * +driver_find_device_by_fwnode(struct device_driver *drv, + const struct fwnode_handle *fwnode) +{ + return driver_find_device(drv, NULL, fwnode, device_match_fwnode); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev);