From patchwork Sun Dec 25 09:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 36464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp461900wrt; Sun, 25 Dec 2022 01:48:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXt3UvfG81+X/5vijUqgChGloQ+WQoaPTyulvO+eTWcEQvURagHiKGpQASaBdta8IdQkOlOX X-Received: by 2002:a05:6402:34f:b0:475:b13b:7d78 with SMTP id r15-20020a056402034f00b00475b13b7d78mr12878378edw.39.1671961696216; Sun, 25 Dec 2022 01:48:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671961696; cv=none; d=google.com; s=arc-20160816; b=Bv9gyO5sGd+RhGuKdeSlzdVIaG1NFzGkamwoScZ6BVmJf+ZjOzoNUOT5pBxxjnq6Gx aCSq7T4Cxl+/Li6uR4pV9S/E5DtW/a9x9u8M4hbgXyRJjuQl9KbaYPn9ztsH0avOo2JB nxLnK8ccQDoC35flpBziwAIAmqnTWchWHI1PKpBw1sCP22cu/w6U6R+dvlH1e/awnlzH wRsJrOURQdoWYlztLCvrSG/BxWEh/IrxByavvvdQzBWGW+9WMr017MVClEp7mqMLB9Z/ PLENdY3cun8h5lKdzeaep+vftIUJJxD1GKgc55H/JOsVnhqGZkGmF6gUFiuPF92Gqho9 nBkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=BWvXWPMzwSTCxxpqcQW0gI5RZCl8AYztczo9joCpUdA=; b=kVDjtpYlbSIt6hF/1vEd4opEL+h2lIeoGrC76xTr7MzARMdZwO7NNoFjSwzRJXOFo4 2AxfQ33amAFIIkJdIc53gjv2uypy7KjZB7OjvYYvEKfPlvOJkYOhRKA1ohmsy9/OD5Ji GglCrOkdcJX3ZcNXzfLFWeR6m4k4o9kHh/KtQaxa6lc+zML0SOpmn32JZ9qRsNUJ0gq8 b3T0jegCrT7qPCs5wgoMbb9gvJrHrkoRzEhoWNvf7fePZLsuDauSCVIicZi01I6tgjKI ItoUp/z/b5Ser0vSHfRY5NUT4Prjc44pouEQcIWddL+rpBWogpE1h7I0khubePp3YBT6 Xr2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b="GWMRd/sU"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056402079500b004700a51c22asi6052120edy.420.2022.12.25.01.47.53; Sun, 25 Dec 2022 01:48:16 -0800 (PST) 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=fail header.i=@mailo.com header.s=mailo header.b="GWMRd/sU"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230510AbiLYJCf (ORCPT + 99 others); Sun, 25 Dec 2022 04:02:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbiLYJC3 (ORCPT ); Sun, 25 Dec 2022 04:02:29 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F32CCC2 for ; Sun, 25 Dec 2022 01:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671958933; bh=Ikp0bAciUuHR4CMbH20GjbpUaRxlCiAZvcXlyc9waLo=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=GWMRd/sU0xw0RjY/sfGybZ415xUmj9CIVv+p28PHWmtDPlOrqOxqBGj1PkikxEUkq R+Trdr7wUiEwD8sCNDULm1P4vj4Qar/txZTOvNi3Z2xnHRcDD+784fOPKm4LyCz125 XM4/Rwg9IfkbUAF5WeMCLJYg4i9VMxZ8kKyNyIGc= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 25 Dec 2022 10:02:13 +0100 (CET) X-EA-Auth: Z6P0qwhHoWnu0O6GC4KeXSFonqwCrW85IJg5SHY+V8thx9eg+ci2uMF9OuzEX4B+nQ56UEBNnAqMBeIPZ5eNEs+/JG8CxndQ Date: Sun, 25 Dec 2022 14:32:08 +0530 From: Deepak R Varma To: Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] drm/nouveau/hwmon: Use sysfs_emit in show function callsbacks Message-ID: MIME-Version: 1.0 Content-Disposition: inline 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_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753178907130766697?= X-GMAIL-MSGID: =?utf-8?q?1753178907130766697?= 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. Signed-off-by: Deepak R Varma --- drivers/gpu/drm/nouveau/nouveau_hwmon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.34.1 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,