From patchwork Wed Aug 19 09:13:46 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: 52531 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 291FD22DB1 for ; Wed, 19 Aug 2015 09:14:44 +0000 (UTC) Received: by labpx14 with SMTP id px14sf4638365lab.1 for ; Wed, 19 Aug 2015 02:14:43 -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=sXS2AOth5Tkfry6ZrYlO03o+J/C/3w553hMv0V4Q058=; b=F47fHl+VYYnBOS+joaR9AjN9CgioUDaJZH3BKXXE5AUfVz8mtCD8+SCnLUM+WpUKyg 19wBDbA3EiVSvZBsXtrekdWh6AWRCgOgzPSTpZdtFdsCcJPOj4XqE/AYEXfyUNl3AIbl nxIBweODSv8GAYk3ztIDsAutYDqX798sZmzfMrVn4+RMg1X93xYf1WymMiKtLLUQNzIM C48JuGvACFsD9I/MR56H+PwIgM9CaRB302bZ8CWtnoeiW2Hw5nAk5nWZgoHwHcfV719T +SIQtHQTf5M1HTa+LAPO4uGSs0jthjOEGIa2B01BpFG5y2LeQ4jJkF5NuilXQv4GnDJU MW4A== X-Gm-Message-State: ALoCoQnyd+grI2xT7f+SnbCTBG6TZUSI4q/JjX5Q+8de5k+myTmEjqMMWC9FEJ3vJ34Fa3fVXMwW X-Received: by 10.112.189.105 with SMTP id gh9mr2996574lbc.16.1439975683106; Wed, 19 Aug 2015 02:14:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.65 with SMTP id r1ls3442lag.31.gmail; Wed, 19 Aug 2015 02:14:42 -0700 (PDT) X-Received: by 10.152.43.41 with SMTP id t9mr10437534lal.4.1439975682919; Wed, 19 Aug 2015 02:14:42 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id gg7si35964lbc.126.2015.08.19.02.14.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 02:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laba3 with SMTP id a3so11869664lab.1 for ; Wed, 19 Aug 2015 02:14:42 -0700 (PDT) X-Received: by 10.112.67.65 with SMTP id l1mr10379318lbt.86.1439975682818; Wed, 19 Aug 2015 02:14:42 -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 yc8csp234068lbb; Wed, 19 Aug 2015 02:14:41 -0700 (PDT) X-Received: by 10.68.234.69 with SMTP id uc5mr22453661pbc.81.1439975676124; Wed, 19 Aug 2015 02:14:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2si130753pds.32.2015.08.19.02.14.35; Wed, 19 Aug 2015 02:14:36 -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 S1753508AbbHSJOc (ORCPT + 28 others); Wed, 19 Aug 2015 05:14:32 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:34881 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753413AbbHSJO0 (ORCPT ); Wed, 19 Aug 2015 05:14:26 -0400 Received: by pacgr6 with SMTP id gr6so153453984pac.2 for ; Wed, 19 Aug 2015 02:14:25 -0700 (PDT) X-Received: by 10.66.175.7 with SMTP id bw7mr23249799pac.155.1439975665773; Wed, 19 Aug 2015 02:14:25 -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.20 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 02:14:24 -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: Wed, 19 Aug 2015 17:13:46 +0800 Message-Id: <59a5ba963dc2aaf9b1f59b0e79387b4d9ce3f30a.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.215.53 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..44d82f5 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 *uchger; unsigned sg_supported:1; unsigned is_otg:1;