From: Alexander Aring <alex.aring@gmail.com>
To: Varka Bhadram <varkabhadram@gmail.com>
Cc: linux-wpan@vger.kernel.org
Subject: Re: [PATCH v3 bluetooth-next] ieee802154: add set transmit power support
Date: Tue, 26 May 2015 23:14:57 +0200 [thread overview]
Message-ID: <20150526211453.GC2954@omega> (raw)
In-Reply-To: <1432655224-7663-1-git-send-email-varkab@cdac.in>
Hi,
On Tue, May 26, 2015 at 09:17:04PM +0530, Varka Bhadram wrote:
> This patch adds transmission power setting support for IEEE-802.15.4
> devices via nl802154.
>
> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> ---
> include/net/cfg802154.h | 1 +
> net/ieee802154/nl802154.c | 29 +++++++++++++++++++++++++++++
> net/ieee802154/rdev-ops.h | 12 ++++++++++++
> net/ieee802154/trace.h | 15 +++++++++++++++
> net/mac802154/cfg.c | 19 +++++++++++++++++++
> 5 files changed, 76 insertions(+)
>
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index 4de59aa..2e3bb01 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -44,6 +44,7 @@ struct cfg802154_ops {
> int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel);
> int (*set_cca_mode)(struct wpan_phy *wpan_phy,
> const struct wpan_phy_cca *cca);
> + int (*set_tx_power)(struct wpan_phy *wpan_phy, s32 power);
> int (*set_pan_id)(struct wpan_phy *wpan_phy,
> struct wpan_dev *wpan_dev, __le16 pan_id);
> int (*set_short_addr)(struct wpan_phy *wpan_phy,
> diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
> index 54f4959..cfdb6e0 100644
> --- a/net/ieee802154/nl802154.c
> +++ b/net/ieee802154/nl802154.c
> @@ -783,6 +783,27 @@ static int nl802154_set_cca_mode(struct sk_buff *skb, struct genl_info *info)
> return rdev_set_cca_mode(rdev, &cca);
> }
>
> +static int nl802154_set_tx_power(struct sk_buff *skb, struct genl_info *info)
> +{
> + struct cfg802154_registered_device *rdev = info->user_ptr[0];
> + s32 power;
> + int i;
> +
> + if (rdev->wpan_phy.flags & WPAN_PHY_FLAG_TXPOWER)
> + return -EOPNOTSUPP;
if (!(rdev->wpan_phy.flags & WPAN_PHY_FLAG_TXPOWER))
return -EOPNOTSUPP;
I did it also wrong in the cca mode setting. I recently send a patch for
fixing this.
> +
> + if (!info->attrs[NL802154_ATTR_TX_POWER])
> + return -EINVAL;
> +
> + power = nla_get_s32(info->attrs[NL802154_ATTR_TX_POWER]);
> +
> + for (i = 0; i < rdev->wpan_phy.supported.tx_powers_size; i++)
> + if (power == rdev->wpan_phy.supported.tx_powers[i])
> + return rdev_set_tx_power(rdev, power);
please add brackets for the for loop.
Otherwise it's looking good. Do you want also change the stuff for
wpan-tools? I have the following solution currently for a fast testing
which works in my first tests:
diff --git a/src/phy.c b/src/phy.c
index ee0e7ad..285801c 100644
--- a/src/phy.c
+++ b/src/phy.c
@@ -53,14 +53,14 @@ static int handle_tx_power_set(struct nl802154_state *state,
int argc, char **argv,
enum id_input id)
{
- long dbm;
+ float dbm;
char *end;
if (argc < 1)
return 1;
/* TX_POWER */
- dbm = strtol(argv[0], &end, 10);
+ dbm = strtof(argv[0], &end);
if (*end != '\0')
return 1;
- Alex
next prev parent reply other threads:[~2015-05-26 21:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-26 15:47 [PATCH v3 bluetooth-next] ieee802154: add set transmit power support Varka Bhadram
2015-05-26 21:14 ` Alexander Aring [this message]
2015-05-27 3:46 ` Varka Bhadram
2015-05-27 8:00 ` Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150526211453.GC2954@omega \
--to=alex.aring@gmail.com \
--cc=linux-wpan@vger.kernel.org \
--cc=varkabhadram@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox