From patchwork Fri Sep 28 10:50:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 1518631 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 74175DF283 for ; Fri, 28 Sep 2012 10:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757464Ab2I1KvT (ORCPT ); Fri, 28 Sep 2012 06:51:19 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:37287 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757271Ab2I1KvT (ORCPT ); Fri, 28 Sep 2012 06:51:19 -0400 Received: by mail-we0-f174.google.com with SMTP id t9so1269622wey.19 for ; Fri, 28 Sep 2012 03:51:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=lalSdyeLu6bxB1FDfkpmVZ91JIH9VLIS2Fws62szZKk=; b=iJAsjK5bd0S0ysWUdRVFc5z2FBYBsfWEFMrlL/pL5qXn64TKQx6mQJRhQmgsKIgjeD hFby7nOYfz0exX+F3YBYJa2wlonD20wSeB56w1Z3DvIOLFoXDsemMdVyCVQ4QrPYxAjA KabjHn/xn1sLhD2IEK9hvWSUh99QMlA/D8r9CWSfI1iRx7uOudg4D7g+O6fp9bm4iAHZ eS8U6Pw8swe42hd17faw1HXvP210yhASfDkhu7rbIsHBBKvKK7oPEybwxw6h0KDsGrYh AV40ixK4qYSxmu4HM5lcyS1M1F2i6mrgAwIwPMjJboDSPbaQ+Ob+rz8uFZrowqAlZJXb +3GA== Received: by 10.216.243.10 with SMTP id j10mr3323863wer.211.1348829478403; Fri, 28 Sep 2012 03:51:18 -0700 (PDT) Received: from piscis.vsilicon.net (122.251.106.212.dynamic.jazztel.es. [212.106.251.122]) by mx.google.com with ESMTPS id cu1sm36060860wib.6.2012.09.28.03.51.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Sep 2012 03:51:18 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl, rusty@rustcorp.com.au, dsd@laptop.org, mchehab@infradead.org, corbet@lwn.net, hdegoede@redhat.com, Javier Martin Subject: [PATCH v2 3/4] via-camera: implement the control framework. Date: Fri, 28 Sep 2012 12:50:57 +0200 Message-Id: <1348829458-13812-4-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348829458-13812-1-git-send-email-javier.martin@vista-silicon.com> References: <1348829458-13812-1-git-send-email-javier.martin@vista-silicon.com> X-Gm-Message-State: ALoCoQmn/HqBvn8XeAEh7DtPT9qQRWil2NBCkLuL6ub/X0rTwK4p42bsGU92NnSV2xEGL/SVzyBs Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org And added a missing kfree to clean up the via_camera struct. Signed-off-by: Hans Verkuil Signed-off-by: Javier Martin --- drivers/media/platform/via-camera.c | 60 ++++++++--------------------------- 1 file changed, 14 insertions(+), 46 deletions(-) diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c index eb404c2..1b5f97d 100644 --- a/drivers/media/platform/via-camera.c +++ b/drivers/media/platform/via-camera.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,7 @@ enum viacam_opstate { S_IDLE = 0, S_RUNNING = 1 }; struct via_camera { struct v4l2_device v4l2_dev; + struct v4l2_ctrl_handler ctrl_handler; struct video_device vdev; struct v4l2_subdev *sensor; struct platform_device *platdev; @@ -818,47 +820,6 @@ static int viacam_g_chip_ident(struct file *file, void *priv, } /* - * Control ops are passed through to the sensor. - */ -static int viacam_queryctrl(struct file *filp, void *priv, - struct v4l2_queryctrl *qc) -{ - struct via_camera *cam = priv; - int ret; - - mutex_lock(&cam->lock); - ret = sensor_call(cam, core, queryctrl, qc); - mutex_unlock(&cam->lock); - return ret; -} - - -static int viacam_g_ctrl(struct file *filp, void *priv, - struct v4l2_control *ctrl) -{ - struct via_camera *cam = priv; - int ret; - - mutex_lock(&cam->lock); - ret = sensor_call(cam, core, g_ctrl, ctrl); - mutex_unlock(&cam->lock); - return ret; -} - - -static int viacam_s_ctrl(struct file *filp, void *priv, - struct v4l2_control *ctrl) -{ - struct via_camera *cam = priv; - int ret; - - mutex_lock(&cam->lock); - ret = sensor_call(cam, core, s_ctrl, ctrl); - mutex_unlock(&cam->lock); - return ret; -} - -/* * Only one input. */ static int viacam_enum_input(struct file *filp, void *priv, @@ -1214,9 +1175,6 @@ static int viacam_enum_frameintervals(struct file *filp, void *priv, static const struct v4l2_ioctl_ops viacam_ioctl_ops = { .vidioc_g_chip_ident = viacam_g_chip_ident, - .vidioc_queryctrl = viacam_queryctrl, - .vidioc_g_ctrl = viacam_g_ctrl, - .vidioc_s_ctrl = viacam_s_ctrl, .vidioc_enum_input = viacam_enum_input, .vidioc_g_input = viacam_g_input, .vidioc_s_input = viacam_s_input, @@ -1418,8 +1376,12 @@ static __devinit int viacam_probe(struct platform_device *pdev) ret = v4l2_device_register(&pdev->dev, &cam->v4l2_dev); if (ret) { dev_err(&pdev->dev, "Unable to register v4l2 device\n"); - return ret; + goto out_free; } + ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10); + if (ret) + goto out_unregister; + cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler; /* * Convince the system that we can do DMA. */ @@ -1436,7 +1398,7 @@ static __devinit int viacam_probe(struct platform_device *pdev) */ ret = via_sensor_power_setup(cam); if (ret) - goto out_unregister; + goto out_ctrl_hdl_free; via_sensor_power_up(cam); /* @@ -1485,8 +1447,12 @@ out_irq: free_irq(viadev->pdev->irq, cam); out_power_down: via_sensor_power_release(cam); +out_ctrl_hdl_free: + v4l2_ctrl_handler_free(&cam->ctrl_handler); out_unregister: v4l2_device_unregister(&cam->v4l2_dev); +out_free: + kfree(cam); return ret; } @@ -1499,6 +1465,8 @@ static __devexit int viacam_remove(struct platform_device *pdev) v4l2_device_unregister(&cam->v4l2_dev); free_irq(viadev->pdev->irq, cam); via_sensor_power_release(cam); + v4l2_ctrl_handler_free(&cam->ctrl_handler); + kfree(cam); via_cam_info = NULL; return 0; }