* [PATCH 1/1] ocb: Use common freqchan helper for setting the operating channel
@ 2017-10-27 21:43 Peter Große
2017-12-11 11:17 ` Johannes Berg
0 siblings, 1 reply; 4+ messages in thread
From: Peter Große @ 2017-10-27 21:43 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
Simplify code by using the helper which has been introduced earlier.
Signed-off-by: Peter Große <pegro@friiks.de>
---
ocb.c | 50 ++++++++------------------------------------------
1 file changed, 8 insertions(+), 42 deletions(-)
diff --git a/ocb.c b/ocb.c
index bcf0474..dfdaf59 100644
--- a/ocb.c
+++ b/ocb.c
@@ -10,56 +10,22 @@ static int join_ocb(struct nl80211_state *state,
struct nl_msg *msg, int argc, char **argv,
enum id_input id)
{
- unsigned long freq;
- char *end;
- unsigned int i;
- const struct chanmode *chanmode_selected = NULL;
- static const struct chanmode chanmode[] = {
- { .name = "5MHz",
- .width = NL80211_CHAN_WIDTH_5,
- .freq1_diff = 0,
- .chantype = -1 },
- { .name = "10MHz",
- .width = NL80211_CHAN_WIDTH_10,
- .freq1_diff = 0,
- .chantype = -1 },
- };
+ struct chandef chandef;
+ int err, parsed;
if (argc < 2)
return 1;
- /* freq */
- freq = strtoul(argv[0], &end, 10);
- if (*end != '\0')
- return 1;
-
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
- argv++;
- argc--;
+ err = parse_freqchan(&chandef, false, argc, argv, &parsed);
- /* channel width */
- for (i = 0; i < ARRAY_SIZE(chanmode); i++) {
- if (strcasecmp(chanmode[i].name, argv[0]) == 0) {
- chanmode_selected = &chanmode[i];
- break;
- }
- }
- if (chanmode_selected) {
- NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
- chanmode_selected->width);
- NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
- get_cf1(chanmode_selected, freq));
+ if (err)
+ return err;
- argv++;
- argc--;
- } else {
- return 1;
- }
+ put_chandef(msg, &chandef);
+ if (err)
+ return err;
return 0;
-
-nla_put_failure:
- return -ENOBUFS;
}
COMMAND(ocb, join, "<freq in MHz> <5MHz|10MHz>",
NL80211_CMD_JOIN_OCB, 0, CIB_NETDEV, join_ocb,
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] ocb: Use common freqchan helper for setting the operating channel
2017-10-27 21:43 [PATCH 1/1] ocb: Use common freqchan helper for setting the operating channel Peter Große
@ 2017-12-11 11:17 ` Johannes Berg
2017-12-13 12:58 ` [PATCH] " Peter Große
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2017-12-11 11:17 UTC (permalink / raw)
To: Peter Große; +Cc: linux-wireless
On Fri, 2017-10-27 at 23:43 +0200, Peter Große wrote:
> Simplify code by using the helper which has been introduced earlier.
>
> Signed-off-by: Peter Große <pegro@friiks.de>
> ---
> ocb.c | 50 ++++++++------------------------------------------
No objection to the patch, but you need to generate the diff against a
full tree (must show a/net/wireless/ocb.c in the diff header), and make
it actually applicable. I'm guessing whitespace got mangled, but this
patch doesn't apply as is.
johannes
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ocb: Use common freqchan helper for setting the operating channel
2017-12-11 11:17 ` Johannes Berg
@ 2017-12-13 12:58 ` Peter Große
2017-12-13 13:00 ` Johannes Berg
0 siblings, 1 reply; 4+ messages in thread
From: Peter Große @ 2017-12-13 12:58 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
Simplify code by using the helper which has been introduced earlier.
Signed-off-by: Peter Große <pegro@friiks.de>
---
Mh, the patch is against the full tree of iw, not the kernel, so there is no
net/wireless/ path.
But yeah, whitespace got mangled.
Regards
Peter
ocb.c | 50 ++++++++------------------------------------------
1 file changed, 8 insertions(+), 42 deletions(-)
diff --git a/ocb.c b/ocb.c
index bcf0474..dfdaf59 100644
--- a/ocb.c
+++ b/ocb.c
@@ -10,56 +10,22 @@ static int join_ocb(struct nl80211_state *state,
struct nl_msg *msg, int argc, char **argv,
enum id_input id)
{
- unsigned long freq;
- char *end;
- unsigned int i;
- const struct chanmode *chanmode_selected = NULL;
- static const struct chanmode chanmode[] = {
- { .name = "5MHz",
- .width = NL80211_CHAN_WIDTH_5,
- .freq1_diff = 0,
- .chantype = -1 },
- { .name = "10MHz",
- .width = NL80211_CHAN_WIDTH_10,
- .freq1_diff = 0,
- .chantype = -1 },
- };
+ struct chandef chandef;
+ int err, parsed;
if (argc < 2)
return 1;
- /* freq */
- freq = strtoul(argv[0], &end, 10);
- if (*end != '\0')
- return 1;
-
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
- argv++;
- argc--;
+ err = parse_freqchan(&chandef, false, argc, argv, &parsed);
- /* channel width */
- for (i = 0; i < ARRAY_SIZE(chanmode); i++) {
- if (strcasecmp(chanmode[i].name, argv[0]) == 0) {
- chanmode_selected = &chanmode[i];
- break;
- }
- }
- if (chanmode_selected) {
- NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
- chanmode_selected->width);
- NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
- get_cf1(chanmode_selected, freq));
+ if (err)
+ return err;
- argv++;
- argc--;
- } else {
- return 1;
- }
+ put_chandef(msg, &chandef);
+ if (err)
+ return err;
return 0;
-
-nla_put_failure:
- return -ENOBUFS;
}
COMMAND(ocb, join, "<freq in MHz> <5MHz|10MHz>",
NL80211_CMD_JOIN_OCB, 0, CIB_NETDEV, join_ocb,
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ocb: Use common freqchan helper for setting the operating channel
2017-12-13 12:58 ` [PATCH] " Peter Große
@ 2017-12-13 13:00 ` Johannes Berg
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2017-12-13 13:00 UTC (permalink / raw)
To: Peter Große; +Cc: linux-wireless
On Wed, 2017-12-13 at 13:58 +0100, Peter Große wrote:
> Simplify code by using the helper which has been introduced earlier.
>
> Signed-off-by: Peter Große <pegro@friiks.de>
> ---
>
> Mh, the patch is against the full tree of iw, not the kernel, so there is no
> net/wireless/ path.
D'oh! I guess you should've mentioned "iw" somewhere - I actually tried
to apply it to the kernel tree :)
johannes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-13 13:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 21:43 [PATCH 1/1] ocb: Use common freqchan helper for setting the operating channel Peter Große
2017-12-11 11:17 ` Johannes Berg
2017-12-13 12:58 ` [PATCH] " Peter Große
2017-12-13 13:00 ` Johannes Berg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.