From patchwork Fri Nov 6 12:39:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 37841 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id BF11AB70B3 for ; Fri, 6 Nov 2009 23:40:55 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757965AbZKFMkl (ORCPT ); Fri, 6 Nov 2009 07:40:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757951AbZKFMkl (ORCPT ); Fri, 6 Nov 2009 07:40:41 -0500 Received: from ey-out-2122.google.com ([74.125.78.25]:64606 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757650AbZKFMkj (ORCPT ); Fri, 6 Nov 2009 07:40:39 -0500 Received: by ey-out-2122.google.com with SMTP id 25so248343eya.19 for ; Fri, 06 Nov 2009 04:40:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=ni6EKaytfgh6oLLcb9yK6nh7cPRu0HAT1jMIxXVi+QE=; b=dURe8HzmkHxIvcMXYquSvFdMns+wA6F6xnTyLW7Bcvrj6c6yOhw+GpzXXa+sTRUs+B GT2FIOEZtcFBTNoyB/3p2Gbty3kJizrshwRRnhHHBL7EE29wZrSJRoEtTfnLDMXTG79r n1p9aruRkF7IpW8JHuNDhHYj9oDZDYYty4DU4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=u3Q3OEM81kOjAv/5JkCb9MYtEd7bJNJSoYQLvdrj+fynoacQE0kODZYlAxxZoiQbGj LsWn/MQH29V6tGsfr41WZaxx2h6Fv0uW+LMPPJihYMC3VgrxBjR57tlmW//EpE3oOIbv mDimLqxPzN0mTyDiwzEbAOLb3q1At+7AqWYok= Received: by 10.213.1.28 with SMTP id 28mr769708ebd.70.1257511243749; Fri, 06 Nov 2009 04:40:43 -0800 (PST) Received: from localhost.localdomain ([91.213.169.4]) by mx.google.com with ESMTPS id 28sm345811eyg.30.2009.11.06.04.40.42 (version=SSLv3 cipher=RC4-MD5); Fri, 06 Nov 2009 04:40:42 -0800 (PST) From: Dmitry Eremin-Solenikov To: "David S. Miller" Cc: netdev@vger.kernel.org, Sergey Lapin Subject: [PATCH 02/17] wpan-phy: add wpan-phy iteration functions Date: Fri, 6 Nov 2009 15:39:26 +0300 Message-Id: <1257511181-19403-3-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.6.5 In-Reply-To: <1257511181-19403-1-git-send-email-dbaryshkov@gmail.com> References: <1257511181-19403-1-git-send-email-dbaryshkov@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add API to iterate over the wpan-phy instances. Signed-off-by: Dmitry Eremin-Solenikov --- include/net/wpan-phy.h | 2 ++ net/ieee802154/wpan-class.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h index 5e803a0..3367dd9 100644 --- a/include/net/wpan-phy.h +++ b/include/net/wpan-phy.h @@ -48,6 +48,8 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size); int wpan_phy_register(struct device *parent, struct wpan_phy *phy); void wpan_phy_unregister(struct wpan_phy *phy); void wpan_phy_free(struct wpan_phy *phy); +/* Same semantics as for class_for_each_device */ +int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data), void *data); static inline void *wpan_phy_priv(struct wpan_phy *phy) { diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c index f306604..0cec138 100644 --- a/net/ieee802154/wpan-class.c +++ b/net/ieee802154/wpan-class.c @@ -91,6 +91,31 @@ struct wpan_phy *wpan_phy_find(const char *str) } EXPORT_SYMBOL(wpan_phy_find); +struct wpan_phy_iter_data { + int (*fn)(struct wpan_phy *phy, void *data); + void *data; +}; + +static int wpan_phy_iter(struct device *dev, void *_data) +{ + struct wpan_phy_iter_data *wpid = _data; + struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); + return wpid->fn(phy, wpid->data); +} + +int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data), + void *data) +{ + struct wpan_phy_iter_data wpid = { + .fn = fn, + .data = data, + }; + + return class_for_each_device(&wpan_phy_class, NULL, + &wpid, wpan_phy_iter); +} +EXPORT_SYMBOL(wpan_phy_for_each); + static int wpan_phy_idx_valid(int idx) { return idx >= 0;