Re: [PATCH v1 1/1] dmaengine: hsu: refactor hsu_dma_do_irq() to return int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 23, 2016 at 04:09:40PM +0300, Andy Shevchenko wrote:
> Since we have nice macro IRQ_RETVAL() we would use it to convert a flag of
> handled interrupt from int to irqreturn_t.
> 
> The rationale of doing this is:
> a) hence we implicitly mark hsu_dma_do_irq() as an auxiliary function that
>    can't be used as interrupt handler directly, and
> b) to be in align with serial driver which is using serial8250_handle_irq()
>    that returns plain int by design.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/dma/hsu/hsu.c              | 9 ++++-----
>  drivers/dma/hsu/pci.c              | 6 +++---
>  drivers/tty/serial/8250/8250_mid.c | 8 ++++----
>  include/linux/dma/hsu.h            | 9 ++++-----

This looks okay to me but needs ACK from greg before I can apply..

>  4 files changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
> index c5f21ef..29d04ca 100644
> --- a/drivers/dma/hsu/hsu.c
> +++ b/drivers/dma/hsu/hsu.c
> @@ -200,10 +200,9 @@ EXPORT_SYMBOL_GPL(hsu_dma_get_status);
>   *      is not a normal timeout interrupt, ie. hsu_dma_get_status() returned 0.
>   *
>   *      Return:
> - *      IRQ_NONE for invalid channel number, IRQ_HANDLED otherwise.
> + *      0 for invalid channel number, 1 otherwise.
>   */
> -irqreturn_t hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr,
> -			   u32 status)
> +int hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr, u32 status)
>  {
>  	struct hsu_dma_chan *hsuc;
>  	struct hsu_dma_desc *desc;
> @@ -211,7 +210,7 @@ irqreturn_t hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr,
>  
>  	/* Sanity check */
>  	if (nr >= chip->hsu->nr_channels)
> -		return IRQ_NONE;
> +		return 0;
>  
>  	hsuc = &chip->hsu->chan[nr];
>  
> @@ -230,7 +229,7 @@ irqreturn_t hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr,
>  	}
>  	spin_unlock_irqrestore(&hsuc->vchan.lock, flags);
>  
> -	return IRQ_HANDLED;
> +	return 1;
>  }
>  EXPORT_SYMBOL_GPL(hsu_dma_do_irq);
>  
> diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c
> index 9916058..b51639f 100644
> --- a/drivers/dma/hsu/pci.c
> +++ b/drivers/dma/hsu/pci.c
> @@ -29,7 +29,7 @@ static irqreturn_t hsu_pci_irq(int irq, void *dev)
>  	u32 dmaisr;
>  	u32 status;
>  	unsigned short i;
> -	irqreturn_t ret = IRQ_NONE;
> +	int ret = 0;
>  	int err;
>  
>  	dmaisr = readl(chip->regs + HSU_PCI_DMAISR);
> @@ -37,14 +37,14 @@ static irqreturn_t hsu_pci_irq(int irq, void *dev)
>  		if (dmaisr & 0x1) {
>  			err = hsu_dma_get_status(chip, i, &status);
>  			if (err > 0)
> -				ret |= IRQ_HANDLED;
> +				ret |= 1;
>  			else if (err == 0)
>  				ret |= hsu_dma_do_irq(chip, i, status);
>  		}
>  		dmaisr >>= 1;
>  	}
>  
> -	return ret;
> +	return IRQ_RETVAL(ret);
>  }
>  
>  static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
> index 339de9c..121a7f2 100644
> --- a/drivers/tty/serial/8250/8250_mid.c
> +++ b/drivers/tty/serial/8250/8250_mid.c
> @@ -99,27 +99,27 @@ static int dnv_handle_irq(struct uart_port *p)
>  	struct uart_8250_port *up = up_to_u8250p(p);
>  	unsigned int fisr = serial_port_in(p, INTEL_MID_UART_DNV_FISR);
>  	u32 status;
> -	int ret = IRQ_NONE;
> +	int ret = 0;
>  	int err;
>  
>  	if (fisr & BIT(2)) {
>  		err = hsu_dma_get_status(&mid->dma_chip, 1, &status);
>  		if (err > 0) {
>  			serial8250_rx_dma_flush(up);
> -			ret |= IRQ_HANDLED;
> +			ret |= 1;
>  		} else if (err == 0)
>  			ret |= hsu_dma_do_irq(&mid->dma_chip, 1, status);
>  	}
>  	if (fisr & BIT(1)) {
>  		err = hsu_dma_get_status(&mid->dma_chip, 0, &status);
>  		if (err > 0)
> -			ret |= IRQ_HANDLED;
> +			ret |= 1;
>  		else if (err == 0)
>  			ret |= hsu_dma_do_irq(&mid->dma_chip, 0, status);
>  	}
>  	if (fisr & BIT(0))
>  		ret |= serial8250_handle_irq(p, serial_port_in(p, UART_IIR));
> -	return ret;
> +	return IRQ_RETVAL(ret);
>  }
>  
>  #define DNV_DMA_CHAN_OFFSET 0x80
> diff --git a/include/linux/dma/hsu.h b/include/linux/dma/hsu.h
> index aaff68e..197eec6 100644
> --- a/include/linux/dma/hsu.h
> +++ b/include/linux/dma/hsu.h
> @@ -41,8 +41,7 @@ struct hsu_dma_chip {
>  /* Export to the internal users */
>  int hsu_dma_get_status(struct hsu_dma_chip *chip, unsigned short nr,
>  		       u32 *status);
> -irqreturn_t hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr,
> -			   u32 status);
> +int hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr, u32 status);
>  
>  /* Export to the platform drivers */
>  int hsu_dma_probe(struct hsu_dma_chip *chip);
> @@ -53,10 +52,10 @@ static inline int hsu_dma_get_status(struct hsu_dma_chip *chip,
>  {
>  	return 0;
>  }
> -static inline irqreturn_t hsu_dma_do_irq(struct hsu_dma_chip *chip,
> -					 unsigned short nr, u32 status)
> +static inline int hsu_dma_do_irq(struct hsu_dma_chip *chip, unsigned short nr,
> +				 u32 status)
>  {
> -	return IRQ_NONE;
> +	return 0;
>  }
>  static inline int hsu_dma_probe(struct hsu_dma_chip *chip) { return -ENODEV; }
>  static inline int hsu_dma_remove(struct hsu_dma_chip *chip) { return 0; }
> -- 
> 2.8.1
> 

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



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux