From patchwork Tue Sep 15 22:13:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 33674 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 0A43AB7B93 for ; Wed, 16 Sep 2009 08:14:18 +1000 (EST) Received: by ozlabs.org (Postfix) id E38DEDDDA0; Wed, 16 Sep 2009 08:14:17 +1000 (EST) 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 7032ADDD0C for ; Wed, 16 Sep 2009 08:14:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758728AbZIOWOF (ORCPT ); Tue, 15 Sep 2009 18:14:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758726AbZIOWOF (ORCPT ); Tue, 15 Sep 2009 18:14:05 -0400 Received: from ey-out-2122.google.com ([74.125.78.24]:4448 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752360AbZIOWOC (ORCPT ); Tue, 15 Sep 2009 18:14:02 -0400 Received: by ey-out-2122.google.com with SMTP id 25so882299eya.19 for ; Tue, 15 Sep 2009 15:14:03 -0700 (PDT) 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=Z0BSTN3/9Gd91N7jaLAj3JH1oGWKV279M2wjAMvhomQ=; b=Btrhrt5oidN89TK0Udshl1bpVAV9JMCsukeYys58MSGkFd5b5OPPAvDLhJFhifsFxc hl+kiXIOQJEWEOqn8Yq+RseAE8zi5XFLi2w0NWVKMEazETgMzVKlSRjF8GywKj5eFcnJ ljK+HLstPzUPcn9jCuojfEFkxr4oNyi+M041c= 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=JE9IsllE8xz5fFhFZkCNU9QdGGp+01WLtA25Opl+PIbGjJYLz1iX6Yu4Xnj/xhwo6j ecaHsY5C1uN6cuaqOk/RT9AzdcH7/v3I+CmBMJsQgRL5543JomZCOx7m5Bv/TQ0fwMN5 piL/dn7ABcHK0CQbCXNmRGh1ZGBn9inaY3wm0= Received: by 10.211.154.18 with SMTP id g18mr9196860ebo.70.1253052842985; Tue, 15 Sep 2009 15:14:02 -0700 (PDT) Received: from localhost.localdomain (ppp91-122-8-155.pppoe.avangarddsl.ru [91.122.8.155]) by mx.google.com with ESMTPS id 7sm381518eyb.37.2009.09.15.15.14.00 (version=SSLv3 cipher=RC4-MD5); Tue, 15 Sep 2009 15:14:02 -0700 (PDT) From: Dmitry Eremin-Solenikov To: "David S. Miller" Cc: linux-zigbee-devel@lists.sourceforge.net, Sergey Lapin , netdev@vger.kernel.org Subject: [PATCH 4/7] ieee802154: add wpan-phy iteration functions Date: Wed, 16 Sep 2009 02:13:02 +0400 Message-Id: <1253052785-26190-5-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1253052785-26190-4-git-send-email-dbaryshkov@gmail.com> References: <1253052785-26190-1-git-send-email-dbaryshkov@gmail.com> <1253052785-26190-2-git-send-email-dbaryshkov@gmail.com> <1253052785-26190-3-git-send-email-dbaryshkov@gmail.com> <1253052785-26190-4-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;