From patchwork Thu Mar 14 09:48:21 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: 13592281 X-Patchwork-Delegate: kvalo@adurom.com Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (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 AC34C6CDDF; Thu, 14 Mar 2024 09:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.138.37.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710409723; cv=none; b=cn9BYad/ihGqtbOodWVcK9+z45M4AJoFKVSavG4qMkS9tusLHbB3ZhsUF/vl8e2+UKFVZ/yVEJ5pYiIT5KLeBnO1qpiqxlrhJMd6soxKPLvY5boFb2c6pACuw6BRR8MbZcUklPAfPKL7Noswqo7iuygwNWhlrvCopKzv7ZO7+cQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710409723; c=relaxed/simple; bh=tXWoDv0MCVcjPegxH+LsuRrAuyb6Of1Y0FhIRJQ/Wsw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IgiS+xD3oiQ1uzVmWpQzmwHavjH9xZYVhYqkd+HeNinGKsmEQVvzIqlfuVeIjue+zpGeiO6HXgqyb2abEHbtd3bwaKNi9iJIvod/QHZZQ3Ee9AmTrEim+u0YlzBpnnNwOUBpj/+Ok1aPpOZOyRt4WOfAiFub+Sz/H1NLQ9imUp4= 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=YI1oeMRO; arc=none smtp.client-ip=139.138.37.100 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="YI1oeMRO" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710409719; x=1741945719; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tXWoDv0MCVcjPegxH+LsuRrAuyb6Of1Y0FhIRJQ/Wsw=; b=YI1oeMRO7bg02fVIy+YWaheiQ1MxCvINdAvuGMmscYsuOh4uwvb8OL5P dXgzJxia4FuTh8mE9PUOg5J17zyRvHFKiNFBY0Y7uZPJ0S5yNHCVyIdoO cu7Pci6zSH3e5mW5p+BASbpYMoNTENWlzZba3tm9u+TP885pC5zjYwJGk 4IRj1pf9QjczwIAfrOMXW04hbZo8OkL31wFyOBN1T39orzIGSbH+nP7ul CKC9QsUlFpxg5XPDpt/hpIe1ufvJ8/kS1g0rPR4o9A5V+qWJNEGSCEMnL Edb4xyxG1y/5g+zJVV8POaEhArjIL5QNhW8ZpJEo1EhKyOClzeGNYmNe6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="131570232" X-IronPort-AV: E=Sophos;i="6.07,125,1708354800"; d="scan'208";a="131570232" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 18:48:36 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id F10D99D107; Thu, 14 Mar 2024 18:48:33 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 3A27DE6268; Thu, 14 Mar 2024 18:48:33 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id C1E5A6B4D4; Thu, 14 Mar 2024 18:48:32 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 1D2AE1A006B; Thu, 14 Mar 2024 17:48:32 +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 1/3] net: ath: Convert sprintf/snprintf to sysfs_emit Date: Thu, 14 Mar 2024 17:48:21 +0800 Message-Id: <20240314094823.1324898-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-28250.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28250.006 X-TMASE-Result: 10--3.130400-10.000000 X-TMASE-MatchedRID: ebEStOsB1eE4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbSrMZ+BqQt2Nps/NNpVQ666iXOD7ucKRbIQiM ingSlKoKMx5HzfQifbPE41045MrHXFDCN/1eC4ASdVNZaI2n6/wmWvXEqQTm5wLkNMQzGl5B+Kr WCPbERPznpYPqS6jzxEi2pD9yuITrh15/JKUJo/p4CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyHEqm 8QYBtMO3LlEZYYZnW9rIyN56uP6NRM6ylMvEXGk1oRQBQClV4HA/0Gjnf5bBp2jOiFp3dpx6YyQ KoFjU2kssxlojaTXaZ9+GrWpP0BdW4wbpXTb5DJKKve1kh3RY37qSWrndbmQn0bOriG5BVc= 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 --- 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 Thu Mar 14 09:48:22 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: 13592280 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 9FBC26CDDD; Thu, 14 Mar 2024 09:48:39 +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=1710409722; cv=none; b=T/7UmOY+POrVSmFrvkLcKsUq2kRi14/s4n6MSN8zD3lcqZNxX0/8ORh5fQdKXfACEWaeGnmkibKVlpmEbjuZzKPsjbcHVwabtTDfrokDNwKPgrsIYhCaz3GWB/UzlffodZXKJ3Ncf19E8dCKvyiXneL/3+ySWzF62CyUTj/Tmtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710409722; c=relaxed/simple; bh=PZgtY/QaJ5AhE+dkBjqtaceUwoWYOLgrPub9Z/ina2E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OSTSswjoQzvTfEgItQd+clhSWjHkbjZ7G3272QtGPd/RN+kbGJy1cwR3rzUj/YPK9omn9pmJ32QIVROtZWe89gauMKXs8k3SXXFfRmEJumW4eWqMMcaWYd5F2t1MVaCgesaCoSQM28gzgFWklATzGDGqCpiQ6WM7U0i6FKQcU5U= 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=f/LWmyu/; 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="f/LWmyu/" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710409721; x=1741945721; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PZgtY/QaJ5AhE+dkBjqtaceUwoWYOLgrPub9Z/ina2E=; b=f/LWmyu/jMVqMmQ2wzalMuL7nSmJStaBmLZw937j7xS3Z85K0+LUyDnB mEqwnCP2Lrw21aNbO28gnDO576ZYj9RhDfG6/8iHKxS9C7RJ/fzStQ8JY bHsgqRVHXpXJxBoQEHxUgMw05hkdP+6G+8HtAnQRYbrxUQspoImao7bDZ vHn6lOoZ1J7X41Zvza77lpXCDxS+uPKzBVB7YQLvsRK5tOTfbv1bI79nQ nmhGMKy1vygkmfi67FjfCR+zMimGWKgW0azhZnVgbTqDw6Mm8gukb9hgx F83aFwc4/dAuD6RAYEH8h/o35dtGDTOEkNuBIWYF30jjnEYJd2DHnrDiS A==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="152290022" X-IronPort-AV: E=Sophos;i="6.07,125,1708354800"; d="scan'208";a="152290022" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 18:48:37 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 78A1FD772F; Thu, 14 Mar 2024 18:48:34 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id B0A25174A21; Thu, 14 Mar 2024 18:48:33 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 2DD026B4D5; Thu, 14 Mar 2024 18:48:33 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 9A2721A006D; Thu, 14 Mar 2024 17:48:32 +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 2/3] net: b43: Convert sprintf/snprintf to sysfs_emit Date: Thu, 14 Mar 2024 17:48:22 +0800 Message-Id: <20240314094823.1324898-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240314094823.1324898-1-lizhijian@fujitsu.com> References: <20240314094823.1324898-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-28250.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28250.006 X-TMASE-Result: 10--3.595400-10.000000 X-TMASE-MatchedRID: APZBv0eB5fI4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbSK0+leiJxLlf0swHSFcVJ6C+fNq7c31fg18a 7/fBfKbtruPzTKuxCyQhBeNJICtc+zK2lwdvrNt2qH6mIBejVf2ItZ2e1geixEd+K6O5Nt53oKE r2irJf5CL637QCIVpi8vc3EUpCmrXqPfCtn+QRF99JA2lmQRNUawh2/JNn5dCBAXl9LkPp6TVka xwyOBfMjXnWb/ze2xPSM4dqF2PUP5H0YXYnbGozFEUknJ/kEl7dB/CxWTRRu+rAZ8KTspSznMvX P7A/YmSt/dXFI10ySicpsJ0mlkgCkJl9QIQjSU5yWMufYVlI8jltvYxr5GgZXZ7ViAqHGNCl44l VuJH6NcYJykdVteYvIcmnZRhVxyrE4HwnSlEuHInEpJmLAFfpC1FNc6oqYVV+3BndfXUhXQ== 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 Signed-off-by: Li Zhijian Acked-by: Larry Finger --- 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 | 17 +++++++---------- 2 files changed, 11 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..b1c5ea4750fa 100644 --- a/drivers/net/wireless/broadcom/b43legacy/sysfs.c +++ b/drivers/net/wireless/broadcom/b43legacy/sysfs.c @@ -75,16 +75,15 @@ 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 +154,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 Thu Mar 14 09:48:23 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: 13592279 X-Patchwork-Delegate: kvalo@adurom.com Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) (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 B1A146D1A0; Thu, 14 Mar 2024 09:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.139.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710409722; cv=none; b=P+T1ebl8u+iI+27OUH2loYTsaYVdduhUEHOnw7koMhdhIgqIedHRowvavfGmZiHPVkacP0ba/Y2iQFtyj1apIRAlrzD2EPXd/g6uJXf9fHLw0ydc6S34JOYVMjTZ+YvSWIiKxadLNO5Rc7tI1lD0ZuBML/diah2BPQhU6N441FE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710409722; c=relaxed/simple; bh=aNmEog2e7xmpj4UDLTsQ+K1MuB1rI9s+eD06tjLRMfM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CXsjbxEqyTjW2oYEgu0vyFOZGZUJXhi3mTbNZJc2cx0TqLCwW7Fx7YXwwBPdUzsxOzXJuMU/hTNR+pHrd2vSKYqxbpCzN535SP/67HtZJjnArK1yYp8o5GNpANwo4G87GYRcZLeczFT5VBk5SoxOSPnbqJ6Mqc7S5LFQkc0HZMU= 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=RGpn/l4j; arc=none smtp.client-ip=68.232.139.130 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="RGpn/l4j" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710409720; x=1741945720; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aNmEog2e7xmpj4UDLTsQ+K1MuB1rI9s+eD06tjLRMfM=; b=RGpn/l4jKxyM92UfJJ23uaV/80qZsATYb1qcIGYP4E6cP8uc2SXqGpf3 DQNOMJiMVG6dXN9MfaBVTSUqxpfwyd/cmeU/rQry3LSaFGUoCr3niRURy C6i6n2u9eKRzJ0LJtdZJHbdtCJ6AJoRtVU1tJRb1oyrsJcxbw8YjIg2EA f3gEGuMVpUEDazh+USe/sLm4pYF7GvgK7PUgCWoFQ1w4FZVKdPZvJaKbG 4oK7vPRsq7Or0w2yr2yvuyAsZqzrdhpRacDFHvUPipVEP4PyDo7nZpcBl wvWlKLM84CB9c9YHkrCAq8sFRklxRZEKsv0Y+oOKmSoFNpR9mmr1Hapuy g==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="151712701" X-IronPort-AV: E=Sophos;i="6.07,125,1708354800"; d="scan'208";a="151712701" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 18:48:37 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id B1986EB462; Thu, 14 Mar 2024 18:48:34 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id E84A9D419F; Thu, 14 Mar 2024 18:48:33 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 75CF36B4D8; Thu, 14 Mar 2024 18:48:33 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 08BFC1A006B; Thu, 14 Mar 2024 17:48:33 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH 3/3] net: ti: Convert sprintf/snprintf to sysfs_emit Date: Thu, 14 Mar 2024 17:48:23 +0800 Message-Id: <20240314094823.1324898-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240314094823.1324898-1-lizhijian@fujitsu.com> References: <20240314094823.1324898-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-28250.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28250.006 X-TMASE-Result: 10--4.932400-10.000000 X-TMASE-MatchedRID: st9CF01730Y4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbSrMZ+BqQt2Nps/NNpVQ666i99T+uJIleRfDo fTpsyCK+KztDhRgoFQW4suX2uLJTkj56IjTnLR+lO5y1KmK5bJRSLgSFq3Tnj31GU/N5W5BDIvl CZY6Ax8AYneqSlSIC/h8LfmnrF5JeR9GF2J2xqMxRFJJyf5BJe3QfwsVk0UbvqwGfCk7KUs0hlc 16YSiR/TrcJt9otOEa3Fo76xroEK7XsH+W6Je0/aK8EHI8yZD5W/yxi3wLIHEm0J0NAcVpR87g3 I2Wf9kB5XPFpvWR7wSHJp2UYVccqxOB8J0pRLhyJxKSZiwBX6QtRTXOqKmFVftwZ3X11IV0= 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 --- 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/ti/wlcore/sysfs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/sysfs.c b/drivers/net/wireless/ti/wlcore/sysfs.c index f0c7e09b314d..376afa3388a4 100644 --- a/drivers/net/wireless/ti/wlcore/sysfs.c +++ b/drivers/net/wireless/ti/wlcore/sysfs.c @@ -19,11 +19,9 @@ 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 +76,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;