Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7277685rwd; Tue, 6 Jun 2023 08:32:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OTQmedIExejxGbZ1/MC7qbcfXZ6JPAAQHK11kQkznQ5wOuN5yaeZTJ8+4/HoN3uQ9rNqW X-Received: by 2002:a05:622a:5c6:b0:3f6:bc91:951 with SMTP id d6-20020a05622a05c600b003f6bc910951mr56677qtb.12.1686065568302; Tue, 06 Jun 2023 08:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686065568; cv=none; d=google.com; s=arc-20160816; b=T1vociJdWwX7wKg4I64bXhAQ2/5x6HVoMvRJnMM+Ea64eturXFY7HtiKk/TJ36njTg 1yCcdvmXo5L4YXjBZsDpW1FlKmW84CNus2gKwtKi1HFEni2MYBPhtf4s67v3q6CtTOgn tBnf6wqo2bdhm9gvsFYlsYhGbJAlU9U1luPXJbLvxklOovY0UrFOs1OlOYYmnyKukknl Ir+BOnido+uL/mEp6zBWW+Xt7k+k8pqfYkEVU6c2UhBqik3SdJ2dfP8TcTa5O3x5LoMs VL2QypnpapEWLdFvpZ63A6dGkBRNt4fHeCOljMYfykK+D15KRpfnSbwj801+uiA43YPy vIVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+5kqkT7lUKxbtfild4J5MCIVIm9HN12KwBRnIZgXb6U=; b=ZPwtDgfDhoG34XoI4bPMzbyMOR2ynsFqB4iuU1Y3qRXKHgMYgpZxjve89pC3/7PpLt Fm2yMzZiQPYW5TYHTDMhmyH9pgTZbSAcC5V8tanVnCEp6gSpZx2sm8mFVsZGXhmzj9AF 9DbaCPYOuAXLUQIldfFA5ItwiE0RITryQ3BBQSXlMu/3HseUPPjk5PkFVJye6tEkGFgL ro83JDoRdXEvcaXAIP6Uao2jPvbCVIKf085VJLjqk5am0o1lUvaDV43WD1HKOiVmk65T uIPhblDr9/w4p+xrhjQHfnORt0yXr25oNFGc+JibLGd2ULheEJZ73cYFyg+JCbh0sv0I 5eBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=vzOfTt1v; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 16-20020ac85710000000b003e4eb9adb9dsi6425943qtw.148.2023.06.06.08.32.30; Tue, 06 Jun 2023 08:32:48 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=vzOfTt1v; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238344AbjFFOtU (ORCPT + 99 others); Tue, 6 Jun 2023 10:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238161AbjFFOtA (ORCPT ); Tue, 6 Jun 2023 10:49:00 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C182123 for ; Tue, 6 Jun 2023 07:48:05 -0700 (PDT) Received: from pendragon.ideasonboard.com (om126253223039.31.openmobile.ne.jp [126.253.223.39]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8606BAB; Tue, 6 Jun 2023 16:47:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686062830; bh=K2gaqtTkXezyTdLUzCJIlQtK/ygyOYqpgIB0q9PaxfU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vzOfTt1vxgtrmOZvXfsCF6chsV584A/W8ybzo3wzv/vxa3giRlx7M1ZhvfNUlMi3B MnDX8tDTEI+TCIn08KRw1m360AwRqBHS473hiUtqfMpDjvX6Kmnl/BRmjQuqgKaqkr FxuQ6fJwJ7O7Ms2Msi2ee1Eo76nZQKnW/eKWUbH0= Date: Tue, 6 Jun 2023 17:47:32 +0300 From: Laurent Pinchart To: Siddh Raman Pant 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 Subject: Re: [PATCH v9 2/8] drm/print: Fix and add support for NULL as first argument in drm_* macros Message-ID: <20230606144732.GG5197@pendragon.ideasonboard.com> References: <20230606140512.GA5197@pendragon.ideasonboard.com> <18891219d8e.6a7d8f15119986.32609419593331086@siddh.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <18891219d8e.6a7d8f15119986.32609419593331086@siddh.me> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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, Jun 06, 2023 at 08:04:39PM +0530, Siddh Raman Pant wrote: > 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. You're right, it's probably best to avoid the "(NULL device *)". Reviewed-by: Laurent Pinchart -- Regards, Laurent Pinchart