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: 9116951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DDAAB9F1C1 for ; Wed, 18 May 2016 08:32:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA57E202EC for ; Wed, 18 May 2016 08:32:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFD5220138 for ; Wed, 18 May 2016 08:32:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2wsr-0003ea-Cu; Wed, 18 May 2016 08:31:13 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2wso-0002iX-Hv for linux-arm-kernel@lists.infradead.org; Wed, 18 May 2016 08:31:11 +0000 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160518_013110_778427_5B0BB611 X-CRM114-Status: GOOD ( 15.41 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ivo.g.dimitrov.75@gmail.com, linux-media@vger.kernel.org, khilman@kernel.org, tony@atomide.com, mchehab@osg.samsung.com, aaro.koskinen@iki.fi, kernel list , sre@kernel.org, sakari.ailus@iki.fi, pali.rohar@gmail.com, linux-omap@vger.kernel.org, patrikbachan@gmail.com, linux-arm-kernel , serge@hallyn.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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");