Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp499189lqe; Sat, 6 Apr 2024 09:46:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNLiFd4jmj65Qq3hr9plhKJBSYufSh+8FnNG2dXA5Jo+pROt6D524MT2ZfSmYHU0acJ1DORNDLRh6JR2R6SbolgftX/TzG3PMXtW5tiQ== X-Google-Smtp-Source: AGHT+IG+HQS7kZl1mEreGf3/gQM47iMitS8jcJOIyTYAtmrGefoXITKmxRfep071Xn2/1VD5uORg X-Received: by 2002:a17:90a:3ec4:b0:2a2:40c4:5175 with SMTP id k62-20020a17090a3ec400b002a240c45175mr4428916pjc.14.1712421963711; Sat, 06 Apr 2024 09:46:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712421963; cv=pass; d=google.com; s=arc-20160816; b=BO+kHGChJk1SAMvqX3Kpw1EaKFg6c+tTuW5xUUjWXGpXFCelWHC7OpzwrQQ5Tm15Nt dMU+NcohPcZ/DoWBvWLhgJDWn7iYK9sBGyWv4+W4bq9KIzyUyobNV6rBF1EnThKriZ+I bibldlRhg1pqLWuJkKsOaI6eUJ0xSLv8xLVE4lqWGstXZOWeR/9RgY2VOFu0VEcFmgAJ MgfgdNi93+VrhMuFEcaPfhWcwTWZR3kVx42lM+byN6bnVPGDm1ocdU7GVRssZRmoLSMW EhPUE2adXBsCD2OxkAMubeaGVJcQeGasI8vni8vHG5nLsPZ8Mv/b3HZ6uCwmst2/dE2B +bZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=xUzxhIyO9Z42EWr6hvKS7Qfwp4EqErW6SFdavLE1o5g=; fh=yx5s12KnifcvbRFHM5ZsyGFfX3tb9y00vNque6NKFqU=; b=k2nDBZHw7oKCmhLkTGXGLYYID4VeQdRecWIINpSAOKPWWfH96jUhBKroFBfypXf0WQ DlJIyJ+iyQZjgTOQmD3ZnGXQDbxs2q7Yn3/41slEBpPeA8EtzGIdLVJSBebYKmRLmKrH hXbP4s1LfkpZYkhaeE19Kit1Sv609p2MwCMPxB8UwlPZK2Zag6MtUKluvV5ZybCu9e/R gpDd5OlIKBbijSZDntvnJ1/BVvHkGsHdTxcydr2fU+YjlPKt5HEuS7oef/69wk0uPIy0 GbYC8nXAbv5j1B07hcqWJCF5rXyp+GWAWnQTw+yQWyFmYqx2m8futF0oMzGZW6ixTCwI uaaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b="KGer5/Rh"; arc=pass (i=1 spf=pass spfdomain=ieee.org dkim=pass dkdomain=ieee.org dmarc=pass fromdomain=ieee.org); spf=pass (google.com: domain of linux-kernel+bounces-134012-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ieee.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q7-20020a17090a2dc700b002a2c4433db2si3409772pjm.85.2024.04.06.09.46.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 09:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134012-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b="KGer5/Rh"; arc=pass (i=1 spf=pass spfdomain=ieee.org dkim=pass dkdomain=ieee.org dmarc=pass fromdomain=ieee.org); spf=pass (google.com: domain of linux-kernel+bounces-134012-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ieee.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4BA632822B2 for ; Sat, 6 Apr 2024 16:46:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6DA63BBDC; Sat, 6 Apr 2024 16:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="KGer5/Rh" Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A552D3839D for ; Sat, 6 Apr 2024 16:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712421956; cv=none; b=EFMVR8JkWgraqXHhrn+mTV88GblYHDdJLHEc43XWtyvCiUI04j+qYkf+rEQQkxj0bWbSpYZa80NiPnWlroLmhuHW+RQBfHr9WRGhhxMNQq6Rl3qlkf4et4L3IKSLSMjq3TRw8Oy0QEh5vGcpjbU3/XaSiG85LGONudXWQ22u5ww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712421956; c=relaxed/simple; bh=7yQ+QmR4Ay0dnL1lrEcKdS/T+SzwCs+q9uObIrWoPs0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pGmUkj1LNTfZreDWO3UQhkPftpGnKEchLjWztTEqGDCgUzdQCrmAPeZ3dYBdnNcswpTDSaransTKjSlNAXHvERV2uilEbKPB/pvB62U1T/NipBd7EkOqIS5sSzTyp4FiUsqNQIDHZ+90aejzn6HlS1HtBvmugRnQsuS3SOBQ/Ug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ieee.org; spf=pass smtp.mailfrom=ieee.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b=KGer5/Rh; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ieee.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ieee.org Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-434761b37d3so1805951cf.2 for ; Sat, 06 Apr 2024 09:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; t=1712421953; x=1713026753; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xUzxhIyO9Z42EWr6hvKS7Qfwp4EqErW6SFdavLE1o5g=; b=KGer5/Rhz4pi9fzFMfw5acJXZ7fpYfCM19uLp7DLpxnXTiva2/NH1HIMWC3zXikzIF ZPBGYfZolhwa4D3xIprsKzc0KkpA2cDT4jNQ9giTpZzCzjeUUVFgZLoTKWvwMfFT+XCJ Y0f7SUFDBoMJ+cB4MkSF8sM03tOHP4XWLvJrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712421953; x=1713026753; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xUzxhIyO9Z42EWr6hvKS7Qfwp4EqErW6SFdavLE1o5g=; b=Xl/8JdJtpH6JBwKyS1z6nCY/ydDkNYPIqpL0HIjL0QhP/F99xCN1KIZbofQ++kEl5/ 5HN8dOsLjqP4iM+/tZYjbv8SwOLny85FmwTYrOzip146WFFVpDeaev10phydDCs90ryk r6pUBedPdlIJLDvR0aBGz33oag2TEAM+t9mswVV7ujlEMdWp1RsPo4G9C60OTLr9H2zz g4SxxRJrgqunDITcy8RqUdolGTn/ff/1+ioZ0+y9F9J1rbsyyKbxZx6SxmNf8LVSXebv X1aeI7lJAznvwZCc0Dqo2o3WX87/5NAloX9QDjcA1FkIJbV0uwhnQpvRRlj2Y/gTeBi4 S78A== X-Forwarded-Encrypted: i=1; AJvYcCV1N7+pQOoVuYo6iKZqITZW3daFFpUO64hGuq1Js723+vtikpHfPND71reIIc+bar6qvC7kmjiSb03XPLRNfkyfhoBwgZXX3gMCfRMP X-Gm-Message-State: AOJu0YxPLnheUUW3ZenB8UY+HSAb1o3C7DpNuhn6x2Wusa6reZ7oDwI4 LSGtPO4ryEdgtzxLCLDhdsyDLzhs7yMaISh0vdwoOkQGXjIAecn7nqDeBy/mjw== X-Received: by 2002:ac8:594a:0:b0:431:5f09:83cb with SMTP id 10-20020ac8594a000000b004315f0983cbmr5549704qtz.32.1712421953535; Sat, 06 Apr 2024 09:45:53 -0700 (PDT) Received: from [10.211.55.3] (c-73-228-159-35.hsd1.mn.comcast.net. [73.228.159.35]) by smtp.googlemail.com with ESMTPSA id e1-20020ac81301000000b004317c90d0d6sm3321qtj.65.2024.04.06.09.45.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Apr 2024 09:45:53 -0700 (PDT) Message-ID: <5e1c5156-d906-4473-970b-bff71e4dcd96@ieee.org> Date: Sat, 6 Apr 2024 11:45:51 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] staging: greybus: Clear up precedence for gcam logging macros Content-Language: en-US To: Dan Carpenter , Jackson Chui Cc: Johan Hovold , Alex Elder , Greg Kroah-Hartman , greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240404001627.94858-1-jacksonchui.qwerty@gmail.com> <658e1f40-d1eb-4ba7-9ba3-0aa05a1ed06e@ieee.org> <5eb3afe2-da7b-4f98-aac2-bff529a02cea@moroto.mountain> From: Alex Elder In-Reply-To: <5eb3afe2-da7b-4f98-aac2-bff529a02cea@moroto.mountain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/6/24 4:09 AM, Dan Carpenter wrote: > On Fri, Apr 05, 2024 at 02:22:05PM -0700, Jackson Chui wrote: >> On Thu, Apr 04, 2024 at 05:05:09PM -0500, Alex Elder wrote: >>> On 4/3/24 7:16 PM, Jackson Chui wrote: >>>> Reported by checkpatch: >>>> >>>> CHECK: Macro argument 'gcam' may be better as '(gcam)' to avoid >>>> precedence issues >>> >>> I agree with your argument about the way the macro should be >>> defined. But perhaps these gcam_*() functions could just >>> be eliminated? >>> >>> I see 15 calls to gcam_err(), 1 call to gcam_dbg(), and none >>> to gcam_info(). It would be a different patch, but maybe >>> you could do that instead? >>> >>> -Alex >>> >>> >>>> >>>> Disambiguates '&' (address-of) operator and '->' operator precedence, >>>> accounting for how '(gcam)->bundle->dev' is a 'struct device' and not a >>>> 'struct device*', which is required by the dev_{dbg,info,err} driver >>>> model diagnostic macros. Issue found by checkpatch. >>>> >>>> Signed-off-by: Jackson Chui >>>> --- >>>> drivers/staging/greybus/camera.c | 6 +++--- >>>> 1 file changed, 3 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c >>>> index a8173aa3a995..d82a2d2abdca 100644 >>>> --- a/drivers/staging/greybus/camera.c >>>> +++ b/drivers/staging/greybus/camera.c >>>> @@ -180,9 +180,9 @@ static const struct gb_camera_fmt_info *gb_camera_get_format_info(u16 gb_fmt) >>>> #define GB_CAMERA_MAX_SETTINGS_SIZE 8192 >>>> -#define gcam_dbg(gcam, format...) dev_dbg(&gcam->bundle->dev, format) >>>> -#define gcam_info(gcam, format...) dev_info(&gcam->bundle->dev, format) >>>> -#define gcam_err(gcam, format...) dev_err(&gcam->bundle->dev, format) >>>> +#define gcam_dbg(gcam, format...) dev_dbg(&((gcam)->bundle->dev), format) >>>> +#define gcam_info(gcam, format...) dev_info(&((gcam)->bundle->dev), format) >>>> +#define gcam_err(gcam, format...) dev_err(&((gcam)->bundle->dev), format) >>>> static int gb_camera_operation_sync_flags(struct gb_connection *connection, >>>> int type, unsigned int flags, >>> >> >> Thanks for the feedback, Alex! >> >> I thought about refactoring it, but I feel it is worth keeping >> the macro around. It acts as an apdater between callers, who >> have 'gcam' and want to log and what the dynamic debug macros >> expect. Without it, the code gets pretty ugly. > > Another idea would be to create a function: > > struct device *gcam_dev(struct gb_camera *gcam) > { > return &gcam->bundle->dev; > } > > dev_dbg(gcam_dev(gcam), "received metadata ... > > (I don't know how to actually compile this code so I haven't tried it). Yes, I prefer this over the original suggestion. But even here the gcam_dev() function doesn't add all that much value; it saves four characters I guess. Jackson, the basic principle that makes me say I don't like the wrapper macros is that the wrapper obscures the simple call(s) to dev_dbg(), etc. If there was something you wanted to do every time--along with calling dev_dbg()--then maybe the wrapper would be helpful, but instead it simply hides the standard call. Better to have the code just use the functions kernel programmers recognize. -Alex > > regards, > dan carpenter