From nobody Sat Oct 4 14:14:58 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 26FC4224B1B for ; Fri, 15 Aug 2025 14:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755268609; cv=none; b=urHO/HuDC0qcxgZq3jpS73bDDPTkn13HIVJh2BS4FPCIFNyJFGbXMhpJgaCYkpbcnsxPicgPwUHzpe1HGBiGTMEqZvbYCgeKBJyYIwU11/HF0huJltemG7yj27EIpkDJCwYaFVyacKl01/+dXua7lEzfJn3I3VLpu6s5GptdXw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755268609; c=relaxed/simple; bh=BzWfToJE3ECxETuJZ3k/sBp7q/SRF/jEhj86+u2O1rk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fzMrB7yE6hOEBjq2SUHZDgMQjxAg+ci0FIKCHPhB7uxRwGz8pBfqUv9sM/BIkYYypFv//zejvF72GmqD/O6bUPABOBfqxkAOUdFRNzUgVrnf/3zWB4uGp/S0lOrtAjJcaMHTUtYR7jB5YNGZ1Xc7Hi3qEIUa4YlHmeIbt5qpAD4= 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=bMHDQ+fe; arc=none smtp.client-ip=205.220.180.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="bMHDQ+fe" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57FEIlIw017486 for ; Fri, 15 Aug 2025 14:36:47 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= FDqwUezYGa9CZCaFbdXED7PEdoZ055Cwe3xHxx1ns7M=; b=bMHDQ+feRetjFTrc m5JlDNqAhot64rJRTsRRmgf7cf42kyAgR1V+l7Y5D0ECygAxX4/yeec64BsqKnlY YbDiwkw7JnoKjaykTWPb4/xiIxDtwRWb7v3OmOOG6xxAbQZBxLLAd+vdmrfjKd58 BcfrdO21VrJvSfRqBiGzNHKrs30CIfgpmwi82btpa+9v4qyVrNIWuivMx/TBmhVD upp0jI3exh1jVPrg5Kj+c9k32yJPhbZienJxS+Oi9N/hKcYwSan3SSZnHvcpAuFN sCUpMqtH5WUAFL4CVbXZYrIqQulAhHSOkM4WvjmhhspFX+4NmbY91pUpcVOoE+Wp 5VqMzQ== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 48eqhxhfw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 15 Aug 2025 14:36:46 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-323267c0292so1940572a91.1 for ; Fri, 15 Aug 2025 07:36:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755268605; x=1755873405; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FDqwUezYGa9CZCaFbdXED7PEdoZ055Cwe3xHxx1ns7M=; b=oh3jpE3hF5pnnTXwrvK3KlBkXKpDScPlKTjpthcLhE3SbmbMoK57PHkph+GtNYYb0E FxCJiO5BcALUxG1I2Znd5zEFNdMwXxyMsmfZAQ3JbXvXg2Wuq/te2vgTMW6UK68SSL6n UNR+DCmd9MDKHoRNNMkiBViQOahbuqV8CWdLhJIlu00/QrYSu9zZFS92GgpcrbVz1537 /nEGxKZdjJ4OLAQ5hvNP4i35YvfWsVVFJ8SXzIoitbs0AexieOibeHrpdEmvFPUxl0JT /tbhoKkBkMLBT0/7eEp2bP/8EIawOcVUo5++66K9hpOMV0oiNz9XDbe3satHhkUS6CRq bTlQ== X-Forwarded-Encrypted: i=1; AJvYcCXGKGOqLb8KzI/p5zb4f/+p4pcZIO4eRMNACGNzZ866e/UUQXrdRorW6tUs+iRPqoyHO+K6qQiUxp6PIO4=@vger.kernel.org X-Gm-Message-State: AOJu0Ywu6ZjK6yjqGnAHGTtPWgoxRq1x0C90wG0+ZFOSYPiXgLmWcDSE gcmDMXEdPXIm3vIBn9caFE+naNFBU0TyGAb0jHLmrIj+cFRNCvW4Nev3Q8U6ej0HVYpjJqv2e8R bzjtXLGt7Rw88xjOEab4KUsaP64WBTFwQIL/9nzq5oogZ/qivfXH1OFDHJzWN1fZbOoE= X-Gm-Gg: ASbGncuakIfSgDmOezkrDtDFKCJ7qBwnoGS8l7XAWktn79JKJ9eBvA94O/1ONLK9sUT TwiqM9Tmp48M94LZxLCU9R1dpfiI2Kch8X+LDNMw3FR0WOeNobBXbfFLTF8aL1K52y+mqVLU4FT YVMZI5c0ev8oT/AyrEn5NYxQzvxHOfOlb7J6vfI+orCxo1cOd2X921QF7k7Hab8V86p7pnf2VHF /oE5L1peVlFVggx7+VYMpWcRkxR6Jx+HQgXjMp7sS0k92cmRILx9WjLRSGT36ISIlnzsIluJMwD kkPq7Yk25jenGJuYbuRgJTPf9VDCSxbwleGkM3at4YAFeq4D870Bc4v1m+9emUx+qrPQ6CVwRwm y X-Received: by 2002:a17:90b:2dd0:b0:31e:f351:bfec with SMTP id 98e67ed59e1d1-32341e5e0a4mr4204549a91.0.1755268605447; Fri, 15 Aug 2025 07:36:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqZ62D0ilw5h3pOxyKsD9atT57r02HUkM9y580UM4/h+lMlRwpO5+zb86tLI7CTdiz0ij7TA== X-Received: by 2002:a17:90b:2dd0:b0:31e:f351:bfec with SMTP id 98e67ed59e1d1-32341e5e0a4mr4204499a91.0.1755268604960; Fri, 15 Aug 2025 07:36:44 -0700 (PDT) Received: from hu-spratap-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b472d73619fsm1437576a12.39.2025.08.15.07.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Aug 2025 07:36:44 -0700 (PDT) From: Shivendra Pratap Date: Fri, 15 Aug 2025 20:05:07 +0530 Subject: [PATCH v14 02/10] power: reset: reboot-mode: Add device tree node-based registration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250815-arm-psci-system_reset2-vendor-reboots-v14-2-37d29f59ac9a@oss.qualcomm.com> References: <20250815-arm-psci-system_reset2-vendor-reboots-v14-0-37d29f59ac9a@oss.qualcomm.com> In-Reply-To: <20250815-arm-psci-system_reset2-vendor-reboots-v14-0-37d29f59ac9a@oss.qualcomm.com> To: Bartosz Golaszewski , Bjorn Andersson , Sebastian Reichel , Rob Herring , Sudeep Holla , Souvik Chakravarty , Krzysztof Kozlowski , Conor Dooley , Andy Yan , Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Konrad Dybcio , cros-qcom-dts-watchers@chromium.org, Vinod Koul , Catalin Marinas , Will Deacon , Florian Fainelli Cc: Dmitry Baryshkov , Mukesh Ojha , Stephen Boyd , Andre Draszik , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Elliot Berman , Shivendra Pratap , Srinivas Kandagatla X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755268580; l=4877; i=shivendra.pratap@oss.qualcomm.com; s=20250710; h=from:subject:message-id; bh=BzWfToJE3ECxETuJZ3k/sBp7q/SRF/jEhj86+u2O1rk=; b=RYuLdurTXlXjQtCHE5nX18yZK2e4lWHzqk3OBDVjfSP6IPXK9bBT/5bHpFJuKNoKQTKctA3aE EXCLcCs1FcgDo9wc3NWVVqzdZmL2XVhAsx81HO1e1vIlJH9mOiOFdu7 X-Developer-Key: i=shivendra.pratap@oss.qualcomm.com; a=ed25519; pk=CpsuL7yZ8NReDPhGgq6Xn/SRoa59mAvzWOW0QZoo4gw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODEwMDA1NyBTYWx0ZWRfX/+Xid+FguiSV NARsE8fxZWQu6Eoe6sH9OukO0YBO5yNB+v5NWUIwWQwN9nOjIVlWdWJlpEmtbjuDk1L4nvHI0eW o6p+zJsZGO32CDQ5IeMeBMB9v4ErkeetbrHm2lsNxoubP6sP1GSggprPUKwDB3cpOODGHeimwDJ EsCrocp9x4Ummi8oYSKY6pZ9WitM3PEqxQaysDWIPIkOrNYYdl5O/MRhamIk3Hlt4fNZXHcrzbk GoWM5Spb1snpl/HDqE+8x3ffFmELZ/A14JfJHW9MZBx0ZGzG5lkisRN20UOusvVAFAxPgE5UdTu d9oAECLb3EAKdxRZ/HfYkd5ZPlTJ+RefCJ5uWn0ncKtuxnnLU/V75TPQ+UHbiTUZ77ztVCHtoN1 9zgZQ+6v X-Proofpoint-GUID: -COjCgXA0WhOvCCXbsnEpC8iSiFkvvAA X-Authority-Analysis: v=2.4 cv=aYNhnQot c=1 sm=1 tr=0 ts=689f45fe cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=2OwXVqhp2XgA:10 a=EUspDBNiAAAA:8 a=IcmTHOqSNbDvJ54L4SUA:9 a=QEXdDO2ut3YA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-ORIG-GUID: -COjCgXA0WhOvCCXbsnEpC8iSiFkvvAA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-15_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 suspectscore=0 phishscore=0 impostorscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508100057 The reboot-mode driver does not have a strict requirement for device-based registration. It primarily uses the device's of_node to read mode- properties and the device pointer for logging. Remove the dependency on struct device and introduce support for Device Tree (DT) node-based registration. This enables drivers that are not associated with a struct device to leverage the reboot-mode framework. Signed-off-by: Shivendra Pratap --- drivers/power/reset/reboot-mode.c | 37 ++++++++++++++++++++++++++---------= -- include/linux/reboot-mode.h | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot= -mode.c index 42bb99128ed3846d4bff62416dc31135ddeaeb90..9bb97bcd33cd3d58c75c791e9b5= 68024e810e5b0 100644 --- a/drivers/power/reset/reboot-mode.c +++ b/drivers/power/reset/reboot-mode.c @@ -3,13 +3,17 @@ * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd */ =20 +#define pr_fmt(fmt) "reboot-mode: " fmt + #include #include #include +#include #include #include #include #include +#include =20 #define PREFIX "mode-" =20 @@ -75,17 +79,21 @@ static int reboot_mode_notify(struct notifier_block *th= is, /** * reboot_mode_register - register a reboot mode driver * @reboot: reboot mode driver + * @np: Pointer to device tree node * * Returns: 0 on success or a negative error code on failure. */ -int reboot_mode_register(struct reboot_mode_driver *reboot) +int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_= node *np) { struct mode_info *info; + struct mode_info *next; struct property *prop; - struct device_node *np =3D reboot->dev->of_node; size_t len =3D strlen(PREFIX); int ret; =20 + if (!np) + return -EINVAL; + INIT_LIST_HEAD(&reboot->head); mutex_init(&reboot->rb_lock); =20 @@ -94,28 +102,28 @@ int reboot_mode_register(struct reboot_mode_driver *re= boot) if (strncmp(prop->name, PREFIX, len)) continue; =20 - info =3D devm_kzalloc(reboot->dev, sizeof(*info), GFP_KERNEL); + info =3D kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { ret =3D -ENOMEM; goto error; } =20 if (of_property_read_u32(np, prop->name, &info->magic)) { - dev_err(reboot->dev, "reboot mode %s without magic number\n", - info->mode); - devm_kfree(reboot->dev, info); + pr_err("reboot mode %s without magic number\n", info->mode); + kfree(info); continue; } =20 info->mode =3D kstrdup_const(prop->name + len, GFP_KERNEL); if (!info->mode) { ret =3D -ENOMEM; + kfree(info); goto error; } else if (info->mode[0] =3D=3D '\0') { kfree_const(info->mode); + kfree(info); ret =3D -EINVAL; - dev_err(reboot->dev, "invalid mode name(%s): too short!\n", - prop->name); + pr_err("invalid mode name(%s): too short!\n", prop->name); goto error; } =20 @@ -129,8 +137,11 @@ int reboot_mode_register(struct reboot_mode_driver *re= boot) return 0; =20 error: - list_for_each_entry(info, &reboot->head, list) + list_for_each_entry_safe(info, next, &reboot->head, list) { + list_del(&info->list); kfree_const(info->mode); + kfree(info); + } =20 mutex_unlock(&reboot->rb_lock); return ret; @@ -144,12 +155,16 @@ EXPORT_SYMBOL_GPL(reboot_mode_register); int reboot_mode_unregister(struct reboot_mode_driver *reboot) { struct mode_info *info; + struct mode_info *next; =20 unregister_reboot_notifier(&reboot->reboot_notifier); =20 mutex_lock(&reboot->rb_lock); - list_for_each_entry(info, &reboot->head, list) + list_for_each_entry_safe(info, next, &reboot->head, list) { + list_del(&info->list); kfree_const(info->mode); + kfree(info); + } mutex_unlock(&reboot->rb_lock); =20 return 0; @@ -178,7 +193,7 @@ int devm_reboot_mode_register(struct device *dev, if (!dr) return -ENOMEM; =20 - rc =3D reboot_mode_register(reboot); + rc =3D reboot_mode_register(reboot, reboot->dev->of_node); if (rc) { devres_free(dr); return rc; diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h index b73f80708197677db8dc2e43affc519782b7146e..98f68f95c9e8460be23282c51ef= 7fcbed73887bd 100644 --- a/include/linux/reboot-mode.h +++ b/include/linux/reboot-mode.h @@ -13,7 +13,7 @@ struct reboot_mode_driver { struct mutex rb_lock; }; =20 -int reboot_mode_register(struct reboot_mode_driver *reboot); +int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_= node *np); int reboot_mode_unregister(struct reboot_mode_driver *reboot); int devm_reboot_mode_register(struct device *dev, struct reboot_mode_driver *reboot); --=20 2.34.1