Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp694348imm; Mon, 9 Jul 2018 09:00:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeCUaoiWhu2UYcL5J8LtOGvIj/BM8Hr5aD3rZflgCDGc4+L0YiII0EvsWF57TO8HW32MbYW X-Received: by 2002:a17:902:a60b:: with SMTP id u11-v6mr21076217plq.158.1531152002956; Mon, 09 Jul 2018 09:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531152002; cv=none; d=google.com; s=arc-20160816; b=SMrL4vsziNL/chF9RisgcoWCYC+EglysDCt9yhltEBkCUmK9V/C9xEvpovL+wyOKKc lLVsLQSEwRxR4VrN4SnPzQG8Qgs1MVrkovluPBPv5NFDkFqDvATv4qyJIz31fK+1KtfP BkHVB12U6lxXGHlB/1qoNfQ24PS1fGXiWIehkFMk0tOQIu9B2kL5nWV7apV+zRFRtgK+ uS+jWE2GeFGN/6vJ3Twfcmcf7XmLtBLUZ79yPc0AkqUlwDISHeYbZ8rEsEscqFdufWyJ 1wgTKBdkUX4Xk6RUlhqpAGAaQt1Lr7+Z6rPpw6WGW3/9GtcTISQfeZnIHYsca4tlPTab gDbg== 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=WHYUUc16HrWqla0VpaLCW3dt6qd6IugvN5Xdf8MRtp4=; b=iZavQ20DrcWCnBznG+8vGww4BrGTlZE6V5qshQZksxuM5whx8MbrAn8yxNyvQC69rZ yCxOVdAAAsr0jjObNOzkZoAmLHYgzsLrccHfpTjutu9S54rreJtX/TN9qZxEilaBbFga ZDYngsW39TkgbtNqZVXCm+6XPEB4yi4SbhhcG8Ne6wA5Oe7g3AK/o6qcsge+ZEizcKMs I0N9h78mz3MEMomQ87Z7p+UPgFQPa1m7pZYy4JwKR4YBboZbEX5u8OQKaUAuJjomcHMI fiGUMwLxkXdGdr9eJik3GlvgOV5wzqEcUChhowckWMQD7fulYSo/RmKdpQ+eYg+PIfw1 Cc+w== 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 r1-v6si13215602pgv.487.2018.07.09.08.59.48; Mon, 09 Jul 2018 09:00:02 -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 S933846AbeGIP57 (ORCPT + 99 others); Mon, 9 Jul 2018 11:57:59 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:42114 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933749AbeGIP5M (ORCPT ); Mon, 9 Jul 2018 11:57:12 -0400 X-UUID: 06c24950b0f742e281ab60f0cf437c4e-20180709 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 730716262; Mon, 09 Jul 2018 23:57:07 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 9 Jul 2018 23:57:05 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 9 Jul 2018 23:57:05 +0800 From: To: , , , CC: , , , , , Sean Wang , Rob Herring , Ulf Hansson , Greg Kroah-Hartman , Jiri Slaby , Subject: [PATCH v5 2/7] serdev: add dev_pm_domain_attach|detach() Date: Mon, 9 Jul 2018 23:56:58 +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-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 Reviewed-by: Ulf Hansson Cc: Rob Herring Cc: Ulf Hansson Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org --- drivers/tty/serdev/core.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index bd47c46..9db93f5 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -350,8 +351,17 @@ 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; - return sdrv->probe(to_serdev_device(dev)); + ret = dev_pm_domain_attach(dev, true); + if (ret) + return ret; + + ret = sdrv->probe(to_serdev_device(dev)); + if (ret) + dev_pm_domain_detach(dev, true); + + return ret; } static int serdev_drv_remove(struct device *dev) @@ -359,6 +369,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