From patchwork Fri Jun 14 17:54:15 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: 166895 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352982ilk; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/IROPwWYjqXsU5JqVc90RzWzEe4DPA8GJRrwHFGJM08kVKbw+Ch044xjRyDyRzI3YYidW X-Received: by 2002:a17:90b:d8a:: with SMTP id bg10mr12407797pjb.92.1560534929157; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534929; cv=none; d=google.com; s=arc-20160816; b=k/bLiPI1wFA5aRWVhAo83lx/RfUpO6fjUgEYTYDH2wfB5efaG6rVLA61mNkC5xBzdP iZx7quuX8UAPa5Vu/NIi1+SGoVCYkoNHLRjRScpO0xlxsYSjDwNl9/aBB2I9phBI1osg 5CAiXQUaufPSukEYDNzxgUhn06zooBz6bxUxDfpi6mc1E/ReidPI6E6zKOq5UJuuSJ1b 1n0Qx+YzDLJaXUswipzBGhCUHtji8N8poJFSNQ902yoxwvFZ18u8f3Gh/BiuXC9YKQYf NuwNdMSW6jwCU1bFmOnkodN2GeV/RpxaymoTVA8UC5DNl+mp/4M0cjj7L0n2eH8ViEf7 DnrA== 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=9sfNlzy7aTx+2mkcDItYe5HTG3N5ZkRlrrK2epdYtZA=; b=aUAAwkgUc++mtGeP8qublZgk81QHU1cJq/Utsdyj3hLOJmyyIg7c2CtGO2wiabDsoc TUEuWpNssIbRBZ6zlhmODq7gLVh3XUy2cAw8pGUODymLNwII6gbaX2KfN97s3bcgfPpi 9ISxoiZ8SM2iQS/n507Vi8cHEORQRYmlGB0V1xZBubmQNukCIrDpBqhwMoPeaMw4o2De n3qz3hAeRSSjeHF2+k7dd/xQ2NPoBGHPEyEF6luGGyBKV2DNUgr3E1hppJIlueH7gOQ3 q27OGgX40jdKZUthD/fD3a9jtFGHVbNKt4seAFwSUrt98nB8aWSzNRAJ0fN95KbSLcN2 DbWg== 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 f9si3064713pfd.110.2019.06.14.10.55.28; Fri, 14 Jun 2019 10:55:29 -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 S1727705AbfFNRz1 (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:27 -0400 Received: from foss.arm.com ([217.140.110.172]:39640 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfFNRzX (ORCPT ); Fri, 14 Jun 2019 13:55:23 -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 677D53EF; Fri, 14 Jun 2019 10:55:22 -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 64BB33F718; Fri, 14 Jun 2019 10:55:21 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH v2 20/28] drivers: Introduce bus_find_next_device() helper Date: Fri, 14 Jun 2019 18:54:15 +0100 Message-Id: <1560534863-15115-21-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 for bus_find_device() to find the next devices on the given bus from the "start" device. Also convert the existing users to make use of the new helper. Cc: Bjorn Helgaas Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/pci/probe.c | 7 +------ drivers/scsi/scsi_proc.c | 9 ++------- include/linux/device.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index f9ef7ad..3504695 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -64,11 +64,6 @@ static struct resource *get_pci_domain_busn_res(int domain_nr) return &r->res; } -static int find_anything(struct device *dev, const void *data) -{ - return 1; -} - /* * Some device drivers need know if PCI is initiated. * Basically, we think PCI is not initiated when there @@ -79,7 +74,7 @@ int no_pci_devices(void) struct device *dev; int no_devices; - dev = bus_find_device(&pci_bus_type, NULL, NULL, find_anything); + dev = bus_find_next_device(&pci_bus_type, NULL); no_devices = (dev == NULL); put_device(dev); return no_devices; diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index c074631..5b31322 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -372,15 +372,10 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf, return err; } -static int always_match(struct device *dev, const void *data) -{ - return 1; -} - static inline struct device *next_scsi_device(struct device *start) { - struct device *next = bus_find_device(&scsi_bus_type, start, NULL, - always_match); + struct device *next = bus_find_next_device(&scsi_bus_type, start); + put_device(start); return next; } diff --git a/include/linux/device.h b/include/linux/device.h index 3c244ac..1c137ab 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -225,6 +225,16 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus, return bus_find_device(bus, NULL, &devt, device_match_devt); } +/** + * bus_find_next_device - Find the next device after a given device in a + * given bus. + */ +static inline struct device * +bus_find_next_device(struct bus_type *bus,struct device *cur) +{ + return bus_find_device(bus, cur, NULL, device_match_any); +} + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,