Commit 3e97e64e authored by Philippe Gerum's avatar Philippe Gerum
Browse files

net/socket: align rtdev do_ioctl handler on the regular ndo_do_ioctl

Align on the signature of the regular ndo_do_ioctl() handler for
interface-directed ioctl requests, since an ifr block must have been
provided by the caller to determine the device to hand over the
request to anyway.
parent 78eaafcd
......@@ -519,7 +519,7 @@ static int rtl8139_close (struct rtnet_device *rtdev);
static int rtl8139_interrupt (rtdm_irq_t *irq_handle);
static int rtl8139_start_xmit (struct rtskb *skb, struct rtnet_device *rtdev);
static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request, void *cmd);
static int rtl8139_ioctl(struct rtnet_device *, struct ifreq *rq, int cmd);
static struct net_device_stats *rtl8139_get_stats(struct rtnet_device*rtdev);
static void rtl8139_init_ring (struct rtnet_device *rtdev);
......@@ -1297,15 +1297,14 @@ static int rtl8139_start_xmit (struct rtskb *skb, struct rtnet_device *rtdev)
return 0;
}
static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request, void *arg)
static int rtl8139_ioctl(struct rtnet_device *rtdev, struct ifreq *ifr, int cmd)
{
struct rtl8139_private *tp = rtdev->priv;
void *ioaddr = tp->mmio_addr;
int nReturn = 0;
struct ifreq *ifr = arg;
struct ethtool_value *value;
switch (request) {
switch (cmd) {
case SIOCETHTOOL:
/* TODO: user-safe parameter access, most probably one layer higher */
value = (struct ethtool_value *)ifr->ifr_data;
......
......@@ -112,15 +112,15 @@ static int rt2x00_radio_off(struct _rt2x00_core * core) {
/*
* user space io handler
*/
static int rt2x00_ioctl(struct rtnet_device * rtnet_dev, unsigned int request, void * arg) {
static int rt2x00_ioctl(struct rtnet_device *rtnet_dev, struct ifreq *ifr, int request)
{
struct rtwlan_device * rtwlan_dev = rtnetdev_priv(rtnet_dev);
struct _rt2x00_core * core = rtwlan_priv(rtwlan_dev);
struct rtwlan_cmd * cmd;
u8 rate, dsss_rate, ofdm_rate;
u32 address, value;
cmd = (struct rtwlan_cmd *)arg;
cmd = (struct rtwlan_cmd *)ifr->ifr_data;
switch(request) {
......
......@@ -216,7 +216,7 @@ static int igb_msix_ring(rtdm_irq_t *irq_handle);
static void igb_poll(struct igb_q_vector *);
static bool igb_clean_tx_irq(struct igb_q_vector *);
static bool igb_clean_rx_irq(struct igb_q_vector *, int);
static int igb_ioctl(struct rtnet_device *, unsigned cmd, void *);
static int igb_ioctl(struct rtnet_device *, struct ifreq *ifr, int cmd);
static void igb_reset_task(struct work_struct *);
static void igb_vlan_mode(struct rtnet_device *netdev,
netdev_features_t features);
......@@ -5063,15 +5063,14 @@ static int igb_mii_ioctl(struct rtnet_device *netdev, struct ifreq *ifr, int cmd
* @ifreq:
* @cmd:
**/
static int igb_ioctl(struct rtnet_device *netdev, unsigned cmd, void *rq)
static int igb_ioctl(struct rtnet_device *netdev, struct ifreq *ifr, int cmd)
{
struct ifreq *ifr = rq;
switch (cmd) {
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
return igb_mii_ioctl(netdev, ifr, cmd);
default:
return -EOPNOTSUPP;
}
......
......@@ -152,7 +152,7 @@ struct rtnet_device {
unsigned int priority);
int (*do_ioctl)(struct rtnet_device *rtdev,
unsigned int request, void * cmd);
struct ifreq *ifr, int cmd);
struct net_device_stats *(*get_stats)(struct rtnet_device *rtdev);
/* DMA pre-mapping hooks */
......
......@@ -121,11 +121,21 @@ int rtwlan_ioctl(struct rtnet_device * rtdev,
unsigned long arg)
{
struct rtwlan_cmd cmd;
struct ifreq ifr;
int ret=0;
if (copy_from_user(&cmd, (void *)arg, sizeof(cmd)) != 0)
return -EFAULT;
/*
* FIXME: proper do_ioctl() should expect a __user pointer
* arg. This only works with the existing WLAN support because the
* only driver currently providing this feature is broken, not
* doing the copy_to/from_user dance.
*/
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_data = &cmd;
switch(request) {
case IOC_RTWLAN_IFINFO:
if (cmd.args.info.ifindex > 0)
......@@ -141,7 +151,7 @@ int rtwlan_ioctl(struct rtnet_device * rtdev,
}
if (rtdev->do_ioctl)
ret = rtdev->do_ioctl(rtdev, request, &cmd);
ret = rtdev->do_ioctl(rtdev, &ifr, request);
else
ret = -ENORTWLANDEV;
......@@ -168,11 +178,11 @@ int rtwlan_ioctl(struct rtnet_device * rtdev,
case IOC_RTWLAN_BBPWRITE:
case IOC_RTWLAN_BBPREAD:
case IOC_RTWLAN_BBPSENS:
if (mutex_lock_interruptible(&rtdev->nrt_lock))
return -ERESTARTSYS;
if (mutex_lock_interruptible(&rtdev->nrt_lock))
return -ERESTARTSYS;
if (rtdev->do_ioctl)
ret = rtdev->do_ioctl(rtdev, request, &cmd);
ret = rtdev->do_ioctl(rtdev, &ifr, request);
else
ret = -ENORTWLANDEV;
......
......@@ -343,7 +343,7 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, void __user *arg)
if (rtdev->do_ioctl != NULL) {
if (rtdm_in_rt_context())
return -ENOSYS;
ret = rtdev->do_ioctl(rtdev, request, arg);
ret = rtdev->do_ioctl(rtdev, ifr, request);
} else
ret = -EOPNOTSUPP;
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment