[v3,2/2] mfd: intel-lpss: Amend IRQ check

Message ID 20231106184052.1166579-3-andriy.shevchenko@linux.intel.com
State New
Headers
Series mfd: intel-lpss: refactor PCI probe and common IRQ check |

Commit Message

Andy Shevchenko Nov. 6, 2023, 6:40 p.m. UTC
  From: Chen Ni <nichen@iscas.ac.cn>

platform_get_irq() returns a negative error code to indicating an
error. All the same does pci_alloc_irq_vectors() and pci_irq_vector().
So in intel_lpss_probe() the erroneous IRQ should be better returned
as is.

The pci_alloc_irq_vectors() call and platform_get_irq() guarantee
that IRQ won't be 0, hence drop that check.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
[andy: updated commit message]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/intel-lpss.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Lee Jones Nov. 23, 2023, 11:18 a.m. UTC | #1
On Mon, 06 Nov 2023, Andy Shevchenko wrote:

> From: Chen Ni <nichen@iscas.ac.cn>
> 
> platform_get_irq() returns a negative error code to indicating an
> error. All the same does pci_alloc_irq_vectors() and pci_irq_vector().
> So in intel_lpss_probe() the erroneous IRQ should be better returned
> as is.
> 
> The pci_alloc_irq_vectors() call and platform_get_irq() guarantee
> that IRQ won't be 0, hence drop that check.
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> [andy: updated commit message]

I reworded it further.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/mfd/intel-lpss.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
> index 9591b354072a..4c9d0222751a 100644
> --- a/drivers/mfd/intel-lpss.c
> +++ b/drivers/mfd/intel-lpss.c
> @@ -378,9 +378,12 @@ int intel_lpss_probe(struct device *dev,
>  	struct intel_lpss *lpss;
>  	int ret;
>  
> -	if (!info || !info->mem || info->irq <= 0)
> +	if (!info || !info->mem)
>  		return -EINVAL;
>  
> +	if (info->irq < 0)
> +		return info->irq;
> +
>  	lpss = devm_kzalloc(dev, sizeof(*lpss), GFP_KERNEL);
>  	if (!lpss)
>  		return -ENOMEM;
> -- 
> 2.40.0.1.gaa8946217a0b
>
  

Patch

diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
index 9591b354072a..4c9d0222751a 100644
--- a/drivers/mfd/intel-lpss.c
+++ b/drivers/mfd/intel-lpss.c
@@ -378,9 +378,12 @@  int intel_lpss_probe(struct device *dev,
 	struct intel_lpss *lpss;
 	int ret;
 
-	if (!info || !info->mem || info->irq <= 0)
+	if (!info || !info->mem)
 		return -EINVAL;
 
+	if (info->irq < 0)
+		return info->irq;
+
 	lpss = devm_kzalloc(dev, sizeof(*lpss), GFP_KERNEL);
 	if (!lpss)
 		return -ENOMEM;