From patchwork Sun Nov 25 18:13:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 1799531 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8D88F3FC23 for ; Sun, 25 Nov 2012 18:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753061Ab2KYSRI (ORCPT ); Sun, 25 Nov 2012 13:17:08 -0500 Received: from mms3.broadcom.com ([216.31.210.19]:1729 "EHLO mms3.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046Ab2KYSRH (ORCPT ); Sun, 25 Nov 2012 13:17:07 -0500 Received: from [10.9.200.133] by mms3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Sun, 25 Nov 2012 10:12:44 -0800 X-Server-Uuid: B86B6450-0931-4310-942E-F00ED04CA7AF Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Sun, 25 Nov 2012 10:13:41 -0800 Received: from mail-sj1-12.sj.broadcom.com (mail-sj1-12.sj.broadcom.com [10.17.16.106]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 980E540FE8; Sun, 25 Nov 2012 10:14:03 -0800 (PST) Received: from linux-e6410-1 (svpn-10-240-253-25.broadcom.com [10.240.253.25]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id C5046207CE; Sun, 25 Nov 2012 10:14:01 -0800 (PST) Received: from arend by linux-e6410-1 with local (Exim 4.80) ( envelope-from ) id 1TcgiM-00030Q-Te; Sun, 25 Nov 2012 19:13:59 +0100 From: "Arend van Spriel" To: "Johannes Berg" cc: "Linux Wireless List" , "Arend van Spriel" Subject: [PATCH] cfg80211: change function signature of cfg80211_get_p2p_attr() Date: Sun, 25 Nov 2012 19:13:28 +0100 Message-ID: <1353867208-11429-1-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-WSS-ID: 7CAC80163P89253265-08-01 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The function cfg80211_get_p2p_attr() can fail and returns a negative error code. However, the return type is unsigned int. The largest positive number is determined by desired_len variable in the function, which is u16. So changing the return type to int to allow easy error checking. Also change the type for the attribute to enum for improved type checking. Signed-off-by: Arend van Spriel --- Hi Johannes, I decided to make use of cfg80211_get_p2p_attr() in brcmfmac and would like this minor change to it. The only other "driver" using it is mac80211 and it seems it will not mind this change ;-) Gr. AvS --- include/net/cfg80211.h | 5 +++-- net/wireless/util.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8a1aec5..45eb8ec 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -3652,8 +3652,9 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev); * the data is malformed or the attribute can't be found (respectively), * or the length of the found attribute (which can be zero). */ -unsigned int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, - u8 attr, u8 *buf, unsigned int bufsize); +int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, + enum ieee80211_p2p_attr_id attr_id, + u8 *buf, unsigned int bufsize); /* Logging, debugging and troubleshooting/diagnostic helpers. */ diff --git a/net/wireless/util.c b/net/wireless/util.c index b99f01c..2344077 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -980,9 +980,11 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate) } EXPORT_SYMBOL(cfg80211_calculate_bitrate); -unsigned int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, - u8 attr, u8 *buf, unsigned int bufsize) +int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, + enum ieee80211_p2p_attr_id attr_id, + u8 *buf, unsigned int bufsize) { + u8 attr = (u8)attr_id; u8 *out = buf; u16 attr_remaining = 0; bool desired_attr = false;