From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7182E30BF68 for ; Wed, 4 Mar 2026 10:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772621005; cv=none; b=oEl9BQyrQDqt0OHwpwqhovKQyKs6COXEHHR8pZbguT5NeAO5bEKQH67BGsSMbXTgg+GPlR5NFGqCalQyBKGM+vsNudJ8i58SHjM30JXaOeuOuObDloWSmdLUssegUi5MWM68vj4O3EmMJTV1DIl/913B4+DqXRwQcLuHVnMrfZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772621005; c=relaxed/simple; bh=g0VY1SnWACmqekRKry+p3Dbh/R88hKSsrMte/jrmuZQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T4cA5nwzhRMZvDGB8nTgS6Gn3OeMknkmUGOc4FITSFVe67V033cVrFshszQxackxkLfh//VfARO5PKUD8TZ+RqB+mw5DDwhqXZ7UOqkW/aOZXmEM6jj2yZ9esvyENcCVY2XXnuf1K6YS9bxlCb/dbQeLkDZ2M3borR0esKpj/5c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=oHdlKwiI; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=AqDQnfpB; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="oHdlKwiI"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="AqDQnfpB" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6245SehB152717 for ; Wed, 4 Mar 2026 10:43:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= rSVxUW7sHSJ3EGoTO0uhgr92gcAUzVZPdRl59oQoUL4=; b=oHdlKwiIQh+CPkxo cbg5r5T0KINufGc/6sgHP7ZAc6riTDqJEfqsHsSLq9H8PDuBf5Bv8ennxVoODYTA RmF28651VQsM7H1G7pUZXcgjyQpIMKHZZ83E6lQe2VGLl4uDjCG9nqyKSXRv5+Np lJFn9jNGIebc4jqmmd8/s10t+V8OECCrRqeyIAh3yMIG1EjVv+ldiqPzIZnojbFb WwfzGih4HTS/08lNCERrsQMLmtCA70KsigsNeDZeAHTNz3wmsjk2adkCsNy/4UQ8 7lTQTVQJNThJjqSnGyHJhxwlt9fxuIBzHWjVPZrjWUMM7ATgTWGdTRYI7WDYi5df wcstTQ== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cp3tvkab0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 04 Mar 2026 10:43:22 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2ae42659a39so256895105ad.1 for ; Wed, 04 Mar 2026 02:43:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772621002; x=1773225802; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rSVxUW7sHSJ3EGoTO0uhgr92gcAUzVZPdRl59oQoUL4=; b=AqDQnfpB7aKqRw9nF4cJ54Q+NT3TZIJ5XhxnbYanqiqHdUv8d7nvBTyoNT11o6ZWMY EAVGzpu/bBA+4rXJbIB0QxzuSKIU1PnK8kazUlOWeW606dQeen+3IOOI7af+sKwdRz1+ bPN0jhF5EbaHPEk+FsxNBsUy7MyjhwA1qX8j9rJGLpHeNkg/Vst3DKiANqm+ReXTiEav ladG/aR5y1bhUugz2tKXeIxfePvjXQ8nf78oYy9l0l/avzbnKpe6+oQPffjSOoE/3G5G 09Ww+qjdHRg9jOPzprk+nhozJaUqE8uFkELVitqCHup9lc5h2cEkscMltcxT92Vi1uyY 8tyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772621002; x=1773225802; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rSVxUW7sHSJ3EGoTO0uhgr92gcAUzVZPdRl59oQoUL4=; b=plShHVFdGpMH/V9sSXNvvAYb5PwNCHz2h95x08meyof5MKiy77o3uwh083rX1mPbIs AS+3VdqL0wSUz+tbQJ1sxpUUJ2Kn1S+ut30om0E5K+E9oZn2NrI/1zr1LZ9evStOPRRp THqxynhITZ11rupC6mylSZAiD1GjO0+yDjZXppCGN4AYoaWTIEBAp6FYMGTr/QWp+q7B gfby86/HxAIev8Rafacfmny5SQRtLb8syYawfd3RTLXuSScng3PObg9cIV3pr3KCQvvF HJLc5va7K3TBo75OuWPUr7DYsbegEQtqIOGJbOuex+cCM7qjV/TEoi8dvN4LS6rQIOuV jOTg== X-Forwarded-Encrypted: i=1; AJvYcCWXQUFXioKOIg5R5QF4jCyJqh8rsrWjNg06GZDnI5OlAuNTclC/pRIqYgxlwKt4ThhCe/9wd+r1ZLMz6uE=@vger.kernel.org X-Gm-Message-State: AOJu0YxEoP347m+HrQbwpxl/Z1SYwLj8d0Mxj9g9XzHkAXPaBKAekTkf GAi8JLAqcy6yyD2bEy5ZZSU9wEVO87NreIgVp/vM62kHnkkesE5NDrghEruI7WoiBgc83GgtXuC A7z8OEY1tDxdTiwWr00Alt/cRVsIGzfJD8SpLgHAIHYte9jfY9PBvbf3vDOT0p/feXZbRPBZ/tn EmsQ== X-Gm-Gg: ATEYQzy8xWUdsENGjS2oVoG4q6/HHjgS+hW215KNtkzmkOH53PlidR65wRNShZCB5hW 63UGOxtmHViLpc9C/T01kW6EOR79UNlf9loeTS4LWcnBAUNjN60SCXHCDMjlP89WZpBC4x1F0Av hS9e/vJ3eFjEq2NWlkyODInWJmT0TNgW5qx/IG5zxiwrRg966Odurh3ZAU6HWCKA5bjzKAUmalI 3xqg8hBNdp6JUQzp/A0ybzzYK2RD2O6vd6PeEwl9OZPU2ta2JYocPAU7mmRGTLDtByUPPhx0QC2 2u+Tm38lY86rF7MtO7tIMlkuYCPMRKMQCAOBISWMdWcENERxc7hTJEOVTH71C2HS+4YPa0JyMCd /B5z0f3LiriQidsKJ9+nhqaSt+7sl3JIp1a87AHtV5gL4CCqywHHKrISZIDp6w31v/823FwqQfJ oWq0Pt5224hPOQ+GJsxw== X-Received: by 2002:a17:902:e5cd:b0:2ae:5039:a075 with SMTP id d9443c01a7336-2ae6ab95fb7mr19412845ad.53.1772621001786; Wed, 04 Mar 2026 02:43:21 -0800 (PST) X-Received: by 2002:a17:902:e5cd:b0:2ae:5039:a075 with SMTP id d9443c01a7336-2ae6ab95fb7mr19412715ad.53.1772621001353; Wed, 04 Mar 2026 02:43:21 -0800 (PST) Received: from [10.133.33.194] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ae4ee6f257sm107497235ad.22.2026.03.04.02.43.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Mar 2026 02:43:20 -0800 (PST) Message-ID: <706e901b-9152-4a88-b5fa-7ab611665136@oss.qualcomm.com> Date: Wed, 4 Mar 2026 18:43:16 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] PM: Move to_device() out of CONFIG_PM_SLEEP protection To: Pengpeng Hou , "Rafael J . Wysocki" Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com References: <20260302105456.4134882-1-pengpeng.hou@isrc.iscas.ac.cn> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <20260302105456.4134882-1-pengpeng.hou@isrc.iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA0MDA4MiBTYWx0ZWRfXzaFSOGryr1FV 2rV1JaFzCfkQSYbKGQIxQlpdYyw2KVaWtGhBtJKBrgKi/f5zR6VDwjfZQWD748pYLUYGI1syUoC 7XEIzkhUaCkZHVAkdQdJUANkUkd+37bZyEQwOM/0+clVIwx/ivIcyhHnz5H0MRtiHA+ZWC0BOoc yzBd1onMybfFTTGJgK3D6VwyGqFu5Yhd2ow3mC7qZvpwNuPkJEGY1VzhZMKRzyAlE8omiYkKtXZ 4i8GXCYdn4kKVvsO+iYqbRKeZWe/d4/n9LDYfUuc60P+0SAEWPM2i1hUBEJFqSHEdhMMcP0M6LS GHdxtA+Z5lzFXmfjfO3wb2et3o8rWBwPDdY69U9ThyEivDv6GgiPsLrkHM+oyzrcYJV4gLE5nDR hdRNoQb57qmj0YREYLnF4XuCZZOE3WZKyCflYU1jlCo0n0d0CUSyy2rYbqUXH5HzT9J5KJsEUoG 1Rvsc0tuOsxx98qn7Fg== X-Authority-Analysis: v=2.4 cv=VYv6/Vp9 c=1 sm=1 tr=0 ts=69a80cca cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=oSJ1uSErN6jGRY7e9e0A:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-GUID: npAB_EQalLhwFhjC2_17tYIC8oTP831A X-Proofpoint-ORIG-GUID: npAB_EQalLhwFhjC2_17tYIC8oTP831A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-04_05,2026-03-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603040082 On 3/2/2026 6:54 PM, Pengpeng Hou wrote: > The helper function to_device() is used to convert a list_head structure > (specifically from dev->power.entry) back to the corresponding struct > device. Currently, this function is only available when CONFIG_PM_SLEEP > is enabled. However, some generic power management code may need to iterate > through the device list even if sleep states (suspend/hibernate) are not > supported. Hi Pengpeng, Thank you for the patch. However, I have some concerns about this change: 1.Your commit message states that "some generic power management code may need to iterate through the device list even if sleep states are not supported." Could you please provide a concrete example of such code? 2.The to_device() function accesses dev->power.entry, which is only present when CONFIG_PM_SLEEP is enabled: struct dev_pm_info { ... #ifdef CONFIG_PM_SLEEP struct list_head entry; } This means any code trying to use to_device() with CONFIG_PM_SLEEP=n would _FAIL_ to compile when actually called. > > There are currently two approaches for moving the function.The first one: > judging from the current conditions where the function is called, all calls > are not wrapped by any macros, so it is appropriate to move the function > definition to the global scope.The second one: if the compilation of the > files where the function is called is controlled by CONFIG_PM, it is more > appropriate to move the function definition into CONFIG_PM. > > To ensure that the availability of the function is consistent with its > usage scenarios and to avoid undefined reference compilation errors, the > first approach is adopted. > > Signed-off-by: Pengpeng Hou > --- > drivers/base/power/power.h | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h > index 922ed457d..0a40bb546 100644 > --- a/drivers/base/power/power.h > +++ b/drivers/base/power/power.h > @@ -106,10 +106,6 @@ extern int pm_async_enabled; > /* drivers/base/power/main.c */ > extern struct list_head dpm_list; /* The active device list */ > > -static inline struct device *to_device(struct list_head *entry) > -{ > - return container_of(entry, struct device, power.entry); > -} > > extern void device_pm_sleep_init(struct device *dev); > extern void device_pm_add(struct device *); > @@ -162,6 +158,11 @@ static inline int pm_wakeup_source_sysfs_add(struct device *parent) > > #endif /* !CONFIG_PM_SLEEP */ > > +static inline struct device *to_device(struct list_head *entry) > +{ > + return container_of(entry, struct device, power.entry); > +} > + > static inline void device_pm_init(struct device *dev) > { > device_pm_init_common(dev); -- Thx and BRs, Zhongqiu Han