* [PATCH] ASoC: wm8804: fix error handling code
@ 2010-10-10 17:29 Vasiliy Kulikov
2010-10-11 12:00 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Vasiliy Kulikov @ 2010-10-10 17:29 UTC (permalink / raw)
To: kernel-janitors
Cc: Mark Brown, Ian Lartey, Dimitris Papastamos, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
kzalloc() returns NULL on error, not ERR_PTR().
Also wm8804_modinit() didn't called i2c_del_driver() if
spi_register_driver() failed.
Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
Compile tested.
sound/soc/codecs/wm8804.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index 642b07c..ff4dffd 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -720,8 +720,8 @@ static int __devinit wm8804_spi_probe(struct spi_device *spi)
int ret;
wm8804 = kzalloc(sizeof *wm8804, GFP_KERNEL);
- if (IS_ERR(wm8804))
- return PTR_ERR(wm8804);
+ if (!wm8804)
+ return -ENOMEM;
wm8804->control_type = SND_SOC_SPI;
spi_set_drvdata(spi, wm8804);
@@ -758,8 +758,8 @@ static __devinit int wm8804_i2c_probe(struct i2c_client *i2c,
int ret;
wm8804 = kzalloc(sizeof *wm8804, GFP_KERNEL);
- if (IS_ERR(wm8804))
- return PTR_ERR(wm8804);
+ if (!wm8804)
+ return -ENOMEM;
wm8804->control_type = SND_SOC_I2C;
i2c_set_clientdata(i2c, wm8804);
@@ -804,6 +804,7 @@ static int __init wm8804_modinit(void)
if (ret) {
printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
ret);
+ goto err;
}
#endif
#if defined(CONFIG_SPI_MASTER)
@@ -811,7 +812,13 @@ static int __init wm8804_modinit(void)
if (ret != 0) {
printk(KERN_ERR "Failed to register wm8804 SPI driver: %d\n",
ret);
+ goto err_i2c;
}
+err_i2c:
+#endif
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+ i2c_del_driver(&wm8804_i2c_driver);
+err:
#endif
return ret;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: wm8804: fix error handling code
2010-10-10 17:29 [PATCH] ASoC: wm8804: fix error handling code Vasiliy Kulikov
@ 2010-10-11 12:00 ` Mark Brown
2010-10-11 12:15 ` Vasiliy Kulikov
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2010-10-11 12:00 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: Dimitris Papastamos, alsa-devel, Takashi Iwai, linux-kernel,
kernel-janitors, Ian Lartey, Liam Girdwood
On Sun, Oct 10, 2010 at 09:29:04PM +0400, Vasiliy Kulikov wrote:
> kzalloc() returns NULL on error, not ERR_PTR().
> Also wm8804_modinit() didn't called i2c_del_driver() if
> spi_register_driver() failed.
>
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Please try to follow Documentation/SubmittingPatches - in particular,
you should always split unrelated changes into separate patches. In
this case your I2C and kzalloc() changes have nothing to do with each
other and so should be in separate patches, and the kzalloc() changes
were already applied from a patch by someone else. For the registration
changes...
> @@ -804,6 +804,7 @@ static int __init wm8804_modinit(void)
> if (ret) {
> printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
> ret);
> + goto err;
> }
> #endif
> #if defined(CONFIG_SPI_MASTER)
...it's not clear to me that this change is an improvement - it'll make
the driver more fragile in the face of errors, I don't see a benefit in
refusing to register the variant for one bus if the other fails?
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: wm8804: fix error handling code
2010-10-11 12:00 ` Mark Brown
@ 2010-10-11 12:15 ` Vasiliy Kulikov
2010-10-11 12:36 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Vasiliy Kulikov @ 2010-10-11 12:15 UTC (permalink / raw)
To: Mark Brown
Cc: kernel-janitors, Ian Lartey, Dimitris Papastamos, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
Hi Mark,
On Mon, Oct 11, 2010 at 13:00 +0100, Mark Brown wrote:
> On Sun, Oct 10, 2010 at 09:29:04PM +0400, Vasiliy Kulikov wrote:
> > kzalloc() returns NULL on error, not ERR_PTR().
> > Also wm8804_modinit() didn't called i2c_del_driver() if
> > spi_register_driver() failed.
> >
> > Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
>
> Please try to follow Documentation/SubmittingPatches - in particular,
> you should always split unrelated changes into separate patches. In
> this case your I2C and kzalloc() changes have nothing to do with each
> other and so should be in separate patches,
Agreed, thanks.
> and the kzalloc() changes
> were already applied from a patch by someone else.
Yes, it was sent by Dan just one day before my patch ;)
> For the registration
> changes...
> > @@ -804,6 +804,7 @@ static int __init wm8804_modinit(void)
> > if (ret) {
> > printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
> > ret);
> > + goto err;
> > }
> > #endif
> > #if defined(CONFIG_SPI_MASTER)
>
> ...it's not clear to me that this change is an improvement - it'll make
> the driver more fragile in the face of errors, I don't see a benefit in
> refusing to register the variant for one bus if the other fails?
I tried to implement your variant with depca driver in past, but it was
rejected by David Miller:
http://lists.openwall.net/netdev/2010/07/12/9
Thanks,
--
Vasiliy
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: wm8804: fix error handling code
2010-10-11 12:15 ` Vasiliy Kulikov
@ 2010-10-11 12:36 ` Mark Brown
2010-10-11 12:50 ` Vasiliy Kulikov
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2010-10-11 12:36 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: Dimitris Papastamos, alsa-devel, Takashi Iwai, linux-kernel,
kernel-janitors, Ian Lartey, Liam Girdwood
On Mon, Oct 11, 2010 at 04:15:55PM +0400, Vasiliy Kulikov wrote:
> On Mon, Oct 11, 2010 at 13:00 +0100, Mark Brown wrote:
> > ...it's not clear to me that this change is an improvement - it'll make
> > the driver more fragile in the face of errors, I don't see a benefit in
> > refusing to register the variant for one bus if the other fails?
> I tried to implement your variant with depca driver in past, but it was
> rejected by David Miller:
> http://lists.openwall.net/netdev/2010/07/12/9
I disagree with David here, and in any case if you're going to make a
style change like this they really ought to be applied over all drivers
rather than just a few individual ones.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: wm8804: fix error handling code
2010-10-11 12:36 ` Mark Brown
@ 2010-10-11 12:50 ` Vasiliy Kulikov
2010-10-11 12:59 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Vasiliy Kulikov @ 2010-10-11 12:50 UTC (permalink / raw)
To: Mark Brown
Cc: kernel-janitors, Ian Lartey, Dimitris Papastamos, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
On Mon, Oct 11, 2010 at 13:36 +0100, Mark Brown wrote:
> On Mon, Oct 11, 2010 at 04:15:55PM +0400, Vasiliy Kulikov wrote:
> > On Mon, Oct 11, 2010 at 13:00 +0100, Mark Brown wrote:
>
> > > ...it's not clear to me that this change is an improvement - it'll make
> > > the driver more fragile in the face of errors, I don't see a benefit in
> > > refusing to register the variant for one bus if the other fails?
>
> > I tried to implement your variant with depca driver in past, but it was
> > rejected by David Miller:
> > http://lists.openwall.net/netdev/2010/07/12/9
>
> I disagree with David here, and in any case if you're going to make a
> style change like this they really ought to be applied over all drivers
> rather than just a few individual ones.
It is not greppable situation to simply change the behavior of all
drivers. I was looking for memory leak bugs in drivers/net/ and fixed
some of them. Manual looking through _all_ drivers takes much more
time. In general I try to search for repeatable bugs with coccinelle,
but it is rare case.
Thanks,
--
Vasiliy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: wm8804: fix error handling code
2010-10-11 12:50 ` Vasiliy Kulikov
@ 2010-10-11 12:59 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2010-10-11 12:59 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: Dimitris Papastamos, alsa-devel, Takashi Iwai, linux-kernel,
kernel-janitors, Ian Lartey, Liam Girdwood
On Mon, Oct 11, 2010 at 04:50:56PM +0400, Vasiliy Kulikov wrote:
> It is not greppable situation to simply change the behavior of all
> drivers. I was looking for memory leak bugs in drivers/net/ and fixed
> some of them. Manual looking through _all_ drivers takes much more
> time. In general I try to search for repeatable bugs with coccinelle,
> but it is rare case.
The method you're using to generate the patches is pretty much
orthogonal to anything else, except of course in the case where you're
also submitting the automation for checking (which is useful where
possible).
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-10-11 12:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-10 17:29 [PATCH] ASoC: wm8804: fix error handling code Vasiliy Kulikov
2010-10-11 12:00 ` Mark Brown
2010-10-11 12:15 ` Vasiliy Kulikov
2010-10-11 12:36 ` Mark Brown
2010-10-11 12:50 ` Vasiliy Kulikov
2010-10-11 12:59 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox