Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1598801imm; Thu, 14 Jun 2018 00:17:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK1dfYSxukjSZaxDIhrU7NWIuMNIk76YITxix8J3pGfN+ntyZM3e9x6Z1GvgHK/jdy0X6v4 X-Received: by 2002:a65:49cb:: with SMTP id t11-v6mr1263579pgs.218.1528960634563; Thu, 14 Jun 2018 00:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528960634; cv=none; d=google.com; s=arc-20160816; b=sRUlV2JLwPsIxD6zBCpElwc4c2yuUIuIplq33I2gjNQA6tMZUuMU6q/babqiRBjgy9 hS5i68i9t/F55RB16/OzkkDmJrehKLumCi3e5XeINeMVghPbIo5AdDRrTcwNupK4fHlr jiYNR6PVgf+OeXMXZPtsp3qdGkLtShUq2IsGuyXMddyJ+sir6uiDqOTgnehTiRevJ2Mo 8738HVdXhWYqq4kydXIozdV14wCpx/4qzpHBeVDW+LWGyogYj6a04JfmZI8ApOnhKIv3 XEAKLNfIorwvAWyO/Wq1ZrkrQ5XJns7Xw7sLHTtwJ7hzsGtr6hfrC8b6IbxRp8CSGEgS 2UcA== 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=wiBQ5lOwzPUYfxPoFVdW9cskch9VMwh0lrA0YlFeGMDHcEZ2Qrbnx7bb8nC+o+0+mZ Y8SRuKmI6GcWfQyqhucTSrWWT9g3b/rJPucNE0OWToTLXjybY35DrwvhdME6N+sh+uCT Dny4ZgjMn3omXPbxQlOCgcJRMX6JwhZ+bWwk8zmkWG+PUZB4MlzCIDgC8njw/9xSGvkC ZajU7ZhiEYVOcZVIRVg+msNNfKcExPOYX8A7WiG7FDXMLSt3HJeNs/yR673TO1+KYgQq 5IaOJWMrSriZZYLqWZuG6uOq4+zyFDMk55j74ZxEduIGfSbRi7fIeQTRDAvm3/SrRXb5 mouQ== 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 h8-v6si5059332plr.268.2018.06.14.00.17.00; Thu, 14 Jun 2018 00:17:14 -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 S1754723AbeFNHOl (ORCPT + 99 others); Thu, 14 Jun 2018 03:14:41 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:32504 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752833AbeFNHOj (ORCPT ); Thu, 14 Jun 2018 03:14:39 -0400 X-UUID: 890d66a68ede4cb9b6a218a2142294b2-20180614 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1208515368; Thu, 14 Jun 2018 15:14:35 +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; Thu, 14 Jun 2018 15:14:33 +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; Thu, 14 Jun 2018 15:14:33 +0800 From: To: , , , CC: , , , , , Sean Wang , Rob Herring , Ulf Hansson , Greg Kroah-Hartman , Jiri Slaby , Subject: [PATCH v3 2/7] serdev: add dev_pm_domain_attach|detach() Date: Thu, 14 Jun 2018 15:14:24 +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 | 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