Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1060227rwj; Fri, 23 Dec 2022 11:59:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXvle4NcJs1n2URTql+JLes5d7MnRtRX4WtHuamBsjEk+FbfKbrJPQCB25j7rhqNcQlyLjYO X-Received: by 2002:a17:906:915:b0:7c0:e98d:b27 with SMTP id i21-20020a170906091500b007c0e98d0b27mr8362517ejd.58.1671825559333; Fri, 23 Dec 2022 11:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671825559; cv=none; d=google.com; s=arc-20160816; b=A6oG020WQ3gCpcC3JKa8lvENRlvbcH2AoumDytON4GJUH2WwoDAurlOK00xyqNu5Ko F7NtZwNMnAhh4aNrc0abuJ9UG1yYkJZ510hkX4eDCO3aO/Lapj2pz6rJkwgoDwwbUpq/ uW6imX+WNHfK7T76Use+x5H8NJJ2376BUKUd1FU5BGW6I1maQmxz3ritPdTuJDJaey1z Ufxr4E9+r50DAIcZiriOc0cTjAqV/R9XvoIZnFiGjz8Sv6gcuJAApGtBmWXEQ86EfC0q WNPu4jT5PD7L0IDUDliiohfocn1KVymlknAhOGlOthyVBjKnwQBzeDgBclLGp/ddVBrz Shcw== 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=R71gQcxs3siuFf60esBGAJyqjz4pNe9lR8645CkceGI=; b=mhE6c1pnwJgophGsQZETjUUMd/0r7wB5P8yx/janB4yPRafRtaTM/EGETx8s/z7jKo I7e6r0tInMv8ntj0FW79Wy1aPSRzkSlhV29Ggg0J+pS+0Gn7NcpR601WRv6x9yB8TioR jnxds31m9emzAHI/X2qWs0O+m3Rsm0Fx1iEYq1l/g6Y8LT6sj0XeU4+CtUNhRIOUSa9W SJhUHAjeTnm42ONj+SErReFRhQcYw7mp7it78vs0PfEpMBYbIV85oN747HiDPGCjHZAf uSAwbVbCg//YyFwMknFyZddFCns4GPYPwB50HG9FH0/aOFepXeUvo7o/10zRWV1Nqq7d puug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=BWqqKwNT; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga7-20020a1709070c0700b007bf9de4fe91si3636268ejc.53.2022.12.23.11.59.04; Fri, 23 Dec 2022 11:59:19 -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=BWqqKwNT; 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 S232944AbiLWTqF (ORCPT + 64 others); Fri, 23 Dec 2022 14:46:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232814AbiLWTqB (ORCPT ); Fri, 23 Dec 2022 14:46:01 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D23630A; Fri, 23 Dec 2022 11:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671824742; bh=blHvl4TwFi6Skuv7VrvkLrtt2LPWZsPhT59Ln7QToC0=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=BWqqKwNT+21sNLvupwmjKXe/uMjPS7JDfTbdIDkU26N4ANxF4mQoQnGmpQtrERXoz RxwaUWl8Oi1wavFWAFmwp9pN2JohJbtF7PN0+9WNKANZmyINUwj1Zo4LQPOZ6PPP2f AgsavzcvRZmhIOf5tt5HPZyR7jAOgV0QueJlSfOs= 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 20:45:42 +0100 (CET) X-EA-Auth: Jkjzspo6MwUxQr8f8PpkqhxDaeHVHWwM9XEEMi6XVUeXbBe9SOg1BaM5HVpi4EeR6T6Fgem9bs0G5dYVjj78dqCrvScd/0rz Date: Sat, 24 Dec 2022 01:15:35 +0530 From: Deepak R Varma To: Hannes Reinecke , "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: myrb: Use sysfs_emit in show function callsbacks Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 According to Documentation/filesystems/sysfs.rst, the show() callback function of kobject attributes should strictly use sysfs_emit instead of sprintf family functions. 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/myrb.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c index e885c1dbf61f..ab7eab0dfa38 100644 --- a/drivers/scsi/myrb.c +++ b/drivers/scsi/myrb.c @@ -1767,7 +1767,7 @@ static ssize_t raid_state_show(struct device *dev, int ret; if (!sdev->hostdata) - return snprintf(buf, 16, "Unknown\n"); + return sysfs_emit(buf, "Unknown\n"); if (sdev->channel == myrb_logical_channel(sdev->host)) { struct myrb_ldev_info *ldev_info = sdev->hostdata; @@ -1886,11 +1886,10 @@ static ssize_t raid_level_show(struct device *dev, name = myrb_raidlevel_name(ldev_info->raid_level); if (!name) - return snprintf(buf, 32, "Invalid (%02X)\n", - ldev_info->state); - return snprintf(buf, 32, "%s\n", name); + return sysfs_emit(buf, "Invalid (%02X)\n", ldev_info->state); + return sysfs_emit(buf, "%s\n", name); } - return snprintf(buf, 32, "Physical Drive\n"); + return sysfs_emit(buf, "Physical Drive\n"); } static DEVICE_ATTR_RO(raid_level); @@ -1903,17 +1902,17 @@ static ssize_t rebuild_show(struct device *dev, unsigned char status; if (sdev->channel < myrb_logical_channel(sdev->host)) - return snprintf(buf, 32, "physical device - not rebuilding\n"); + return sysfs_emit(buf, "physical device - not rebuilding\n"); status = myrb_get_rbld_progress(cb, &rbld_buf); if (rbld_buf.ldev_num != sdev->id || status != MYRB_STATUS_SUCCESS) - return snprintf(buf, 32, "not rebuilding\n"); + return sysfs_emit(buf, "not rebuilding\n"); - return snprintf(buf, 32, "rebuilding block %u of %u\n", - rbld_buf.ldev_size - rbld_buf.blocks_left, - rbld_buf.ldev_size); + return sysfs_emit(buf, "rebuilding block %u of %u\n", + rbld_buf.ldev_size - rbld_buf.blocks_left, + rbld_buf.ldev_size); } static ssize_t rebuild_store(struct device *dev, @@ -2140,7 +2139,7 @@ static ssize_t ctlr_num_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 20, "%u\n", cb->ctlr_num); + return sysfs_emit(buf, "%u\n", cb->ctlr_num); } static DEVICE_ATTR_RO(ctlr_num); @@ -2150,7 +2149,7 @@ static ssize_t firmware_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 16, "%s\n", cb->fw_version); + return sysfs_emit(buf, "%s\n", cb->fw_version); } static DEVICE_ATTR_RO(firmware); @@ -2160,7 +2159,7 @@ static ssize_t model_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 16, "%s\n", cb->model_name); + return sysfs_emit(buf, "%s\n", cb->model_name); } static DEVICE_ATTR_RO(model); -- 2.34.1