From patchwork Wed Mar 23 09:16:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 654711 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2N9ROv9013802 for ; Wed, 23 Mar 2011 09:28:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756021Ab1CWJQ2 (ORCPT ); Wed, 23 Mar 2011 05:16:28 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:54797 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755943Ab1CWJQ1 (ORCPT ); Wed, 23 Mar 2011 05:16:27 -0400 Received: from axis700.grange (pD9EB90DE.dip0.t-ipconnect.de [217.235.144.222]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0Lm8NJ-1PSiRU0myv-00ZhtD; Wed, 23 Mar 2011 10:16:25 +0100 Received: by axis700.grange (Postfix, from userid 1000) id B4321189B86; Wed, 23 Mar 2011 10:16:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id AB32F189B85; Wed, 23 Mar 2011 10:16:24 +0100 (CET) Date: Wed, 23 Mar 2011 10:16:24 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List cc: Magnus Damm Subject: [PATCH 1/3 v2] V4L: soc_camera_platform: add helper functions to manage device instances Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:0Hd4ZbuiAlUgP5SlYOIFSjXbISjC8jlNViV/o7iclY+ F6uYSxpHhndW9Px9lKjHiQT1E8xSIVYFeSoQUY505Jhauc8yQW 9nSfOxD/I+6zpgDg96G+tBAHyKorQ/GYdPWjRW6jdx/WsSSWN9 6M65Fk7p1LKx4lDfecYw39tPtuPE5wBEjjsSoSA5vBcB0p4YYg ztRKfEC919cU55i3iyggztyHjpSRhNwW0CfbiGGQjY= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 23 Mar 2011 09:28:16 +0000 (UTC) diff --git a/include/media/soc_camera_platform.h b/include/media/soc_camera_platform.h index 0ecefe2..6d7a4fd 100644 --- a/include/media/soc_camera_platform.h +++ b/include/media/soc_camera_platform.h @@ -25,4 +25,54 @@ struct soc_camera_platform_info { int (*set_capture)(struct soc_camera_platform_info *info, int enable); }; +static inline void soc_camera_platform_release(struct platform_device **pdev) +{ + *pdev = NULL; +} + +static inline int soc_camera_platform_add(const struct soc_camera_link *icl, + struct device *dev, + struct platform_device **pdev, + struct soc_camera_link *plink, + void (*release)(struct device *dev), + int id) +{ + struct soc_camera_platform_info *info = plink->priv; + int ret; + + if (icl != plink) + return -ENODEV; + + if (*pdev) + return -EBUSY; + + *pdev = platform_device_alloc("soc_camera_platform", id); + if (!*pdev) + return -ENOMEM; + + info->dev = dev; + + (*pdev)->dev.platform_data = info; + (*pdev)->dev.release = release; + + ret = platform_device_add(*pdev); + if (ret < 0) { + platform_device_put(*pdev); + *pdev = NULL; + info->dev = NULL; + } + + return ret; +} + +static inline void soc_camera_platform_del(const struct soc_camera_link *icl, + struct platform_device *pdev, + const struct soc_camera_link *plink) +{ + if (icl != plink || !pdev) + return; + + platform_device_unregister(pdev); +} + #endif /* __SOC_CAMERA_H__ */