Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B49D7C7EE23 for ; Wed, 1 Mar 2023 20:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229719AbjCAUCT (ORCPT ); Wed, 1 Mar 2023 15:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjCAUCQ (ORCPT ); Wed, 1 Mar 2023 15:02:16 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85BA94E5D7 for ; Wed, 1 Mar 2023 12:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677700935; x=1709236935; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=6EAWrrc5IPUWooTbxGsI6tMEta8jrC1xOMHR2AXxGGw=; b=cVEK5SD1VlQGI6iEAdKy7c1B4E8nEjgL5CZOyQXQ3VMkhml+nYq7rjNK tYCnDnNwFANLYVK3NUWc4PQNUia+khfCeNqsLQhdA/eXJ0UREjgs4G99A ab0UtZJA2UjnNQXnPZ/x/qQU2NqvaKDEmUVV8dtdKQbvEgCkT0r88Vagw 7zTkJHrIYr0q6E9S8lEvgHJJzZ9dBMdG9SaKYroBhhGZFUdPHu7yIz4oo SA1UZSfsMmUxm9VBiVmxYtv/PW6AkGk6JUGMNJEGY4lzZrEGuLx1TPVdM rb6Mta4E52i8MCaqsmp8C5zq6NLU57s1vtg8Bs7tJ/BkU4l07TS88aEO2 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="335999793" X-IronPort-AV: E=Sophos;i="5.98,225,1673942400"; d="scan'208";a="335999793" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 12:02:15 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="624630698" X-IronPort-AV: E=Sophos;i="5.98,225,1673942400"; d="scan'208";a="624630698" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.209.115.221]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 12:02:08 -0800 Date: Wed, 01 Mar 2023 12:02:08 -0800 Message-ID: <87r0u844vz.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Deepak R Varma Cc: Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, Praveen Kumar , Saurabh Singh Sengar Subject: Re: [PATCH RESEND] drm/nouveau/hwmon: Use sysfs_emit in show function callsbacks In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 01 Mar 2023 11:35:41 -0800, Deepak R Varma wrote: > > According to Documentation/filesystems/sysfs.rst, the show() callback > function of kobject attributes should strictly use sysfs_emit() instead > of sprintf() family functions. So, make this change. > Issue identified using the coccinelle device_attr_show.cocci script. Reviewed-by: Ashutosh Dixit > > Signed-off-by: Deepak R Varma > --- > Note: > Resending the patch for review and feedback. No functional changes. > > > drivers/gpu/drm/nouveau/nouveau_hwmon.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c > index a7db7c31064b..e844be49e11e 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c > +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c > @@ -41,7 +41,7 @@ static ssize_t > nouveau_hwmon_show_temp1_auto_point1_pwm(struct device *d, > struct device_attribute *a, char *buf) > { > - return snprintf(buf, PAGE_SIZE, "%d\n", 100); > + return sysfs_emit(buf, "%d\n", 100); > } > static SENSOR_DEVICE_ATTR(temp1_auto_point1_pwm, 0444, > nouveau_hwmon_show_temp1_auto_point1_pwm, NULL, 0); > @@ -54,8 +54,8 @@ nouveau_hwmon_temp1_auto_point1_temp(struct device *d, > struct nouveau_drm *drm = nouveau_drm(dev); > struct nvkm_therm *therm = nvxx_therm(&drm->client.device); > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000); > + return sysfs_emit(buf, "%d\n", > + therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000); > } > static ssize_t > nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d, > @@ -87,8 +87,8 @@ nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d, > struct nouveau_drm *drm = nouveau_drm(dev); > struct nvkm_therm *therm = nvxx_therm(&drm->client.device); > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000); > + return sysfs_emit(buf, "%d\n", > + therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000); > } > static ssize_t > nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d, > -- > 2.34.1 > > >