Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2142485lqp; Sun, 24 Mar 2024 05:16:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV57y961NtYGXBhClGZv9z5MwqU5NvjlnEqoOlmvO0tpWsWWZ9yseeA2T3Juba/+PgEw8aokcUwgeUaooIEZawsAWeXEiY55TOyoNBMtw== X-Google-Smtp-Source: AGHT+IGY5PGD0ADn7B0KLopR56MDXxRC+wJhD2BdcS3lAqYXCpmeF/F/7NOSkUHrWKGVNaYHN0+R X-Received: by 2002:a05:6358:7f1c:b0:17e:69cf:2105 with SMTP id p28-20020a0563587f1c00b0017e69cf2105mr5175253rwn.29.1711282597281; Sun, 24 Mar 2024 05:16:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711282597; cv=pass; d=google.com; s=arc-20160816; b=yt9Sc/6l7ZiRJpzyH8pGHReTHwrRbXy6mwuecb0aA2MIYNP8aNRbSBudZLC1q7JODR 6yxYPISgyQsNFL3glYgOqWFVqVnhfqflk9I3j3YZuKGBRrj3/PfYjIwhb6lIZBkuBy1X d2IJaEyCmrZSHACcp6j+tqI8DO4ewUDPJGBjfQJXvhejVzXmGcEI6pKVBnISMXxqyd6d MjA1q2E+m8PhkMEckUk5jritMHJj9vnyDJGncJo1zOHQPRKjql5RNqLIpGZKRSLxMaCa eOJv4rQUBMaQiOVoIRg6MFkpbxwXyFkkPImtYOM5vmF2803qA7q1N/ujEvfvPl68wpHT RosQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=yKfr7rfXBXDnhGP0eixmHjl5NFQrhF2DewfqUJVhXuc=; fh=RlR5PvByDq3V4k3V6wwiOEv8cH7ArlZ/mWH1PuUPYQw=; b=ChFYC98HU7rllbSR1d1ZrxDtVsA0K0x1796MXv21T0vUEkcsR6qAn7a4Yfh90g97EA C9EgPWmHT2x24PJaGomrnMoD1F+RuL04df/Ja6EQODcMbhxkKtpxAEL5sYwG9vet14qg KRnGU5xCENRm9dkur9Be8ra6NyhbYvMnSOoWgbOGienrU118+Anoe3cU8XSvBPycuL/t pwc1aJggo+R3esYddRyb6LyStFLuFDwPBTB58e3GDupBBd9BtIvSMjxdBdwnxXAGronK GCtfo1+J5TXy1fbhZVPwdp7OexijsTmt3NMjcZf76jdAzxPbCPP0BMtoPeWI9CNPjh8Y WJXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W2IbvpxJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f16-20020a637550000000b005dc7e78163csi5563812pgn.458.2024.03.24.05.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 05:16:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W2IbvpxJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0F038B20B92 for ; Sun, 24 Mar 2024 12:16:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 584FA17BBB; Sun, 24 Mar 2024 12:16:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W2IbvpxJ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7BAF317736; Sun, 24 Mar 2024 12:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711282583; cv=none; b=sxJjnqvzht+EhMCxf8AlsZqOjkr9afx/alwQ2taRaxDhAWQwIlZL52oToxQScz8OYB1KPTDWv+EjaJx58Eu2Eqrp9V3YC1oiI+3W2RcdRKRs/wM9PRZY2d2ddXeRYT1VqpW0iJ2V+w3deZJxGWfZIY+C6qJnY32266pQHl1IBRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711282583; c=relaxed/simple; bh=PXRDCrEc+u0PcMCf601WouC7laGk8s3Xs3CLxtUdZV8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WV0wIzW3YzFzTw1W3pxlXFGoM5RCnvZL0D7kS0kSjJ+aeDtq2xYRJVOIU9Bwt8u2YBLdl0RCOJiG9cjV2UdObQ7o/sml8N7h+DCbiCNDEpHxiFtEgOeQCJhm0qPFXXSUqrlQEIcfyrqHz/1Ac5rZ28kHiw2ACt61yQq5lJsTJgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W2IbvpxJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF9ABC433F1; Sun, 24 Mar 2024 12:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711282583; bh=PXRDCrEc+u0PcMCf601WouC7laGk8s3Xs3CLxtUdZV8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=W2IbvpxJguEvyynQn3fQMmrclzMYGYbmKLk7n4wJSDydWgpdywkTh+AAKPWM5ye1o 9A2VvfuhQSU5DKJvfFksMKWi/lU5r6UEPJYvc8f5RCDMQUIvHw0GGOPuILFrGoAhfe KarfpwLVN1J0oflthQ21t0kb2QTCRK4xZbTgXhFiD7cNWTdbM4nynxp1wmqOaHBENc 6pWqkarUElQRuAIZDBMASCe/R/GYQTygjl24O7sGU4BV15egclY5HVq514VahafcDF dII1OZzGBkzI88iKqRlDoyGqHMvQ5kkvDj6xLjEb5HeCE02AOk5ZNRLhvsFUhnfJzy sxRI+wF7FrXBA== Date: Sun, 24 Mar 2024 12:16:08 +0000 From: Jonathan Cameron To: Li Zhijian Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Srinivas Pandruvada , Benjamin Tissoires , linux-input@vger.kernel.org, linux-iio@vger.kernel.org, Jonathan Cameron Subject: Re: [PATCH v4 2/4] HID: hid-sensor-custom: Convert sprintf() family to sysfs_emit() family Message-ID: <20240324121608.30b2217b@jic23-huawei> In-Reply-To: <20240319054527.1581299-2-lizhijian@fujitsu.com> References: <20240319054527.1581299-1-lizhijian@fujitsu.com> <20240319054527.1581299-2-lizhijian@fujitsu.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 19 Mar 2024 13:45:25 +0800 Li Zhijian wrote: > 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() and scnprintf() will be converted as well 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: Jiri Kosina > CC: Jonathan Cameron > CC: Srinivas Pandruvada > CC: Benjamin Tissoires > CC: linux-input@vger.kernel.org > CC: linux-iio@vger.kernel.org As a general rule, don't have cc's of lists up here. It makes a mess of the logs. Also once you have another tag drop CC of same person (even if it's a different email address). We don't want to fill the git log with useless information. I think git is fine picking up CC's from below the --- so you can add them there if it simplifies how you send your patch sets out. > Reviewed-by: Jonathan Cameron > Signed-off-by: Li Zhijian > --- > V3: > rewrap the line as will be under 80 chars and add Reviewed-by # Jonathan > 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/hid/hid-sensor-custom.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c > index d85398721659..ac214777d7d9 100644 > --- a/drivers/hid/hid-sensor-custom.c > +++ b/drivers/hid/hid-sensor-custom.c > @@ -155,7 +155,7 @@ static ssize_t enable_sensor_show(struct device *dev, > { > struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); > > - return sprintf(buf, "%d\n", sensor_inst->enable); > + return sysfs_emit(buf, "%d\n", sensor_inst->enable); > } > > static int set_power_report_state(struct hid_sensor_custom *sensor_inst, > @@ -372,14 +372,13 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr, > sizeof(struct hid_custom_usage_desc), > usage_id_cmp); > if (usage_desc) > - return snprintf(buf, PAGE_SIZE, "%s\n", > - usage_desc->desc); > + return sysfs_emit(buf, "%s\n", usage_desc->desc); > else > - return sprintf(buf, "not-specified\n"); > + return sysfs_emit(buf, "not-specified\n"); > } else > return -EINVAL; > > - return sprintf(buf, "%d\n", value); > + return sysfs_emit(buf, "%d\n", value); > } > > static ssize_t store_value(struct device *dev, struct device_attribute *attr,