Corinna Vinschen <vinsc...@redhat.com> :
[...]
> diff --git a/drivers/net/ethernet/realtek/r8169.c 
> b/drivers/net/ethernet/realtek/r8169.c
> index f790f61..f26a48d 100644
> --- a/drivers/net/ethernet/realtek/r8169.c
> +++ b/drivers/net/ethernet/realtek/r8169.c
[...]
> @@ -2179,6 +2191,47 @@ static int rtl8169_get_sset_count(struct net_device 
> *dev, int sset)
>       }
>  }
>  
> +DECLARE_RTL_COND(rtl_reset_counters_cond)
> +{
> +     void __iomem *ioaddr = tp->mmio_addr;
> +
> +     return RTL_R32(CounterAddrLow) & CounterReset;
> +}
> +
> +static void rtl8169_reset_counters(struct net_device *dev)
> +{

rtl8169_reset_counters duplicates most of rtl8169_update_counters. Please
factor out the dma_alloc + parametrized CounterAddrLow write + cleanup.

[...]
> @@ -2220,6 +2273,39 @@ static void rtl8169_update_counters(struct net_device 
> *dev)
>       dma_free_coherent(d, sizeof(*counters), counters, paddr);
>  }
>  
> +static void rtl8169_init_counter_offsets(struct net_device *dev)
> +{
> +     struct rtl8169_private *tp = netdev_priv(dev);
> +
> +     /*
> +      * rtl8169_init_counter_offsets is called from rtl_open.  On chip
> +      * versions prior to RTL_GIGA_MAC_VER_19 the tally counters are only
> +      * reset by a power cycle, while the counter values collected by the
> +      * driver are reset at every driver unload/load cycle.
> +      *
> +      * To make sure the HW values returned by @get_stats64 match the SW
> +      * values, we collect the initial values at first open(*) and use them
> +      * as offsets to normalize the values returned by @get_stats64.
> +      *
> +      * (*) We can't call rtl8169_init_counter_offsets from rtl_init_one
> +      * for the reason stated in rtl8169_update_counters; CmdRxEnb is only
> +      * set at open time by rtl_hw_start.
> +      */
> +
> +     if (tp->tc_offset.inited)
> +             return;
> +
> +     rtl8169_reset_counters(dev);
> +
> +     rtl8169_update_counters(dev);


The code should propagate failure when both rtl8169_reset_counters and
rtl8169_update_counters fail.

--
Ueimor
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to