From patchwork Wed Jun 5 15:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 165900 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7486025ili; Wed, 5 Jun 2019 08:15:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxO11cUpimdONsnPDvHAft4g5d2AOJZ+RQ3k5MdlhTA7FpBAnrMkW73KaDiv2Qam1qphtXa X-Received: by 2002:a63:4c0f:: with SMTP id z15mr5054949pga.245.1559747706009; Wed, 05 Jun 2019 08:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559747706; cv=none; d=google.com; s=arc-20160816; b=eri9l5aTb+Jk6jAiTETc1CHKmHvTmSFI/W1PIiG7cXZJezNIQjWp8tOv/p35nYhhhU USqNhCeBv12lwS7vH6n7hB9EFQZ4jnq70IYVwyb4N4rLwxAGIjsz1p2weVeYsbJGSGP+ RsEUjmL0bj6OH1U2TjJtZCJm/gTB27niZenwcApCdZwFHTRVjR9RUwI5EpJitKJ6p6sA PdeAe83YRm7L23DDgQ8zdIQ3gO26mFg3AafQfSelUn8Cfn133yr28W/kXXf42ftMbmtW WIl3tIImxp1QUZwo22RHF+rlIh5KG032Jfkemq1P646tkTDM4WpEXRoJz/WI7sF66dTO +nzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OnhwLcJA1jVjA6cIKCDwpWAQlqEybey0MoUiSawl56k=; b=RU5znu2nVVuymAqHa4vKXXTeED5M3qzrk2YG4emSp5y9eGcVEcl2UgE3622pH+3cJC SbBanO0h4G16323hIfNydXFC0NTyDu4tZxk9JAuecqP1Gk5CymGYf81+T7Y2dVQn/aCj OQGveVlgTWx+0TEMXeziuZsF8CzZ6moe2ajJtrtk0RTvPOFTW60imU0YsoJhBlHJp4RA /1x+3pwmCvdv+0JXmtiClhmMpryamP4rHBHOAXDMiZaRjNHEAo+NvbIA7rVzFxKNf35g 7qcGQOPg23MuWs04iU7O/Ib4KPhUNUoQIiI6xweA4kSYre5ETurzD2KHYgjrwH2RilVo GBNA== 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 i18si22473813pfr.65.2019.06.05.08.15.05; Wed, 05 Jun 2019 08:15:05 -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 S1728676AbfFEPPE (ORCPT + 30 others); Wed, 5 Jun 2019 11:15:04 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33644 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728510AbfFEPPC (ORCPT ); Wed, 5 Jun 2019 11:15:02 -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 CD78F1682; Wed, 5 Jun 2019 08:15:01 -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 2BD483F246; Wed, 5 Jun 2019 08:15:00 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Eric Anholt , =?utf-8?q?Heiko_St=C3=BCbner?= , Inki Dae , Sandy Huang , Seung-Woo Kim Subject: [PATCH 13/13] platform: Add platform_find_device_by_driver() helper Date: Wed, 5 Jun 2019 16:13:50 +0100 Message-Id: <1559747630-28065-14-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> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a helper to lookup platform devices by matching device driver in order to avoid drivers trying to use platform bus internals. Cc: Eric Anholt Cc: Greg Kroah-Hartman Cc: "Heiko Stübner" Cc: Inki Dae Cc: "Rafael J. Wysocki" Cc: Sandy Huang Cc: Seung-Woo Kim Signed-off-by: Suzuki K Poulose --- drivers/base/platform.c | 14 ++++++++++++++ include/linux/platform_device.h | 3 +++ 2 files changed, 17 insertions(+) -- 2.7.4 diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4d17298..158ac24 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1197,6 +1197,20 @@ struct bus_type platform_bus_type = { }; EXPORT_SYMBOL_GPL(platform_bus_type); +/** + * platform_find_device_by_driver - Find a platform device with a given + * driver. + * @start: The device to start the search from. + * @drv: The device driver to look for. + */ +struct device *platform_find_device_by_driver(struct device *start, + const struct device_driver *drv) +{ + return bus_find_device(&platform_bus_type, start, drv, + (void *)platform_match); +} +EXPORT_SYMBOL_GPL(platform_find_device_by_driver); + int __init platform_bus_init(void) { int error; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index cc46485..36aa775 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -52,6 +52,9 @@ extern struct device platform_bus; extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); +extern struct device * +platform_find_device_by_driver(struct device * dev, + const struct device_driver *drv); extern void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index);