Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7220907rwd; Tue, 6 Jun 2023 07:53:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77BnJbgfGKplgTfBeG23QtjkSDyxelknoREB2fnK1YgvVqz4va/go9unewfMjQWNMyqhX+ X-Received: by 2002:ad4:5b8f:0:b0:626:32fc:99a6 with SMTP id 15-20020ad45b8f000000b0062632fc99a6mr2683812qvp.17.1686063236453; Tue, 06 Jun 2023 07:53:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686063236; cv=pass; d=google.com; s=arc-20160816; b=Unm5FoT/Oiw84BF50/2hnPZuxA6P6O0e/nXhNVkhaALymlfIfESO61p1s0c0lXH91l TDSCjNf3yaP9j2I3D0cdYRVdBV/F667lx+jUEhdQ5bz2XnVmzgVi3bkyDf7gU1LvYpW5 zJrSAWKe5cFka1II1rF+aJ6swjfQ/M6kcvkYB9wV6KBPD6WbOP8I53SfN6Fc+telhLGO Ns3wapKkI+0+R5zO8rtmCzvIvIs8aeWUPxF21r5ZtKLUtbfpj+i+myrmiJyvVom5kzn4 zTPCokFn+UsPHbOQVyVaz1kxrMUMaaXeR1FrR9emJhddwKopX5ieFSdG33DRODTc/6vu Co4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:dkim-signature; bh=nhq6ObVRtO0F/91ipiCPjsG/qJ9zJ64B4gXqedyDihU=; b=fVZyCkjKj4Wrgqy6Ok3AefobtY1FtkjC00ButrKVVAyk+b/Xy0xDX9dg0A4cWVzGqZ a+Rqc7875DA5cFPTjoobuAtKwcWM945gV2k5LYxFM4XYYgFvyCOMsHIXXg0/0/5L1FDI IMmdYdj1M6UuG8LYce1Hy01TW1PQxIvO4mUpTyAXMqIx70HgXM7thDKGcE1GD1KX5cu+ HszpvTp7vEcfRFQSZBPMCAgs+mR8IvMK2h5yPuW85KulQBzroTHxsgINBBrHwrDgJLPJ v+1k6/Uipi942En6pVSKe+gAWPVz3lpjavtE0g41e4XnjV5r16pgqqhUPA1xo/HNga4V Id4A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=ea4aSFIC; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); 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=siddh.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a0562141bcd00b0062639f098f0si6469357qvc.205.2023.06.06.07.53.42; Tue, 06 Jun 2023 07:53:56 -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=@siddh.me header.s=zmail header.b=ea4aSFIC; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); 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=siddh.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233481AbjFFOgI (ORCPT + 99 others); Tue, 6 Jun 2023 10:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbjFFOgH (ORCPT ); Tue, 6 Jun 2023 10:36:07 -0400 Received: from sender-of-o51.zoho.in (sender-of-o51.zoho.in [103.117.158.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94ED1E6C for ; Tue, 6 Jun 2023 07:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686062111; cv=none; d=zohomail.in; s=zohoarc; b=FoV90p8s7KGaX/AFXXGRhVbKUQdUKO2sbtjs5ppLjap3oUZw8CqU+N13Wg3aTYAqRPSZAi52hCdPoxdrkrOwiYQ5AzBPtnP7KBKbv8QXVhczksabmfWjJpcZdJ8NRP3SNi67eOCUejoRpbRx4e8Wxb/kgExij9EA8zBwObstuKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1686062111; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nhq6ObVRtO0F/91ipiCPjsG/qJ9zJ64B4gXqedyDihU=; b=PjoWZh7AMGFCsBVZgB5ttbmU3/UHrqT7dv0aiYmOX0OhmemYaEErbOG3EjlW8rgKrHDQ/7zW/LztC/9GbkVrbn6V3JbMaX2TiwYXAHUn7+68S8Su7m+ClVcaPRysuB8hRgrn1/BV39vdyNbfVRBuAJHoaziuXXAb3MrZoluFTSg= ARC-Authentication-Results: i=1; mx.zohomail.in; dkim=pass header.i=siddh.me; spf=pass smtp.mailfrom=code@siddh.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1686062111; s=zmail; d=siddh.me; i=code@siddh.me; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=nhq6ObVRtO0F/91ipiCPjsG/qJ9zJ64B4gXqedyDihU=; b=ea4aSFICrqljBDAllkvvJUzxGaPmplAPZ2LzUC+BO7tT/ohYqTLT90xsiK+dbii2 G+X3unpnzvNEFHfaUCzqdTkb2dSbphflmz6Gdhhk12QxbnLMaT8QSH3X1Jw+yqwY3Nt 45IOMsAysJn4VEi895FZ3m3qQ2P5s7v40DmzhDXU= Received: from mail.zoho.in by mx.zoho.in with SMTP id 168606207938986.73514266463042; Tue, 6 Jun 2023 20:04:39 +0530 (IST) Date: Tue, 06 Jun 2023 20:04:39 +0530 From: Siddh Raman Pant To: "Laurent Pinchart" Cc: "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Daniel Vetter" , "Andrzej Hajda" , "Neil Armstrong" , "Robert Foss" , "Jonas Karlman" , "Jernej Skrabec" , "Jani Nikula" , "dri-devel" , "linux-kernel" , "Suraj Upadhyay" Message-ID: <18891219d8e.6a7d8f15119986.32609419593331086@siddh.me> In-Reply-To: <20230606140512.GA5197@pendragon.ideasonboard.com> References: <20230606140512.GA5197@pendragon.ideasonboard.com> Subject: Re: [PATCH v9 2/8] drm/print: Fix and add support for NULL as first argument in drm_* macros MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, 06 Jun 2023 19:35:12 +0530, Laurent Pinchart wrote: > Hi Siddh, > > Thank you for the patch. Anytime :) > On Tue, Jun 06, 2023 at 04:15:16PM +0530, Siddh Raman Pant wrote: > > Comments say macros DRM_DEBUG_* are deprecated in favor of > > drm_dbg_*(NULL, ...), but they have broken support for it, > > as the macro will result in `(NULL) ? (NULL)->dev : NULL`. > > What's the problem there ? (NULL)->dev is invalid C. It's a macro, so preprocessor substitutes that text directly, there is no evaluation. GCC will throw an error regarding dereferencing a void* pointer. > > /* Helper for struct drm_device based logging. */ > > #define __drm_printk(drm, level, type, fmt, ...) \ > > - dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__) > > +({ \ > > + struct device *__dev_ = __drm_dev_ptr(drm); \ > > + if (__dev_) \ > > + dev_##level##type(__dev_, "[drm] " fmt, ##__VA_ARGS__); \ > > + else \ > > + pr_##level##type("[drm] " fmt, ##__VA_ARGS__); \ > > If I recall correctly, dev_*() handle a NULL dev pointer just fine. Do > we need to manually fall back to pr_*() ? I took drm_dev_printk (on line 261 of drm_print.c) as the reference, wherein it uses a conditional for determining whether dev_printk or printk should be called. I suppose it is to avoid printing "(NULL device *)", which dev_printk does if it gets a NULL device pointer (refer the definition on line 4831 of drivers/base/core.c). Though if I'm wrong, kindly let me know. Thanks, Siddh