Message ID | 20221207-rpi-hdmi-improvements-v1-2-6b15f774c13a@cerno.tech |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp271435wrr; Wed, 7 Dec 2022 08:10:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7fMi4IxcCAaF9Zb3kh8xL8bHBjW8oJicvean3DWyfk1rEyHqXYGa50GGDBpBFyKd97h3rW X-Received: by 2002:a63:7111:0:b0:478:a6de:4d1b with SMTP id m17-20020a637111000000b00478a6de4d1bmr17062939pgc.95.1670429415113; Wed, 07 Dec 2022 08:10:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670429415; cv=none; d=google.com; s=arc-20160816; b=dRaYvnkAWTuYtmHRCT2yfbdXjeZJimsDn+jdvLaQwycdrcZmakmGfTD0AHCoDWUSer YCvF77qIGK8nPCPNRCEq1Sb5CoA9lkZ+vt0zwviPyjCvi961D4F1nX9mwVmHY1RQnTm9 rNkoXefAWC4EZOacmDKr4DwNxg8Wxiv8WFKbLjtjT8DzvVy2miEOVaFh5X4+AhRR5yGZ 9EoFc+9QDQeZnI75gtDj3pxYeyzXxXMkdqd5GiD62NMHAsngZ/pfsjPl/8qzxdXa65MR PEy9CB8/FOoEyP5nBhnPE6n7Q+scOHVw5qbGv93YSicb9ikHHfwFBSWBndCq0HIzQWib WHHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :feedback-id:dkim-signature:dkim-signature; bh=px2+MbhbeI+jrnsZ/vqUEifAPSMXpR4NGEBEX3i+hsw=; b=XQsQ41ew7+ozE4YA/mH32pBc9nb76ZjvL8dVRC+HUYvaCSGkHRWpfeaw6JHI0A6l0b wRxCONjBLX3mWZvEyiZGh4CUK4SdoLiLKjw+CRwgCR1V9CvmJRpjSdSK8rwXn5auQkhO bmsXbsNkCdUhNTJtaPZkr1nh0ohkd4Jwh64pb1Ac51E8XSAKS7KbOd4Fx8wMOvaTNooS HmcUhG2UnNjhvK98IuQ1ordA076FfAgK4n6tU52XuB9+g1RF1SR7IX+MA9kXxI4c8bLZ e2qrhfrNAQF2Z7Lpb/3OG3uMIqvbsqRPeQp526vl2HbgGtSntUmMhrCRUIg3quVw7Bne 4Hmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=YCaxLUsx; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=lanFwiR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a056a00179800b00576caf113acsi11642139pfg.8.2022.12.07.08.09.59; Wed, 07 Dec 2022 08:10:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=YCaxLUsx; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=lanFwiR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbiLGQJO (ORCPT <rfc822;foxyelen666@gmail.com> + 99 others); Wed, 7 Dec 2022 11:09:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiLGQJL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 11:09:11 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF93D54B23 for <linux-kernel@vger.kernel.org>; Wed, 7 Dec 2022 08:09:10 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 57F075C00A6; Wed, 7 Dec 2022 11:09:10 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 07 Dec 2022 11:09:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670429350; x= 1670515750; bh=px2+MbhbeI+jrnsZ/vqUEifAPSMXpR4NGEBEX3i+hsw=; b=Y CaxLUsx7sbkNkpYxwbVV5dtH3TbJG0pr0L1judfcJdwMCQJzJCnZiIavSMV0g7Ks YyF0gdwyjwrG8q2N12xJsmPVQokQJsajMUdflALXTZKRVAnyeFpcGV2SCDnoFvEq V79ab1iMFu0eCrT6zMrjypZoNueZBiBvenCg7nmpEClMlFr/BmbujZxd8E3VnC3x u3Dn0QB5/qszbtHKgTdimHbu2gbvoNKcibQV9UMz6OigNVMxIrswoqqXyLBRqJ2h vaKQWFvb7Z3XIXoYVYeGTTnzM6rFfhw1XTCEd3NM1j0wEGxOh0+sKJGwuZxHKuAV NIa+wcCDnwzADN9rZQ0LA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670429350; x= 1670515750; bh=px2+MbhbeI+jrnsZ/vqUEifAPSMXpR4NGEBEX3i+hsw=; b=l anFwiR4bWUyMdKHuFjfIMQCTitktsAklfKzRoMPcyJXuMmRlc7VZKWoKmTiPGQB+ dLSNYHA38TqvPt7u1jFmf7hWoASTn0ndYdI5GdGSwLA8F8wNiuzWEI5Q56Rh/f8O 8xvGrVJZYncHbJJFZcCso28KaXesRnt24L1lzCs4579Znz1RG/2XzghORO0cJee9 FMJIuJrclpggKINshV+qLTfYNKYOedP/miEgzm9G+ocvnxii9cUgqUBs130ifRuN gCVoVq3BxWRXZWpK6dNOBRgyXAAXdgMyCsRhvbbCiXXRiOOZD1I6pxHXvGxYr8d+ fhsjsSZXDHWVlBpoP1qBA== X-ME-Sender: <xms:prqQY-zk18ih-Jl0BxGj8OV50gA5djEjNR7iNaB8Rc-ZGrFJNVApVg> <xme:prqQY6ScHnWUEdwRtAwB2YSP5GikB-P74ArYHuqLy5yxLt3T8aYGtSEi-MJ9jInMg 6aXmSqrQoA6A9tQB74> X-ME-Received: <xmr:prqQYwViVPXrcZni0pnyNkTrjew4Ag5q_y711CxYwvxY1xqR21qu4TtnKkGOwmLNPPYAqmCR6yoK7LJsD6VPKpbAWO-nMoiTt2uS8cmZniYdxA> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: <xmx:prqQY0imfTyDtG9wRyhIlVIGanSaQEy0giwSys4NiI0A4WuDpi_tgw> <xmx:prqQYwBBiJt4tapmIYS6NogJ5nLPfPovHvcSmvutwtiWoOo89vxYwg> <xmx:prqQY1JJUBCHz9WBmnk66eyTwMx5kbU-T_4DZLm7-q6rb5mgRCeBow> <xmx:prqQY4bdVg50Duvc-gFYpFCPuC4mRjNoL0NlyNBlPmf3N7G4174Liw> Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 11:09:09 -0500 (EST) From: Maxime Ripard <maxime@cerno.tech> Date: Wed, 07 Dec 2022 17:07:46 +0100 Subject: [PATCH 2/9] drm/vc4: hdmi: Constify container_of wrappers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20221207-rpi-hdmi-improvements-v1-2-6b15f774c13a@cerno.tech> References: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> In-Reply-To: <20221207-rpi-hdmi-improvements-v1-0-6b15f774c13a@cerno.tech> To: Emma Anholt <emma@anholt.net>, Maxime Ripard <mripard@kernel.org>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dave Stevenson <dave.stevenson@raspberrypi.com>, Maxime Ripard <maxime@cerno.tech> X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=1406; i=maxime@cerno.tech; h=from:subject:message-id; bh=dCH6llKR5UwxqNbbxar32+yc+y4RRk/F+4gf1CbtXyE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTdgV1SruruN33CH23+ET6vpLqMvtVofxOG6dtXczKW7FN Uq+to5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABMRVWVkeCSoY/rAvPPKJk29p7d+3h VrrQ38mDPROPXpxY9ma43PTGD47zP35PuuwqorzNf7lJSuTX4YvHnBq8u/rnI3RcTFq1+dzgEA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751572194637318983?= X-GMAIL-MSGID: =?utf-8?q?1751572194637318983?= |
Series |
drm/vc4: hdmi: Broadcast RGB, BT601, BT2020
|
|
Commit Message
Maxime Ripard
Dec. 7, 2022, 4:07 p.m. UTC
None of our wrappers around container_of to access our objects from the
DRM object pointer actually modify the latter.
Let's make them const.
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
drivers/gpu/drm/vc4/vc4_hdmi.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
Hi Am 07.12.22 um 17:07 schrieb Maxime Ripard: > None of our wrappers around container_of to access our objects from the > DRM object pointer actually modify the latter. > > Let's make them const. > > Signed-off-by: Maxime Ripard <maxime@cerno.tech> Personally, I wouldn't take this patch as it does an implicit const cast on the pointer. For const correctness, it seems better to add new helpers that keep the const. Those could be use in places where the caller is not allowed to modify the state (i.e., atomic_update, et al). Something like this: const struct vc4_hdmi * const_connector_to_vc4_hdmi(const struct drm_connector *connector) { return container_of(connector, const struct vc4_hdmi, connector); } Best regards Thomas > --- > drivers/gpu/drm/vc4/vc4_hdmi.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h > index dc3ccd8002a0..023ea64ef006 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.h > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h > @@ -224,13 +224,13 @@ struct vc4_hdmi { > }; > > static inline struct vc4_hdmi * > -connector_to_vc4_hdmi(struct drm_connector *connector) > +connector_to_vc4_hdmi(const struct drm_connector *connector) > { > return container_of(connector, struct vc4_hdmi, connector); > } > > static inline struct vc4_hdmi * > -encoder_to_vc4_hdmi(struct drm_encoder *encoder) > +encoder_to_vc4_hdmi(const struct drm_encoder *encoder) > { > struct vc4_encoder *_encoder = to_vc4_encoder(encoder); > return container_of(_encoder, struct vc4_hdmi, encoder); > @@ -244,7 +244,7 @@ struct vc4_hdmi_connector_state { > }; > > static inline struct vc4_hdmi_connector_state * > -conn_state_to_vc4_hdmi_conn_state(struct drm_connector_state *conn_state) > +conn_state_to_vc4_hdmi_conn_state(const struct drm_connector_state *conn_state) > { > return container_of(conn_state, struct vc4_hdmi_connector_state, base); > } > -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
On Wed, 11 Jan 2023, Thomas Zimmermann <tzimmermann@suse.de> wrote: > Hi > > Am 07.12.22 um 17:07 schrieb Maxime Ripard: >> None of our wrappers around container_of to access our objects from the >> DRM object pointer actually modify the latter. >> >> Let's make them const. >> >> Signed-off-by: Maxime Ripard <maxime@cerno.tech> > > Personally, I wouldn't take this patch as it does an implicit const cast > on the pointer. > > For const correctness, it seems better to add new helpers that keep the > const. Those could be use in places where the caller is not allowed to > modify the state (i.e., atomic_update, et al). > > Something like this: > > const struct vc4_hdmi * > const_connector_to_vc4_hdmi(const struct drm_connector *connector) > { > return container_of(connector, const struct vc4_hdmi, > connector); > } See container_of_const(). BR, Jani. > > Best regards > Thomas > >> --- >> drivers/gpu/drm/vc4/vc4_hdmi.h | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h >> index dc3ccd8002a0..023ea64ef006 100644 >> --- a/drivers/gpu/drm/vc4/vc4_hdmi.h >> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h >> @@ -224,13 +224,13 @@ struct vc4_hdmi { >> }; >> >> static inline struct vc4_hdmi * >> -connector_to_vc4_hdmi(struct drm_connector *connector) >> +connector_to_vc4_hdmi(const struct drm_connector *connector) >> { >> return container_of(connector, struct vc4_hdmi, connector); >> } >> >> static inline struct vc4_hdmi * >> -encoder_to_vc4_hdmi(struct drm_encoder *encoder) >> +encoder_to_vc4_hdmi(const struct drm_encoder *encoder) >> { >> struct vc4_encoder *_encoder = to_vc4_encoder(encoder); >> return container_of(_encoder, struct vc4_hdmi, encoder); >> @@ -244,7 +244,7 @@ struct vc4_hdmi_connector_state { >> }; >> >> static inline struct vc4_hdmi_connector_state * >> -conn_state_to_vc4_hdmi_conn_state(struct drm_connector_state *conn_state) >> +conn_state_to_vc4_hdmi_conn_state(const struct drm_connector_state *conn_state) >> { >> return container_of(conn_state, struct vc4_hdmi_connector_state, base); >> } >>
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index dc3ccd8002a0..023ea64ef006 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -224,13 +224,13 @@ struct vc4_hdmi { }; static inline struct vc4_hdmi * -connector_to_vc4_hdmi(struct drm_connector *connector) +connector_to_vc4_hdmi(const struct drm_connector *connector) { return container_of(connector, struct vc4_hdmi, connector); } static inline struct vc4_hdmi * -encoder_to_vc4_hdmi(struct drm_encoder *encoder) +encoder_to_vc4_hdmi(const struct drm_encoder *encoder) { struct vc4_encoder *_encoder = to_vc4_encoder(encoder); return container_of(_encoder, struct vc4_hdmi, encoder); @@ -244,7 +244,7 @@ struct vc4_hdmi_connector_state { }; static inline struct vc4_hdmi_connector_state * -conn_state_to_vc4_hdmi_conn_state(struct drm_connector_state *conn_state) +conn_state_to_vc4_hdmi_conn_state(const struct drm_connector_state *conn_state) { return container_of(conn_state, struct vc4_hdmi_connector_state, base); }