diff options
| author | Johannes Berg <johannes.berg@intel.com> | 2014-05-19 11:59:50 -0400 |
|---|---|---|
| committer | Johannes Berg <johannes.berg@intel.com> | 2014-05-19 12:06:50 -0400 |
| commit | 922bd80fc33b5b90eb34b1485ebcf3c7b2e61618 (patch) | |
| tree | 7f03c80775ba39c43d34f8038583db768b311029 | |
| parent | c1e5f4714d591cc0a5e986613fdefa61abe98ac2 (diff) | |
cfg80211: constify wowlan/coalesce mask/pattern pointers
This requires changing the nl80211 parsing code a bit to use
intermediate pointers for the allocation, but clarifies the
API towards the drivers.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
| -rw-r--r-- | drivers/net/wireless/ti/wlcore/main.c | 2 | ||||
| -rw-r--r-- | drivers/net/wireless/ti/wlcore/wlcore_i.h | 4 | ||||
| -rw-r--r-- | include/net/cfg80211.h | 2 | ||||
| -rw-r--r-- | net/wireless/nl80211.c | 39 |
4 files changed, 26 insertions, 21 deletions
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index 077eb5b9cd74..02c91d6db753 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c | |||
| @@ -1416,7 +1416,7 @@ void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter) | |||
| 1416 | 1416 | ||
| 1417 | int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, | 1417 | int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, |
| 1418 | u16 offset, u8 flags, | 1418 | u16 offset, u8 flags, |
| 1419 | u8 *pattern, u8 len) | 1419 | const u8 *pattern, u8 len) |
| 1420 | { | 1420 | { |
| 1421 | struct wl12xx_rx_filter_field *field; | 1421 | struct wl12xx_rx_filter_field *field; |
| 1422 | 1422 | ||
diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h index 756e890bc5ee..c2c34a84ff3d 100644 --- a/drivers/net/wireless/ti/wlcore/wlcore_i.h +++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h | |||
| @@ -512,8 +512,8 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif); | |||
| 512 | void wl12xx_queue_recovery_work(struct wl1271 *wl); | 512 | void wl12xx_queue_recovery_work(struct wl1271 *wl); |
| 513 | size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); | 513 | size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); |
| 514 | int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, | 514 | int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, |
| 515 | u16 offset, u8 flags, | 515 | u16 offset, u8 flags, |
| 516 | u8 *pattern, u8 len); | 516 | const u8 *pattern, u8 len); |
| 517 | void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter); | 517 | void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter); |
| 518 | struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void); | 518 | struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void); |
| 519 | int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter); | 519 | int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter); |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 3299d1b731ef..fe4fa287f788 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
| @@ -1827,7 +1827,7 @@ struct cfg80211_pmksa { | |||
| 1827 | * memory, free @mask only! | 1827 | * memory, free @mask only! |
| 1828 | */ | 1828 | */ |
| 1829 | struct cfg80211_pkt_pattern { | 1829 | struct cfg80211_pkt_pattern { |
| 1830 | u8 *mask, *pattern; | 1830 | const u8 *mask, *pattern; |
| 1831 | int pattern_len; | 1831 | int pattern_len; |
| 1832 | int pkt_offset; | 1832 | int pkt_offset; |
| 1833 | }; | 1833 | }; |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ca19b1520389..49adf58646e6 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
| @@ -8554,6 +8554,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
| 8554 | 8554 | ||
| 8555 | nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], | 8555 | nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], |
| 8556 | rem) { | 8556 | rem) { |
| 8557 | u8 *mask_pat; | ||
| 8558 | |||
| 8557 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), | 8559 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), |
| 8558 | nla_len(pat), NULL); | 8560 | nla_len(pat), NULL); |
| 8559 | err = -EINVAL; | 8561 | err = -EINVAL; |
| @@ -8577,19 +8579,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
| 8577 | goto error; | 8579 | goto error; |
| 8578 | new_triggers.patterns[i].pkt_offset = pkt_offset; | 8580 | new_triggers.patterns[i].pkt_offset = pkt_offset; |
| 8579 | 8581 | ||
| 8580 | new_triggers.patterns[i].mask = | 8582 | mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL); |
| 8581 | kmalloc(mask_len + pat_len, GFP_KERNEL); | 8583 | if (!mask_pat) { |
| 8582 | if (!new_triggers.patterns[i].mask) { | ||
| 8583 | err = -ENOMEM; | 8584 | err = -ENOMEM; |
| 8584 | goto error; | 8585 | goto error; |
| 8585 | } | 8586 | } |
| 8586 | new_triggers.patterns[i].pattern = | 8587 | new_triggers.patterns[i].mask = mask_pat; |
| 8587 | new_triggers.patterns[i].mask + mask_len; | 8588 | memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]), |
| 8588 | memcpy(new_triggers.patterns[i].mask, | ||
| 8589 | nla_data(pat_tb[NL80211_PKTPAT_MASK]), | ||
| 8590 | mask_len); | 8589 | mask_len); |
| 8590 | mask_pat += mask_len; | ||
| 8591 | new_triggers.patterns[i].pattern = mask_pat; | ||
| 8591 | new_triggers.patterns[i].pattern_len = pat_len; | 8592 | new_triggers.patterns[i].pattern_len = pat_len; |
| 8592 | memcpy(new_triggers.patterns[i].pattern, | 8593 | memcpy(mask_pat, |
| 8593 | nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), | 8594 | nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), |
| 8594 | pat_len); | 8595 | pat_len); |
| 8595 | i++; | 8596 | i++; |
| @@ -8781,6 +8782,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev, | |||
| 8781 | 8782 | ||
| 8782 | nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], | 8783 | nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], |
| 8783 | rem) { | 8784 | rem) { |
| 8785 | u8 *mask_pat; | ||
| 8786 | |||
| 8784 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), | 8787 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), |
| 8785 | nla_len(pat), NULL); | 8788 | nla_len(pat), NULL); |
| 8786 | if (!pat_tb[NL80211_PKTPAT_MASK] || | 8789 | if (!pat_tb[NL80211_PKTPAT_MASK] || |
| @@ -8802,17 +8805,19 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev, | |||
| 8802 | return -EINVAL; | 8805 | return -EINVAL; |
| 8803 | new_rule->patterns[i].pkt_offset = pkt_offset; | 8806 | new_rule->patterns[i].pkt_offset = pkt_offset; |
| 8804 | 8807 | ||
| 8805 | new_rule->patterns[i].mask = | 8808 | mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL); |
| 8806 | kmalloc(mask_len + pat_len, GFP_KERNEL); | 8809 | if (!mask_pat) |
| 8807 | if (!new_rule->patterns[i].mask) | ||
| 8808 | return -ENOMEM; | 8810 | return -ENOMEM; |
| 8809 | new_rule->patterns[i].pattern = | 8811 | |
| 8810 | new_rule->patterns[i].mask + mask_len; | 8812 | new_rule->patterns[i].mask = mask_pat; |
| 8811 | memcpy(new_rule->patterns[i].mask, | 8813 | memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]), |
| 8812 | nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len); | 8814 | mask_len); |
| 8815 | |||
| 8816 | mask_pat += mask_len; | ||
| 8817 | new_rule->patterns[i].pattern = mask_pat; | ||
| 8813 | new_rule->patterns[i].pattern_len = pat_len; | 8818 | new_rule->patterns[i].pattern_len = pat_len; |
| 8814 | memcpy(new_rule->patterns[i].pattern, | 8819 | memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), |
| 8815 | nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len); | 8820 | pat_len); |
| 8816 | i++; | 8821 | i++; |
| 8817 | } | 8822 | } |
| 8818 | 8823 | ||
