Received: by 10.213.65.68 with SMTP id h4csp3208357imn; Tue, 3 Apr 2018 00:20:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4981Ojvic1uF9yzwSgUr7OyCtQToYpPr94JthF1RiuB0H7TDd4/fmYUCRu7yYbpcoZTRY7Y X-Received: by 10.99.145.193 with SMTP id l184mr8136129pge.394.1522740004551; Tue, 03 Apr 2018 00:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522740004; cv=none; d=google.com; s=arc-20160816; b=DUbcNQF2KasA5Q8XnT/M8EgKSfg3iRzphf7lnTxEO8YMDZfoiHOyMoNcnI8FikV0Gl Mlb0qw/Yu7pDd2u2yIOdJ3C/jygDAn1ghfAcR96vFrSS4UeGXkmln+hrxziIQr1kmmXw tiRbaqHe8OZ6l/xFDU3ccg5d0lw/nh6ruqKVzIa/YoKdryXPpseeOaH13+e+GHph6yjL vYdA1xYpygmXOPVwp/cYWqzaIDUbbgN9UsfEawhgq8jW1G6+wGS8Z5Y4kiXoUYOS4bss lfZGkYGq5gvzStjrbt9tJ2ooRFYBKX3Kb5XTlrhQtHnMBx0cYP3MwBri9SyVXA7HQ1d5 8tmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=dPhxBop60CHwDYhEj7MeMK79M6nbbNPObkcAyN5oATQ=; b=Xa97YBN7O7Pj8QNpdHJN/ccfU077jTCGbvsxhKYegZlVfWHQkcxmFqAAr8Bnaxn5Rl 7Wivh/fofUXvJx9O/TBWtW18kg2dg3FpN8H0Ihf/7vHjL6x43t8kvTC1GyrEhcfgJvjf y+KFHkZ2MIsIkv9XbO3FgV9aAvuL7WMKKtV1sJCh4h2GRd+SkLsILkNzciP8QjCYgQCu gSj3OUJRtGUn2urBxfSXMYx9QPqX82lbOzHLPYA1MMIicdX7bi55/sthAbwDtePqSzNO FkzOSahrp/pkHg44H/5S1TVhvJTLfkl/91SRvPkmjx/l37u8Vj0vfgE11tFCOCJLKZhs jL3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3-v6si2328314plk.11.2018.04.03.00.19.50; Tue, 03 Apr 2018 00:20:04 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755098AbeDCHSM (ORCPT + 99 others); Tue, 3 Apr 2018 03:18:12 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:12568 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753229AbeDCHQL (ORCPT ); Tue, 3 Apr 2018 03:16:11 -0400 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: , , , CC: , , , , , Sean Wang , "Rob Herring" , Ulf Hansson , "Greg Kroah-Hartman" , Jiri Slaby , 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 Content-Type: text/plain 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.7.4