From patchwork Tue Apr 3 07:15:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 10320703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 114EB60390 for ; Tue, 3 Apr 2018 07:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBFB1288C5 for ; Tue, 3 Apr 2018 07:18:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E08A8288CD; Tue, 3 Apr 2018 07:18:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53DA5288C5 for ; Tue, 3 Apr 2018 07:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X2ca7/L0dauk4KmOmOgSZVrx9H92GPF9xegEowYWsTw=; b=sQLUL2F1pwxS7H rVz/F7iWJ/vPZa1x7xgbN2mk0+34fJGAg2Sp2+TieaLJyMNs6RS8Ilr7is2ELsvnPTk5BvSahY1Ur 4agFVOEirZy5xwCnv5WG+fuenaCHaR5j/Pd5nN9X2r79cHq5+FyCZJ8WRT3mOfK3bScXDIPsDUSmA r1mH4fzsmDz7VFT94cpqE+i9BKe3hA/v0nBwph5p6S5kdDuJ5HIrqp5A6wRLUYMhTtO/WIlqIvZcx P3j3NQHfz1QjNG/IOY1fFNucUGqbVb2EaSeH+hdHnssiwdVl9uNof5pFxzZhYskEWN0RgrhLVnzV4 5DTFe21T/NgNjEeGrstA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3GCb-0000if-TZ; Tue, 03 Apr 2018 07:17:57 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3GB0-0008DJ-GW; Tue, 03 Apr 2018 07:16:42 +0000 X-UUID: 4047101442074bfb99c18671aa2f0332-20180403 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1853897166; Tue, 03 Apr 2018 15:16:07 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 3 Apr 2018 15:16:05 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Tue, 3 Apr 2018 15:16:05 +0800 From: To: , , , Subject: [PATCH v1 2/7] serdev: add dev_pm_domain_attach|detach() Date: Tue, 3 Apr 2018 15:15:52 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.5042-8.2.9001-23760.005 X-TM-AS-Result: No-3.649100-8.000000-10 X-TMASE-MatchedRID: yFGXaP8bkQNb8Ol7R+ysii9PRkKGjWuXqUtSHIEdjlVcKZwALwMGs1rX FZpR0HMKmxlFMGczjUERs1kezRVUMoqWws9vyPBrA9lly13c/gGscK/K2Dlvjn5h6y4KCSJci18 y270V9us9waMZNTtOdzBlAzQBY9aAkfRhdidsajMURSScn+QSXt0H8LFZNFG76sBnwpOylLOcOe RXOqtleRIjp8Nc/3IRnJu7HGwX0W+Y6Xq7tfHnESRoZt/hZbTp/DcqmgW8WtabJNSLF/plcYW8i uNOJjReW54PuKeGq90PXLxHfxLeXVRHOSKs7RDUXmH0pBaurgG+4xOvsJAknn7cGd19dSFd X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.649100-8.000000 X-TMASE-Version: SMEX-12.5.0.5042-8.2.9001-23760.005 X-TMASE-POSTMAN: 2-d; X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180403_001618_706422_E8BF4C0A X-CRM114-Status: GOOD ( 13.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Ulf Hansson , Rob Herring , Greg Kroah-Hartman , Sean Wang , linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Wang In order to open up the required power gate before any operation can be effectively performed over the serial bus between CPU and serdev, it's clearly essential to add common attach functions for PM domains to serdev at the probe phase. Similarly, the relevant dettach function for the PM domains should be properly and reversely added at the remove phase. Signed-off-by: Sean Wang Cc: Rob Herring Cc: Ulf Hansson Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org --- drivers/tty/serdev/core.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index df93b72..c93d8ee 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -330,8 +331,16 @@ EXPORT_SYMBOL_GPL(serdev_device_set_tiocm); static int serdev_drv_probe(struct device *dev) { const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver); + int ret; + + ret = dev_pm_domain_attach(dev, true); + if (ret != -EPROBE_DEFER) { + ret = sdrv->probe(to_serdev_device(dev)); + if (ret) + dev_pm_domain_detach(dev, true); + } - return sdrv->probe(to_serdev_device(dev)); + return ret; } static int serdev_drv_remove(struct device *dev) @@ -339,6 +348,9 @@ static int serdev_drv_remove(struct device *dev) const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver); if (sdrv->remove) sdrv->remove(to_serdev_device(dev)); + + dev_pm_domain_detach(dev, true); + return 0; }