From patchwork Wed May 18 08:30:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 34333 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2wtC-0003IQ-Cg; Wed, 18 May 2016 08:31:34 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-5) with esmtp id 1b2wt7-0005iL-9X; Wed, 18 May 2016 10:31:32 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbcERIa6 (ORCPT + 1 other); Wed, 18 May 2016 04:30:58 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:41100 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752632AbcERIaw (ORCPT ); Wed, 18 May 2016 04:30:52 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 092F7823BD; Wed, 18 May 2016 10:30:48 +0200 (CEST) Date: Wed, 18 May 2016 10:30:48 +0200 From: Pavel Machek To: Marcus Folkesson Cc: pali.rohar@gmail.com, sre@kernel.org, kernel list , linux-arm-kernel , linux-omap@vger.kernel.org, tony@atomide.com, khilman@kernel.org, aaro.koskinen@iki.fi, ivo.g.dimitrov.75@gmail.com, patrikbachan@gmail.com, serge@hallyn.com, linux-media@vger.kernel.org, mchehab@osg.samsung.com, sakari.ailus@iki.fi Subject: Re: [PATCH] support for AD5820 camera auto-focus coil Message-ID: <20160518083048.GA30870@amd> References: <20160517181927.GA28741@amd> <20160517183340.GA10358@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160517183340.GA10358@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.5.18.82116 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, KNOWN_FREEWEB_URI 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, INVALID_MSGID_NO_FQDN 0, NO_URI_HTTPS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CP_URI_IN_BODY 0, __CT 0, __CT_TEXT_PLAIN 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __KNOWN_FREEWEB_URI2 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __MULTIPLE_URI_TEXT 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NS , __URI_WITH_PATH 0, __USER_AGENT 0' 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 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");