From patchwork Fri Dec 23 17:52:51 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: 36315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp441882wrn; Fri, 23 Dec 2022 09:56:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBw+MZHaYlXEiVMRtP5R1H2CeIv7InDiT79iQmjNZpkOOQagRP7F8VRIaoN+amebS4MME8 X-Received: by 2002:a50:fe0e:0:b0:46f:9507:36bc with SMTP id f14-20020a50fe0e000000b0046f950736bcmr10640559edt.16.1671818211335; Fri, 23 Dec 2022 09:56:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671818211; cv=none; d=google.com; s=arc-20160816; b=D9OD3eSsD8meCK1i0WuZyl801a7mVBGLe0mDU7o2OWWNY0zoUGJHFBP3Vq8IhafMgb qQQZj1uOYonqMgPPOnSyYiiCsVkQCaXwI5IS96xsz+TaR1BGFJ8HK0CfR8da1LrEC+an PgfX4xJnpDJyI1Q4BmSkaA6wlRhfrlktpeU+D/o4yl8qdwp2BwL4zMjGPCIm0vBubYzZ RR3abw337TC1MR3Wh0lHijdBn+nCGPMYzQ3BO5AJH4PgVMg5lI+yZw0iQP+CpLmYp191 3HEg79EQsHWBR5lg1euEVrTGNXm9pHJHAe+Hnz4oUjKtpiBseTVbbwxd+68pADFIIpX9 R+WA== 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=6DlSlhDIPa1XD0oqbrAmowoSBXSArl5CPIfZzn6HsvA=; b=qea7OoLQbUNVc7kUH4PctkF2ngCf3WUQTD5dZoIOhMnHL2qexgxg12Le4F1WvfcTth 65rCgskEQGzg+DAvVYywbQJyp9+u84eZ81ncVz7JLKDOcEAI1QdrwulKm1p70dgMU2/R DLu2K0JT9DothBu0pHxgUGheJEGCzJpeyZlCPsvoiq/7Y+phaJPwGbRm8OBChzoDVq4V niR54s0iSNWKJ7i+mStcf/P51OPYpNHkdUMpWvvlGVhQ61KHynd3diQnCoFVfkShAs3d xV94PzYaxtmGRxU6Pp0rHQt8FyFWvdOFZIbjN/NYtf0vRzuvjDRXOt11dBrnloCnWSCi Pfog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=aYGw+ohR; 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 g1-20020a056402320100b0048227222e14si1492516eda.248.2022.12.23.09.56.27; Fri, 23 Dec 2022 09:56:51 -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=aYGw+ohR; 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 S231802AbiLWRxG (ORCPT + 99 others); Fri, 23 Dec 2022 12:53:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbiLWRxE (ORCPT ); Fri, 23 Dec 2022 12:53:04 -0500 X-Greylist: delayed 169 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 23 Dec 2022 09:53:03 PST Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7874413D16; Fri, 23 Dec 2022 09:53:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671817975; bh=vic0AKsJwRQB5l4OjER1p+febXfqn7JDFSD0OPmAFL0=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=aYGw+ohRTozbpJf4Zqv7qZLzF2LfJXIsULJeAwvOlWJsECw+G1Wj7ak8io6NdrFD4 /dBlk3AMMJmwM/CILoXTGn5JNJf+NNWZiKhN8BUorDY5uem5rkybOnNDVq97+FQZU3 cXixDDugS8NKKjni6aLf59BAzO0sMBRzIAfa0Nb8= Received: by b-1.in.mailobj.net [192.168.90.11] with ESMTP via ip-206.mailobj.net [213.182.55.206] Fri, 23 Dec 2022 18:52:55 +0100 (CET) X-EA-Auth: +8N21lyApftGT6DNzN3hcEBdXdk1JiW/qk9Iw6HjijP+lHSWgf8kECEJnufHGTjQ6UgP1Aptkv5THegbpFTf8qF4I/nSv5ym Date: Fri, 23 Dec 2022 23:22:51 +0530 From: Deepak R Varma To: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , drv@mailo.com Subject: [PATCH] scsi: arcmsr: 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?1753028452609178045?= X-GMAIL-MSGID: =?utf-8?q?1753028452609178045?= According to Documentation/filesystems/sysfs.rst, the show() callback function of kobject attributes should strictly use sysfs_emit instead of sprintf family functions. Issue identified using the coccinelle device_attr_show.cocci script. Signed-off-by: Deepak R Varma --- drivers/scsi/arcmsr/arcmsr_attr.c | 44 ++++++++++--------------------- 1 file changed, 14 insertions(+), 30 deletions(-) -- 2.34.1 diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index baeb5e795690..feec18222f8c 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c @@ -258,9 +258,7 @@ static ssize_t arcmsr_attr_host_driver_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, - "%s\n", - ARCMSR_DRIVER_VERSION); + return sysfs_emit(buf, "%s\n", ARCMSR_DRIVER_VERSION); } static ssize_t @@ -270,9 +268,8 @@ arcmsr_attr_host_driver_posted_cmd(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - atomic_read(&acb->ccboutstandingcount)); + + return sysfs_emit(buf, "%4d\n", atomic_read(&acb->ccboutstandingcount)); } static ssize_t @@ -282,9 +279,8 @@ arcmsr_attr_host_driver_reset(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->num_resets); + + return sysfs_emit(buf, "%4d\n", acb->num_resets); } static ssize_t @@ -294,9 +290,8 @@ arcmsr_attr_host_driver_abort(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->num_aborts); + + return sysfs_emit(buf, "%4d\n", acb->num_aborts); } static ssize_t @@ -306,9 +301,8 @@ arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%s\n", - acb->firm_model); + + return sysfs_emit(buf, "%s\n", acb->firm_model); } static ssize_t @@ -319,9 +313,7 @@ arcmsr_attr_host_fw_version(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%s\n", - acb->firm_version); + return sysfs_emit(buf, "%s\n", acb->firm_version); } static ssize_t @@ -332,9 +324,7 @@ arcmsr_attr_host_fw_request_len(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_request_len); + return sysfs_emit(buf, "%4d\n", acb->firm_request_len); } static ssize_t @@ -345,9 +335,7 @@ arcmsr_attr_host_fw_numbers_queue(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_numbers_queue); + return sysfs_emit(buf, "%4d\n", acb->firm_numbers_queue); } static ssize_t @@ -358,9 +346,7 @@ arcmsr_attr_host_fw_sdram_size(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_sdram_size); + return sysfs_emit(buf, "%4d\n", acb->firm_sdram_size); } static ssize_t @@ -371,9 +357,7 @@ arcmsr_attr_host_fw_hd_channels(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_hd_channels); + return sysfs_emit(buf, "%4d\n", acb->firm_hd_channels); } static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL);