From patchwork Mon Jan 30 20:22:00 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: 648881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D93FC636D3 for ; Mon, 30 Jan 2023 20:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbjA3UWO (ORCPT ); Mon, 30 Jan 2023 15:22:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjA3UWN (ORCPT ); Mon, 30 Jan 2023 15:22:13 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42CB2470AF; Mon, 30 Jan 2023 12:22:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1675110125; bh=pOqor3QSVU7vfogPUbrnGNPF65OQgfQ9DubvQZ9Hg8M=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=oIor9ak8pXR65QOhYfff4SGTjzd8NjsqAidXb6hPH3/c/hPb8GC6mUuTz07lgAmHR ATfwb6Iw3xE0NZdPdsbFCsAPGF1jvUlioZhAViDU8ELRGndonDJjfNVNykgBibD+sU v6I5FcaNbe/+KxNLL7arAN2liBKq2KjM5TT4AZLc= Received: by b-4.in.mailobj.net [192.168.90.14] with ESMTP via ip-206.mailobj.net [213.182.55.206] Mon, 30 Jan 2023 21:22:04 +0100 (CET) X-EA-Auth: KFh5ORkxrJaJFJViVaNy7TAPZFh6u5OSl1mCjUOG+bGhs8BMAdxOJnykaGc6EMAivV1gucpipKqF6rQ4YTZLNwZDKnAQ1nKt Date: Tue, 31 Jan 2023 01:52:00 +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 , Deepak R Varma Subject: [PATCH] scsi: pmcraid: Use sysfs_emit in show function callback Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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/pmcraid.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 836ddc476764..2705dcaa7798 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3493,7 +3493,7 @@ static ssize_t pmcraid_show_log_level( struct Scsi_Host *shost = class_to_shost(dev); struct pmcraid_instance *pinstance = (struct pmcraid_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", pinstance->current_log_level); + return sysfs_emit(buf, "%d\n", pinstance->current_log_level); } /** @@ -3554,8 +3554,7 @@ static ssize_t pmcraid_show_drv_version( char *buf ) { - return snprintf(buf, PAGE_SIZE, "version: %s\n", - PMCRAID_DRIVER_VERSION); + return sysfs_emit(buf, "version: %s\n", PMCRAID_DRIVER_VERSION); } static struct device_attribute pmcraid_driver_version_attr = { @@ -3588,9 +3587,8 @@ static ssize_t pmcraid_show_adapter_id( pinstance->pdev->devfn; u32 aen_group = pmcraid_event_family.id; - return snprintf(buf, PAGE_SIZE, - "adapter id: %d\nminor: %d\naen group: %d\n", - adapter_id, MINOR(pinstance->cdev.dev), aen_group); + return sysfs_emit(buf, "adapter id: %d\nminor: %d\naen group: %d\n", + adapter_id, MINOR(pinstance->cdev.dev), aen_group); } static struct device_attribute pmcraid_adapter_id_attr = {