Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3134429rwr; Fri, 21 Apr 2023 22:39:32 -0700 (PDT) X-Google-Smtp-Source: AKy350b+GB4qrnHJJwpXGZdTx/nRVtk1s52DrIecqC/2V/pzWGP4SOrywu4EuHMEf3Jrfnj3k/rM X-Received: by 2002:a17:90a:1a01:b0:24b:5ebd:56c3 with SMTP id 1-20020a17090a1a0100b0024b5ebd56c3mr4747235pjk.2.1682141972346; Fri, 21 Apr 2023 22:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682141972; cv=none; d=google.com; s=arc-20160816; b=e0ESkxDbd7Lh07YvYRMV3c5huHAijt4AqVMAex7gD6MxGrprNy8O+VFDexzfMTJaMe On0/4J/xfXgSj7IaOjYEU01cMzcW3NP4VFlSTXaEMhEPaNDSzx16AxjiyHToZUX3To5E zDq532uciWqaUEEY63ofM/slbU7QW1goUZMunHjp9mVDBdeLF4Rd7nvOWcA5UMiiNA/N LOVEcwRpJiMNUyKdDsyNge19XtlSFmDWZXYP1bfXZ1I5XicME+3Cf4/v4S7sPZdMP7mo o7UnDWfbxmnJsbGIKwLVbN96wqIE3S7qJ7dhRmNzCsxc953yru7xirXxipTBmQvDn63l sOlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=/ZA/p0aXRTlXVY6YgSQMGx1MCcNGLE9UL/682DsXF4o=; b=kuCHYQxzPI+1DdW0JO4YU8L14W2ca5AgOSWOdC7bKB+3oQ5gAidURWAm6RPZpCmHUu 6TCXouhoxy+bQldIRvtWFZ9xuyY+yFmFkF6oPyH3h8a2WDWjdmUK31NUAltppUk43Clz 0S2tUU7aEKR80S3jMmYJrmo5lp5IJHuQbpNGy8zP0wuPPTfyWNZc0tfhUq5bvVn2FTMo WAfRRukr4bFxXkr0U6yT91ZLSjeL+o34QgSCX99GJHqMbz/jAX3yF515eoz/SEpS7Kjm ts1Z1Z3T8GJtb2Qp+rpWIVsV9fQwgmBIAclH7AmXVkSEPZsYqN4TfkL7aB2n9ksibnHs U8Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gkY2dbkE; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a17090a6a8600b002478b610a39si8862059pjj.75.2023.04.21.22.39.09; Fri, 21 Apr 2023 22:39:32 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=gkY2dbkE; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjDVF1G (ORCPT + 99 others); Sat, 22 Apr 2023 01:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjDVF1F (ORCPT ); Sat, 22 Apr 2023 01:27:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4989D1729 for ; Fri, 21 Apr 2023 22:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682141177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/ZA/p0aXRTlXVY6YgSQMGx1MCcNGLE9UL/682DsXF4o=; b=gkY2dbkEYZINrkbznhAI+SGffhGt+0tQr3/0ep4sMsbXur0VTb20lkzUxV8b/oWid+tlZ8 mxOmiLDqFGtcL/YXn/cR2J1QnctmUnPg5QBNj3UuWFeEB10iIMzALuvlRvoh/+7fbOkOiu LBkHUpteu/H+0926bMtfR5QMezuxbRY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-oo8c4aKZOZ6w9r98gc4oNg-1; Sat, 22 Apr 2023 01:26:15 -0400 X-MC-Unique: oo8c4aKZOZ6w9r98gc4oNg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-2f831f6e175so1365921f8f.2 for ; Fri, 21 Apr 2023 22:26:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682141174; x=1684733174; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/ZA/p0aXRTlXVY6YgSQMGx1MCcNGLE9UL/682DsXF4o=; b=cyB6dYskp2qS09yk1pJFdzGhd4jF0rCYQeEtIrq8JsvLx9TYaHj6t+mYnGRhMtWoWX l5UH++nbl6yIJmGSB1BN67c8H8Z46A9ywEgVwgIzkbnScMBxNf4ESGwrlbnSyrTiKb9V jjQcW3i04QeZrf5iKgTJ+Wcx1rq3PfJsclPJnjY4W1SQYe9lrt+LXIMi1qFthLkUwRtH 4Z4Je7pSLU/x9uPL5NrQ6j4pGvrOZRb967b3rrN+Qq0TpwV8XbTWyfq1sUXdT4XgTNll MlssBs5m3TiZ5Xcxb/NtvLaCGAFp2jnO26WuGYL70wBtvV7C4/0e38afmVWrIhBShTZf 32PQ== X-Gm-Message-State: AAQBX9e/9uCN+cqmYk6FXdScSxN5LWavc8Azp1qAyyjenP9w7FZI8Te3 /v6slLnBK0vwipc89tkQaFolsjTdDeW4XfS7Qg1U4MWvEi7sn6QtuoEfSy0H+NJcuObo6IrUWtc eu1HVfolPm20FiqJpuJGLBNOk X-Received: by 2002:adf:e649:0:b0:301:2452:e4d with SMTP id b9-20020adfe649000000b0030124520e4dmr5101657wrn.46.1682141174565; Fri, 21 Apr 2023 22:26:14 -0700 (PDT) X-Received: by 2002:adf:e649:0:b0:301:2452:e4d with SMTP id b9-20020adfe649000000b0030124520e4dmr5101650wrn.46.1682141174288; Fri, 21 Apr 2023 22:26:14 -0700 (PDT) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id l2-20020a05600c4f0200b003ee74c25f12sm9988052wmq.35.2023.04.21.22.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 22:26:13 -0700 (PDT) From: Javier Martinez Canillas To: Maxime Ripard , Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter Cc: Hans Verkuil , Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Subject: Re: [PATCH v3 1/9] drm/vc4: Switch to container_of_const In-Reply-To: <20221207-rpi-hdmi-improvements-v3-1-bdd54f66884e@cerno.tech> References: <20221207-rpi-hdmi-improvements-v3-0-bdd54f66884e@cerno.tech> <20221207-rpi-hdmi-improvements-v3-1-bdd54f66884e@cerno.tech> Date: Sat, 22 Apr 2023 07:26:13 +0200 Message-ID: <87354sij2i.fsf@minerva.mail-host-address-is-not-set> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org Maxime Ripard writes: Hello Maxime, > container_of_const() allows to preserve the pointer constness and is > thus more flexible than inline functions. > > Let's switch all our instances of container_of() to > container_of_const(). > > Signed-off-by: Maxime Ripard > --- [...] > -static inline struct vc4_dpi * > -to_vc4_dpi(struct drm_encoder *encoder) > -{ > - return container_of(encoder, struct vc4_dpi, encoder.base); > -} > +#define to_vc4_dpi(_encoder) \ > + container_of_const(_encoder, struct vc4_dpi, encoder.base) > A disadvantage of this approach though is that the type checking is lost. Since you already had these, I would probably had changed them to return a const pointer and just replace container_of() for container_of_const(). But I see that there are a lot of patches from Greg all over the kernel that do exactly this, dropping static inline functions in favor of using container_of_const() directly. So it seems the convention is what you do. Reviewed-by: Javier Martinez Canillas -- Best regards, Javier Martinez Canillas Core Platforms Red Hat