From patchwork Wed Mar 1 19:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 63047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3832710wrd; Wed, 1 Mar 2023 11:48:55 -0800 (PST) X-Google-Smtp-Source: AK7set+JtSjliFkGaxv1npnSsR1849mhs2UQRTaqEXVvH3x5k4Uf9m310XkRCBYhfOxX14LKeD7z X-Received: by 2002:a62:6401:0:b0:577:272f:fdb with SMTP id y1-20020a626401000000b00577272f0fdbmr6195342pfb.29.1677700135555; Wed, 01 Mar 2023 11:48:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677700135; cv=none; d=google.com; s=arc-20160816; b=HlOM6CgzXoFiUHBlOzhxFTilXzIrU5XaELLj3QfAFYYqCJSAjkIHFbGhtDrmnAQZ53 LKVBHOOCH/U3q2xpRa8wynKahXW2Gh4WGGJYxRz6p+VzxcotBbh1ScL1bTU/kNyU+yQI LExi6hlg3Uj41fDLRRJehBklPNGiRrrih2XlfOULj5tFBgpajIeFIML7c+MjXOOJpKED 4XSLIUGOHDrAQ+CIYN2wZA96KUXgbkC3LOXDsOnaFU4Sl16ubgpQco727+NCghEU9X7Y ZkuZzgDhLpmSFMFT0N/m5Pl3GJtJzCsIBWjRXOlyj/+2iw+j4aSNyB4KWYUpuLtbKQXD 3aOA== 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=8s5G5DHymrhL0UY67mc0gcaRFTAclTTB8YttB+A8G7U=; b=VxS5dVs3zR5WkdYhFbtRpJ3EPuJQB8S9J44psjuloJmSlIbtjbDbLNQZ6tk/hgAYM5 NogeRiro1s2iH7/zlbiYOjYDKePgqVv3fhgkZs5UnGsbnSDqTtLIeG2Q4sZFnxqgOEzE hZpBOX0kjV/8UNXjWZhiiGq6QijaVwcrVYo+AnuRn5hFT88KFimRyXmVChuOKQeYfHPZ oeMRoSjUJ+L0QOOOWoquhqYqcOi+2Fo2AslFm2CIhNaNE+6z54MT8llu8Ec/gLWkkjjb D6XtQWFPlDxVLv8ENSl64Aw33v18hBGvLQG+s3fBc8C2UpiSm05LB26jZvnfhwVobtkS d8GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=M+bk0agZ; 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 u18-20020a62d452000000b0058bbe6710absi4219720pfl.261.2023.03.01.11.48.41; Wed, 01 Mar 2023 11:48:55 -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=M+bk0agZ; 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 S229670AbjCATf7 (ORCPT + 99 others); Wed, 1 Mar 2023 14:35:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjCATf6 (ORCPT ); Wed, 1 Mar 2023 14:35:58 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D622134332 for ; Wed, 1 Mar 2023 11:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1677699348; bh=wMm9SK0T1X6wjNTxe4InzSuoAuJv/ovXH3Yd9x3INdU=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=M+bk0agZs/ip9NlWKZDeUxfjq8j6MC+6xVMMX5fU/IoWhEkbNWW1yC9t5wgOcujW3 9UpzH2khiWtofRavCKeOROPNzJ7F1MwDHi1MQC8lAMQrLQvxFJRM/n+qZ371YI/pA4 ryeabzdxFT5WjBOu4Wulvt4pgZaD1gbmA35PMcD0= Received: by b221-2.in.mailobj.net [192.168.90.22] with ESMTP via ip-20.mailobj.net [213.182.54.20] Wed, 1 Mar 2023 20:35:48 +0100 (CET) X-EA-Auth: PldJwNJFnC6SMwwwKTtAv1uOQAxuwnwELDsuScmNAdkFQxNVkfwbnt8OHmVTfN7luEAx/wUZHVjyHoFVwndeyg== Date: Thu, 2 Mar 2023 01:05:41 +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 RESEND] 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?1759196097362859459?= X-GMAIL-MSGID: =?utf-8?q?1759196097362859459?= 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 Reviewed-by: Ashutosh Dixit Reviewed-by: Lyude Paul --- 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,