From patchwork Sat Feb 22 00:50:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 3700801 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A957BF13A for ; Sat, 22 Feb 2014 00:56:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E1832018B for ; Sat, 22 Feb 2014 00:56:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97AC12018A for ; Sat, 22 Feb 2014 00:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753575AbaBVA4o (ORCPT ); Fri, 21 Feb 2014 19:56:44 -0500 Received: from qmta06.emeryville.ca.mail.comcast.net ([76.96.30.56]:56648 "EHLO qmta06.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057AbaBVA4o (ORCPT ); Fri, 21 Feb 2014 19:56:44 -0500 Received: from omta18.emeryville.ca.mail.comcast.net ([76.96.30.74]) by qmta06.emeryville.ca.mail.comcast.net with comcast id VCjr1n0031bwxycA6CqfNN; Sat, 22 Feb 2014 00:50:39 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta18.emeryville.ca.mail.comcast.net with comcast id VCqd1n00x0MU7Qa8eCqeq7; Sat, 22 Feb 2014 00:50:38 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 9AF3340437; Fri, 21 Feb 2014 17:50:37 -0700 (MST) From: Shuah Khan To: m.chehab@samsung.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, shuahkhan@gmail.com Subject: [RFC] [PATCH 1/6] media: em28xx - add suspend/resume to em28xx_ops Date: Fri, 21 Feb 2014 17:50:13 -0700 Message-Id: X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1393030239; bh=GhU/Dk3uZpp+Wf+HUHGk2CgBnny0s9h6wWRzLtYekZM=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=tmB7+GVi4Ek2YFEnPEyJkAw82miXT9IAnnfl9oUbK8Tyr9l5w+rWpzSut3fhnUIXw UwI7+lDzOxW8VM8SQzzkj0AkCmYHBiuBmLlFtKsLxKkSxzEBparecIWA3+CzNiI0J0 magtd3DNWcI5KrempnGCWK4ZTdeO0d8owhdL2YsjdoOjR106zYHcjFb6zjNJKq13e9 CgCKlN3bYLVpBwY/mIQ9IGPLVTU1vUgGQ9wWE1TymO5GthpwFlokqUzfTWk7PfACn1 xMOjq6dDwlQlsEt4JmPziLNNkDCuFyYYgpVRRy5mc9WxXzDlNibZxrQsXHdGvChp5c Wi4lYZWt9MYCg== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 em28xx usb driver will have to suspend and resume its extensions. Adding suspend and resume to em28xx_ops gives extensions the ability to install suspend and resume that can be invoked from em28xx_usb driver suspend() and resume() interfaces. Approach: Add power management support to em28xx usb driver. This driver works in conjunction with extensions for each of the functions on the USB device for video/audio/dvb/remote functionality that is present on media USB devices it supports. During suspend and resume each of these extensions will have to do their part in suspending the components they control. Adding suspend and resume hooks to the existing struct em28xx_ops will enable the extensions the ability to implement suspend and resume hooks to be called from em28xx driver. The overall approach is as follows: -- add suspend and resume hooks to em28xx_ops -- add suspend and resume routines to em28xx-core to invoke suspend and resume hooks for all registered extensions. -- change em28xx dvb, audio, input, and video extensions to implement em28xx_ops: suspend and resume hooks. These hooks do what is necessary to suspend and resume the devices they control. Signed-off-by: Shuah Khan --- drivers/media/usb/em28xx/em28xx-core.c | 28 ++++++++++++++++++++++++++++ drivers/media/usb/em28xx/em28xx.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index 898fb9b..6de41c6 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c @@ -1106,3 +1106,31 @@ void em28xx_close_extension(struct em28xx *dev) list_del(&dev->devlist); mutex_unlock(&em28xx_devlist_mutex); } + +int em28xx_suspend_extension(struct em28xx *dev) +{ + const struct em28xx_ops *ops = NULL; + + em28xx_info("Suspending extensions"); + mutex_lock(&em28xx_devlist_mutex); + list_for_each_entry(ops, &em28xx_extension_devlist, next) { + if (ops->suspend) + ops->suspend(dev); + } + mutex_unlock(&em28xx_devlist_mutex); + return 0; +} + +int em28xx_resume_extension(struct em28xx *dev) +{ + const struct em28xx_ops *ops = NULL; + + em28xx_info("Resuming extensions"); + mutex_lock(&em28xx_devlist_mutex); + list_for_each_entry(ops, &em28xx_extension_devlist, next) { + if (ops->resume) + ops->resume(dev); + } + mutex_unlock(&em28xx_devlist_mutex); + return 0; +} diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 32d8a4b..9b02f15 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -713,6 +713,8 @@ struct em28xx_ops { int id; int (*init)(struct em28xx *); int (*fini)(struct em28xx *); + int (*suspend)(struct em28xx *); + int (*resume)(struct em28xx *); }; /* Provided by em28xx-i2c.c */ @@ -758,6 +760,8 @@ int em28xx_register_extension(struct em28xx_ops *dev); void em28xx_unregister_extension(struct em28xx_ops *dev); void em28xx_init_extension(struct em28xx *dev); void em28xx_close_extension(struct em28xx *dev); +int em28xx_suspend_extension(struct em28xx *dev); +int em28xx_resume_extension(struct em28xx *dev); /* Provided by em28xx-cards.c */ extern struct em28xx_board em28xx_boards[];