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: 9116921 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 467B2BF29F for ; Wed, 18 May 2016 08:31:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69AB4202AE for ; Wed, 18 May 2016 08:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 798A62010C for ; Wed, 18 May 2016 08:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752664AbcERIa7 (ORCPT ); Wed, 18 May 2016 04:30:59 -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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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");