From patchwork Tue Jun 8 09:02:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 455766 Delivered-To: patches@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3492127jae; Tue, 8 Jun 2021 02:03:08 -0700 (PDT) X-Received: by 2002:a05:651c:169b:: with SMTP id bd27mr12161832ljb.219.1623142987635; Tue, 08 Jun 2021 02:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623142987; cv=none; d=google.com; s=arc-20160816; b=liL2xGS1KTqkEZgsNlvZe1fkCqy/6kPJ1V8IOsPOXjN3k56fqx4w2pvsFhXFjQjM+r K6o1J+kVr03MtMmm9MmrPjq0nA2gqvB25W6LZA9Z6w2zy9bJNQ7d9Wdu2Dmxk7QVEwvv eI9gJdvq8OpCdFmEXNnfUGPlNO8D4WxWD1TpGqQc1ht1axZ8vHLsCeu13PAtZ21Av+Ec +NJlB85kDVfTI7uF1mGo5+jcTrdigUgCRCrL0/uXxgR+GyyBv2Whlj+Jd+XDHgU0lqmO OLBy6OJp2zId16wDGs3PD0cDcJE3o9ymtuAwxwOOWTZBCBMx7tQ+s7vu2myeNeBsmk2d NPrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=cnFHa21pMNW2jSUA5XLazyeCEAKZE26JFLYB4VhYyNQ=; b=Ve4Zj6Cg//LhImwXmJlUNa5Xhv7cebI/uukH4ARCH+iNJ2W8Rs0ZCSOF7hkqzQsgIj hG46qo/NiOQcFmT9MqA5TRICyM7OWrJm0ODh/T8grKKLdk/m6NECghAg/LnXFrsAKcoE TjaC5Xk4CmSzXlYn4j+3nzl3ff0Q2xpY7PkYqt2SaBgE93PnUoGzSteVT2SI+6VZ7Eti htZK10cIc7H1gGE9vB3S7sQSUNY4MsQ0UwZu7nRZfl613fQPB/z3IoEyPve4lego19HT +3FCueQwK19WjU2mC0HLW62D8dR741TZibHDNQUEuFNg7NgxLz45X2MsadMtssXkjwkG eALw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IgmBj3uQ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id i18sor6993985ljn.14.2021.06.08.02.03.07 for (Google Transport Security); Tue, 08 Jun 2021 02:03:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IgmBj3uQ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cnFHa21pMNW2jSUA5XLazyeCEAKZE26JFLYB4VhYyNQ=; b=IgmBj3uQF/Drcu204B+VWTFpSeocdqBPPSoxqws7142jumL25Uh5R6+dPP3v0J9iDm j5QqH9Ueia7WhFVQ1v7KZarY1H2h/Eq3xB25ZWAf+ABK2kLFWm3LoepZMmcAk1dj7kPJ 46dqfwubP/ws+WPzvXo9LK6LFtc5lpDs+TabH+uCeUi+C5A0gGRZiLboqtFAWmVkmGVw w40ygOPUcdE2e6jgopsgKqAi6jk8FzXRZF/WwTCijJ1nYRib8SmANKg8IVxH+bHIs6Zb AGWWja740laEZ6wEwACI96rsf2teqI61gIyrMTRpymTewlClTj3Jq/AD5nJS9cz1cIos BYGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cnFHa21pMNW2jSUA5XLazyeCEAKZE26JFLYB4VhYyNQ=; b=ozytzaCE14gk6ZTXtwya1xkcGX9M5wq3Ned+aP8gfUmmkXym9C+Ml0CV2ek6zkN+vk u00YHH3WJi8mWTbKVJZiX5fz/V4bE6EM5PI9ZWS2oTJ6q05wDmb+diLQaHdR1fRfQAl/ Tiqz+sgy3RktsLdcXRWF3KnnmkfhdU/WyDTjnaQCw3C4XxOhyrC3BFoRZ1Zu1wHqKCQe 5zB1yitZ0St7o5o+PKhCale6lNtRzuKI/m2LZI/GP3KjwKIhrPf2Nw7xlxnV0hlGMEgy o3vnkYvpNtKlvtV0jDQVn0FSGezxE9qWZDBBTQ5Lb3nm7hVCHmkaqMxvl5ONSaiDPi5b to3w== X-Gm-Message-State: AOAM533CzBCybjqZIkql5KX1tfbFoIqUhGd1M5lv9TgGg/D5WPoiJuYO 5GIpP62mC1c5bjNmEjyMSLgsCHsi X-Google-Smtp-Source: ABdhPJwI7y00opt25k6XFPvLGoi/PJ+2CRkZfM2+49l59Hp/hIZD5O6F5RgnDnBcP7p2eJIkt8skQg== X-Received: by 2002:a05:651c:1138:: with SMTP id e24mr17675880ljo.403.1623142986144; Tue, 08 Jun 2021 02:03:06 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id n17sm1295197lfq.118.2021.06.08.02.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 02:03:05 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Saravana Kannan , Alan Stern , Adrian Hunter , Tony Lindgren , Kevin Hilman , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks Date: Tue, 8 Jun 2021 11:02:49 +0200 Message-Id: <20210608090250.85256-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608090250.85256-1-ulf.hansson@linaro.org> References: <20210608090250.85256-1-ulf.hansson@linaro.org> MIME-Version: 1.0 We are currently allowing ->runtime_idle() callbacks to be unassigned without returning an error code from rpm_idle(). This has been useful to avoid boilerplate code in drivers. Let's take this approach a step further, by allowing also unassigned ->runtime_suspend|resume() callbacks. In this way, a consumer/supplier device link can be used to let a consumer device be power managed through its supplier device, without requiring assigned ->runtime_suspend|resume() callbacks for the consumer device, for example. Signed-off-by: Ulf Hansson --- Changes in v2: - Small updates to commit message. --- drivers/base/power/runtime.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 68bebbf81347..8a66eaf731e4 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -345,7 +345,7 @@ static void rpm_suspend_suppliers(struct device *dev) static int __rpm_callback(int (*cb)(struct device *), struct device *dev) __releases(&dev->power.lock) __acquires(&dev->power.lock) { - int retval, idx; + int retval = 0, idx; bool use_links = dev->power.links_count > 0; if (dev->power.irq_safe) { @@ -373,7 +373,8 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) } } - retval = cb(dev); + if (cb) + retval = cb(dev); if (dev->power.irq_safe) { spin_lock(&dev->power.lock); @@ -484,9 +485,6 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev) { int retval; - if (!cb) - return -ENOSYS; - if (dev->power.memalloc_noio) { unsigned int noio_flag;