From patchwork Sun Dec 25 10:18: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: 36465 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp475348wrt; Sun, 25 Dec 2022 02:48:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8/A4zpUTyWmXHTp9UCJ1Yb9lszwkIDga7dPqW2C4fYnfCIIpnRqKO9i/GzUfDNh/fQhGf X-Received: by 2002:a05:6a20:1608:b0:a8:a203:ec97 with SMTP id l8-20020a056a20160800b000a8a203ec97mr22983031pzj.60.1671965309884; Sun, 25 Dec 2022 02:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671965309; cv=none; d=google.com; s=arc-20160816; b=LLxzSjqr1Njmm10qiib9kfWCzKs+hkEnMEpc6yu05DrYs2pkovvl/K7RNQUWJy3VVO eg+ZqajeFx98BUlO2IqP7qdIeMAM/GfevUqKEwpJ75it0roUB30I8u7g/AlzvUmD7xiT NVx9kknhZPUFebDyjFbe9r96ZBfn9kn3UvaFum34EnjcR3UiMlg5W0C8DB76WAmXN2sw QN0VgA9yMhTQoC6AVP1IrfEKASoHjwwdgOwRrYL4Dujb/09alMD+XIVEUrvC4UMezBT+ kMNvdwQwZP6MYAJ16rgGpmQdboC8RSofd5CHr/YYP7dCsodQV2tP/nQ+e+Q81xlxmEhW E2FA== 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=S4BP3UJrous21MmwczeO1vYXqIglatVYk8Zje+Kr/BQ=; b=LzV+1mNJSZCnADHlhqPG+Cu4WV44821fikkCkMvbz8sGLqWlepVtSu28vzXXYzIHF/ 3cxKnK8zHfzfj1hgFwgrfLnYbTqpdG2d6HJR/WQ//eTW1fTI5IarxwEm+N65XDvbieH4 aw5sKNqdoKK3LkEdsF4KDkhdqzbR5T4i8riIFCfdvoJjfQfbh3mqbRMArWonYJM1Gq1Z DxC9XK0MU5AMJpIT+SOYSIl+k9LGgHeuXWXpeZjI1CNv3buVGeJrwIhCJ7sAmZTJkZUq vPG535qBg18boH6GBloK0r7NWDT7pBBp7S4HumfIZIzWWQRClcDLIO4tYiu8bxsaJ5UN VxMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=MRQvcu3I; 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 w63-20020a638242000000b004977d9f3fcbsi4100153pgd.843.2022.12.25.02.48.14; Sun, 25 Dec 2022 02:48:29 -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=MRQvcu3I; 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 S229759AbiLYKSk (ORCPT + 99 others); Sun, 25 Dec 2022 05:18:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiLYKSj (ORCPT ); Sun, 25 Dec 2022 05:18:39 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D3338B5; Sun, 25 Dec 2022 02:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671963503; bh=VKddANfidYSZkl7mhdUiLj9w4dOBYWTjz1jmCI1ynMI=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=MRQvcu3IL2zD8cij4DfSH9/IzQpmWZJEJj/9lUCCecdfz88tvfA+VrJFgi9q2paXY b+USkBlZ0rFyAVRULXj9lEBxlg+0IocPnw94CZXSwFzERO6ZpT0F+2XYIaterjlqyO 3aumgzQ4nZT4JPbcElyX5QFlz37RO0B/u6WEXJjo= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 25 Dec 2022 11:18:23 +0100 (CET) X-EA-Auth: 8X9Yb/Jt7KQNXICzc/RUtRooJc4xrAVX0UPML0Ft13Dlg18UFZEObQLOEhLF7LD9mfkZTaJ6saww7zT8cF6mKnK6q8PhTMNh Date: Sun, 25 Dec 2022 15:48:18 +0530 From: Deepak R Varma To: Adaptec OEM Raid Solutions , "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: aacraid: 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?1753182696692464323?= X-GMAIL-MSGID: =?utf-8?q?1753182696692464323?= 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, change in length of lines enables code allows to reformat code for improved readability. Issue identified using the coccinelle device_attr_show.cocci script. Signed-off-by: Deepak R Varma --- drivers/scsi/aacraid/linit.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.34.1 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 5ba5c18b77b4..7ef31dc4cb8d 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -559,11 +559,9 @@ static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute * struct scsi_device *sdev = to_scsi_device(dev); struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); if (sdev_channel(sdev) != CONTAINER_CHANNEL) - return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach - ? "Hidden\n" : + return sysfs_emit(buf, sdev->no_uld_attach ? "Hidden\n" : ((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : "")); - return snprintf(buf, PAGE_SIZE, "%s\n", - get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); + return sysfs_emit(buf, "%s\n", get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); } static struct device_attribute aac_raid_level_attr = { @@ -586,12 +584,13 @@ static ssize_t aac_show_unique_id(struct device *dev, if (sdev_channel(sdev) == CONTAINER_CHANNEL) memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn)); - return snprintf(buf, 16 * 2 + 2, - "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", - sn[0], sn[1], sn[2], sn[3], - sn[4], sn[5], sn[6], sn[7], - sn[8], sn[9], sn[10], sn[11], - sn[12], sn[13], sn[14], sn[15]); + return sysfs_emit(buf, + "%02X%02X%02X%02X%02X%02X%02X%02X" + "%02X%02X%02X%02X%02X%02X%02X%02X\n", + sn[0], sn[1], sn[2], sn[3], + sn[4], sn[5], sn[6], sn[7], + sn[8], sn[9], sn[10], sn[11], + sn[12], sn[13], sn[14], sn[15]); } static struct device_attribute aac_unique_id_attr = { @@ -1297,7 +1296,7 @@ static ssize_t aac_show_driver_version(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", aac_driver_version); + return sysfs_emit(buf, "%s\n", aac_driver_version); } static ssize_t aac_show_serial_number(struct device *device, @@ -1323,15 +1322,13 @@ static ssize_t aac_show_serial_number(struct device *device, static ssize_t aac_show_max_channel(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", - class_to_shost(device)->max_channel); + return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_channel); } static ssize_t aac_show_max_id(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", - class_to_shost(device)->max_id); + return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_id); } static ssize_t aac_store_reset_adapter(struct device *device,