Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1516364imd; Thu, 1 Nov 2018 17:33:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5eeSHf8TzUKwVneiFyv7iiu9pRHZOyHsEZIH6jzEXpcT0B7dizFdtoRGXAymMk+66yPtsyc X-Received: by 2002:a63:a30a:: with SMTP id s10mr8578382pge.234.1541118796814; Thu, 01 Nov 2018 17:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541118796; cv=none; d=google.com; s=arc-20160816; b=wVieINguYccpyAkmueVW+QblP3EDVbCfCJM+BFrfwBEzv3SRIW4kY6VFdL2JFfVMAe YVhKM31EsJQF2ww5WsvcQ624HeLIqIrTU+46AjzpO+Vh6LERK6gDeB3FYmX6LF9zlXx0 7q8BKqohBlhCQx4oV+sSGUiU//H/Dx/Vg7kFOR+jpALz3itlN0O7Z/8gpNxUHRwE2HjA Qi/rg0KKlK8VZb18mT3+ywcf7fcgmo0aLjh/Io40ec8PM6lfp9tUq2vCS+/PR2g3H6kS nDZw+umjWw6QRyaJ/rZnGWHvnxKHzBiNcGyugFJBMWpyw6BUmtao/V4s9Sgzzs5D8Fp6 OKUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=2riaIq/X/8LCQd2KpobBi+jSZIrZWd9o7SpWxU4ZfIA=; b=SeYglAkHNuyf6S1o2ZYzwiFzrqjS7KQ1SZSlArVCsgbnzrePS/y0jLOF7peS1JNfkL IOOyc7WT0btgVsRY8XkYMplfk+Fwd887gzCSOtOwS3xzGOJqO3CSM/c8FTtXbk7pdOgG YkZiS+GrxNUrgI+3G3bZg0GoVaH4CHSoZ5GMeYnTRn2xHzEBnCcYGIKv8hw2wFI5cIz+ fdMI2vy5FZOGoYEzBSerFTyTWUI6DpyRcyu6A7YXS0VN3CO3r645iSu7hrcOp5rB9aWx q62EPV3a/hE7gk8mJ1ZjmhM86qKLJ1mOv9nAdf5u4rcYL+4tNGhenVR2VlFIHMiMmodS mklA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PWpmzX3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si32166757pgs.356.2018.11.01.17.33.01; Thu, 01 Nov 2018 17:33:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PWpmzX3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728422AbeKBJg6 (ORCPT + 99 others); Fri, 2 Nov 2018 05:36:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:41874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728058AbeKBJg5 (ORCPT ); Fri, 2 Nov 2018 05:36:57 -0400 Received: from localhost.localdomain (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF6BA2082E; Fri, 2 Nov 2018 00:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541118705; bh=05Uvfrcry3CTIRujcJGjHXPRkFbZQdevDJEoAb9ZAZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=PWpmzX3TlN2wsUHUAmCTGVwJLHRZ0IdTpiNoKuXWMSHrfUX7m1jDrOmzslf9H02qT 0oM0hwGDMur+caK+Vo3fFULEKlDS6YuaE6KG3V4AZe3YX0AM5PyeJ5pVxwIlQ8AdE+ BXYKk3WB94KdNBvExFNjcQE3900J7k/6XWkA77ks= From: shuah@kernel.org To: mchehab@kernel.org, perex@perex.cz, tiwai@suse.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [RFC PATCH v8 2/4] media: change au0828 to use Media Device Allocator API Date: Thu, 1 Nov 2018 18:31:31 -0600 Message-Id: <0f9977e1d2ab39e8b8e5f0307ee89cfca012c9f3.1541109584.git.shuah@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuah Khan 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 --- 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 cd363a2100d4..837409d190a1 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -155,9 +155,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev) dev->media_dev->disable_source = NULL; mutex_unlock(&mdev->graph_mutex); - 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 } @@ -210,14 +208,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; @@ -478,6 +472,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 004eadef55c7..7dbe3db15ebe 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h @@ -31,6 +31,7 @@ #include #include #include +#include /* DVB */ #include -- 2.17.0