From patchwork Tue Jun 26 09:24:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alex.bluesman.smirnov@gmail.com X-Patchwork-Id: 167356 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.180.67]) by ozlabs.org (Postfix) with ESMTP id AC811B6FA4 for ; Tue, 26 Jun 2012 19:29:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755748Ab2FZJ33 (ORCPT ); Tue, 26 Jun 2012 05:29:29 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:47395 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753040Ab2FZJ3H (ORCPT ); Tue, 26 Jun 2012 05:29:07 -0400 Received: by wibhq12 with SMTP id hq12so3484510wib.1 for ; Tue, 26 Jun 2012 02:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=wYLCcSiBxZJLMJtwuBXER20pMiKGqDFyi3r0+6bb9Vo=; b=zL+WPoefdGmywpcHypG5WQesz5CaQaFNxQ+dRSCKm7dtDPjWeZiKuW1ZQtntUV4LLL vFt9pjYpRMTN3mLWFvYtUKoUpDXFbogz8CSt+xsYRn/dDLl9uN5Di/D5tfYQ6wVQyKvF tZnw5PVz+qIqxAHAPPT4baZVcsouw1GhukjPbasWFKuY6aGsDq8923HYD8VSlZS8B4kt XoD1iue71UFPyPRR+oMA/V+lPxhsKG16JZhgyl/H07Q0KkvbREMD/hJBuEsvoYBOA4Vn AMQhpvwc22VGXgtC+uIEyOypNjkrwR3n1i6UY7bP2U4k2IZ0HxKQVy6gGc+wG6sC6pjX rWPw== Received: by 10.216.141.213 with SMTP id g63mr3330593wej.34.1340702946236; Tue, 26 Jun 2012 02:29:06 -0700 (PDT) Received: from localhost.localdomain ([91.213.169.4]) by mx.google.com with ESMTPS id z8sm6132508wiy.1.2012.06.26.02.29.04 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 02:29:05 -0700 (PDT) From: Alexander Smirnov To: davem@davemloft.net Cc: netdev@vger.kernel.org, dbaryshkov@gmail.com, Alexander Smirnov Subject: [PATCH v2 net-next 4/7] mac802154: page and channel setter Date: Tue, 26 Jun 2012 13:24:51 +0400 Message-Id: <1340702694-24706-5-git-send-email-alex.bluesman.smirnov@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1340702694-24706-1-git-send-email-alex.bluesman.smirnov@gmail.com> References: <1340702694-24706-1-git-send-email-alex.bluesman.smirnov@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A new method to set page and channel values for a transceiver was added to the MIB. Signed-off-by: Alexander Smirnov --- net/mac802154/mac802154.h | 1 + net/mac802154/mib.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h index 9951072..6967864 100644 --- a/net/mac802154/mac802154.h +++ b/net/mac802154/mac802154.h @@ -112,5 +112,6 @@ void mac802154_dev_set_short_addr(struct net_device *dev, u16 val); void mac802154_dev_set_ieee_addr(struct net_device *dev); u16 mac802154_dev_get_pan_id(const struct net_device *dev); void mac802154_dev_set_pan_id(struct net_device *dev, u16 val); +void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); #endif /* MAC802154_H */ diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c index d74503b..380829d 100644 --- a/net/mac802154/mib.c +++ b/net/mac802154/mib.c @@ -28,6 +28,11 @@ #include "mac802154.h" +struct phy_chan_notify_work { + struct work_struct work; + struct net_device *dev; +}; + struct hw_addr_filt_notify_work { struct work_struct work; struct net_device *dev; @@ -139,3 +144,42 @@ void mac802154_dev_set_pan_id(struct net_device *dev, u16 val) set_hw_addr_filt(dev, IEEE802515_AFILT_PANID_CHANGED); } } + +static void phy_chan_notify(struct work_struct *work) +{ + struct phy_chan_notify_work *nw = container_of(work, + struct phy_chan_notify_work, work); + struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev); + struct mac802154_sub_if_data *priv = netdev_priv(nw->dev); + int res; + + res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); + if (res) + pr_debug("set_channel failed\n"); + + kfree(nw); +} + +void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) +{ + struct mac802154_sub_if_data *priv = netdev_priv(dev); + struct phy_chan_notify_work *work; + + BUG_ON(dev->type != ARPHRD_IEEE802154); + + spin_lock_bh(&priv->mib_lock); + priv->page = page; + priv->chan = chan; + spin_unlock_bh(&priv->mib_lock); + + if (priv->hw->phy->current_channel != priv->chan || + priv->hw->phy->current_page != priv->page) { + work = kzalloc(sizeof(*work), GFP_ATOMIC); + if (!work) + return; + + INIT_WORK(&work->work, phy_chan_notify); + work->dev = dev; + queue_work(priv->hw->dev_workqueue, &work->work); + } +}