From: David Ellingsworth <david@identd.dyndns.org>
To: linux-media@vger.kernel.org
Cc: Markus Demleitner <msdemlei@tucana.harvard.edu>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
David Ellingsworth <david@identd.dyndns.org>
Subject: [PATCH/RFC v2 7/8] dsbr100: cleanup usb probe routine
Date: Thu, 27 May 2010 12:39:15 -0400 [thread overview]
Message-ID: <1274978356-25836-8-git-send-email-david@identd.dyndns.org> (raw)
In-Reply-To: <[PATCH/RFC 0/7] dsbr100: driver cleanup>
This patch simplifies the error paths within the
usb_dsbr100_probe routine. It also removes an unnecessary
local variable.
Signed-off-by: David Ellingsworth <david@identd.dyndns.org>
---
drivers/media/radio/dsbr100.c | 39 ++++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 96e6128..81e6aa5 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -645,33 +645,28 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct dsbr100_device *radio;
- struct v4l2_device *v4l2_dev;
int retval;
radio = kzalloc(sizeof(struct dsbr100_device), GFP_KERNEL);
-
if (!radio)
return -ENOMEM;
radio->transfer_buffer = kmalloc(TB_LEN, GFP_KERNEL);
-
if (!(radio->transfer_buffer)) {
- kfree(radio);
- return -ENOMEM;
+ retval = -ENOMEM;
+ goto err_nobuf;
}
- v4l2_dev = &radio->v4l2_dev;
-
- retval = v4l2_device_register(&intf->dev, v4l2_dev);
+ retval = v4l2_device_register(&intf->dev, &radio->v4l2_dev);
if (retval < 0) {
- v4l2_err(v4l2_dev, "couldn't register v4l2_device\n");
- kfree(radio->transfer_buffer);
- kfree(radio);
- return retval;
+ v4l2_err(&radio->v4l2_dev, "couldn't register v4l2_device\n");
+ goto err_v4l2;
}
- strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name));
- radio->videodev.v4l2_dev = v4l2_dev;
+ strlcpy(radio->videodev.name, radio->v4l2_dev.name,
+ sizeof(radio->videodev.name));
+
+ radio->videodev.v4l2_dev = &radio->v4l2_dev;
radio->videodev.fops = &usb_dsbr100_fops;
radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops;
radio->videodev.release = usb_dsbr100_video_device_release;
@@ -685,14 +680,20 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr);
if (retval < 0) {
- v4l2_err(v4l2_dev, "couldn't register video device\n");
- v4l2_device_unregister(v4l2_dev);
- kfree(radio->transfer_buffer);
- kfree(radio);
- return -EIO;
+ v4l2_err(&radio->v4l2_dev, "couldn't register video device\n");
+ goto err_vdev;
}
+
usb_set_intfdata(intf, radio);
return 0;
+
+err_vdev:
+ v4l2_device_unregister(&radio->v4l2_dev);
+err_v4l2:
+ kfree(radio->transfer_buffer);
+err_nobuf:
+ kfree(radio);
+ return retval;
}
static int __init dsbr100_init(void)
--
1.7.1
next prev parent reply other threads:[~2010-05-27 16:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH/RFC 0/7] dsbr100: driver cleanup>
2010-05-27 16:39 ` [PATCH/RFC v2 0/8] dsbr100: driver cleanup and fixes David Ellingsworth
2010-07-07 22:19 ` David Ellingsworth
2010-09-14 14:56 ` David Ellingsworth
2010-09-14 15:25 ` Douglas Schilling Landgraf
2010-10-01 12:43 ` David Ellingsworth
2010-10-01 13:17 ` Bjørn Mork
2010-05-27 16:39 ` [PATCH/RFC v2 1/8] dsbr100: implement proper locking David Ellingsworth
2010-05-27 16:39 ` [PATCH/RFC v2 2/8] dsbr100: fix potential use after free David Ellingsworth
2010-05-27 16:39 ` [PATCH/RFC v2 3/8] dsbr100: only change frequency upon success David Ellingsworth
2010-05-27 16:39 ` [PATCH/RFC v2 4/8] dsbr100: remove disconnected indicator David Ellingsworth
2010-05-27 16:39 ` [PATCH/RFC v2 5/8] dsbr100: cleanup return value of start/stop handlers David Ellingsworth
2010-05-27 16:39 ` [PATCH/RFC v2 6/8] dsbr100: properly initialize the radio David Ellingsworth
2010-05-27 16:39 ` David Ellingsworth [this message]
2010-05-27 16:39 ` [PATCH/RFC v2 8/8] dsbr100: simplify access to radio device David Ellingsworth
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=1274978356-25836-8-git-send-email-david@identd.dyndns.org \
--to=david@identd.dyndns.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=msdemlei@tucana.harvard.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).