Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3414079ybf; Tue, 3 Mar 2020 05:39:48 -0800 (PST) X-Google-Smtp-Source: ADFU+vvaZnn0v5tBvq4A2VeO3wq2XbZg0heJUZbGX3wPILB8ItfWlNx164N+iU58X9R+fB1Jif9w X-Received: by 2002:aca:f405:: with SMTP id s5mr2452611oih.93.1583242787797; Tue, 03 Mar 2020 05:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583242787; cv=none; d=google.com; s=arc-20160816; b=mhmNcvIxcwqP4qqbEc9dvEvLvR75sq329VIoIZYEdHcckm3KqHwkRMftB/xJL4Ds+h qYxezfz/vlpl7XzBbgbRYQj6jT6DrtfjmNF0qcxVxipgNh/G/qBC4M6vtKj3FXI4GVpE HcSyoHnXzHFubmEgOJ4GBcX+oEHhASmqCmLYKQ049JZpnjpFGQMhhJ8+64p2KaFveOUD P6dLBF7rzh1DuX+9pOnC1VxsXPsxyE0AlmNagvZ3gYpvPtDv/orQNyhho6fBI43VGYhx dnwZ2rIvXOXSX7lEcGNcpIeXecF1DJiNVqhJq9kEJYFb02UJzeAqUlaafjBkZ38v0sh+ 3f4w== 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 :in-reply-to:references:mime-version:dkim-signature; bh=hicGAyZ5CpHfmsbw4Kl9cPGuNpt8g32PuytU/UcEDL8=; b=PXRIJhVJ330AQbc37I71O9dJPjKkVP98GQtmuWXaXGaYp7R4ltD4vnVSfOPD9zc1BC SzD8hgLIQIHirU5FCFVEVfP7RKM405q0gSa6F7u+LojDvuVV58QmuNA126mZIQEUnTv7 UlSvMQeiLeJ9j3tn/G0VnZb9bOv2tgAm4Oh9Vpt7r1s1Gunn1znUAMWl1BME4+a+REpt nvNq65GBEpjbOG++9HXywz0fKX4nPDDHWxba9MRQX04vRzZfGTrwJT4/MiIUiDNUw4ny rciboJVSrTBGhyDPOfpmmqWZcZ67fcgSZ3rjmxPTx8x2mZk6sPGT/KEBKDKr2qt2PnXw Cw+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CV1elQMg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y13si3042208oto.33.2020.03.03.05.39.35; Tue, 03 Mar 2020 05:39:47 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=CV1elQMg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729404AbgCCN3r (ORCPT + 99 others); Tue, 3 Mar 2020 08:29:47 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39028 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727913AbgCCN3r (ORCPT ); Tue, 3 Mar 2020 08:29:47 -0500 Received: by mail-wr1-f66.google.com with SMTP id y17so4340556wrn.6; Tue, 03 Mar 2020 05:29:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hicGAyZ5CpHfmsbw4Kl9cPGuNpt8g32PuytU/UcEDL8=; b=CV1elQMgZLhBpuFfL5DjPopxXqFjooMD4nNFS/3zO/mg/Y0/qPPlbnp33SZup+b6Xn R0cE9JzQP4R+zgJnfJFQeNA7dybshykF3a2Ldu9qefqWJuiMHnZSFlgqQpSJtEsRyXab qAGDJu1tgLL/6+jZDbiLPhijElTtaRK5jMYuE82RT5dC2hH+bHvuAP9EdL3BBOjQkmxT IqqyonwLWKq58HGm6CL1MVGtHWy1+FBRHWDoYPPWKlVhP9gL8EQOMMNbZGEZrl7vM5RD qncE4ethqNSxzsEB357sbW5pZKYYUinUGRcUtKfY65TpSbFeZUURs1wPKt6vMXtGRShc wPsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hicGAyZ5CpHfmsbw4Kl9cPGuNpt8g32PuytU/UcEDL8=; b=B0I+pBRyERpcphZ6LbOgvprf5w8MAWJiv1sPM5AC3awdlw3KTkGkLX7OxpVPIZiURU AM5BuM5zrZmZmjY/PV3Bro0qceBDBGZv56B3QcNkJUCqrMN2f1b3XF3CpEzpvHY39rG8 Br79LahWoMWlOyZkAY4Vt48Z81NAtv8aDYVaF0x7cSOH8HZhhAVJDPl/vXIYWa29u9TS 7Pmuttt7RDCNvuxH4wkPMRm7NegER+YE52oNKVOYHT2+td5zRKB0Ea2zsQzkx+yTk+iz RHSzw1EnQ2PZfIL4/Vn+Ykb/0JNlm7YF28RzF1Bptgf0ySOgKT46v03wTBe0ZciGa9t5 CQJA== X-Gm-Message-State: ANhLgQ2MoEKt5w3eVarxLKyNNjjBqnPkjB4XuhYXLzz09j63mg5c3rS4 HOAXh4Mpa1DTLKP9Shpbl7u332QjfKYDxPkoZvE= X-Received: by 2002:adf:9dcc:: with SMTP id q12mr5802969wre.164.1583242185866; Tue, 03 Mar 2020 05:29:45 -0800 (PST) MIME-Version: 1.0 References: <20200302205700.29746-1-daniel.baluta@oss.nxp.com> <20200302205700.29746-2-daniel.baluta@oss.nxp.com> In-Reply-To: From: Daniel Baluta Date: Tue, 3 Mar 2020 15:29:34 +0200 Message-ID: Subject: Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers To: "Sridharan, Ranjani" Cc: Daniel Baluta , rjw@rjwysocki.net, "Brown, Len" , Pavel Machek , Aisheng Dong , Ulf Hansson , Fabio Estevam , Linux-ALSA , linux-pm@vger.kernel.org, Greg KH , Sascha Hauer , khilman@kernel.org, Ranjani Sridharan , Linux Kernel Mailing List , Daniel Baluta , Pierre-Louis Bossart , Paul Olaru , dl-linux-imx , Pengutronix Kernel Team , Shawn Guo , "S.j. Wang" , linux-arm-kernel 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 Hello Ranjani, On Mon, Mar 2, 2020 at 11:24 PM Sridharan, Ranjani wrote: >> + */ >> +struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev) >> +{ >> + struct dev_multi_pm_domain_data *mpd, *retp; >> + int num_domains; >> + int i; >> + >> + num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", >> + "#power-domain-cells"); >> + if (num_domains < 2) > > Hi Daniel, > > Just out of curiosity, should it be an error when num_domains is 1? Is it an error because the expectation is that the caller would use dev_pm_domain_attach() in that case? NULL here doesn't really mean an error. It means that we don't need to handle Power domains because as you said the caller already used dev_pm_domain_attach. Similar with this: $ drivers/base/power/domain.c +2504 int genpd_dev_pm_attach(struct device *dev) / * Devices with multiple PM domains must be attached separately, as we * can only attach one PM domain per device. */ if (of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells") != 1) return 0; Will update the description for when this function returns a NULL. > >> + return NULL; >> + >> + mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd)); >> + if (!mpd) >> + return ERR_PTR(-ENOMEM); >> + >> + mpd->dev = dev; >> + mpd->num_domains = num_domains; >> + >> + mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains, >> + sizeof(*mpd->virt_devs), >> + GFP_KERNEL); >> + if (!mpd->virt_devs) >> + return ERR_PTR(-ENOMEM); >> + >> + mpd->links = devm_kmalloc_array(dev, mpd->num_domains, >> + sizeof(*mpd->links), GFP_KERNEL); >> + if (!mpd->links) >> + return ERR_PTR(-ENOMEM); >> + >> + for (i = 0; i < mpd->num_domains; i++) { >> + mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i); >> + if (IS_ERR(mpd->virt_devs[i])) { >> + retp = (struct dev_multi_pm_domain_data *) >> + mpd->virt_devs[i]; > > Should retp be PTR_ERR(mpd->virt_devs[i]) here? PTR_ERR returns a long but our function needs to return struct dev_multi_pm_domain_data *. > Thanks, > Ranjani