From patchwork Wed Jun 17 13:42:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6626281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A9ED09F326 for ; Wed, 17 Jun 2015 13:50:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C69872089E for ; Wed, 17 Jun 2015 13:50:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 022F62062F for ; Wed, 17 Jun 2015 13:50:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5DgS-0006iI-Hf; Wed, 17 Jun 2015 13:47:16 +0000 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5Dcv-0002xH-6E for linux-arm-kernel@lists.infradead.org; Wed, 17 Jun 2015 13:43:38 +0000 Received: by wgv5 with SMTP id 5so37485780wgv.1 for ; Wed, 17 Jun 2015 06:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fojWOlDiYpT22xlLA2ZetiCJBK+6IDHbw/xvusJpk2s=; b=o2uSTSeXQT8KJ5Je6I8PTvayHdN/1LxDaVGC/BFJY6ZmfJn9zot0Evz+3+v9wp2OaS lHxiC05SiEJGzbm8RwY52y0r7T0jMazlIeLfGr3Cbi4MmOZD0xlccb61/jj29ldc60xc LVSxqgdzqjTQF+KwzWcGxdwvZLbilvoW7mNgEgYprR7f53o/xwd3+5ATaC/jP/jgWxif 7BBVlUUgEvjUL8EyTcLurb28Slup9ddFRkaap8yrRIZNfx9RJerAEY111r3GdK9YNZex KujNJnd0lwSjRkG6bdUZRDw9RCASNxykeqfn1JQULvoPkFFqAP/98nXYeKczntz+RyU+ sB3A== X-Received: by 10.180.72.145 with SMTP id d17mr54781076wiv.69.1434548595233; Wed, 17 Jun 2015 06:43:15 -0700 (PDT) Received: from cizrna.lan ([109.72.12.132]) by mx.google.com with ESMTPSA id v3sm6920361wja.31.2015.06.17.06.43.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 06:43:14 -0700 (PDT) From: Tomeu Vizoso To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 10/13] driver-core: add for_each_class() Date: Wed, 17 Jun 2015 15:42:20 +0200 Message-Id: <1434548543-22949-11-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1434548543-22949-1-git-send-email-tomeu.vizoso@collabora.com> References: <1434548543-22949-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150617_064337_401679_3F3D3162 X-CRM114-Status: GOOD ( 11.01 ) X-Spam-Score: -0.7 (/) Cc: Mark Rutland , Krzysztof Kozlowski , Linus Walleij , Andrzej Hajda , Thierry Reding , Lv Zheng , Alexander Holler , Alexandre Courbot , Russell King , Pawel Moll , Stephen Warren , Robert Moore , Grant Likely , Len Brown , Arnd Bergmann , Ian Campbell , Rob Herring , =?UTF-8?q?Terje=20Bergstr=C3=B6m?= , Tomeu Vizoso , Greg Kroah-Hartman , Dmitry Torokhov , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Mark Brown , Kumar Gala , Javier Martinez Canillas X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The purpose of this function is to allow other parts of the driver core to iterate over the currently registered classes. Signed-off-by: Tomeu Vizoso --- drivers/base/base.h | 2 ++ drivers/base/class.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index 29c985e..be81c88 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -149,3 +149,5 @@ extern int devtmpfs_init(void); #else static inline int devtmpfs_init(void) { return 0; } #endif + +extern void for_each_class(void (*fn)(struct class *, void *), void *data); diff --git a/drivers/base/class.c b/drivers/base/class.c index 6e81088..f4114a4 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -583,6 +583,22 @@ void class_compat_remove_link(struct class_compat *cls, struct device *dev, } EXPORT_SYMBOL_GPL(class_compat_remove_link); +void for_each_class(void (*fn)(struct class *, void *), void *data) +{ + struct subsys_private *cp; + struct kobject *k; + + if (!class_kset) + return; + + list_for_each_entry(k, &class_kset->list, entry) { + cp = to_subsys_private(k); + class_get(cp->class); + fn(cp->class, data); + class_put(cp->class); + } +} + int __init classes_init(void) { class_kset = kset_create_and_add("class", NULL, NULL);