From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 978F7313537 for ; Wed, 26 Nov 2025 19:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764185253; cv=none; b=Ynss0vporN2sc6/AxP9GyrXMJL8ueXHswe0dR58fu9ChEXqEFpPaHcX3c4flCR4JXTYtM2QjMm51NbuK4/5Bt1dU+0nf8r0zIWCwnCp3NX0Bv8f/Nv/yL63uig5DkicWS8ypww81R+CBCg6vZCacG+JBWSScNZfDrnzY0yloxHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764185253; c=relaxed/simple; bh=m2fPhSioBfNyvNi0lC27gAZgiCgsqcmUV+MU0HZxHhc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lqErwbxnQIjimJP/9PkVJwpL5tsz4z6+aIZNiPrYpw3xRroSd7OSiSnrZEcGqFlCxYXhf9Vi4FzivqMrpIVmYPyESQ7ZkJgYhSJvMUgosWVVQn5WPiKu8GVRhB8guBlo8RrCPffibnZqaAdKkI8Uj515ncHwy2Xbdl2kQzDKvPI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=runbox.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=C/YxGupY; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=runbox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="C/YxGupY" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vOLAj-00AG9c-VB; Wed, 26 Nov 2025 20:27:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date; bh=MW76C/tKkqjitKqxRYBdRkyFQyH7LDbc4JBvzi/1Kq0=; b=C/YxGupYrXYyRD7Ta5vZ7quTaR RhATNEN/aZAmpIl4F/ZJhr7vereWqI7Eyk/kt3YywveLPc+KOedJU3jVwEb4jxL21ttAIAgb3HaFy AGgd33ngQBxjvq78NA/yhFeGv7ob2oX2niKbgZhC+gXwGoa2hoxzztULaeDG2Oj+r9HVq6dwHMWBe tzWwG7zZ6n65lkmjcPareuf8+0p2eoVIMGQ+ruNDjcFBiY9rzTSoos/9iYysApJMZxchSQgUlEiDZ ZrqwVQcMkxm/FDldT3Pj6pg6/aC8PkTul/mS0tpFufsgLxGiy22H1fCFIKAuRqoZzjTBeuJrGLoCT kofTNv0Q==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vOLAj-0001fe-Jd; Wed, 26 Nov 2025 20:27:25 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vOLAR-00FYDe-RZ; Wed, 26 Nov 2025 20:27:07 +0100 Date: Wed, 26 Nov 2025 19:27:05 +0000 From: david laight To: Krzysztof Kozlowski Cc: Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: Re: [PATCH] w1: Use container_of_const() when all types are const Message-ID: <20251126192705.36321d87@pumpkin> In-Reply-To: <20251126171841.72379-2-krzysztof.kozlowski@oss.qualcomm.com> References: <20251126171841.72379-2-krzysztof.kozlowski@oss.qualcomm.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 26 Nov 2025 18:18:42 +0100 Krzysztof Kozlowski wrote: > Use container_of_const(), which is preferred over container_of(), when > the argument 'ptr' and returned pointer are already const, for better > code safety and readability. I thought there was a plan to make container_of() return a const pointer when the input is const? Can't be done yet because a few things need some 'const' sprinkles to compile. David > > Signed-off-by: Krzysztof Kozlowski > --- > drivers/w1/w1.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c > index 002d2639aa12..3b48d15390be 100644 > --- a/drivers/w1/w1.c > +++ b/drivers/w1/w1.c > @@ -575,11 +575,11 @@ static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env) > int err = 0; > > if (dev->driver == &w1_master_driver) { > - md = container_of(dev, struct w1_master, dev); > + md = container_of_const(dev, struct w1_master, dev); > event_owner = "master"; > name = md->name; > } else if (dev->driver == &w1_slave_driver) { > - sl = container_of(dev, struct w1_slave, dev); > + sl = container_of_const(dev, struct w1_slave, dev); > event_owner = "slave"; > name = sl->name; > } else {