^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file implement the Wireless Extensions priv API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * (As all part of the Linux kernel, this file is GPL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/wireless.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <net/iw_handler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <net/wext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int iw_handler_get_private(struct net_device * dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct iw_request_info * info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) union iwreq_data * wrqu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) char * extra)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* Check if the driver has something to export */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) if ((dev->wireless_handlers->num_private_args == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) (dev->wireless_handlers->private_args == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* Check if there is enough buffer up there */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (wrqu->data.length < dev->wireless_handlers->num_private_args) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /* User space can't know in advance how large the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * needs to be. Give it a hint, so that we can support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * any size buffer we want somewhat efficiently... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) wrqu->data.length = dev->wireless_handlers->num_private_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return -E2BIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* Set the number of available ioctls. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) wrqu->data.length = dev->wireless_handlers->num_private_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* Copy structure to the user buffer. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) memcpy(extra, dev->wireless_handlers->private_args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) sizeof(struct iw_priv_args) * wrqu->data.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* Size (in bytes) of the various private data types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static const char iw_priv_type_size[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 0, /* IW_PRIV_TYPE_NONE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 1, /* IW_PRIV_TYPE_BYTE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 1, /* IW_PRIV_TYPE_CHAR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 0, /* Not defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) sizeof(__u32), /* IW_PRIV_TYPE_INT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 0, /* Not defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static int get_priv_size(__u16 args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int num = args & IW_PRIV_SIZE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int type = (args & IW_PRIV_TYPE_MASK) >> 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return num * iw_priv_type_size[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static int adjust_priv_size(__u16 args, struct iw_point *iwp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int num = iwp->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int max = args & IW_PRIV_SIZE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int type = (args & IW_PRIV_TYPE_MASK) >> 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* Make sure the driver doesn't goof up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (max < num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) num = max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return num * iw_priv_type_size[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * Wrapper to call a private Wireless Extension handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * We do various checks and also take care of moving data between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * user space and kernel space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * It's not as nice and slimline as the standard wrapper. The cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * is struct iw_priv_args, which was not really designed for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * job we are going here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * IMPORTANT : This function prevent to set and get data on the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * IOCTL and enforce the SET/GET convention. Not doing it would be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * far too hairy...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * If you need to set and get data at the same time, please don't use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * a iw_handler but process it in your ioctl handler (i.e. use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * old driver API).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static int get_priv_descr_and_size(struct net_device *dev, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) const struct iw_priv_args **descrp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) const struct iw_priv_args *descr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) int i, extra_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) descr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) for (i = 0; i < dev->wireless_handlers->num_private_args; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (cmd == dev->wireless_handlers->private_args[i].cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) descr = &dev->wireless_handlers->private_args[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) extra_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) if (descr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (IW_IS_SET(cmd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int offset = 0; /* For sub-ioctls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /* Check for sub-ioctl handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (descr->name[0] == '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* Reserve one int for sub-ioctl index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) offset = sizeof(__u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /* Size of set arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extra_size = get_priv_size(descr->set_args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /* Does it fits in iwr ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if ((descr->set_args & IW_PRIV_SIZE_FIXED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ((extra_size + offset) <= IFNAMSIZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) extra_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /* Size of get arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) extra_size = get_priv_size(descr->get_args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* Does it fits in iwr ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if ((descr->get_args & IW_PRIV_SIZE_FIXED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) (extra_size <= IFNAMSIZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) extra_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) *descrp = descr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return extra_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static int ioctl_private_iw_point(struct iw_point *iwp, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) const struct iw_priv_args *descr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) iw_handler handler, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct iw_request_info *info, int extra_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) char *extra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* Check what user space is giving us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (IW_IS_SET(cmd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (!iwp->pointer && iwp->length != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (iwp->length > (descr->set_args & IW_PRIV_SIZE_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return -E2BIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) } else if (!iwp->pointer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) extra = kzalloc(extra_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (!extra)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* If it is a SET, get all the extra data in here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (IW_IS_SET(cmd) && (iwp->length != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (copy_from_user(extra, iwp->pointer, extra_size)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) err = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* Call the handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) err = handler(dev, info, (union iwreq_data *) iwp, extra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* If we have something to return to the user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (!err && IW_IS_GET(cmd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /* Adjust for the actual length if it's variable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * avoid leaking kernel bits outside.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (!(descr->get_args & IW_PRIV_SIZE_FIXED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) extra_size = adjust_priv_size(descr->get_args, iwp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (copy_to_user(iwp->pointer, extra, extra_size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) err = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) kfree(extra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int ioctl_private_call(struct net_device *dev, struct iwreq *iwr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) unsigned int cmd, struct iw_request_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) iw_handler handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) int extra_size = 0, ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) const struct iw_priv_args *descr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) extra_size = get_priv_descr_and_size(dev, cmd, &descr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /* Check if we have a pointer to user space data or not. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (extra_size == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /* No extra arguments. Trivial to handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) ret = handler(dev, info, &(iwr->u), (char *) &(iwr->u));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ret = ioctl_private_iw_point(&iwr->u.data, cmd, descr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) handler, dev, info, extra_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /* Call commit handler if needed and defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (ret == -EIWCOMMIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ret = call_commit_handler(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) int compat_private_call(struct net_device *dev, struct iwreq *iwr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) unsigned int cmd, struct iw_request_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) iw_handler handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) const struct iw_priv_args *descr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int ret, extra_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) extra_size = get_priv_descr_and_size(dev, cmd, &descr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* Check if we have a pointer to user space data or not. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (extra_size == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /* No extra arguments. Trivial to handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ret = handler(dev, info, &(iwr->u), (char *) &(iwr->u));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct compat_iw_point *iwp_compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct iw_point iwp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) iwp_compat = (struct compat_iw_point *) &iwr->u.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) iwp.pointer = compat_ptr(iwp_compat->pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) iwp.length = iwp_compat->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) iwp.flags = iwp_compat->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ret = ioctl_private_iw_point(&iwp, cmd, descr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) handler, dev, info, extra_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) iwp_compat->pointer = ptr_to_compat(iwp.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) iwp_compat->length = iwp.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) iwp_compat->flags = iwp.flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /* Call commit handler if needed and defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (ret == -EIWCOMMIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ret = call_commit_handler(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) #endif