Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4177828rwl; Sat, 7 Jan 2023 12:37:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZCxeWf0+Gvd0S7wTnMrbEBtRLFa+wCsRMDHIDzmN8GxRE2Qo9zPBCtQrvwBH83ILaZLdn X-Received: by 2002:a05:6a20:1455:b0:ad:58d4:2a71 with SMTP id a21-20020a056a20145500b000ad58d42a71mr81582671pzi.4.1673123857756; Sat, 07 Jan 2023 12:37:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673123857; cv=none; d=google.com; s=arc-20160816; b=A4PHiz44F9EJ5/UikwiCYXVgkQnL/Bd1PnUHWjgp5IXtBeevSsX2g/vd6GhBhBHMBc E1QAevx+oBQt2G4aNavrawFA3n/CV2sjq6B0vOhVALSW8N+IGITYDYTMY/xzmkjINnCS z5t65PwP4ZSw9P5ZHtRYUjv+VSoXx3o8xtu35vYDnmE96QSh20FAhqa/wkG/OpZ9aN2e 0kQk3Lgl3Vrg3e0tkYFl4NQnVjwi7ckua4yuAm0tNu3rKvu1S+pgEnL0i/Z5D/+4UNkn 3WyhBpIUTLPM9p9WDjH/ZWwPd0couGsdXEpiOwrcVZOzBkA+16M8AgCAd9h+moILlY+L NaNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RtKiAsnIiqQmVxiyyutpvUN4UsR7xn+rfekurx2R7UM=; b=giYJ1iXQzUljtJ6NC+oAchV/HW8ccB5X4OS+OcW6jJYaBrEz4hhpLbrNxQ3Q5mMzF4 7AhTYtO1/J0V97jdqUhlZ0rEzUrDJsyXicSnWYH4tfOI81ovShWAmHnmKhGzZKFwgmSp j/E0gwhwt+vCMcRAWLCgatXbQyzKhFjA5HfwszFw1mI2+ijXXmIq/2Aw1nHJ9U4KwG4z onls3sqpUf+HA4n7OKEcDWJ3Upe9K+mmhzEZAVarIBZgm/jdCNLPVwrJbPXqdo0UxAtT c+soohmscuGr6h0dC244pIghIUyWUM+tO4368FU+Uo2JvmRidsGR7Bv8+kjCT4WMOfDU ZG1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=Pe3lbZOT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a656897000000b0049eefd9389asi4786817pgt.549.2023.01.07.12.37.30; Sat, 07 Jan 2023 12:37:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=Pe3lbZOT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232550AbjAGUYh (ORCPT + 53 others); Sat, 7 Jan 2023 15:24:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjAGUYf (ORCPT ); Sat, 7 Jan 2023 15:24:35 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D23C53226D for ; Sat, 7 Jan 2023 12:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1673123066; bh=Uh4U0dKEgNfWJXZrRD67fFz6Ha75QkDeMZkXGcZYmSM=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=Pe3lbZOTGoOsVVP9JKmQX7exo4F3ka4azGOI0lW1OXyUCgSNR21BzLgrhu2qxxaHb xMtBHcHSPuJkGq6RbO4fIuxKDbXG3MOSRqgZqo1zLH5lsRcjoRCh5Sf1XMgWBFH7wA 4wkZHNRClKW9Y8UcA0HOphUPjhw+QAzYDvwwvCnQ= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sat, 7 Jan 2023 21:24:26 +0100 (CET) X-EA-Auth: tOFVDrkiO4StBWfJqHWwnCpJQD1PnhA4eQKeCH2Zgsq0EX9tZWUedt/fkAglK7bTFMXJihRL6zTzqaGHpUsVc5fvJQSj8w/e Date: Sun, 8 Jan 2023 01:54:18 +0530 From: Deepak R Varma To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: Re: [PATCH] most: core: Use sysfs_emit in show function callsbacks Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 24, 2022 at 12:43:30AM +0530, Deepak R Varma wrote: > According to Documentation/filesystems/sysfs.rst, the show() callback > function of kobject attributes should strictly use sysfs_emit instead > of sprintf family functions. > > Issue identified using the coccinelle device_attr_show.cocci script. > > Signed-off-by: Deepak R Varma > --- Hello, May I please request a review and comment on this patch proposal? Also, let me know if I am missing a maintainer(s) in my request. Thank you, ./drv > drivers/most/core.c | 61 ++++++++++++++++++++++----------------------- > 1 file changed, 30 insertions(+), 31 deletions(-) > > diff --git a/drivers/most/core.c b/drivers/most/core.c > index e4412c7d25b0..f9ca6a7d885c 100644 > --- a/drivers/most/core.c > +++ b/drivers/most/core.c > @@ -208,8 +208,8 @@ static ssize_t number_of_packet_buffers_show(struct device *dev, > struct most_channel *c = to_channel(dev); > unsigned int i = c->channel_id; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - c->iface->channel_vector[i].num_buffers_packet); > + return sysfs_emit(buf, "%d\n", > + c->iface->channel_vector[i].num_buffers_packet); > } > > static ssize_t number_of_stream_buffers_show(struct device *dev, > @@ -219,8 +219,8 @@ static ssize_t number_of_stream_buffers_show(struct device *dev, > struct most_channel *c = to_channel(dev); > unsigned int i = c->channel_id; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - c->iface->channel_vector[i].num_buffers_streaming); > + return sysfs_emit(buf, "%d\n", > + c->iface->channel_vector[i].num_buffers_streaming); > } > > static ssize_t size_of_packet_buffer_show(struct device *dev, > @@ -230,8 +230,8 @@ static ssize_t size_of_packet_buffer_show(struct device *dev, > struct most_channel *c = to_channel(dev); > unsigned int i = c->channel_id; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - c->iface->channel_vector[i].buffer_size_packet); > + return sysfs_emit(buf, "%d\n", > + c->iface->channel_vector[i].buffer_size_packet); > } > > static ssize_t size_of_stream_buffer_show(struct device *dev, > @@ -241,8 +241,8 @@ static ssize_t size_of_stream_buffer_show(struct device *dev, > struct most_channel *c = to_channel(dev); > unsigned int i = c->channel_id; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - c->iface->channel_vector[i].buffer_size_streaming); > + return sysfs_emit(buf, "%d\n", > + c->iface->channel_vector[i].buffer_size_streaming); > } > > static ssize_t channel_starving_show(struct device *dev, > @@ -251,7 +251,7 @@ static ssize_t channel_starving_show(struct device *dev, > { > struct most_channel *c = to_channel(dev); > > - return snprintf(buf, PAGE_SIZE, "%d\n", c->is_starving); > + return sysfs_emit(buf, "%d\n", c->is_starving); > } > > static ssize_t set_number_of_buffers_show(struct device *dev, > @@ -260,7 +260,7 @@ static ssize_t set_number_of_buffers_show(struct device *dev, > { > struct most_channel *c = to_channel(dev); > > - return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.num_buffers); > + return sysfs_emit(buf, "%d\n", c->cfg.num_buffers); > } > > static ssize_t set_buffer_size_show(struct device *dev, > @@ -269,7 +269,7 @@ static ssize_t set_buffer_size_show(struct device *dev, > { > struct most_channel *c = to_channel(dev); > > - return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.buffer_size); > + return sysfs_emit(buf, "%d\n", c->cfg.buffer_size); > } > > static ssize_t set_direction_show(struct device *dev, > @@ -279,10 +279,10 @@ static ssize_t set_direction_show(struct device *dev, > struct most_channel *c = to_channel(dev); > > if (c->cfg.direction & MOST_CH_TX) > - return snprintf(buf, PAGE_SIZE, "tx\n"); > + return sysfs_emit(buf, "tx\n"); > else if (c->cfg.direction & MOST_CH_RX) > - return snprintf(buf, PAGE_SIZE, "rx\n"); > - return snprintf(buf, PAGE_SIZE, "unconfigured\n"); > + return sysfs_emit(buf, "rx\n"); > + return sysfs_emit(buf, "unconfigured\n"); > } > > static ssize_t set_datatype_show(struct device *dev, > @@ -294,10 +294,9 @@ static ssize_t set_datatype_show(struct device *dev, > > for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) { > if (c->cfg.data_type & ch_data_type[i].most_ch_data_type) > - return snprintf(buf, PAGE_SIZE, "%s", > - ch_data_type[i].name); > + return sysfs_emit(buf, "%s", ch_data_type[i].name); > } > - return snprintf(buf, PAGE_SIZE, "unconfigured\n"); > + return sysfs_emit(buf, "unconfigured\n"); > } > > static ssize_t set_subbuffer_size_show(struct device *dev, > @@ -306,7 +305,7 @@ static ssize_t set_subbuffer_size_show(struct device *dev, > { > struct most_channel *c = to_channel(dev); > > - return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.subbuffer_size); > + return sysfs_emit(buf, "%d\n", c->cfg.subbuffer_size); > } > > static ssize_t set_packets_per_xact_show(struct device *dev, > @@ -315,7 +314,7 @@ static ssize_t set_packets_per_xact_show(struct device *dev, > { > struct most_channel *c = to_channel(dev); > > - return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.packets_per_xact); > + return sysfs_emit(buf, "%d\n", c->cfg.packets_per_xact); > } > > static ssize_t set_dbr_size_show(struct device *dev, > @@ -323,7 +322,7 @@ static ssize_t set_dbr_size_show(struct device *dev, > { > struct most_channel *c = to_channel(dev); > > - return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.dbr_size); > + return sysfs_emit(buf, "%d\n", c->cfg.dbr_size); > } > > #define to_dev_attr(a) container_of(a, struct device_attribute, attr) > @@ -395,7 +394,7 @@ static ssize_t description_show(struct device *dev, > { > struct most_interface *iface = dev_get_drvdata(dev); > > - return snprintf(buf, PAGE_SIZE, "%s\n", iface->description); > + return sysfs_emit(buf, "%s\n", iface->description); > } > > static ssize_t interface_show(struct device *dev, > @@ -406,25 +405,25 @@ static ssize_t interface_show(struct device *dev, > > switch (iface->interface) { > case ITYPE_LOOPBACK: > - return snprintf(buf, PAGE_SIZE, "loopback\n"); > + return sysfs_emit(buf, "loopback\n"); > case ITYPE_I2C: > - return snprintf(buf, PAGE_SIZE, "i2c\n"); > + return sysfs_emit(buf, "i2c\n"); > case ITYPE_I2S: > - return snprintf(buf, PAGE_SIZE, "i2s\n"); > + return sysfs_emit(buf, "i2s\n"); > case ITYPE_TSI: > - return snprintf(buf, PAGE_SIZE, "tsi\n"); > + return sysfs_emit(buf, "tsi\n"); > case ITYPE_HBI: > - return snprintf(buf, PAGE_SIZE, "hbi\n"); > + return sysfs_emit(buf, "hbi\n"); > case ITYPE_MEDIALB_DIM: > - return snprintf(buf, PAGE_SIZE, "mlb_dim\n"); > + return sysfs_emit(buf, "mlb_dim\n"); > case ITYPE_MEDIALB_DIM2: > - return snprintf(buf, PAGE_SIZE, "mlb_dim2\n"); > + return sysfs_emit(buf, "mlb_dim2\n"); > case ITYPE_USB: > - return snprintf(buf, PAGE_SIZE, "usb\n"); > + return sysfs_emit(buf, "usb\n"); > case ITYPE_PCIE: > - return snprintf(buf, PAGE_SIZE, "pcie\n"); > + return sysfs_emit(buf, "pcie\n"); > } > - return snprintf(buf, PAGE_SIZE, "unknown\n"); > + return sysfs_emit(buf, "unknown\n"); > } > > static DEVICE_ATTR_RO(description); > -- > 2.34.1 >