From patchwork Fri Dec 23 20:30:18 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: 36337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp498251wrn; Fri, 23 Dec 2022 12:37:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXt5BxFzT/r+9l79pZ0T3O0D+E7u0/xsnJvTol6+WV7o8xdqIC4toRy8OOz4r43L7Z3z8xG3 X-Received: by 2002:a17:906:27c5:b0:7c0:c220:a33d with SMTP id k5-20020a17090627c500b007c0c220a33dmr9800322ejc.9.1671827862813; Fri, 23 Dec 2022 12:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671827862; cv=none; d=google.com; s=arc-20160816; b=Xj3dSEp28udKfxbj/aC+HT96j4b2+ce+AwcFdtVOwlkgSnVda2BjabfCT4gO+ctoll bkWODlj0fbf0tY9NY0CtLg/hqr/nhf17OCvxwrbJQQYUxitdYBfFlXAAehBjD6Qd2ieM 0GfcK6IzqHFaG1vAPC5mP98PMmvg2z0pWko3IwRyXttshM7F4SfTc2tSieqsmhfdGM8Y CoXTwJxb7h4M3CfGYksHgPj+fELO9IStV8whkpQOlYqAsAdfiMatozZgMCQqhNx8l8Yl DFOvuVEzlvX+nypJ0MNjvZS+d22zgUeEC+UwDbF7sA3Y90gbi4YykWkXFtqqyniC/SyC wVfg== 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=84JhKIVW+/CqegfKcDDSSVO2l+hXX1OKYwd3Xz1Sv14=; b=H8tF/ygx5ZGP5CyegqBM6tiu+QM+I0smf3d42pIHzwZnygkdyv2iMhOlR/3mvB+mq0 Tr2B6h+ENpRVXN5LrsPtJuSSOkhODyIKGd1MlkJ7lMbMkA8hFPe3csQRjySA3HjigX29 V64nGGSm0tQmo9hYOfpexklan+1lked9lDWiN/6e61DlN3OCNMVBzRbyCIDV6HthGF1y BKVbjltxCLVuMMzkBen5lMKZCxCS/VVr1+38g5EZZelTCh3Si0R8a0+Va5MWAo5X87Zp CrurMGCj8o8R+moNvrvtEQcdIQCRF9oQ48O2tLe4dz/MzTMHR6++wXeGbk8NeHUWC6L0 r6xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=DOFTE9bh; 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 sc36-20020a1709078a2400b0077f3a9c58e2si3471310ejc.6.2022.12.23.12.37.12; Fri, 23 Dec 2022 12:37:42 -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=DOFTE9bh; 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 S232273AbiLWUai (ORCPT + 99 others); Fri, 23 Dec 2022 15:30:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiLWUah (ORCPT ); Fri, 23 Dec 2022 15:30:37 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA6251CB35; Fri, 23 Dec 2022 12:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671827426; bh=vS/Li6+Zpr7ZVWYqMAYDUhEPOIJVm0V6qi7y4a+hgec=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=DOFTE9bh+/75w7++Fzm8CplrQvVTNgunb2xbH8+SYagFUIdYrX8+1RQs8SL+BkSyZ nKUH7nSwqGWjenqDvpNeDthszclzY5+Xp8KVcQ0DehP5GZYpkOn2I/mAnkej7fjbOb MHc0zhEYwiFIv1ZYHt/3CBDPJi3D1NFjZt1VIf4I= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Fri, 23 Dec 2022 21:30:26 +0100 (CET) X-EA-Auth: c7h24WgU1hn1i+tB6xwSDyBlqMaEz3g4uv7Rzli+8tGkg/uIxCiLw7CsxEWTL5vDC2rjihhk4WDnChAIIEcfxbpkuSeqHNv6 Date: Sat, 24 Dec 2022 02:00:18 +0530 From: Deepak R Varma To: Kashyap Desai , Sumit Saxena , Shivasharan S , "James E.J. Bottomley" , "Martin K. Petersen" , megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] scsi: megaraid_sas: 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?1753038572974414451?= X-GMAIL-MSGID: =?utf-8?q?1753038572974414451?= 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. Also, merge split lines wherever possible due to shortened length of lines. Issue identified using the coccinelle device_attr_show.cocci script. Signed-off-by: Deepak R Varma --- drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.34.1 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 3ceece988338..7fa472ab0b94 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3335,7 +3335,7 @@ fw_crash_buffer_size_show(struct device *cdev, struct megasas_instance *instance = (struct megasas_instance *) shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long) + return sysfs_emit(buf, "%ld\n", (unsigned long) ((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE); } @@ -3382,14 +3382,14 @@ fw_crash_state_show(struct device *cdev, struct megasas_instance *instance = (struct megasas_instance *) shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state); + return sysfs_emit(buf, "%d\n", instance->fw_crash_state); } static ssize_t page_size_show(struct device *cdev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)PAGE_SIZE - 1); + return sysfs_emit(buf, "%ld\n", (unsigned long)PAGE_SIZE - 1); } static ssize_t @@ -3399,7 +3399,7 @@ ldio_outstanding_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->ldio_outstanding)); + return sysfs_emit(buf, "%d\n", atomic_read(&instance->ldio_outstanding)); } static ssize_t @@ -3409,7 +3409,7 @@ fw_cmds_outstanding_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding)); + return sysfs_emit(buf, "%d\n", atomic_read(&instance->fw_outstanding)); } static ssize_t @@ -3419,7 +3419,7 @@ enable_sdev_max_qd_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd); + return sysfs_emit(buf, "%d\n", instance->enable_sdev_max_qd); } static ssize_t @@ -3473,8 +3473,7 @@ raid_map_id_show(struct device *cdev, struct device_attribute *attr, struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%ld\n", - (unsigned long)instance->map_id); + return sysfs_emit(buf, "%ld\n", (unsigned long)instance->map_id); } static DEVICE_ATTR_RW(fw_crash_buffer);