From patchwork Thu Sep 24 17:39:25 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: 54124 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 4F1C322DC2 for ; Thu, 24 Sep 2015 17:40:54 +0000 (UTC) Received: by lamf6 with SMTP id f6sf44190051lam.1 for ; Thu, 24 Sep 2015 10:40:52 -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=PJKY/11KPBx2G/a0YKB+uhYctjdqvoUM2unqxfucgwg=; b=AE09RnMOsX//HXxeFfD4ImSMz5JyKLs8nfBKZEw5CCVK56QEMaz2I3MEQtVG5rzv/V qQFx9neGEL2RoiuMr9A/nMDJUYWkXi86kHSu4wc6RM9ca6+F3az+xm89LEmQQwH/m8+R i7NZehBPD9rZYb7TLBiTuS+eJFSxqUQlL6soqgae4gdamx61IM00cFHoepF13FoB+Gip tpep63hykW2B1pNMzRctKiVK8JjLRM5vZIYRbTz7dDymjglAkBvgjfOc9Sd3/rR2JKlR wMooMWjEdBlv/A7E4mzb9Clq2ZEoEuuCdbsddDlgycPzw8bW/u7ea4r6t7e7SDGHQP// 8/TQ== X-Gm-Message-State: ALoCoQlwSECRd85CV3/Xb2gIIrmKN7PKmh9CtKQD1nsXyM3tKA12mBZDokhwdRrEFsAA3R0Ww0v/ X-Received: by 10.112.55.69 with SMTP id q5mr152298lbp.24.1443116452910; Thu, 24 Sep 2015 10:40:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.193 with SMTP id 1ls138967law.30.gmail; Thu, 24 Sep 2015 10:40:52 -0700 (PDT) X-Received: by 10.25.43.9 with SMTP id r9mr174415lfr.45.1443116452739; Thu, 24 Sep 2015 10:40:52 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id ez3si5178632lbc.92.2015.09.24.10.40.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 10:40:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lacao8 with SMTP id ao8so72028828lac.3 for ; Thu, 24 Sep 2015 10:40:52 -0700 (PDT) X-Received: by 10.112.156.167 with SMTP id wf7mr268407lbb.88.1443116452264; Thu, 24 Sep 2015 10:40:52 -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 w3csp471538lbq; Thu, 24 Sep 2015 10:40:51 -0700 (PDT) X-Received: by 10.66.138.11 with SMTP id qm11mr1097409pab.126.1443116451125; Thu, 24 Sep 2015 10:40:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fu3si8259598pbd.138.2015.09.24.10.40.50; Thu, 24 Sep 2015 10:40:51 -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 S1757711AbbIXRkk (ORCPT + 30 others); Thu, 24 Sep 2015 13:40:40 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:32866 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757673AbbIXRke (ORCPT ); Thu, 24 Sep 2015 13:40:34 -0400 Received: by pacex6 with SMTP id ex6so78939216pac.0 for ; Thu, 24 Sep 2015 10:40:34 -0700 (PDT) X-Received: by 10.66.240.37 with SMTP id vx5mr1100380pac.76.1443116434175; Thu, 24 Sep 2015 10:40:34 -0700 (PDT) Received: from ubuntu.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id c16sm14716394pbu.37.2015.09.24.10.40.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Sep 2015 10:40:33 -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 3/5] gadget: Support for the usb charger framework Date: Thu, 24 Sep 2015 10:39:25 -0700 Message-Id: <7ee4199f14eb9e84c8ea8d66568e0d4dde193583.1443057232.git.baolin.wang@linaro.org> 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.47 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: , For supporting the usb charger, it adds the usb_charger_init() and usb_charger_exit() functions for usb charger initialization and exit. Introduce a callback 'get_charger_type' which will implemented by user for usb gadget operations to get the usb charger type. Signed-off-by: Baolin Wang --- drivers/usb/gadget/udc/udc-core.c | 8 ++++++++ include/linux/usb/gadget.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 4238fc3..370376e 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -28,6 +28,7 @@ #include #include #include +#include /** * struct usb_udc - describes one usb device controller @@ -437,8 +438,14 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, mutex_unlock(&udc_lock); + ret = usb_charger_init(gadget); + if (ret) + goto err5; + return 0; +err5: + device_del(&udc->dev); err4: list_del(&udc->list); mutex_unlock(&udc_lock); @@ -513,6 +520,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); flush_work(&gadget->work); device_unregister(&udc->dev); + usb_charger_exit(gadget); device_unregister(&gadget->dev); } EXPORT_SYMBOL_GPL(usb_del_gadget_udc); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 755e8bc..451ad32 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -537,6 +537,7 @@ struct usb_gadget_ops { struct usb_ep *(*match_ep)(struct usb_gadget *, struct usb_endpoint_descriptor *, struct usb_ss_ep_comp_descriptor *); + enum usb_charger_type (*get_charger_type)(struct usb_gadget *); }; /** @@ -611,6 +612,7 @@ struct usb_gadget { struct usb_otg_caps *otg_caps; struct raw_notifier_head nh; struct mutex lock; + struct usb_charger *charger; unsigned sg_supported:1; unsigned is_otg:1;