From patchwork Thu Sep 24 17:39:26 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: 54125 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id ADFEC22DC2 for ; Thu, 24 Sep 2015 17:41:00 +0000 (UTC) Received: by wisv5 with SMTP id v5sf45107719wis.0 for ; Thu, 24 Sep 2015 10:41:00 -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=aPpGxSmtc+i2b5iy3d142R8SszGX/leO3ii1KWuGsAM=; b=a0cKN/Ev409JEvZjvTCZVsnT8oP4L9gsFqyJaonvrA4mvpfhhYj/7Yx6HDRQnaHLIp pyaRWRPsf9VToyc85STmBOk5sxY+7/hwd2Q/RnDggAaGBCc+sAcz3ycjM6xS/l5egXI7 Fg874XQopb/1zZUJw+3ut4wwQkWcZxmSfDlR53t8lQLgYwhEJQw+VTzOBhMhqc+byJHu gm2KpF55S9v8osjcjBvDRZQs7SmEaEzFULRie1zPPE62yMDjsUGrOLEFNBee7yJlOQRV PBMItludOthT1LDJdMhOXwqegpfbzct2Wqv18KSx4PMh4N7VjCKBb7aOJ+IJru5jLkDH /sLA== X-Gm-Message-State: ALoCoQmB1+4w5xUL/yoYJH4Vyztl4izgLbNNlHqPblbOEhTctSvqvj5hZvaT8EG1/IepNYhqJOU5 X-Received: by 10.180.107.167 with SMTP id hd7mr267876wib.6.1443116460017; Thu, 24 Sep 2015 10:41:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.233 with SMTP id i9ls61100lae.4.gmail; Thu, 24 Sep 2015 10:40:59 -0700 (PDT) X-Received: by 10.25.150.143 with SMTP id y137mr167766lfd.123.1443116459703; Thu, 24 Sep 2015 10:40:59 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id i5si5183320lbs.64.2015.09.24.10.40.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 10:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lacdq2 with SMTP id dq2so16893378lac.1 for ; Thu, 24 Sep 2015 10:40:59 -0700 (PDT) X-Received: by 10.112.64.72 with SMTP id m8mr256817lbs.41.1443116459586; Thu, 24 Sep 2015 10:40:59 -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.59.35 with SMTP id w3csp471581lbq; Thu, 24 Sep 2015 10:40:58 -0700 (PDT) X-Received: by 10.66.144.199 with SMTP id so7mr1136047pab.42.1443116458433; Thu, 24 Sep 2015 10:40:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id eg4si19743300pbc.189.2015.09.24.10.40.57; Thu, 24 Sep 2015 10:40:58 -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 S932496AbbIXRkv (ORCPT + 30 others); Thu, 24 Sep 2015 13:40:51 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:35946 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757723AbbIXRkp (ORCPT ); Thu, 24 Sep 2015 13:40:45 -0400 Received: by pacgz1 with SMTP id gz1so12362106pac.3 for ; Thu, 24 Sep 2015 10:40:44 -0700 (PDT) X-Received: by 10.68.109.97 with SMTP id hr1mr1093604pbb.110.1443116444490; Thu, 24 Sep 2015 10:40:44 -0700 (PDT) Received: from ubuntu.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id c16sm14716394pbu.37.2015.09.24.10.40.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Sep 2015 10:40:43 -0700 (PDT) From: Baolin Wang To: balbi@ti.com, sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org Cc: gregkh@linuxfoundation.org, peter.chen@freescale.com, stern@rowland.harvard.edu, r.baldyga@samsung.com, sojka@merica.cz, yoshihiro.shimoda.uh@renesas.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, sameo@linux.intel.com, lee.jones@linaro.org, ckeepax@opensource.wolfsonmicro.com, broonie@kernel.org, patches@opensource.wolfsonmicro.com, linux-pm@vger.kernel.org, device-mainlining@lists.linuxfoundation.org, baolin.wang@linaro.org Subject: [PATCH v4 4/5] gadget: Integrate with the usb gadget supporting for usb charger Date: Thu, 24 Sep 2015 10:39:26 -0700 Message-Id: X-Mailer: git-send-email 1.9.1 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.215.42 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..a919f38 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->charger; 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->charger = 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->charger; if (!uchger) return -EINVAL;