From patchwork Tue Feb 22 09:57:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 579941 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 p1M9vlLr029130 for ; Tue, 22 Feb 2011 09:57:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752015Ab1BVJ5q (ORCPT ); Tue, 22 Feb 2011 04:57:46 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:50803 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902Ab1BVJ5o (ORCPT ); Tue, 22 Feb 2011 04:57:44 -0500 Received: from axis700.grange (pD9EB8B24.dip0.t-ipconnect.de [217.235.139.36]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MKdqV-1Ps6Vv3ukR-001vyX; Tue, 22 Feb 2011 10:57:41 +0100 Received: by axis700.grange (Postfix, from userid 1000) id A2DD4189B80; Tue, 22 Feb 2011 10:57:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 9FD1E189B7F; Tue, 22 Feb 2011 10:57:40 +0100 (CET) Date: Tue, 22 Feb 2011 10:57:40 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List cc: linux-sh@vger.kernel.org, Kuninori Morimoto Subject: [PATCH 1/3] V4L: soc_camera_platform: add helper functions to manage device instances In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:QjJV0Dyfw1mReI6x2lhn0wnSo0EyI/sFJc6rj2c6asw 9m/gqmDjhFrolgSjkdP+eab9jrLdmLby82+g2FoRtHoddzvPlW UpuW3OrkDyDkClQfTvZ+hVxDdjBKuVGNRGMqHz0Gy7lMTdv8T0 n8CQnxcRr/fTRWdqcT35UFL1SW7M6m+SXHq6nb1qT2z1jb6nH0 qPJBGqdwIxxEPfw8fsKuE6bcWhR1o5XjC9GVz+U0VM= 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]); Tue, 22 Feb 2011 09:57:47 +0000 (UTC) diff --git a/include/media/soc_camera_platform.h b/include/media/soc_camera_platform.h index 0ecefe2..fbf4b79 100644 --- a/include/media/soc_camera_platform.h +++ b/include/media/soc_camera_platform.h @@ -25,4 +25,53 @@ 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; + + (*pdev)->dev.platform_data = info; + (*pdev)->dev.release = release; + + ret = platform_device_add(*pdev); + if (ret < 0) { + platform_device_put(*pdev); + *pdev = NULL; + } else { + info->dev = dev; + } + + return 0; +} + +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__ */