aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2013-11-13 19:48:56 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-14 16:22:10 -0500
commita5be8cd3875ca051db857c9d76b253a7e7ea3f22 (patch)
treea9d5b9f6d2597b1fabf95853e70de55e568b435f /drivers/net/ethernet
parent2ee91e54bd5367bf4123719a4f7203857b28e046 (diff)
ixp4xx_eth: Validate hwtstamp_config completely before applying it
hwtstamp_ioctl() should validate all fields of hwtstamp_config before making any changes. Currently it sets the TX configuration before validating the rx_filter field. Untested as I don't have a cross-compiler to hand. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/xscale/ixp4xx_eth.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index e78802e75ea6..bcc224a83734 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -389,16 +389,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
389 ch = PORT2CHANNEL(port); 389 ch = PORT2CHANNEL(port);
390 regs = (struct ixp46x_ts_regs __iomem *) IXP4XX_TIMESYNC_BASE_VIRT; 390 regs = (struct ixp46x_ts_regs __iomem *) IXP4XX_TIMESYNC_BASE_VIRT;
391 391
392 switch (cfg.tx_type) { 392 if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON)
393 case HWTSTAMP_TX_OFF:
394 port->hwts_tx_en = 0;
395 break;
396 case HWTSTAMP_TX_ON:
397 port->hwts_tx_en = 1;
398 break;
399 default:
400 return -ERANGE; 393 return -ERANGE;
401 }
402 394
403 switch (cfg.rx_filter) { 395 switch (cfg.rx_filter) {
404 case HWTSTAMP_FILTER_NONE: 396 case HWTSTAMP_FILTER_NONE:
@@ -416,6 +408,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
416 return -ERANGE; 408 return -ERANGE;
417 } 409 }
418 410
411 port->hwts_tx_en = cfg.tx_type == HWTSTAMP_TX_ON;
412
419 /* Clear out any old time stamps. */ 413 /* Clear out any old time stamps. */
420 __raw_writel(TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED, 414 __raw_writel(TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED,
421 &regs->channel[ch].ch_event); 415 &regs->channel[ch].ch_event);