Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765043AbYAYIKe (ORCPT ); Fri, 25 Jan 2008 03:10:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762117AbYAYIAM (ORCPT ); Fri, 25 Jan 2008 03:00:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:53633 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761677AbYAYH7o (ORCPT ); Fri, 25 Jan 2008 02:59:44 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Dave Young , James Bottomley , Greg Kroah-Hartman Subject: [PATCH 191/196] scsi: use class iteration api Date: Thu, 24 Jan 2008 23:33:40 -0800 Message-Id: <1201246425-5058-112-git-send-email-gregkh@suse.de> X-Mailer: git-send-email 1.5.3.8 In-Reply-To: <20080125071127.GA4860@kroah.com> References: <20080125071127.GA4860@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1798 Lines: 63 From: Dave Young Convert to use the class iteration api. Signed-off-by: Dave Young Cc: James Bottomley Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/hosts.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 24271a8..6325115 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -429,6 +429,15 @@ void scsi_unregister(struct Scsi_Host *shost) } EXPORT_SYMBOL(scsi_unregister); +static int __scsi_host_match(struct class_device *cdev, void *data) +{ + struct Scsi_Host *p; + unsigned short *hostnum = (unsigned short *)data; + + p = class_to_shost(cdev); + return p->host_no == *hostnum; +} + /** * scsi_host_lookup - get a reference to a Scsi_Host by host no * @@ -439,19 +448,12 @@ EXPORT_SYMBOL(scsi_unregister); **/ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) { - struct class *class = &shost_class; struct class_device *cdev; - struct Scsi_Host *shost = ERR_PTR(-ENXIO), *p; + struct Scsi_Host *shost = ERR_PTR(-ENXIO); - down(&class->sem); - list_for_each_entry(cdev, &class->children, node) { - p = class_to_shost(cdev); - if (p->host_no == hostnum) { - shost = scsi_host_get(p); - break; - } - } - up(&class->sem); + cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match); + if (cdev) + shost = scsi_host_get(class_to_shost(cdev)); return shost; } -- 1.5.3.8 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/