Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp187603lqb; Thu, 14 Mar 2024 08:37:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhBaI3xnbLH/xJlvlE/2e3gjnHo00FXENLAGFoyDBHU92SBe9llu/Vo1Zxjg8plDQFNPU6vgN8pGrX6kAJ8IV0GYQ9l8GK9EvHadJsYw== X-Google-Smtp-Source: AGHT+IFug3UtoBVC1tARBZ1a0KwiRINztk5ko7sLPc8d40zBAX5nnUa598OFBDPk1FrANnVylMwq X-Received: by 2002:a05:6a00:39a0:b0:6e6:57a9:f8b1 with SMTP id fi32-20020a056a0039a000b006e657a9f8b1mr8052166pfb.9.1710430655796; Thu, 14 Mar 2024 08:37:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710430655; cv=pass; d=google.com; s=arc-20160816; b=HZ63YAPtBIia3XJtZ0TCH1dOlK9JsK7HxzZjOm9L9CMcXFFDZnWxeSbKm+5E5Oc8pC pWGYNMLTg4us037anieMqoRWJKh0/YZSK2IDcVC5odS37xMp03RfT+V29uX4DKJSCDN1 F04AU/W2ae/yAADB0VblinFHFusKXZ3+iOqKU0a26jhmXkSZCPX6+jSEFWlL/qsfu4Yo VS11B0EpfzvnKmRn8XVQHmw7T/j/QFF9p+MpKS+x2dreKk5C4SusMDn8ckkop/k430Zd HK4lkoe2uFQVuPBhrODex0gwFHI6bNf017uHIMGrhMqmwwL2Nnqm/sX32tJbLCOmvxuK mEjA== 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=DL3SqaY2x8zYDT6f9jKBgoqkxrTf+YmxNr7TmowIiLw=; fh=pXC80uBo6DOzfxn9X4D2LxQaroYpRjIY8fNpc/4LDO8=; b=Dez9Ii4PzHTYI0d0IBLGqxw7UkcW4EylBk3AzAFZFWb5jY7Sa1v30Fq+1IsE3TKPcI fKzYx4mMr3+kGGZsVzuFng3HTSwtxdHNNFlvzil4Rq+MW2h0TzqgCBB0ObDNDZ2Gdq+M kP76RjsIROOPrJ4Bx1VZWkLJj1KPm3nipvyPWLijZY5tRcS7rizm/zNWDsukZsioqnuG /2H/hC3jswlJZu8Bgp0Sq42JTBPo2X8WtA/QKqM9Gi0spblQPx+GyEe9cp6A9N8aL383 6Nx1aRIU8+DZyT/1B27xnSg21McCeOfjOqIS40aXbJGWqFOdMdh0tMNgbW+7GQgQlAkj /Lzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WO4zFE6l; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103508-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103508-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 t36-20020a632264000000b005dc16b88e8dsi748081pgm.353.2024.03.14.08.37.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 08:37:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103508-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=WO4zFE6l; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103508-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103508-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 BBBECB22A39 for ; Thu, 14 Mar 2024 15:35:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F5D973508; Thu, 14 Mar 2024 15:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WO4zFE6l" 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 6553C7175B; Thu, 14 Mar 2024 15:33:41 +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=1710430421; cv=none; b=cQrjj5AYkwJg7krFqOzSX6lbbDSK2ZqCDl4duRFP5zISvxRqes1H72mUsD4Z6M9jViS5lkBH7UycVDTx51tkpwbduNug7tcrtB04KbzJLya7pv6sz1XtSO41nP31OrG3HzauMt7FweYfAckvdl1WgL1yuABGn/D+RBbAQGJe6iI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710430421; c=relaxed/simple; bh=aCDonrkKYBPwiH8R2bMD582lXFzDsl0VVpShAkgDxdQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rx3E4FjTqxAsPRARcRfZclKYoJtRfrZZt+nbAl/XMo0nDOQbe/gtOMsddLcCZ8lnnaT6kMhPBEXEk/KwnvZ6dRBYnniCwaM6abORbX5b64kzysT2F4ZN2ryiT6n4jQshzqOrI9lJmrYdMm+0Lzv6mi9DYctvwP3xHuxBl/joaG4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WO4zFE6l; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2783EC433F1; Thu, 14 Mar 2024 15:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710430421; bh=aCDonrkKYBPwiH8R2bMD582lXFzDsl0VVpShAkgDxdQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WO4zFE6l0q3diFd5YdMxGJymp+DtRSFJ0f/VuXvm56UlZuAIBWndg8n91L0PeH1px AFAdRDau5Y4nedRpjHWd4atk8FrhZT4MMq4/lDYy8C/RveYRfl9wFyBS7/ZYfgkep+ 3nZO0GZJxb3GwTEzGaER4ayeBiWcKI+naAm3lxVq/edC2xsgmfnORe9+dmBks5SmrS Xym6FcxFXw2aiBQirXqOQeP8Gg+58iz7fzXe/VzcxlwMXYVxTcGNjJexH0V7uOXZ8S 4ljz2IYlI56V6C7jiO7HNPq0O4mqmcZULEsi/qAPk5VKGB4ehflOXyXAL6Q1d48Kmy wXHbn691YoVZg== Date: Thu, 14 Mar 2024 15:33:26 +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 Subject: Re: [PATCH v2 2/4] HID: hid-sensor-custom: Convert sprintf/snprintf to sysfs_emit Message-ID: <20240314153326.2126d3df@jic23-huawei> In-Reply-To: <20240314084753.1322110-2-lizhijian@fujitsu.com> References: <20240314084753.1322110-1-lizhijian@fujitsu.com> <20240314084753.1322110-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 Thu, 14 Mar 2024 16:47:51 +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() 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: Jiri Kosina > CC: Jonathan Cameron > CC: Srinivas Pandruvada > CC: Benjamin Tissoires > CC: linux-input@vger.kernel.org > CC: linux-iio@vger.kernel.org > Signed-off-by: Li Zhijian Hi Li Zhijian, One trivial comment inline. Otherwise straight forward so Reviewed-by: Jonathan Cameron > --- > 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 | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c > index d85398721659..ee1a118834f0 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,14 @@ 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); rewrap the line as will be under 80 chars. > 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,