From patchwork Fri Aug 21 05:34:50 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: 52605 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id C1B8F20AF6 for ; Fri, 21 Aug 2015 05:35:13 +0000 (UTC) Received: by wijp15 with SMTP id p15sf2786344wij.3 for ; Thu, 20 Aug 2015 22:35:13 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=NUJrcGeS8nku7heTIv1oklY0lmaUq2b5MyF9PBdV1XM=; b=O5GSheyt5aZAR4bRn1h58AVS3k8R9CnS2wtm0eXW5i4AXskQ5DTlUIR1CV/LhKWM9g lCDsZNWS8QND7Lp9kXoPEq+lmjajodzUmtibKASOyJOTpIg+l0p4HgLapGF+ue5WqmGZ 1+SPenclG7GwhXxizoiLFk9DYyXwLEcpP654DUTxp6IpaOZdqH7QaXoe+IMdfBIYx3e+ TYCq9XR/pAZQZTU8SnXR/VUM3oJrZvtplH+KOY17vO7mkAgNR8oweSBPvnM9Y73Y/jUQ AxMRloCcDPVP8goZdRBhzzQ9DaSArp52qb9ZqX8tUDRCPDLsAIJ4O7qrapES8vS0gy6U D6uQ== X-Gm-Message-State: ALoCoQnkRFA5p2we9Q0H9u1OSFACP5q5RKIMsn11FnUYXjzf6oPHnCqPTmt3sjFqciu73I7o8175 X-Received: by 10.112.90.225 with SMTP id bz1mr1825762lbb.12.1440135313074; Thu, 20 Aug 2015 22:35:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.2 with SMTP id wm2ls221832lac.38.gmail; Thu, 20 Aug 2015 22:35:12 -0700 (PDT) X-Received: by 10.112.185.66 with SMTP id fa2mr6295527lbc.42.1440135312921; Thu, 20 Aug 2015 22:35:12 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id mt3si5438463lbb.113.2015.08.20.22.35.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2015 22:35:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbcbn3 with SMTP id bn3so36852750lbc.2 for ; Thu, 20 Aug 2015 22:35:12 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr6348555lac.73.1440135312818; Thu, 20 Aug 2015 22:35:12 -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 yc8csp431676lbb; Thu, 20 Aug 2015 22:35:11 -0700 (PDT) X-Received: by 10.66.222.103 with SMTP id ql7mr13542115pac.144.1440135310968; Thu, 20 Aug 2015 22:35:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si866997pac.193.2015.08.20.22.35.10; Thu, 20 Aug 2015 22:35:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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 S1751933AbbHUFfI (ORCPT + 13 others); Fri, 21 Aug 2015 01:35:08 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:34656 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751473AbbHUFfH (ORCPT ); Fri, 21 Aug 2015 01:35:07 -0400 Received: by pdbfa8 with SMTP id fa8so22590819pdb.1 for ; Thu, 20 Aug 2015 22:35:06 -0700 (PDT) X-Received: by 10.70.16.67 with SMTP id e3mr13773957pdd.98.1440135305971; Thu, 20 Aug 2015 22:35:05 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id mj1sm4763158pab.29.2015.08.20.22.35.00 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Aug 2015 22:35:05 -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 3/5] gadget: Support for the usb charger framework Date: Fri, 21 Aug 2015 13:34:50 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@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.171 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;