Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5985011imm; Tue, 26 Jun 2018 23:37:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL2u0FkNTjTsJvopUrfkBs8eVgrVeR4tXbxviKB1ht67U1qT6U2Y8s+j44FmXDqy9s+dgxr X-Received: by 2002:a17:902:294a:: with SMTP id g68-v6mr4959350plb.58.1530081436638; Tue, 26 Jun 2018 23:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530081436; cv=none; d=google.com; s=arc-20160816; b=hPJrkXjqrDrQtLh2oiEXQarRL/E5+/kwWU4Sh55kOyNLXlONL0Bx4KYmodaMbv9Fkq J85w8ZFnXvb+XjtuMObyAyWPsFNpT04hZt++qvSwfhjzznksC9+H8bbro1vHDk0YXZNB 54u31DvIkol+H6ANg+9Pumj8d8Wv3gb8hx8jGwStS8AHtkag6o6RdCKsaIFmIDj2b3gJ yVWr6LjzAN+7pToEySn98MyoA+nRBDHkkhlPa0rIO0GRNqTmJwXCy644fRpISVJ+0av3 hBtd2Jay5ZXC+TGAJJxsp6lHygZ7aBQQfF1tjUvelbOIobUOmORqBYf9NfNdjWhuSJ9w Y7GQ== 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=c8nDZnLp5zfz42G2swuQf1lQT0Z/0gj+mCchklH8ngo=; b=pbPG2Vmm3jGErxaYVCDsZtKJpW1vaXptzhLnrMmLWtDb7WPkwVdnSc1GRGdacuSbK7 j6U/kOii97weGAueXmLFic0MxOHYSmWNhHIV6yTN8DQrSwU/HdPj3IsZRX0XqobTvZW+ 3rHJZ0ZQHKG4KaCV1TdN5Y28Om/M02dnO546bLbr8i+pu10XxiPldSlYKucSE739hd1X MEN6Pr/IiZjg9q0vdsWny59V8TQyp9TZr4M8qvBbF1NqDLFTq/gTtT+nFeC5Lryvon58 gB2KlQa0Vmp4lRbmb3qtaCaPTtnobgmb58cKyMPEH0nZBjYXSL6ev7hxvE6CtP7FZXI3 pg8Q== 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 x1-v6si3014697pgx.60.2018.06.26.23.37.02; Tue, 26 Jun 2018 23:37:16 -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 S1753025AbeF0Fnp (ORCPT + 99 others); Wed, 27 Jun 2018 01:43:45 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:46162 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752800AbeF0Fnk (ORCPT ); Wed, 27 Jun 2018 01:43:40 -0400 X-UUID: 564879aa1dd04995a9bfe0830c1852dc-20180627 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 596235481; Wed, 27 Jun 2018 13:43:34 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 27 Jun 2018 13:43:27 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 27 Jun 2018 13:43:27 +0800 From: To: , , , CC: , , , , , Sean Wang , "Rob Herring" , Ulf Hansson , "Greg Kroah-Hartman" , Jiri Slaby , Subject: [PATCH v4 2/7] serdev: add dev_pm_domain_attach|detach() Date: Wed, 27 Jun 2018 13:43:20 +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 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 df93b72..8096138 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,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) @@ -339,6 +349,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