Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1402794

Re: [PATCH] support for AD5820 camera auto-focus coil

From Pavel Machek <pavel@ucw.cz>
Newsgroups linux.kernel
Subject Re: [PATCH] support for AD5820 camera auto-focus coil
Date 2016-05-18 10:40 +0200
Message-ID <rA5bj-83w-9@gated-at.bofh.it> (permalink)
References <rzRL3-7Yd-5@gated-at.bofh.it> <rzS4q-875-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi!

...
> Use module_i2c_driver() instead.

Thanks for all the comments, I've fixed it up like this, will post new
version soon.

Best regards,
								Pavel

commit 97a793fb20be29e7ed217c007e8bf857f9854968
Author: Pavel <pavel@ucw.cz>
Date:   Wed May 18 10:22:06 2016 +0200

    Cleanups, as suggested by Marcus Folkesson

diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
index b71cc11..7725829 100644
--- a/drivers/media/i2c/ad5820.c
+++ b/drivers/media/i2c/ad5820.c
@@ -147,7 +147,6 @@ static int ad5820_set_ctrl(struct v4l2_ctrl *ctrl)
 	struct ad5820_device *coil =
 		container_of(ctrl->handler, struct ad5820_device, ctrls);
 	u32 code;
-	int r = 0;
 
 	switch (ctrl->id) {
 	case V4L2_CID_FOCUS_ABSOLUTE:
@@ -165,7 +164,7 @@ static int ad5820_set_ctrl(struct v4l2_ctrl *ctrl)
 		break;
 	}
 
-	return r;
+	return 0;
 }
 
 static const struct v4l2_ctrl_ops ad5820_ctrl_ops = {
@@ -245,8 +244,6 @@ static int ad5820_init_controls(struct ad5820_device *coil)
  */
 static int ad5820_registered(struct v4l2_subdev *subdev)
 {
-	static const int CHECK_VALUE = 0x3FF0;
-
 	struct ad5820_device *coil = to_ad5820_device(subdev);
 	struct i2c_client *client = v4l2_get_subdevdata(subdev);
 
@@ -364,16 +361,19 @@ static int ad5820_probe(struct i2c_client *client,
 	strcpy(coil->subdev.name, "ad5820 focus");
 
 	ret = media_entity_pads_init(&coil->subdev.entity, 0, NULL);
-	if (ret < 0) {
-		kfree(coil);
-		return ret;
-	}
+	if (ret < 0)
+		goto free;
 
 	ret = v4l2_async_register_subdev(&coil->subdev);
 	if (ret < 0)
-		kfree(coil);
+		goto cleanup;
 
 	return ret;
+cleanup:
+	media_entity_cleanup(&coil->subdev.entity);
+free:
+	kfree(coil);
+	return ret;
 }
 
 static int __exit ad5820_remove(struct i2c_client *client)
@@ -409,26 +409,7 @@ static struct i2c_driver ad5820_i2c_driver = {
 	.id_table	= ad5820_id_table,
 };
 
-static int __init ad5820_init(void)
-{
-	int rval;
-
-	rval = i2c_add_driver(&ad5820_i2c_driver);
-	if (rval)
-		printk(KERN_INFO "%s: failed registering " AD5820_NAME "\n",
-		       __func__);
-
-	return rval;
-}
-
-static void __exit ad5820_exit(void)
-{
-	i2c_del_driver(&ad5820_i2c_driver);
-}
-
-
-module_init(ad5820_init);
-module_exit(ad5820_exit);
+module_i2c_driver(ad5820_i2c_driver);
 
 MODULE_AUTHOR("Tuukka Toivonen");
 MODULE_DESCRIPTION("AD5820 camera lens driver");

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-17 20:20 +0200
  Re: [PATCH] support for AD5820 camera auto-focus coil Marcus Folkesson <marcus.folkesson@gmail.com> - 2016-05-17 20:40 +0200
    Re: [PATCH] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-18 10:40 +0200
  [PATCHv2] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-21 07:50 +0200
    Re: [PATCHv2] support for AD5820 camera auto-focus coil Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-05-21 08:30 +0200
      [PATCHv3] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-21 13:00 +0200
        Re: [PATCHv3] support for AD5820 camera auto-focus coil Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-05-21 13:50 +0200
          Re: [PATCHv3] support for AD5820 camera auto-focus coil Pali Rohár <pali.rohar@gmail.com> - 2016-05-23 09:50 +0200
          Re: [PATCHv3] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-24 11:10 +0200
            Re: [PATCHv3] support for AD5820 camera auto-focus coil Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-05-24 11:20 +0200
              Re: [PATCHv3] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-24 22:30 +0200
                Re: [PATCHv3] support for AD5820 camera auto-focus coil Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-05-26 05:50 +0200
            [PATCHv4] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-24 11:20 +0200
              Re: [PATCHv4] support for AD5820 camera auto-focus coil Sakari Ailus <sakari.ailus@iki.fi> - 2016-05-25 23:30 +0200
                Re: [PATCHv4] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-27 22:40 +0200
                [PATCHv5] support for AD5820 camera auto-focus coil Pavel Machek <pavel@ucw.cz> - 2016-05-27 23:00 +0200

csiph-web