From patchwork Fri Nov 6 12:39:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 37852 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 5648DB6F2B for ; Fri, 6 Nov 2009 23:42:24 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759113AbZKFMlC (ORCPT ); Fri, 6 Nov 2009 07:41:02 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758771AbZKFMlB (ORCPT ); Fri, 6 Nov 2009 07:41:01 -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 S1758210AbZKFMk7 (ORCPT ); Fri, 6 Nov 2009 07:40:59 -0500 Received: by ey-out-2122.google.com with SMTP id 25so248343eya.19 for ; Fri, 06 Nov 2009 04:41:05 -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=mgohQv51ZAekZYj1KuTnW71Z0Ez5Myg4mbhB0f8bES4=; b=wfZ6vWS60kvYTlVRoAjQlnTJMRkoF/Wun7VdS9V41/XOq0crD5/pUR0KedKA8nqa+v ON0t6e5v1oon9mQ8gCHmh6j72HGbHk+c26Z75mVy6xWnK2vVmKI8p+9h70Sd7gnGHpRE PHXQG4ufH515QWDDc0z23mb2ZcrRCcBMU/IAs= 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=ZsAcYKHw0U+O5aJyMGPxmvnNJB+mJKxtzWlsFdgwUVGtEmVGiym9K73XdjegsA2iEt duhLq+ApyqiF6RTwNGJ0m3PebagWYMi0S21yvG5dy2rPHCXYtc01HCsXFXjaafaQ7Qew n22haffmbL4xxqFRplcJ9xpMk0lWcY8RicxLE= Received: by 10.213.110.14 with SMTP id l14mr3768749ebp.58.1257511264782; Fri, 06 Nov 2009 04:41:04 -0800 (PST) Received: from localhost.localdomain ([91.213.169.4]) by mx.google.com with ESMTPS id 28sm345811eyg.30.2009.11.06.04.41.03 (version=SSLv3 cipher=RC4-MD5); Fri, 06 Nov 2009 04:41:04 -0800 (PST) From: Dmitry Eremin-Solenikov To: "David S. Miller" Cc: netdev@vger.kernel.org, Sergey Lapin Subject: [PATCH 13/17] ieee802154: add an mlme_ops call to retrieve PHY object Date: Fri, 6 Nov 2009 15:39:37 +0300 Message-Id: <1257511181-19403-14-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 ops->get_phy should increment reference to wpan-phy. As we return the external structure, we should do refcounting correctly. Signed-off-by: Dmitry Eremin-Solenikov --- include/net/ieee802154_netdev.h | 6 ++++++ include/net/wpan-phy.h | 2 ++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h index d23fb5a..5743055 100644 --- a/include/net/ieee802154_netdev.h +++ b/include/net/ieee802154_netdev.h @@ -74,8 +74,12 @@ static inline int mac_cb_type(struct sk_buff *skb) #define IEEE802154_MAC_SCAN_PASSIVE 2 #define IEEE802154_MAC_SCAN_ORPHAN 3 +struct wpan_phy; /* * This should be located at net_device->ml_priv + * + * get_phy should increment the reference counting on returned phy. + * Use wpan_wpy_put to put that reference. */ struct ieee802154_mlme_ops { int (*assoc_req)(struct net_device *dev, @@ -94,6 +98,8 @@ struct ieee802154_mlme_ops { int (*scan_req)(struct net_device *dev, u8 type, u32 channels, u8 page, u8 duration); + struct wpan_phy *(*get_phy)(const struct net_device *dev); + /* * FIXME: these should become the part of PIB/MIB interface. * However we still don't have IB interface of any kind diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h index f63537c..a65e985 100644 --- a/include/net/wpan-phy.h +++ b/include/net/wpan-phy.h @@ -44,6 +44,8 @@ struct wpan_phy { char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); }; +#define to_phy(_dev) container_of(_dev, struct wpan_phy, dev) + struct wpan_phy *wpan_phy_alloc(size_t priv_size); static inline void wpan_phy_set_dev(struct wpan_phy *phy, struct device *dev) {