Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFran├žois Romieu <romieu@cogenit.fr>2002-03-06 16:42:39 -0500
committerJeff Garzik <jgarzik@mandrakesoft.com>2002-03-06 16:42:39 -0500
commitfd0812f699324d111225cc9a7e51ad8a81d2859c (patch)
tree6899ff6d071a192830f8e421e30b7baed10f35f2
parent10e9aaa79a14e1d9fab1269ab651b8cfe3718f41 (diff)
WAN drivers update 3/5:
Clean up WAN driver ioctl handling to be more independent of line settings structure changes.
-rw-r--r--drivers/net/wan/c101.c21
-rw-r--r--drivers/net/wan/dscc4.c18
-rw-r--r--drivers/net/wan/farsync.c35
-rw-r--r--drivers/net/wan/n2.c21
4 files changed, 26 insertions, 69 deletions
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
index 291f4c755e30..7474c9547e28 100644
--- a/drivers/net/wan/c101.c
+++ b/drivers/net/wan/c101.c
@@ -179,9 +179,10 @@ static int c101_close(struct net_device *dev)
static int c101_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
+ union line_settings *line = &ifr->ifr_settings->ifs_line;
+ const size_t size = sizeof(sync_serial_settings);
hdlc_device *hdlc = dev_to_hdlc(dev);
port_t *port = hdlc_to_port(hdlc);
- const size_t size = sizeof(sync_serial_settings);
#ifdef CONFIG_HDLC_DEBUG_RINGS
if (cmd == SIOCDEVPRIVATE) {
@@ -192,28 +193,18 @@ static int c101_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (cmd != SIOCWANDEV)
return hdlc_ioctl(dev, ifr, cmd);
- switch(ifr->ifr_settings.type) {
+ switch(ifr->ifr_settings->type) {
case IF_GET_IFACE:
- ifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL;
- if (ifr->ifr_settings.data_length == 0)
- return 0; /* return interface type only */
- if (ifr->ifr_settings.data_length < size)
- return -ENOMEM; /* buffer too small */
- if (copy_to_user(ifr->ifr_settings.data,
- &port->settings, size))
+ ifr->ifr_settings->type = IF_IFACE_SYNC_SERIAL;
+ if (copy_to_user(&line->sync, &port->settings, size))
return -EFAULT;
- ifr->ifr_settings.data_length = size;
return 0;
case IF_IFACE_SYNC_SERIAL:
if(!capable(CAP_NET_ADMIN))
return -EPERM;
- if (ifr->ifr_settings.data_length != size)
- return -ENOMEM; /* incorrect data length */
-
- if (copy_from_user(&port->settings,
- ifr->ifr_settings.data, size))
+ if (copy_from_user(&port->settings, &line->sync, size))
return -EFAULT;
/* FIXME - put sanity checks here */
return c101_set_iface(port);
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index a27919a9f8e1..991996da0fb1 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -1065,8 +1065,8 @@ static int dscc4_set_clock(struct net_device *dev, u32 *bps, u32 *state)
static int dscc4_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
+ union line_settings *line = &ifr->ifr_settings->ifs_line;
struct dscc4_dev_priv *dpriv = dscc4_priv(dev);
- struct if_settings *if_s = &ifr->ifr_settings;
const size_t size = sizeof(dpriv->settings);
int ret = 0;
@@ -1076,26 +1076,18 @@ static int dscc4_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (cmd != SIOCWANDEV)
return -EOPNOTSUPP;
- switch(ifr->ifr_settings.type) {
+ switch(ifr->ifr_settings->type) {
case IF_GET_IFACE:
- if_s->type = IF_IFACE_SYNC_SERIAL;
- if (if_s->data_length == 0)
- return 0;
- if (if_s->data_length < size)
- return -ENOMEM;
- if (copy_to_user(if_s->data, &dpriv->settings, size))
+ ifr->ifr_settings->type = IF_IFACE_SYNC_SERIAL;
+ if (copy_to_user(&line->sync, &dpriv->settings, size))
return -EFAULT;
- if_s->data_length = size;
break;
case IF_IFACE_SYNC_SERIAL:
if(!capable(CAP_NET_ADMIN))
return -EPERM;
- if (if_s->data_length != size)
- return -ENOMEM;
-
- if (copy_from_user(&dpriv->settings, if_s->data, size))
+ if (copy_from_user(&dpriv->settings, &line->sync, size))
return -EFAULT;
ret = dscc4_set_iface(dev);
break;
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 0d3e13bf28d6..f6be495fbb6c 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -1013,25 +1013,19 @@ static int
fst_set_iface ( struct fst_card_info *card, struct fst_port_info *port,
struct ifreq *ifr )
{
+ union line_settings *line = &ifr->ifr_settings->ifs_line;
sync_serial_settings sync;
int i;
- if ( ifr->ifr_settings.data_length != sizeof ( sync ))
- {
- return -ENOMEM;
- }
-
- if ( copy_from_user ( &sync, ifr->ifr_settings.data, sizeof ( sync )))
- {
+ if ( copy_from_user ( &sync, &line->sync, sizeof ( sync )))
return -EFAULT;
- }
if ( sync.loopback )
return -EINVAL;
i = port->index;
- switch ( ifr->ifr_settings.type )
+ switch ( ifr->ifr_settings->type )
{
case IF_IFACE_V35:
FST_WRW ( card, portConfig[i].lineInterface, V35 );
@@ -1076,6 +1070,7 @@ static int
fst_get_iface ( struct fst_card_info *card, struct fst_port_info *port,
struct ifreq *ifr )
{
+ union line_settings *line = &ifr->ifr_settings->ifs_line;
sync_serial_settings sync;
int i;
@@ -1086,25 +1081,16 @@ fst_get_iface ( struct fst_card_info *card, struct fst_port_info *port,
switch ( port->hwif )
{
case V35:
- ifr->ifr_settings.type = IF_IFACE_V35;
+ ifr->ifr_settings->type = IF_IFACE_V35;
break;
case V24:
- ifr->ifr_settings.type = IF_IFACE_V24;
+ ifr->ifr_settings->type = IF_IFACE_V24;
break;
case X21:
default:
- ifr->ifr_settings.type = IF_IFACE_X21;
+ ifr->ifr_settings->type = IF_IFACE_X21;
break;
}
- if ( ifr->ifr_settings.data_length == 0 )
- {
- return 0; /* only type requested */
- }
-
- if ( ifr->ifr_settings.data_length < sizeof ( sync ))
- {
- return -ENOMEM;
- }
i = port->index;
sync.clock_rate = FST_RDL ( card, portConfig[i].lineSpeed );
@@ -1112,12 +1098,9 @@ fst_get_iface ( struct fst_card_info *card, struct fst_port_info *port,
sync.clock_type = FST_RDB ( card, portConfig[i].internalClock );
sync.loopback = 0;
- if ( copy_to_user ( ifr->ifr_settings.data, &sync, sizeof ( sync )))
- {
+ if ( copy_to_user (&line->sync, &sync, sizeof ( sync )))
return -EFAULT;
- }
- ifr->ifr_settings.data_length = sizeof ( sync );
return 0;
}
@@ -1241,7 +1224,7 @@ fst_ioctl ( struct net_device *dev, struct ifreq *ifr, int cmd )
return set_conf_from_info ( card, port, &info );
case SIOCWANDEV:
- switch ( ifr->ifr_settings.type )
+ switch ( ifr->ifr_settings->type )
{
case IF_GET_IFACE:
return fst_get_iface ( card, port, ifr );
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index beb3e98fc3a6..2874ef8aeb7b 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -250,9 +250,10 @@ static int n2_close(struct net_device *dev)
static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
+ union line_settings *line = &ifr->ifr_settings->ifs_line;
+ const size_t size = sizeof(sync_serial_settings);
hdlc_device *hdlc = dev_to_hdlc(dev);
port_t *port = hdlc_to_port(hdlc);
- const size_t size = sizeof(sync_serial_settings);
#ifdef CONFIG_HDLC_DEBUG_RINGS
if (cmd == SIOCDEVPRIVATE) {
@@ -263,28 +264,18 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (cmd != SIOCWANDEV)
return hdlc_ioctl(dev, ifr, cmd);
- switch(ifr->ifr_settings.type) {
+ switch(ifr->ifr_settings->type) {
case IF_GET_IFACE:
- ifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL;
- if (ifr->ifr_settings.data_length == 0)
- return 0; /* return interface type only */
- if (ifr->ifr_settings.data_length < size)
- return -ENOMEM; /* buffer too small */
- if (copy_to_user(ifr->ifr_settings.data,
- &port->settings, size))
+ ifr->ifr_settings->type = IF_IFACE_SYNC_SERIAL;
+ if (copy_to_user(&line->sync, &port->settings, size))
return -EFAULT;
- ifr->ifr_settings.data_length = size;
return 0;
case IF_IFACE_SYNC_SERIAL:
if(!capable(CAP_NET_ADMIN))
return -EPERM;
- if (ifr->ifr_settings.data_length != size)
- return -ENOMEM; /* incorrect data length */
-
- if (copy_from_user(&port->settings,
- ifr->ifr_settings.data, size))
+ if (copy_from_user(&port->settings, &line->sync, size))
return -EFAULT;
/* FIXME - put sanity checks here */
return n2_set_iface(port);