All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Romain Perier <romain.perier@free-electrons.com>
Cc: Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch 1/3] spi: armada-3700: Signedness bug in probe
Date: Fri, 16 Dec 2016 09:56:55 +0000	[thread overview]
Message-ID: <20161216095655.GB8244@mwanda> (raw)
In-Reply-To: <e1c6a534-6b6c-a83f-390f-b65654ff2bcf@free-electrons.com>

On Fri, Dec 16, 2016 at 10:36:29AM +0100, Romain Perier wrote:
> Hello,
> 
> Le 16/12/2016 à 10:33, Dan Carpenter a écrit :
> >We need "irq" to be an int because platform_get_irq() returns negative
> >error codes.
> >
> >Fixes: 5762ab71eb24 ("spi: Add support for Armada 3700 SPI Controller")
> >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> >diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c
> >index e89da0af45d2..5c7508dc6f0b 100644
> >--- a/drivers/spi/spi-armada-3700.c
> >+++ b/drivers/spi/spi-armada-3700.c
> >@@ -108,7 +108,7 @@ struct a3700_spi {
> > 	struct spi_master *master;
> > 	void __iomem *base;
> > 	struct clk *clk;
> >-	unsigned int irq;
> >+	int irq;
> > 	unsigned int flags;
> > 	bool xmit_data;
> > 	const u8 *tx_buf;
> >
> 
> It is already fixed, see https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?idöf0083cca66e673cca6fa26b52b107b5570081d
> 

Ah good.

> And no we cannot just replace the type of the irq field like this
> because devm_request_irq/request_irq require an unsigned int as
> "irq" parameter.

That's immaterial, my patch works fine.  There are other place that use
a signed IRQ like the irq handler and platform_get_irq() which I
mentioned in my patch description.  It's never going to be perfectly
consistent.

But this is actually important that you thought it mattered.  Is there
something that prints a warning?  These irq signedness bugs are some of
the most common recurring bugs I see so it would help to figure out
why people are doing this...

regards,
dan carpenter


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

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Romain Perier <romain.perier@free-electrons.com>
Cc: Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch 1/3] spi: armada-3700: Signedness bug in probe
Date: Fri, 16 Dec 2016 12:56:55 +0300	[thread overview]
Message-ID: <20161216095655.GB8244@mwanda> (raw)
In-Reply-To: <e1c6a534-6b6c-a83f-390f-b65654ff2bcf@free-electrons.com>

On Fri, Dec 16, 2016 at 10:36:29AM +0100, Romain Perier wrote:
> Hello,
> 
> Le 16/12/2016 à 10:33, Dan Carpenter a écrit :
> >We need "irq" to be an int because platform_get_irq() returns negative
> >error codes.
> >
> >Fixes: 5762ab71eb24 ("spi: Add support for Armada 3700 SPI Controller")
> >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> >diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c
> >index e89da0af45d2..5c7508dc6f0b 100644
> >--- a/drivers/spi/spi-armada-3700.c
> >+++ b/drivers/spi/spi-armada-3700.c
> >@@ -108,7 +108,7 @@ struct a3700_spi {
> > 	struct spi_master *master;
> > 	void __iomem *base;
> > 	struct clk *clk;
> >-	unsigned int irq;
> >+	int irq;
> > 	unsigned int flags;
> > 	bool xmit_data;
> > 	const u8 *tx_buf;
> >
> 
> It is already fixed, see https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=f6f0083cca66e673cca6fa26b52b107b5570081d
> 

Ah good.

> And no we cannot just replace the type of the irq field like this
> because devm_request_irq/request_irq require an unsigned int as
> "irq" parameter.

That's immaterial, my patch works fine.  There are other place that use
a signed IRQ like the irq handler and platform_get_irq() which I
mentioned in my patch description.  It's never going to be perfectly
consistent.

But this is actually important that you thought it mattered.  Is there
something that prints a warning?  These irq signedness bugs are some of
the most common recurring bugs I see so it would help to figure out
why people are doing this...

regards,
dan carpenter



  reply	other threads:[~2016-12-16  9:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16  9:33 [patch 1/3] spi: armada-3700: Signedness bug in probe Dan Carpenter
2016-12-16  9:33 ` Dan Carpenter
     [not found] ` <20161216082443.GA7031-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2016-12-16  9:36   ` Romain Perier
2016-12-16  9:36     ` Romain Perier
2016-12-16  9:56     ` Dan Carpenter [this message]
2016-12-16  9:56       ` Dan Carpenter
2016-12-16 10:29       ` Romain Perier
2016-12-16 10:29         ` Romain Perier
     [not found]         ` <9e5f6a38-6177-4026-7930-150c6b281a99-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-12-16 10:34           ` Dan Carpenter
2016-12-16 10:34             ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161216095655.GB8244@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=broonie@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=romain.perier@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.