From mboxrd@z Thu Jan 1 00:00:00 1970 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 43BA730504A for ; Wed, 26 Nov 2025 17:05:15 +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=1764176717; cv=none; b=it0zNWdvho0iJ25aSPwNrsyoivCAYMzxE0r7HGf5QpjTeMusXblEhAmHqEupjMdxMSaTDO2VkNVjX4m3FCMb3v+UyxGvexCKSNLIaSiTF7Tbm0wiKE9i3h+lVC3+a+kwj/3E0EzwSoJWYO8Nva0G2VKr5T+2sanLrV0hazAmdCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764176717; c=relaxed/simple; bh=IBJIyCGos+Df5v2QF9ELzxIsygjlK7zQK9zsEMYIOSs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=X3cSuiBUlJraGl7+qTcHhhcFCn318zT76kqbjtDlHk+3LGnjLqb8mKTP+D9TIqiNjPcgGNuaF0Iyz2LtKFohqtRHc9IBQjSiK/IeuCrZ5SDAm6j2e1SEjrTmtHvXfNPeSl13tgvgb77Mbcwzo9zCJT9k6ZuIEuMHogx8l1fk1qY= 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=IWjTbkgy; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=fv29vcsx; 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="IWjTbkgy"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="fv29vcsx" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AQEp10C3890204 for ; Wed, 26 Nov 2025 17:05:15 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= QryErQwyuR3L+zgYIAijcUhN4Vw58XDmRjXoajIzf28=; b=IWjTbkgyS2JGpM8G 1fvLxTYmJd+9XsG38c0YEdFpUQ3FxN8qoAI9C9OgHu8j+6ztprmKVsfcXPbiDn+z qazFJBFSopbMk73JhxXN+ST5DGpMQAwiLolkj0eVuC4wfgNZZpBGu02DKK4K2gSJ Zrsp2JvMDyDK3bHGTgLEJkxG6OoLZWM1tyio7PibvAlwDyiBOz86jf3iqfAQn9fU 31AmKLPTRsi80Y0tgIuWEW4OnHp3zir0RTf6hMjSFTEuAeK8ZZZKkhL5Ha+wzKl9 gpr1aKASKGSJGmw7CH8U8DZchWzL1QCrGTuNBCRKophnij+vb5j5ccah7nOhTST5 MWY/xA== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4angmebk4h-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 26 Nov 2025 17:05:14 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-297d50cd8c4so218672195ad.0 for ; Wed, 26 Nov 2025 09:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1764176713; x=1764781513; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QryErQwyuR3L+zgYIAijcUhN4Vw58XDmRjXoajIzf28=; b=fv29vcsxJdcAB9+6cgbvYNS0lNzRobx8gYvre3T2FBIxcKys6TalEIq6/+QAWabs6A KRoh7i4BExXCD64Uta4PY1M79bdwzM0gW822XRsEcVXWXE40p0ZIRPvCwBhW0aXxE6GB wpBxktZ3W1J0GCT6NRzNA8yTURiAb8l5jlDIdm5K0lVezPeH4WrKCMnWnYtQTJqp3rNd OGGSPPDz7Egdsif8uLqiWmEVrmRiiJT0NlrWHhFsDWOWNHK103n4OTocqYv90uu6FdGQ Cw1DQueZExgZgSG894HrueFy//y+8MCKv8iZQc+iTYf48GByWYpKaZzAr7nDOt3Lbthc gEPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764176713; x=1764781513; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language: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=QryErQwyuR3L+zgYIAijcUhN4Vw58XDmRjXoajIzf28=; b=Bf1d52zGd0Ug1Lmh9/t1MCVLjhYphTDkpa5MoxcZ/bzCqEpbJfNevHPbGzhrt5d5tE W16s2yTL9+8o7ZDkTyW/lAxfVf8qk2qfkSjSijXZTA3TDx793sirw5o6oCA/zTCoK29P PH0udbE2IOeZjAwwIFj7XaUTuiyCSQxy4SCfXukHMUyf8sATBUpuLLK8LRK6CqTocOqQ wHQW8+rOoMnGaoeB5DR2dTXceAZUULtAd07hJ9QXYZ6FFhvRilaNXqvQ9uGN2336XXTM HU9YzQsBNQTSRTPWsoVORS73EXE+7Sg0/fM/8jOue1nzRKt2bClhJtHnIAxoD+2vuyJ7 HpyA== X-Gm-Message-State: AOJu0YzIHd+fRtJ87WBDUarrETvFS7nyB7uRwX0mw9nUEEV+i0/r8E9o 1F5dRiM8qJzvG4w7mkmkzf9VtLL+MLNpTT9Idudnjg659LLSvMh/bRao6Oog6BL93u+ZExkJ5zz TCbHwj2L9KA6qrKa5pHPNNdAPF7lYWP7Ja0nCyjBepItiXilADOwTYr9p+zwWQD++JdETt5gfoY M= X-Gm-Gg: ASbGncvgyvYauKpe2XSqx3f9BLTraZQuBU/y6eU9mQe3KQ0/Ctdxq6ytDkTsSk5kFPr wwSWmvWc3CQLVJUX2mf7SU92uKo5VFQQUbdYGdTRV7Nn0ld036KTmsKl1DuAJ6VjasG7a/Jl4yR UZdwcye13NjriSXAOFrJ3bWaxosIbpto/zhYaGT3Ehaqy5m9lu05oxIzqLmWQtdyamSBREN+NF7 4/jOQIQYsFYqcFdPhRO80NzQ7TyJH016hu5fw9ANVKnq2JQd0mOoYdAEfvvxKR9t3GI4lnhHoK1 3Wr2NSYpWi2D2lZEthJllEoURI6tZouovNkfWJqLa7D5nnIlGzQIVq9nxJrGilsegGmDSeZmoBF sIMDch1sUW6aOsoOHdpQsvSoUYu1UFoZ5ioGcbIfCT9U= X-Received: by 2002:a17:902:e950:b0:295:ed0:f7bf with SMTP id d9443c01a7336-29bab1e47f5mr84626495ad.58.1764176713406; Wed, 26 Nov 2025 09:05:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUQrY36O8LKohiysR7lCMjX4h2Y3t9x93Pa/HJTHoIlnYg80C9KIw1s456QFTdB0W4TqJ1bQ== X-Received: by 2002:a17:902:e950:b0:295:ed0:f7bf with SMTP id d9443c01a7336-29bab1e47f5mr84625795ad.58.1764176712571; Wed, 26 Nov 2025 09:05:12 -0800 (PST) Received: from [10.216.6.208] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29b5b29b37fsm200792405ad.79.2025.11.26.09.05.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Nov 2025 09:05:12 -0800 (PST) Message-ID: <164ae7a4-37b4-c8c4-3457-905c6bde52e1@oss.qualcomm.com> Date: Wed, 26 Nov 2025 22:35:07 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v19 2/2] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Content-Language: en-US To: Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, Sebastian Reichel , Bartosz Golaszewski , Bjorn Andersson References: <20251122-next-15nov_expose_sysfs-v19-0-4d3d578ad9ee@oss.qualcomm.com> <20251122-next-15nov_expose_sysfs-v19-2-4d3d578ad9ee@oss.qualcomm.com> From: Shivendra Pratap In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=PJgCOPqC c=1 sm=1 tr=0 ts=6927334a cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=dyCLUdSM9kKjni6Dxd0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI2MDEzOSBTYWx0ZWRfX3amTcaincC9t HIJpYqupPs5mTd3CdTxy61ABjXaJ1/TV5uXVkKH2a07Ti4gI/Hy1dkFnHiM/zZt1z4Kr7s6vdK/ dIxYPOonfdzguKMa4S0A4i0TQFFQsNLo6CruoMnoIYYxY3OyoEUm+bkQwd7NuEWINI7PfgQ7iz9 jmJ8ipGN0H9OfyVgjNM47W/SoE5EVKin4xLLhtmbM1tU93wTDcNuWLCV120Pgr+2d0rP6vwa3tZ y+tTK9UVR9XIzCMjSmYCAHwN7A6f9lQFhfjRJ7bjKEYhpq5i+qDV28w1amY2V3MHxGRypZLqyS1 FYw9ViYVLlqdAResxARViagRiwpYX0y5P60yq/DLuiKqQjBhMTDbjIEGIGnWwBdtiXJbEbou+7E rx8byDJzxjTk/O8TkskxTlyBf2ga2w== X-Proofpoint-GUID: KMjgvgETTFUpNIC2CfqQCHkDZ_YCP8R0 X-Proofpoint-ORIG-GUID: KMjgvgETTFUpNIC2CfqQCHkDZ_YCP8R0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-25_02,2025-11-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511260139 On 11/26/2025 10:26 PM, Bartosz Golaszewski wrote: > On Wed, Nov 26, 2025 at 5:48 PM Shivendra Pratap > wrote: >> >>>> >>>> +static bool reboot_mode_class_registered; >>> >>> You don't need this, please see below. >> >> reboot_mode_class_registered was used for two reason. >> one is resolved: will directly call class_unregister. >> >> for second : If class_register fails, we want don't call register device >> in reboot_mode_register. >> >> at - >> if (reboot_mode_class_registered) >> reboot_mode_register_device(reboot); >> > > I'd just error out of the initcall if registering the class fails. > It's very unlikely anyway and points to a bigger problem. sure. thanks. will update this. > >>>> + >>>> +static void reboot_mode_register_device(struct reboot_mode_driver *reboot) >>>> +{ >>>> + reboot->reboot_mode_device.class = &reboot_mode_class; >>>> + reboot->reboot_mode_device.release = reboot_mode_device_release; >>>> + dev_set_name(&reboot->reboot_mode_device, reboot->driver_name); >>>> + if (!device_register(&reboot->reboot_mode_device)) >>>> + reboot->reboot_mode_device_registered = true; >>>> + else >>>> + reboot->reboot_mode_device_registered = false; >>> >>> Just use device_create(). I would also suggest creating a private structure >>> that embeds the pointer to the struct device created by device_create() and >>> the pointer to the reboot_mode_driver. If you pass it as driver data to >>> device_create(), you'll be able to retrieve it with dev_get_drvdata() in >>> sysfs callbacks. >> >> Had made change to use device_create and dev_get_drvdata in below change, and have then >> changed it to above as per the reviews on the same. >> https://lore.kernel.org/all/qhlxxfsyc42xemerhi36myvil3bf45isgmpugkuqzsvgcc3ifn@njrtwuooij2q/ >> >> Should we change to device_create? >> > > Ah, I missed that part. My preference is for device_create() as IMO it > results in much more elegant code (especially if we don't end up > extending the public struct) and memory is cheap but I'll let Bjorn > decide. > > Bart