linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: brcm80211: better feedback to user on ioctl errors
@ 2011-04-20  8:38 Roland Vossen
  2011-04-20 16:08 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Vossen @ 2011-04-20  8:38 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-wireless

Messages are now logged that provide the user with a clue on what went wrong.

Signed-off-by: Roland Vossen <rvossen@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/staging/brcm80211/brcmsmac/wlc_main.c |   44 ++++++++++++++++++++----
 1 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_main.c b/drivers/staging/brcm80211/brcmsmac/wlc_main.c
index 46bf93b..dba6195 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_main.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_main.c
@@ -4141,7 +4141,7 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
 	     void *params, int p_len, void *arg, int len,
 	     bool set, struct wlc_if *wlcif)
 {
-	int err = 0;
+	int err;
 	int val_size;
 	const bcm_iovar_t *vi = NULL;
 	u32 actionid;
@@ -4151,8 +4151,34 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
 	    !(IS_ALIGNED((unsigned long)(arg), (uint) sizeof(int)))) {
 		dev_err(wlc->dev, "wl%d: %s unaligned get ptr for %s\n",
 			 wlc->pub->unit, __func__, name);
-		err = ENOTSUPP;
-		goto exit;
+		return -ENOTSUPP;
+	}
+
+	if (name == NULL || len < 0) {
+		dev_err(wlc->dev, "wl%d: %s name/arg error len=%d\n",
+			wlc->pub->unit, __func__, len);
+		return -ENOTSUPP;
+	}
+
+	if (!set && !(arg && len)) {
+		dev_err(wlc->dev, "Get MUST have return space\n");
+		goto fail;
+	}
+
+	if (wlc->pub->hw_off && wlc->pub->up) {
+		dev_err(wlc->dev, "hw is off but adapter is up!\n");
+		goto fail;
+	}
+
+	if (set && (params || p_len)) {
+		dev_err(wlc->dev, "Set does NOT take qualifiers\n");
+		goto fail;
+	}
+
+	if (!set && len == sizeof(int) &&
+	    !IS_ALIGNED((unsigned long)(arg), (uint) sizeof(int))) {
+		dev_err(wlc->dev, "unaligned access on get\n");
+		goto fail;
 	}
 
 	/* find the given iovar name */
@@ -4164,10 +4190,8 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
 			break;
 	}
 	/* iovar name not found */
-	if (i >= WLC_MAXMODULES) {
-		err = -ENOTSUPP;
-		goto exit;
-	}
+	if (i >= WLC_MAXMODULES)
+		return -ENOTSUPP;
 
 	/* set up 'params' pointer in case this is a set command so that
 	 * the convenience int and bool code can be common to set and get
@@ -4192,8 +4216,12 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
 					name, params, p_len, arg, len, val_size,
 					wlcif);
 
- exit:
 	return err;
+
+fail:
+	dev_err(wlc->dev, "wl%d: %s(set=%d,%s) failed\n", wlc->pub->unit,
+		__func__, set, name);
+	return -ENOTSUPP;
 }
 
 int
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-20 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20  8:38 [PATCH] staging: brcm80211: better feedback to user on ioctl errors Roland Vossen
2011-04-20 16:08 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).