Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1681162imm; Thu, 14 Jun 2018 01:59:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIlyUyPM403x8P6pvQTi+OWqXaFhvrRL3WN63efg/HkrGAkvqsUhiLn477OXWKcbLPAgteC X-Received: by 2002:a17:902:5ac8:: with SMTP id g8-v6mr2009749plm.221.1528966747996; Thu, 14 Jun 2018 01:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528966747; cv=none; d=google.com; s=arc-20160816; b=lIO7ERBb2MvekHaN9qnLBOMCuCoW/eH40TNNmX+LikiCxxa1fsQWHAtsnAxuGOe1cc upyRZkts/3fxfQJsBSh7x2ffzN5zHmyAvj5TJP7So5V3geay1nDT3cakHEw8zHoQ6aCr cpjutMw0OrKK9+2bwAmJohG+xlWBL1cY0ZIidAzdGUUFDFGQ27IVBf6lQ5naodVA7ClG bG2z/UR5pMq5Mjfb9bvYIRKzDtWVYC9hymqOIC/WPFTikg7fUz3ILMwugkqY2/mPKRHU OHCDDrs3VyiXwvX+TzpO6idG1xxQ0aq82uHTfdLngIz4rthY6J8NAwCpnntIEtfITCqS TE5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Qz9dx9asYfpqPveRT3qKL9SCYTDiHMd9TYDd6idML5U=; b=QmTxY+JbOgUds5EctiI/WbC8Nx07za5/8uNz90WUYPk79HYfaewE8eVAjAXGcz+GLu Fkmkox0RjuZO3vL2ByueLDu+mS17amNkkjx21lRUtQKFhn/cHVIFXXx20m33Xbc8NLON 76BbuhN2s7j9ugqozzkRp1i0a9oa+eGpnvlj1GQP7qTXrr4Wg3XyGv2aix3pKx18/Md9 BOHbij0ADlBmc9is9q7PitgC1nSON1IPvLJ2IZDq5D+3yNS1EOitEWmJGxT5zfFSYegV 6HWUseCTArXkrpcd8R7Ss4t6wAu5B4jumYbmX2ZSwZpx6ScEyh6tcqhipt2LOEBqXwr7 adgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d1LuZHqO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si3837302pgt.400.2018.06.14.01.58.53; Thu, 14 Jun 2018 01:59:07 -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; dkim=pass header.i=@linaro.org header.s=google header.b=d1LuZHqO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754770AbeFNI61 (ORCPT + 99 others); Thu, 14 Jun 2018 04:58:27 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:42032 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581AbeFNI6X (ORCPT ); Thu, 14 Jun 2018 04:58:23 -0400 Received: by mail-io0-f195.google.com with SMTP id r24-v6so6378960ioh.9 for ; Thu, 14 Jun 2018 01:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Qz9dx9asYfpqPveRT3qKL9SCYTDiHMd9TYDd6idML5U=; b=d1LuZHqOdRH27D4+TYPoH3Xzi4hsRrJ867zWFNLGPpAZN1O1a40Nucy/NEc88A0QUU IvtQFLcOFWJfjwXnCY5lhkaXX4T6Vw2bm95BHCsSsoLARx1HnqnVKQLVD66J7res0mIs L0Mj9De1EWu8ZBB/clZS5e8SAPUXXreOZAWVs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Qz9dx9asYfpqPveRT3qKL9SCYTDiHMd9TYDd6idML5U=; b=HHGtQ1rnnduqbMm/gCOl63uhCS4imaTJrx4LKDVHXriZo3DO6d4K97JQvw57dlENID 30iq20VEBupLwBMsqUF1iTh/xl3yao1rSDRsQ1VFHn1S6LVWvKohTfX2a2BH3FMSYfS+ VF/xFtqtSN9gJTXKKi6ADAtuY6aHMNyW4b61dA1OMbIVkgZ/lpEVTu5Dcvcemz3/9rnP Gxz+/sL3B4peQD7OhZrVDpvdWpyLaj56tgscq4T4foUfTDeQvEJr1cRptP/8MOmHI3I0 DgWBeByaJESodNzyp0teW+tls6HBjv3STuusnO5A8I+bl69YARRSOYaKTz2Rp9+aOhV8 qPvA== X-Gm-Message-State: APt69E2bp3abLNaw0yFDyGGCYwWUDgJulnzz3AKBMY1uPaqN/SJh7i6U 84XvnIFqstdGQh+mxJd+cSkzudkwiYmZZA9eSPb/SA== X-Received: by 2002:a6b:1410:: with SMTP id 16-v6mr1491951iou.218.1528966703091; Thu, 14 Jun 2018 01:58:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:c054:0:0:0:0:0 with HTTP; Thu, 14 Jun 2018 01:58:22 -0700 (PDT) In-Reply-To: References: From: Ulf Hansson Date: Thu, 14 Jun 2018 10:58:22 +0200 Message-ID: Subject: Re: [PATCH v3 2/7] serdev: add dev_pm_domain_attach|detach() To: sean.wang@mediatek.com Cc: Rob Herring , Mark Rutland , Marcel Holtmann , Johan Hedberg , devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org, Linux ARM , linux-mediatek@lists.infradead.org, Linux Kernel Mailing List , Rob Herring , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Jun 2018 at 09:14, wrote: > > 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) { From 4.18 rc1 via commit 919b7308fcc4, dev_pm_domain_attach() will return better error codes. I suggest to change the above error path to: if (ret) return ret; Then continue with the probing below. > + 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 > Otherwise, this makes sense to me! Kind regards Uffe