From patchwork Wed Nov 16 14:29:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 9431721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A264F60469 for ; Wed, 16 Nov 2016 14:29:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 932BA2816B for ; Wed, 16 Nov 2016 14:29:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 858EC26785; Wed, 16 Nov 2016 14:29:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D106C26785 for ; Wed, 16 Nov 2016 14:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932346AbcKPO3W (ORCPT ); Wed, 16 Nov 2016 09:29:22 -0500 Received: from resqmta-po-01v.sys.comcast.net ([96.114.154.160]:60644 "EHLO resqmta-po-01v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752206AbcKPO3T (ORCPT ); Wed, 16 Nov 2016 09:29:19 -0500 Received: from resomta-po-12v.sys.comcast.net ([96.114.154.236]) by resqmta-po-01v.sys.comcast.net with SMTP id 71Cgc9fJeucHZ71DCcHvKl; Wed, 16 Nov 2016 14:29:18 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-12v.sys.comcast.net with SMTP id 71DAcNQvxjuMt71DAcxj8A; Wed, 16 Nov 2016 14:29:18 +0000 Received: from localhost.localdomain (shuah-xps.internal [192.168.1.87]) by mail.gonehiking.org (Postfix) with ESMTP id 8F7409F4E5; Wed, 16 Nov 2016 07:29:15 -0700 (MST) From: Shuah Khan To: mchehab@kernel.org, perex@perex.cz, tiwai@suse.com, hans.verkuil@cisco.com, javier@osg.samsung.com, chehabrafael@gmail.com, g.liakhovetski@gmx.de, ONeukum@suse.com, k@oikw.org, daniel@zonque.org, mahasler@gmail.com, clemens@ladisch.de, geliangtang@163.com, vdronov@redhat.com, laurent.pinchart@ideasonboard.com Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH v4 2/3] media: change au0828 to use Media Device Allocator API Date: Wed, 16 Nov 2016 07:29:10 -0700 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-CMAE-Envelope: MS4wfFwQ/v1qrOSan7PS7iJYlXFTgjUY5vh0yBd2s12EGM76vxesil9E0P0C+O+l0dIjF0JNaPcA+/94kCW1dDCsJDbBjyfYI9zA5bcNdMVb42SES/BC4Az7 JqBFWq85tTXFNFe767bqZiub2098JZBwFhCk6r1fZ8pwvFhvMTmMqOOP7G7HcrRt6ggPQBL6stYHOY8DRuZ6ikbV0Ye0BzmO6yi4A4/7dqM46pMvNh1qcSmd HT5u29eJoMJPnmdxZQSXsJqUWedHuNxiCXWfY08D5o72KvDCJByynutlJCubbF43PKi6858JVaEuqn+eaJs6Kv+szOkGcrCYY7F0Q8qdGiqHHWul5T4fFmP2 MkJJPGYFoQxYtkD56oTQHM4zUYtmp7F5nnO03jo12SE67O/5m2Qj1yGID5/llJn7f7tKUqjclRuDzsENkfb3EiA9cUrMvi4tzMdqKPeCRPWT/8s7/K0ZyXAh 4hSx92IFk1t3aDOK1LU/gPYtU9JkN4cxVeqUHtQoIBuov8flVrP9KO18j8erj8dIMweynp/6Om8GdjovrAh93nckdVj1xjiF5nRuLGG9VCoJSm8Bl2dttVWo 89upFYxAr58JNGV5barWV+D9RdtVCwJO1YeuYzg1J/l8hJOdD7RQBPqpo8Cnu2CUiyP7OlZFRb0foTBJUqSBxulbWGEsAmbTl9dnQ5iZGhM3uZbx8AilamEG OTaXvUiqPD+7HrKu1exBLDyPfK/5cGy1BEWzVSnBFRArKqhV/lPeuA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change au0828 to use Media Device Allocator API to allocate media device with the parent usb struct device as the key, so it can be shared with the snd_usb_audio driver. Signed-off-by: Shuah Khan Reviewed-by: Mauro Carvalho Chehab --- Changes since v2: - Updated media_device_delete() to pass in module name. drivers/media/usb/au0828/au0828-core.c | 12 ++++-------- drivers/media/usb/au0828/au0828.h | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index bf53553..582f31f 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -157,9 +157,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev) dev->media_dev->enable_source = NULL; dev->media_dev->disable_source = NULL; - media_device_unregister(dev->media_dev); - media_device_cleanup(dev->media_dev); - kfree(dev->media_dev); + media_device_delete(dev->media_dev, KBUILD_MODNAME); dev->media_dev = NULL; #endif } @@ -212,14 +210,10 @@ static int au0828_media_device_init(struct au0828_dev *dev, #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev; - mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + mdev = media_device_usb_allocate(udev, KBUILD_MODNAME); if (!mdev) return -ENOMEM; - /* check if media device is already initialized */ - if (!mdev->dev) - media_device_usb_init(mdev, udev, udev->product); - dev->media_dev = mdev; #endif return 0; @@ -487,6 +481,8 @@ static int au0828_media_device_register(struct au0828_dev *dev, /* register media device */ ret = media_device_register(dev->media_dev); if (ret) { + media_device_delete(dev->media_dev, KBUILD_MODNAME); + dev->media_dev = NULL; dev_err(&udev->dev, "Media Device Register Error: %d\n", ret); return ret; diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h index dd7b378..4bf1b0c 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h @@ -35,6 +35,7 @@ #include #include #include +#include /* DVB */ #include "demux.h"