From patchwork Mon Jan 30 20:53:48 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: 50479 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2393879wrn; Mon, 30 Jan 2023 13:00:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKges+SmuD10RSOG8wzuWseec/jSaBybAkco49HnYCyigThGzXLPgegOZg8aBeIt3jLIx4 X-Received: by 2002:a17:906:6843:b0:86c:a3ed:1442 with SMTP id a3-20020a170906684300b0086ca3ed1442mr53763359ejs.4.1675112458675; Mon, 30 Jan 2023 13:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675112458; cv=none; d=google.com; s=arc-20160816; b=qKGy92bq1Y6BG+y8z5s4sO2+aXn3rr5sWkrQCq5YDhYFrS9pezeKNKDNqyZ1MutqTi MZanvB3gl4mkbwZXjQ8XP76TXuW1+8lQ08ENZ4ETg18vYf8kx7mYB7NbiELRJ2X2cx5G p/atCvJdqF7FKfG2N3niKu98VrZPWz4621THGyrXStINbzr8d54TaW32rr+zFH0kSp8D CoJF/5BzJRADaMXpNw43+w5bi/E0aEuIf6I6FPXFU6e9NWQQdA3NhDblmW8c2DnqIEbl EEHuZhxwp72ze5GR2ohvIh1nd8qzM+5KFTT28rKR9Eta6ILccpGO3r1QEKXku0VWJy5s ryvQ== 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=BAAMqZl1WDeEY+4OPzw6L2K+1NtljyWqjI8c3CdhxPo=; b=srEZuf9BlhCsi+GCXdxI7b24kjYsHV0W/WYb2qX1u0JKG+emAcPQYpvhoU36g33KoV q4WpFu5SvZjtVQh0/T6qe0smRKAn6m4eoMTuj+gECQHRGZ07J+A8sH4pacH6qvNzHkNs TywIA5x/z5gZJetDhmJXvKNjyp1BihxQ5jFRRvTiYmm4bLX+ZYNYlXSa0NXNZ7uTQ1er SxSCvpUThzkBEhhHHj26lX1XEEWHU+FdL0MZgJijy6YpleLC2x4xh7VJQNDksEJA6C3+ TSyfovpSV6w3YxPdCJPPZcmxaMkY7giGRle72H+D/flmHHIS4US88+f3qE1Mn3ba5Hgb xvEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=NPE+T1eM; 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 15-20020a17090601cf00b008889c04b60fsi4545634ejj.959.2023.01.30.13.00.32; Mon, 30 Jan 2023 13:00:58 -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=NPE+T1eM; 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 S230149AbjA3Uyr (ORCPT + 99 others); Mon, 30 Jan 2023 15:54:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230158AbjA3Uyn (ORCPT ); Mon, 30 Jan 2023 15:54:43 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13FB47094; Mon, 30 Jan 2023 12:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1675112039; bh=bfFcOrFbHGSJZOWyBtjJIaGYLkbNQlO/HXEzfdCL/Z8=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=NPE+T1eMlbAH+D0Jo9yKQXLorxTS033etNTja+viPr4XJKvLancAuQNB25fKYtXlN LoembH9yE48g+fixD+TJJNI3A5BB+vMuGEvJhLmR4o0IDfItCe/s1oY+b6R+eCP2wX 8GfClIxYBCNO7q+AvVdFPT2+zDaGdFQh+I7ZjrYQ= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via ip-206.mailobj.net [213.182.55.206] Mon, 30 Jan 2023 21:53:54 +0100 (CET) X-EA-Auth: 2KrLQiI3TtiSULUBE7lRV/apfvNhZ1NXjTW6KXqza+vYvgiL2sY3VY5lm0Dm88hooY8qgPAL1l/zXkh2EvEmTJCiEIWmAnKx Date: Tue, 31 Jan 2023 02:23:48 +0530 From: Deepak R Varma To: HighPoint Linux Team , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] scsi: hptiop: Use sysfs_emit in show function callback 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?1756482721189610697?= X-GMAIL-MSGID: =?utf-8?q?1756482721189610697?= According to Documentation/filesystems/sysfs.rst, show() callback function should only use sysfs_emit() or sysfs_emit_at() instead of sprint() family functions when formatting the device attribute values to be returned to user space. Issue identified using the device_attr_show.cocci Coccinelle script. Signed-off-by: Deepak R Varma --- drivers/scsi/hptiop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index 7e8903718245..a92998dd77a6 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -1111,7 +1111,7 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev, static ssize_t hptiop_show_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver); + return sysfs_emit(buf, "%s\n", driver_ver); } static ssize_t hptiop_show_fw_version(struct device *dev, @@ -1120,11 +1120,11 @@ static ssize_t hptiop_show_fw_version(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; - return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", - hba->firmware_version >> 24, - (hba->firmware_version >> 16) & 0xff, - (hba->firmware_version >> 8) & 0xff, - hba->firmware_version & 0xff); + return sysfs_emit(buf, "%d.%d.%d.%d\n", + hba->firmware_version >> 24, + (hba->firmware_version >> 16) & 0xff, + (hba->firmware_version >> 8) & 0xff, + hba->firmware_version & 0xff); } static struct device_attribute hptiop_attr_version = {