From patchwork Wed Aug 19 09:13:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 52532 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 81E1722DB1 for ; Wed, 19 Aug 2015 09:14:59 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf63071287lbc.2 for ; Wed, 19 Aug 2015 02:14:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=T/KZjaZhu1ZUEaWc/YFKB/0N+n6ZOFDYZcywjhu2fdY=; b=gLLxTVTNfjM7wJYM6XKHvsUvx8yfL2N5h4cqe83oTSfrYjc5aBf+HXnSx1PeMNqgdD RGFiZyLOyKmvEW/uVapvzTeDlTvA9c6LuXASUc6VPCYh5ncv+GGoygrOMyjCjZ1RA7kC 5vFINHfVotmprDnhumTINlobJTUMEw7hlaEhn1bEqTsjqgrGAsi3LqKY7/xpleQkvlDW uRNnJWegZScYQBdUYLRiiAqH09/7sUWlXR6XA8Rudfd1xTzrNXBdAU7ivj4iKJPNJz2V hc7Cyf+9jsAN51miwkKTcBTcC/K2vdzsfN3MIN4JkISxkZGUQpk4fhS2ttFVTZD8NApW HYcQ== X-Gm-Message-State: ALoCoQmA1zL1cPiJZr3R1RQwymKWAjKBCNGDjPN73hJH3lMBh/a41oBisu/3RtYHJ9RH0D3kzMhO X-Received: by 10.180.186.36 with SMTP id fh4mr191322wic.7.1439975698272; Wed, 19 Aug 2015 02:14:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.219.4 with SMTP id pk4ls2582lac.90.gmail; Wed, 19 Aug 2015 02:14:57 -0700 (PDT) X-Received: by 10.112.171.68 with SMTP id as4mr10423056lbc.64.1439975697800; Wed, 19 Aug 2015 02:14:57 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id jo12si49054lab.37.2015.08.19.02.14.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 02:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbpu9 with SMTP id pu9so119842471lbb.3 for ; Wed, 19 Aug 2015 02:14:57 -0700 (PDT) X-Received: by 10.112.235.130 with SMTP id um2mr6485075lbc.72.1439975697371; Wed, 19 Aug 2015 02:14:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.162.200 with SMTP id yc8csp234224lbb; Wed, 19 Aug 2015 02:14:55 -0700 (PDT) X-Received: by 10.70.91.14 with SMTP id ca14mr23010852pdb.79.1439975695628; Wed, 19 Aug 2015 02:14:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pv9si130112pbb.44.2015.08.19.02.14.54; Wed, 19 Aug 2015 02:14:55 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753571AbbHSJOh (ORCPT + 28 others); Wed, 19 Aug 2015 05:14:37 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36474 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753413AbbHSJOc (ORCPT ); Wed, 19 Aug 2015 05:14:32 -0400 Received: by pawq9 with SMTP id q9so56782630paw.3 for ; Wed, 19 Aug 2015 02:14:32 -0700 (PDT) X-Received: by 10.68.206.74 with SMTP id lm10mr22445179pbc.117.1439975671982; Wed, 19 Aug 2015 02:14:31 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id w6sm91903pdn.46.2015.08.19.02.14.26 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 02:14:31 -0700 (PDT) From: Baolin Wang To: balbi@ti.com Cc: broonie@kernel.org, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, gregkh@linuxfoundation.org, peter.chen@freescale.com, sojka@merica.cz, stern@rowland.harvard.edu, r.baldyga@samsung.com, yoshihiro.shimoda.uh@renesas.com, linux-usb@vger.kernel.org, device-mainlining@lists.linuxfoundation.org, sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org, sameo@linux.intel.com, lee.jones@linaro.org, patches@opensource.wolfsonmicro.com, linux-pm@vger.kernel.org Subject: [PATCH v4 4/5] gadget: Integrate with the usb gadget supporting for usb charger Date: Wed, 19 Aug 2015 17:13:47 +0800 Message-Id: <9cce1f96035f94ebcfe5b2ac48e7483791213340.1439974219.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When the usb gadget supporting for usb charger is ready, the usb charger should get the type by the 'get_charger_type' callback which is implemented by the usb gadget operations, and get the usb charger pointer from struct 'usb_gadget'. Signed-off-by: Baolin Wang --- drivers/usb/gadget/charger.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/charger.c b/drivers/usb/gadget/charger.c index 35b46c1..93fd36f 100644 --- a/drivers/usb/gadget/charger.c +++ b/drivers/usb/gadget/charger.c @@ -181,6 +181,13 @@ int usb_charger_unregister_notify(struct usb_charger *uchger, enum usb_charger_type usb_charger_detect_type(struct usb_charger *uchger) { + if (uchger->gadget && uchger->gadget->ops + && uchger->gadget->ops->get_charger_type) + uchger->type = + uchger->gadget->ops->get_charger_type(uchger->gadget); + else + uchger->type = UNKNOWN_TYPE; + return uchger->type; } @@ -313,7 +320,8 @@ static int usb_charger_plug_by_gadget(struct notifier_block *nb, unsigned long state, void *data) { - struct usb_charger *uchger = NULL; + struct usb_gadget *gadget = (struct usb_gadget *)data; + struct usb_charger *uchger = gadget->uchger; enum usb_charger_state uchger_state; if (!uchger) @@ -480,6 +488,7 @@ int usb_charger_init(struct usb_gadget *ugadget) /* register a notifier on a usb gadget device */ uchger->gadget = ugadget; + ugadget->uchger = uchger; uchger->old_gadget_state = ugadget->state; uchger->gadget_nb.notifier_call = usb_charger_plug_by_gadget; usb_gadget_register_notify(ugadget, &uchger->gadget_nb); @@ -503,7 +512,7 @@ fail: int usb_charger_exit(struct usb_gadget *ugadget) { - struct usb_charger *uchger = NULL; + struct usb_charger *uchger = ugadget->uchger; if (!uchger) return -EINVAL;