Subject: Re: [PATCH net 3/6] pch_gbe: Validate hwtstamp_config completely before applying it

From: Richard Cochran <[email-masked]>
Date: Thu, 14 Nov 2013 08:21:37 +0100

On Thu, Nov 14, 2013 at 12:42:50AM +0000, Ben Hutchings wrote:
> --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> @@ -245,16 +245,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
>  	/* Get ieee1588's dev information */
>  	pdev = adapter->ptp_pdev;
>  
> -	switch (cfg.tx_type) {
> -	case HWTSTAMP_TX_OFF:
> -		adapter->hwts_tx_en = 0;
> -		break;
> -	case HWTSTAMP_TX_ON:
> -		adapter->hwts_tx_en = 1;
> -		break;
> -	default:
> +	if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON)
>  		return -ERANGE;
> -	}
>  
>  	switch (cfg.rx_filter) {
>  	case HWTSTAMP_FILTER_NONE:
> @@ -284,6 +276,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
>  		return -ERANGE;
>  	}
>  
> +	adapter->hwts_tx_en = cfg.tx_type == HWTSTAMP_TX_ON;
> +

But now there is no way to turn transmit time stamping off?

>  	/* Clear out any old time stamps. */
>  	pch_ch_event_write(pdev, TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED);

Thanks,
Richard