From patchwork Sun Nov 8 14:09:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 58544 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA8E9Lnj022906 for ; Sun, 8 Nov 2009 14:09:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753904AbZKHOJO (ORCPT ); Sun, 8 Nov 2009 09:09:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753901AbZKHOJO (ORCPT ); Sun, 8 Nov 2009 09:09:14 -0500 Received: from mail.gmx.net ([213.165.64.20]:59184 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753864AbZKHOJO (ORCPT ); Sun, 8 Nov 2009 09:09:14 -0500 Received: (qmail invoked by alias); 08 Nov 2009 14:09:18 -0000 Received: from p57BD19F0.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.25.240] by mail.gmx.net (mp035) with SMTP; 08 Nov 2009 15:09:18 +0100 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX1/i2N5ZxT7i/DhzgqtNEWGPJBt1XVXuS1iR3T3bNl KKgpMC6vlchfGn Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1N78SX-000633-8V for linux-media@vger.kernel.org; Sun, 08 Nov 2009 15:09:37 +0100 Date: Sun, 8 Nov 2009 15:09:37 +0100 (CET) From: Guennadi Liakhovetski To: Linux Media Mailing List Subject: [PATCH] soc-camera: properly initialise the device object when reusing Message-ID: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.49 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 36e617b..95fdeb2 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -1097,6 +1097,13 @@ static int default_s_crop(struct soc_camera_device *icd, struct v4l2_crop *a) return v4l2_subdev_call(sd, video, s_crop, a); } +static void soc_camera_device_init(struct device *dev, void *pdata) +{ + dev->platform_data = pdata; + dev->bus = &soc_camera_bus_type; + dev->release = dummy_release; +} + int soc_camera_host_register(struct soc_camera_host *ici) { struct soc_camera_host *ix; @@ -1158,6 +1165,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici) list_for_each_entry(icd, &devices, list) { if (icd->iface == ici->nr) { + void *pdata = icd->dev.platform_data; /* The bus->remove will be called */ device_unregister(&icd->dev); /* @@ -1169,6 +1177,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici) * device private data. */ memset(&icd->dev, 0, sizeof(icd->dev)); + soc_camera_device_init(&icd->dev, pdata); } } @@ -1200,10 +1209,7 @@ static int soc_camera_device_register(struct soc_camera_device *icd) * man, stay reasonable... */ return -ENOMEM; - icd->devnum = num; - icd->dev.bus = &soc_camera_bus_type; - - icd->dev.release = dummy_release; + icd->devnum = num; icd->use_count = 0; icd->host_priv = NULL; mutex_init(&icd->video_lock); @@ -1311,12 +1317,13 @@ static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) icd->iface = icl->bus_id; icd->pdev = &pdev->dev; platform_set_drvdata(pdev, icd); - icd->dev.platform_data = icl; ret = soc_camera_device_register(icd); if (ret < 0) goto escdevreg; + soc_camera_device_init(&icd->dev, icl); + icd->user_width = DEFAULT_WIDTH; icd->user_height = DEFAULT_HEIGHT;