From patchwork Fri Mar 15 05:52:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13593064 X-Patchwork-Delegate: kvalo@adurom.com Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95B7B12E5D; Fri, 15 Mar 2024 05:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481956; cv=none; b=EOYlBP1JDbVT9ySWdOuvyzbLifOIHII89UxzI31K5/g5R47Jt7+LNdZZTeSBsnRhI3V9ofqbmn6c5R7CAG5dDWHHN2E8ewrcQQBQrV8XxmaF0X0UhabOw1tyddcELdDeUamt7O9jvPJlPbd822Xxsx6EmApsjF8KwG+q0km0n/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481956; c=relaxed/simple; bh=Qv6phc/4FuyjqrfYPdqCTnpCxBNfhp35atRySiUpzR8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mu4ub+lwNQYImM7o5kcmE6uMcJnXGHhMYFJIGjXot8fxCL7rcRCD3HA8CnEMNGZfoOJbCoVSIrSHh6zBijixCoM/tLpB5WtK8iui3wPz6hEZeERPMcahJLr9TMf6S1QyShjdODJNYLiCuVuu3TRE4AE3losKlM8yHqYr1woC9YM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=o+N57xuP; arc=none smtp.client-ip=207.54.90.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="o+N57xuP" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710481953; x=1742017953; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Qv6phc/4FuyjqrfYPdqCTnpCxBNfhp35atRySiUpzR8=; b=o+N57xuPi/Z7+TC/ISSCVVhAZ1hWGntvgTDA7tkJsTmZgZu4lcEIqXD8 w+alt92cGw9Xc1+JQN7/GJV0ti1MHvOdNf9LOVrNnMsntc12SZUtgGavh IqobV0clTy/CmY+BS9wTAilAsonNEnn+/tWQjQ9Sta6FUGqeqarhQXLxb WPJ6G5ZIcXlW7ABaMVLBbqX7afzCTrhZ7+72J6Pa3FOU75OIsGrYECSmV NukKDZ+JkeEpX6OWLPcpM4kUGOFgZRKIsRN4K0Ha+qESc/xlGFi1AbgW7 fCwhGZpQq5DdWNivnFTh//bIOIxXsXmg2dkroLpq2UpDgKtWB1bmHkVh8 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="152383413" X-IronPort-AV: E=Sophos;i="6.07,127,1708354800"; d="scan'208";a="152383413" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 14:52:29 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 3C36DF2647; Fri, 15 Mar 2024 14:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 6609F10613D; Fri, 15 Mar 2024 14:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id E188820097CFA; Fri, 15 Mar 2024 14:52:25 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 1A9A31A006B; Fri, 15 Mar 2024 13:52:24 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Kalle Valo , Jeff Johnson , linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org Subject: [PATCH v2 1/3] wifi: ath: Convert sprintf/snprintf to sysfs_emit Date: Fri, 15 Mar 2024 13:52:09 +0800 Message-Id: <20240315055211.1347548-1-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28252.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28252.004 X-TMASE-Result: 10--3.370400-10.000000 X-TMASE-MatchedRID: /mcjwogdDrk4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbSrMZ+BqQt2Nps/NNpVQ666hXsn8ikX6Gtzv0 +UmYCZcMPNxz2EvpSIAhBeNJICtc+zK2lwdvrNt2qH6mIBejVf2ItZ2e1geixEd+K6O5Nt53oKE r2irJf5CL637QCIVpi8vc3EUpCmrV8M8QL/JCA9N9JA2lmQRNUrzl8sNiWClKbKItl61J/yZ+in TK0bC9eKrauXd3MZDXdPm6Zo4+L6rfjitlkYmpJaIu8tbWsF6z9+jPt2YyIEwSvEMdfhO/82WMg P9XH4iW61V4Xac0M7FrnjD0+bxg0N7Br+Gphn4yMa1PejsZJrBXFEH92Kf64nTtPxlIuIBW9Hzj 86YHXBCnifx5AGfCL X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). sprintf() will be converted as weel if they have. Generally, this patch is generated by make coccicheck M= MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended CC: Kalle Valo CC: Jeff Johnson CC: linux-wireless@vger.kernel.org CC: ath11k@lists.infradead.org CC: ath10k@lists.infradead.org Signed-off-by: Li Zhijian --- V2: subject updated This is a part of the work "Fix coccicheck device_attr_show warnings"[1] Split them per subsystem so that the maintainer can review it easily [1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@fujitsu.com/ --- drivers/net/wireless/ath/ath10k/thermal.c | 2 +- drivers/net/wireless/ath/ath11k/thermal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c index 31c8d7fbb095..8b15ec07b107 100644 --- a/drivers/net/wireless/ath/ath10k/thermal.c +++ b/drivers/net/wireless/ath/ath10k/thermal.c @@ -100,7 +100,7 @@ static ssize_t ath10k_thermal_show_temp(struct device *dev, spin_unlock_bh(&ar->data_lock); /* display in millidegree celsius */ - ret = snprintf(buf, PAGE_SIZE, "%d\n", temperature * 1000); + ret = sysfs_emit(buf, "%d\n", temperature * 1000); out: mutex_unlock(&ar->conf_mutex); return ret; diff --git a/drivers/net/wireless/ath/ath11k/thermal.c b/drivers/net/wireless/ath/ath11k/thermal.c index 41e7499f075f..18d6eab5cce3 100644 --- a/drivers/net/wireless/ath/ath11k/thermal.c +++ b/drivers/net/wireless/ath/ath11k/thermal.c @@ -101,7 +101,7 @@ static ssize_t ath11k_thermal_show_temp(struct device *dev, spin_unlock_bh(&ar->data_lock); /* display in millidegree Celsius */ - ret = snprintf(buf, PAGE_SIZE, "%d\n", temperature * 1000); + ret = sysfs_emit(buf, "%d\n", temperature * 1000); out: mutex_unlock(&ar->conf_mutex); return ret; From patchwork Fri Mar 15 05:52:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13593063 X-Patchwork-Delegate: kvalo@adurom.com Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBE3912E63; Fri, 15 Mar 2024 05:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481955; cv=none; b=SAfOdYPBWcZ77DxW8LEOJTIk5VWwWqpUveELVEj+shxyhSnBBnP49vEYGXJN1R6lqbGjP+v89YvfRciT+5P6BLbaWK/28Z0qZI/Cvdkpv0g/HEHcqDSPmY2uagJo0rA/lu8wGwi1mNvWQJt+wruerDgTrfwnHSrulQl/zoOXvXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481955; c=relaxed/simple; bh=CiPT7Tebx6aLcsDUlO8+2vRvufZYRCatvwZilYy8IT0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Mg93ts0U+n17ZWgEuPUAEbpWHa23FcqHAEOTYhlo+bxUc9kGn51AiSdeGtBYK11hloFwXxpj80O1nfEt09PvKyHheB2h/A28IjY0w12AX6FVsfw45jk+uXYpk0dU6Nt2EzXWD6I+DuY/YasGFyu9VdzMMog+Dc4DpfvoBcvOxA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=XlcMPOtS; arc=none smtp.client-ip=207.54.90.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="XlcMPOtS" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710481953; x=1742017953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CiPT7Tebx6aLcsDUlO8+2vRvufZYRCatvwZilYy8IT0=; b=XlcMPOtS7djygQ9t+cXmg2Bpe8rHuYcmwX8oqTH47/QrTJYKEKNlx+Ch 6JHuAzk/t7NJYqFouil/6908dl6RslAtC/fmysozMVHEpwISc8Qi5H/3s VKBaKwIBhEh9ZZvSftFrqO3qCnrytnu+roEKJv50CIpi5aFND2xyGtSzc bib3m0bi0Uxx+U1xhiN258cbJUwZrx+nWXzOH/s90dWdJmSgP60lD8cq1 k+7+6JJ+QjH9A3gkw30tPsMGFVp1FequAsD54qixIljrfH943/R01/8OO KFBbUTee9G/uUNqLID0lAa+x9QB2imiQ86QzCmV601XYlCNUCnfz6hJzV A==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="152221217" X-IronPort-AV: E=Sophos;i="6.07,127,1708354800"; d="scan'208";a="152221217" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 14:52:29 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 6AF38141205; Fri, 15 Mar 2024 14:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 9331BD9C43; Fri, 15 Mar 2024 14:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 31D4020097CFA; Fri, 15 Mar 2024 14:52:26 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 94B541A006C; Fri, 15 Mar 2024 13:52:25 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Larry Finger , Kalle Valo , linux-wireless@vger.kernel.org, b43-dev@lists.infradead.org Subject: [PATCH v2 2/3] wifi: b43: Convert sprintf/snprintf to sysfs_emit Date: Fri, 15 Mar 2024 13:52:10 +0800 Message-Id: <20240315055211.1347548-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315055211.1347548-1-lizhijian@fujitsu.com> References: <20240315055211.1347548-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28252.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28252.004 X-TMASE-Result: 10--3.135400-10.000000 X-TMASE-MatchedRID: NwgUWlK30I84ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbSK0+leiJxLlf0swHSFcVJ6C+fNq7c31fg18a 7/fBfKbtsH3yLH3eS2KM07FLsxDxnV/iiNsapK9v+xRIVoKNMvE3yuY9BGW8rugVDwZELU+uzXD BpgFAuCz3+8VUHHGqAepi+JVYshcq1UOlz1sLXchF4zyLyne+ATJDl9FKHbrkDBQ+XBh4YJeK5f hRxt1aAaqQjB20KvEp0R7kGywzHs4SasxSwyoX8Zj7E6vHnuNavOXyw2JYKUpsoi2XrUn/J8m+h zBStanuKNyKr3HDyRSdET58jp62Se1tzlfEsCEjf6Uj/7wqoheeV309kYPkCJqS9dJdH2q3RQR/ GKLsybD7TTdZXIbZlE9X3mtYh1QrW0XXTT4K+7uG9IZU1A0HawGC8e6520fKw0PJt06oJaHpaQl 5xviY7wxgWdRvK9Un9g+oMf9KM6Q== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). sprintf() will be converted as weel if they have. Generally, this patch is generated by make coccicheck M= MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended CC: Larry Finger CC: Kalle Valo CC: linux-wireless@vger.kernel.org CC: b43-dev@lists.infradead.org Acked-by: Larry Finger Signed-off-by: Li Zhijian --- V2: subject updated and wrap line style This is a part of the work "Fix coccicheck device_attr_show warnings"[1] Split them per subsystem so that the maintainer can review it easily [1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@fujitsu.com/ --- drivers/net/wireless/broadcom/b43/sysfs.c | 13 ++++--------- drivers/net/wireless/broadcom/b43legacy/sysfs.c | 16 ++++++---------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43/sysfs.c b/drivers/net/wireless/broadcom/b43/sysfs.c index 0679d132968f..261b2b746a9c 100644 --- a/drivers/net/wireless/broadcom/b43/sysfs.c +++ b/drivers/net/wireless/broadcom/b43/sysfs.c @@ -53,19 +53,14 @@ static ssize_t b43_attr_interfmode_show(struct device *dev, switch (wldev->phy.g->interfmode) { case B43_INTERFMODE_NONE: - count = - snprintf(buf, PAGE_SIZE, - "0 (No Interference Mitigation)\n"); + count = sysfs_emit(buf, "0 (No Interference Mitigation)\n"); break; case B43_INTERFMODE_NONWLAN: - count = - snprintf(buf, PAGE_SIZE, - "1 (Non-WLAN Interference Mitigation)\n"); + count = sysfs_emit(buf, + "1 (Non-WLAN Interference Mitigation)\n"); break; case B43_INTERFMODE_MANUALWLAN: - count = - snprintf(buf, PAGE_SIZE, - "2 (WLAN Interference Mitigation)\n"); + count = sysfs_emit(buf, "2 (WLAN Interference Mitigation)\n"); break; default: B43_WARN_ON(1); diff --git a/drivers/net/wireless/broadcom/b43legacy/sysfs.c b/drivers/net/wireless/broadcom/b43legacy/sysfs.c index eec087ca30e6..d988fe541bf7 100644 --- a/drivers/net/wireless/broadcom/b43legacy/sysfs.c +++ b/drivers/net/wireless/broadcom/b43legacy/sysfs.c @@ -75,16 +75,14 @@ static ssize_t b43legacy_attr_interfmode_show(struct device *dev, switch (wldev->phy.interfmode) { case B43legacy_INTERFMODE_NONE: - count = snprintf(buf, PAGE_SIZE, "0 (No Interference" - " Mitigation)\n"); + count = sysfs_emit(buf, "0 (No Interference Mitigation)\n"); break; case B43legacy_INTERFMODE_NONWLAN: - count = snprintf(buf, PAGE_SIZE, "1 (Non-WLAN Interference" - " Mitigation)\n"); + count = sysfs_emit(buf, + "1 (Non-WLAN Interference Mitigation)\n"); break; case B43legacy_INTERFMODE_MANUALWLAN: - count = snprintf(buf, PAGE_SIZE, "2 (WLAN Interference" - " Mitigation)\n"); + count = sysfs_emit(buf, "2 (WLAN Interference Mitigation)\n"); break; default: B43legacy_WARN_ON(1); @@ -155,11 +153,9 @@ static ssize_t b43legacy_attr_preamble_show(struct device *dev, mutex_lock(&wldev->wl->mutex); if (wldev->short_preamble) - count = snprintf(buf, PAGE_SIZE, "1 (Short Preamble" - " enabled)\n"); + count = sysfs_emit(buf, "1 (Short Preamble enabled)\n"); else - count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble" - " disabled)\n"); + count = sysfs_emit(buf, "0 (Short Preamble disabled)\n"); mutex_unlock(&wldev->wl->mutex); From patchwork Fri Mar 15 05:52:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13593062 X-Patchwork-Delegate: kvalo@adurom.com Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C3C58F70; Fri, 15 Mar 2024 05:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.137 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481955; cv=none; b=qCOUTjFqD14ahGu7g5vJ2iYgY1DNIy4yeTpXXDCaTvR3a5RKY9UxhOz7htTjLAa5U+YW49eWGEIaOl0nJf1TQNOfpb3Qg0OkhCCRvD6+gmbEhYNQ61sRB1O1tof2J+kOEDPEYsqEbjTHJFbXgKXQ7CAjw/8fPyV5whSF9Mq/WmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481955; c=relaxed/simple; bh=GaRvUMYJRgQO4S22m+dRiQR4wBFciE7wN7V24w8WpVE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JNEDlH4K7t+CFXDn+yP5AyV53LRCpYv6dOAT84gsNLHbx0VfJvBIXHV0lr8q029dkGThzWF7tRQTWGaH9wIVn/8AxQhNQPBb22cKnoRUY38FullyyNHjoMuMMX1gPzbWI9Ep8Zd1KoNEoBXuOEf6PtsLHlGCgR2ZngJ01aicMjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=N3w3+JOL; arc=none smtp.client-ip=207.54.90.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="N3w3+JOL" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710481953; x=1742017953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GaRvUMYJRgQO4S22m+dRiQR4wBFciE7wN7V24w8WpVE=; b=N3w3+JOLokBFrRwj8exxSquKWsLAwnKF5uVK9QkIQmoYejeoTum/bLrO arnoKuJZO8YoJ3ZwXcKh0mAxIKp15zBypSeywEMSx77ycxyPHIymvlLf7 6lopIR7uHyfJpRU1+Z4ZSo/pW4wPrVlJ/ehmeO7/jLouE0C2sdy8NrYeQ /ecuTlQ2xTxgc56G8qiHGGuI4vVwMMTdI6cP0pUq5n6ZN+DbDD7qWQtl0 AjhNvLUBbzRvnqmPrZLG6oje/U2jiREPw0/OnFCSmkAhDkh1Xxl/iOtu1 6DLj0/EM2g+UWSdpxghpwVgYOkkk88/z9XzYkSwQj0BS1cN92019k/kNC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="131718016" X-IronPort-AV: E=Sophos;i="6.07,127,1708354800"; d="scan'208";a="131718016" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 14:52:30 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 8F0CDC21AA; Fri, 15 Mar 2024 14:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id BCC87206005; Fri, 15 Mar 2024 14:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 6058D202CCD27; Fri, 15 Mar 2024 14:52:26 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id F25FA1A006E; Fri, 15 Mar 2024 13:52:25 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH v2 3/3] wifi: ti: Convert sprintf/snprintf to sysfs_emit Date: Fri, 15 Mar 2024 13:52:11 +0800 Message-Id: <20240315055211.1347548-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240315055211.1347548-1-lizhijian@fujitsu.com> References: <20240315055211.1347548-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28252.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28252.004 X-TMASE-Result: 10--5.172400-10.000000 X-TMASE-MatchedRID: /mcjwogdDrk4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbSrMZ+BqQt2NqnJEIlJ6Y9uLV5fSMRD1zq8Jg qp/3e7heEkt/L8HtAJ785xNkZcrN2ePWEUnWb98FBDn6Fjq77jvioIsi7Sa0gwLkNMQzGl5B+Kr WCPbERPznpYPqS6jzxEi2pD9yuITpisGdm68NWTHaNJ/iTxXCafS0Ip2eEHnwj/1Rbkzl1EymDn I5x2hWCjoczmuoPCq0Nn6pNPJRC8NOThyVNyDhs53U0BEDMf+ClEs0EKf18lWQ2h0Kw1ovG X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). sprintf() will be converted as weel if they have. Generally, this patch is generated by make coccicheck M= MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended CC: Kalle Valo CC: linux-wireless@vger.kernel.org Signed-off-by: Li Zhijian --- V2: subject updated This is a part of the work "Fix coccicheck device_attr_show warnings"[1] Split them per subsystem so that the maintainer can review it easily [1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@fujitsu.com/ Signed-off-by: Li Zhijian --- drivers/net/wireless/ti/wlcore/sysfs.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/sysfs.c b/drivers/net/wireless/ti/wlcore/sysfs.c index f0c7e09b314d..c07acfcbbd9c 100644 --- a/drivers/net/wireless/ti/wlcore/sysfs.c +++ b/drivers/net/wireless/ti/wlcore/sysfs.c @@ -19,11 +19,8 @@ static ssize_t bt_coex_state_show(struct device *dev, struct wl1271 *wl = dev_get_drvdata(dev); ssize_t len; - len = PAGE_SIZE; - mutex_lock(&wl->mutex); - len = snprintf(buf, len, "%d\n\n0 - off\n1 - on\n", - wl->sg_enabled); + len = sysfs_emit(buf, "%d\n\n0 - off\n1 - on\n", wl->sg_enabled); mutex_unlock(&wl->mutex); return len; @@ -78,13 +75,11 @@ static ssize_t hw_pg_ver_show(struct device *dev, struct wl1271 *wl = dev_get_drvdata(dev); ssize_t len; - len = PAGE_SIZE; - mutex_lock(&wl->mutex); if (wl->hw_pg_ver >= 0) - len = snprintf(buf, len, "%d\n", wl->hw_pg_ver); + len = sysfs_emit(buf, "%d\n", wl->hw_pg_ver); else - len = snprintf(buf, len, "n/a\n"); + len = sysfs_emit(buf, "n/a\n"); mutex_unlock(&wl->mutex); return len;