Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp224869pxj; Fri, 28 May 2021 02:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysw58fp3BbEh3LcN+fE+BdyPV3C28Up4WIsMEsZmYS0O3EcVSjKZmQ/1PfphUBjFClVNPq X-Received: by 2002:a92:1e0f:: with SMTP id e15mr6769560ile.265.1622193906069; Fri, 28 May 2021 02:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622193906; cv=none; d=google.com; s=arc-20160816; b=s0qsGf2IOYtBDh8H47OBOKuKikzF1u7okUNa43dhvHsms3Z5cI+uTAwQc1i+gGWcfS ChjpJoliEU1L4aKzkpMmJq+JPzpApRGMLHlw62EbdwFXTpusRvyD1gNGK+zf2CLLiNw5 H+TBBZfRdsbFD9nuP0hQU04qNOCHaYoJG6pBHp73NC3McTWJRU4TPKybjCdadE6/fB3R f4IW63gyiAmAfwxqzJHmxhPzG2xmNxqj3CB7Sc5KX/hNoPQK2ZsObhOjNKmDe8B3aavn tQIghNhCGGYLp6/G5mrTOYOHCTIvwH44lZuzdO4pu5GGvM7FaBROqXXlF6gfnev0x3Ez XOfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZB800bOhKFCGK6d7wDa9t/A1lZSI4wYj4YKflJqW4BE=; b=PcCJr6weTcdkT/8G/RKb1erykHfh9T+2xVh036R9COn39mtHFYyA/UahpTXBg+z83g 3TpCo9elvmolQvYjp8oV0szKH9cMHQn0yysa8slcUFSRmjpdGgz8QHAHadILoWYIxpoZ xaS8Gh9PIMSIuwMZRAAtLqO9R3B+jbl/R1N7WWXOa/fv2vBUdfaFppu5xdc9eEFsbWng EaDZfru87gsYB2+xGlj3COnzHzodgIULGds6YiZUTa/mt3s4YSpWzUMuFjSbHS2Suqji vMppK8aU3UqTxq/49z9cCV/S7R/th2cw9q0Sf9M2OW6zeQYmZ4GlmlTIysnQSHjHprZq A7Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlhgpHI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id j11si5410610jat.42.2021.05.28.02.24.51; Fri, 28 May 2021 02:25:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlhgpHI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235452AbhE1JNn (ORCPT + 99 others); Fri, 28 May 2021 05:13:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235393AbhE1JNm (ORCPT ); Fri, 28 May 2021 05:13:42 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFED9C061574 for ; Fri, 28 May 2021 02:12:07 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id b26so4304954lfq.4 for ; Fri, 28 May 2021 02:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZB800bOhKFCGK6d7wDa9t/A1lZSI4wYj4YKflJqW4BE=; b=KlhgpHI6b5tTvVjNUp85mgiuuWggqNBSOcObUyi0mrUDSuH0/J9coPaxoqyBwaw9qK RDGeCgR8eODiassfVCSNeLmOyRUMFeid8Yd2LyGwWto6lydEIzcSGgSgXTe4/2PRJW71 CXBY4DZpHotaNtp7TMg/f57+OpBhzFCZDWicDleIh8Ijdey1ym7VFXViRzwojlW0gUjK sdcY27oD7qneN++kxIT1Atlis8+pgDdeeXS+VfZ7hQdqJO8PfLg1lx8vBtbIm1afRH0E QOQ+2yycLqX3/9bcWZUU5wNBncEx0hCGD9LiKoGKFadmS0jwTc39Ei8JtuQlxzhpWZOS dELQ== 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:mime-version :content-transfer-encoding; bh=ZB800bOhKFCGK6d7wDa9t/A1lZSI4wYj4YKflJqW4BE=; b=TT0KFfqXZsX+3Ggff28Ae86d9x+qqU0LkCF1Ne/eP8LCUCtEhF3vUUcThqfv36lRPI C5q+hdrnqYoITw2jbcJb/ssLBTKkRxBpnGQKQMnNApB+wwYojydoaEFaniCGsaaEWR7J PnRtHxkiqc1X67aTJxdfFzUpxsf8NFN5iQ7knBOHgsRKWK5ZYDUexq06cHz6WCoWiODX bFcoI+mY/4X5xauFRo8qDdk5rCttGGwZqW+NT4RjlYCLFDbUScbVS872hE29zv+cOC2V HKOMAW7JPnXPAstqO2a+2BSz7Y0/AwxmX09lLabjoFGgDQZFpRfwChmmznKDQ+NO+Swf 74Rw== X-Gm-Message-State: AOAM531XwjUU09o9nT/QR3YdV581mAr/REcJQWu5olnvkl5f10eR2SGd gF9grkH1RgdVQjYaAbB+AWeJZw== X-Received: by 2002:ac2:598e:: with SMTP id w14mr5037682lfn.558.1622193126115; Fri, 28 May 2021 02:12:06 -0700 (PDT) Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id m4sm537061ljp.9.2021.05.28.02.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 02:12: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 2/2] PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks Date: Fri, 28 May 2021 11:12:02 +0200 Message-Id: <20210528091202.11603-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We are currently allowing ->rpm_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 unassigned ->runtime_suspend|resume() callbacks as well. 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 --- drivers/base/power/runtime.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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; -- 2.25.1