Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp310199imm; Tue, 15 May 2018 01:56:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpUEZ88j30EctbTiMAdSaAPj+F085ZSe0z+aTIrFa928LUiBVrkCx7IqAI42ck7O49QzBOS X-Received: by 2002:a17:902:7d8a:: with SMTP id a10-v6mr13491217plm.317.1526374572136; Tue, 15 May 2018 01:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526374572; cv=none; d=google.com; s=arc-20160816; b=VicywXc1L9q5GwIM+hRLxsu1cT5mMijvvYXxfwIT9iURTjZ042eCAvyyzESdQ9uK/E lzXE5T3WUd7OQbwBhd9dYTk0wGu3mRKNQa9zFMRBnElcjX7svRuQfqB3/dn1irWixwI4 WSf4Khn3dMs7YTWsTkLcfNW/r90+JodAB+YZjaslnDkALOKXUf8M+PfKTv+komc+r2kl LgBMyjuVq5Q/+LXvNPciOgb3vgLbC5fgbkSCpO2cf8ysbHd5+F6Gt0YSmzL8IIO707kX CCgvFMXkYN3MI521FwiL0l+VvtEe5sZNMynXgWphKoJ3lfyDzsFKv++pY32TkZb3Rwyi wMeA== 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=k4H97+OkJ5uX3O3oAa8U0HPJvW4HJrlLh2b94R6lUZbXSIFCMfMAXs9cYQGN3pGXrr bWCpCuv5Oqk76e+hXVKQTyJwM45XUPAnBbUMLqicupEkTI/MGFR6ZRizX7ooLmc8hLDu NVkclnccrzG6gC+NdVwa8K9i0Rm33+u7imSUAQ6jt/UsTnldpJIbkSiZNDgdGQEFiVth Wx3wRt7r5SePgS7+lywoe4/QlKpMWaXeve2WIo7Uew4S23DKp6P/+P/J5RK0wbDDHS7h DNoEC21DZ8Ey1zaEi33C1HNTlOs9Qwj+KNevn47yhm5jw1wy/1YAbaXf3UT+ptvgjqFK +ueA== 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 f9-v6si8973193pgr.123.2018.05.15.01.55.57; Tue, 15 May 2018 01:56:12 -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 S1752744AbeEOIzA (ORCPT + 99 others); Tue, 15 May 2018 04:55:00 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:45654 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752547AbeEOIwi (ORCPT ); Tue, 15 May 2018 04:52:38 -0400 X-UUID: 11ce0376175c4ed7a06c94c746e885ef-20180515 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 457316611; Tue, 15 May 2018 16:52:33 +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; Tue, 15 May 2018 16:52:32 +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; Tue, 15 May 2018 16:52:32 +0800 From: To: , , , CC: , , , , , Sean Wang , "Rob Herring" , Ulf Hansson , "Greg Kroah-Hartman" , Jiri Slaby , Subject: [PATCH v2 2/7] serdev: add dev_pm_domain_attach|detach() Date: Tue, 15 May 2018 16:52:17 +0800 Message-ID: <6b4831836d1d642f9d4c520ffd6796e8a6295303.1526374087.git.sean.wang@mediatek.com> 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 | 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