Subject: Re: [PATCH RFC] net: davinci_emac: Fix rollback of emac_dev_open()

From: Mugunthan V N <[email-masked]>
Date: Fri, 7 Mar 2014 20:15:00 +0530

On Friday 07 March 2014 07:37 PM, Christian Riesch wrote:
> Signed-off-by: Christian Riesch <christian.riesch-3mrvs1K0uXizZXS1Dc/[email-masked]>
> Cc: Prabhakar Lad <[email-masked]>
> Cc: Mugunthan V N <[email-masked]>
> Cc: Florian Fainelli <[email-masked]>
> ---
>
> Hi again,
>
> How about this solution for fixing the rollback of emac_dev_open()?
> Especially the change in davinci_cpdma.c, would this break anything?
>
> The patch applies on top of 
> [PATCH] net: davinci_emac: Replace devm_request_irq with request_irq
>
> Regards,
> Christian
>
>  drivers/net/ethernet/ti/davinci_cpdma.c |    4 +--
>  drivers/net/ethernet/ti/davinci_emac.c  |   44 ++++++++++++++++++++-----------
>  2 files changed, 31 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
> index 364d0c7..88ef270 100644
> --- a/drivers/net/ethernet/ti/davinci_cpdma.c
> +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
> @@ -355,7 +355,7 @@ int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr)
>  	int i;
>  
>  	spin_lock_irqsave(&ctlr->lock, flags);
> -	if (ctlr->state != CPDMA_STATE_ACTIVE) {
> +	if (ctlr->state == CPDMA_STATE_TEARDOWN) {
>  		spin_unlock_irqrestore(&ctlr->lock, flags);
>  		return -EINVAL;
>  	}
> @@ -891,7 +891,7 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
>  	unsigned		timeout;
>  
>  	spin_lock_irqsave(&chan->lock, flags);
> -	if (chan->state != CPDMA_STATE_ACTIVE) {
> +	if (chan->state == CPDMA_STATE_TEARDOWN) {
>  		spin_unlock_irqrestore(&chan->lock, flags);
>  		return -EINVAL;
>  	}

Even when in idle mode chan stop should return error.

Regards
Mugunthan V N