@@ -1054,60 +1054,51 @@ static int wilc_mac_close(struct net_device *ndev)
static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
{
- u8 *buff = NULL;
- s8 rssi;
- u32 size = 0;
- struct wilc_vif *vif;
s32 ret = 0;
- struct wilc *wilc;
-
- vif = netdev_priv(ndev);
- wilc = vif->wilc;
+ u8 *buff = NULL;
+ struct wilc_vif *vif = netdev_priv(ndev);
+ struct wilc *wilc = vif->wilc;
if (!wilc->initialized)
return 0;
switch (cmd) {
- case SIOCSIWPRIV:
- {
+ case SIOCSIWPRIV: {
struct iwreq *wrq = (struct iwreq *)req;
+ struct iw_point *data = &wrq->u.data;
+ u32 size = data->length;
- size = wrq->u.data.length;
+ if (size && data->pointer) {
+ s8 rssi;
- if (size && wrq->u.data.pointer) {
- buff = memdup_user(wrq->u.data.pointer,
- wrq->u.data.length);
+ buff = memdup_user(data->pointer, data->length);
if (IS_ERR(buff))
return PTR_ERR(buff);
- if (strncasecmp(buff, "RSSI", size) == 0) {
- ret = wilc_get_rssi(vif, &rssi);
- netdev_info(ndev, "RSSI :%d\n", rssi);
+ if (strncasecmp(buff, "RSSI", size) != 0)
+ break;
+
+ ret = wilc_get_rssi(vif, &rssi);
+ netdev_info(ndev, "RSSI: %d\n", rssi);
- rssi += 5;
+ rssi += 5;
- snprintf(buff, size, "rssi %d", rssi);
+ snprintf(buff, size, "rssi %d", rssi);
- if (copy_to_user(wrq->u.data.pointer, buff, size)) {
- netdev_err(ndev, "failed to copy\n");
- ret = -EFAULT;
- goto done;
- }
+ if (copy_to_user(data->pointer, buff, size)) {
+ netdev_err(ndev, "failed to copy\n");
+ ret = -EFAULT;
}
}
+ break;
}
- break;
default:
- {
netdev_info(ndev, "Command - %d - has been received\n", cmd);
ret = -EOPNOTSUPP;
- goto done;
- }
+ break;
}
-done:
-
kfree(buff);
return ret;