From patchwork Fri Dec 13 12:03:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 3339841 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BCFFF9F243 for ; Fri, 13 Dec 2013 12:01:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1586B207C3 for ; Fri, 13 Dec 2013 12:01:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B42E207B0 for ; Fri, 13 Dec 2013 12:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752244Ab3LMMBV (ORCPT ); Fri, 13 Dec 2013 07:01:21 -0500 Received: from mga01.intel.com ([192.55.52.88]:2133 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496Ab3LMMBV (ORCPT ); Fri, 13 Dec 2013 07:01:21 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 13 Dec 2013 04:01:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,478,1384329600"; d="scan'208";a="449532207" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga002.fm.intel.com with ESMTP; 13 Dec 2013 04:01:19 -0800 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id D701A200F4 for ; Fri, 13 Dec 2013 14:01:18 +0200 (EET) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id C508E2010D; Fri, 13 Dec 2013 14:03:36 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [RFC 1/2] media: Use a better owner for the media device Date: Fri, 13 Dec 2013 14:03:35 +0200 Message-Id: <1386936216-32296-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 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 mdev->fops->owner is actually the owner of the very same module which implements media_device_register(), so it can't be unloaded anyway. Instead, use THIS_MODULE through a macro as does video_register_device(). Signed-off-by: Sakari Ailus Acked-by: Laurent Pinchart --- drivers/media/media-device.c | 7 ++++--- drivers/media/media-devnode.c | 5 +++-- include/media/media-device.h | 4 +++- include/media/media-devnode.h | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index d5a7a13..51217f0 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -372,7 +372,8 @@ static void media_device_release(struct media_devnode *mdev) * - dev must point to the parent device * - model must be filled with the device model name */ -int __must_check media_device_register(struct media_device *mdev) +int __must_check __media_device_register(struct media_device *mdev, + struct module *owner) { int ret; @@ -388,7 +389,7 @@ int __must_check media_device_register(struct media_device *mdev) mdev->devnode.fops = &media_device_fops; mdev->devnode.parent = mdev->dev; mdev->devnode.release = media_device_release; - ret = media_devnode_register(&mdev->devnode); + ret = media_devnode_register(&mdev->devnode, owner); if (ret < 0) return ret; @@ -400,7 +401,7 @@ int __must_check media_device_register(struct media_device *mdev) return 0; } -EXPORT_SYMBOL_GPL(media_device_register); +EXPORT_SYMBOL_GPL(__media_device_register); /** * media_device_unregister - unregister a media device diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c index fb0f046..7acd19c 100644 --- a/drivers/media/media-devnode.c +++ b/drivers/media/media-devnode.c @@ -232,7 +232,8 @@ static const struct file_operations media_devnode_fops = { * the media_devnode structure is *not* called, so the caller is responsible for * freeing any data. */ -int __must_check media_devnode_register(struct media_devnode *mdev) +int __must_check media_devnode_register(struct media_devnode *mdev, + struct module *owner) { int minor; int ret; @@ -253,7 +254,7 @@ int __must_check media_devnode_register(struct media_devnode *mdev) /* Part 2: Initialize and register the character device */ cdev_init(&mdev->cdev, &media_devnode_fops); - mdev->cdev.owner = mdev->fops->owner; + mdev->cdev.owner = owner; ret = cdev_add(&mdev->cdev, MKDEV(MAJOR(media_dev_t), mdev->minor), 1); if (ret < 0) { diff --git a/include/media/media-device.h b/include/media/media-device.h index 12155a9..6e6db78 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -87,7 +87,9 @@ struct media_device { /* media_devnode to media_device */ #define to_media_device(node) container_of(node, struct media_device, devnode) -int __must_check media_device_register(struct media_device *mdev); +int __must_check __media_device_register(struct media_device *mdev, + struct module *owner); +#define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE) void media_device_unregister(struct media_device *mdev); int __must_check media_device_register_entity(struct media_device *mdev, diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h index 3446af2..0dc7060 100644 --- a/include/media/media-devnode.h +++ b/include/media/media-devnode.h @@ -82,7 +82,8 @@ struct media_devnode { /* dev to media_devnode */ #define to_media_devnode(cd) container_of(cd, struct media_devnode, dev) -int __must_check media_devnode_register(struct media_devnode *mdev); +int __must_check media_devnode_register(struct media_devnode *mdev, + struct module *owner); void media_devnode_unregister(struct media_devnode *mdev); static inline struct media_devnode *media_devnode_data(struct file *filp)