Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp932231rwd; Tue, 13 Jun 2023 02:19:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4u57z45tVjK9N6JBJ9xGj9qtUatAsj2tBdzSKlLpj+6d6gR35y5VbeeHlCWa0YAAdj+NG5 X-Received: by 2002:a17:902:ef81:b0:1b3:a928:18e6 with SMTP id iz1-20020a170902ef8100b001b3a92818e6mr6737427plb.66.1686647991178; Tue, 13 Jun 2023 02:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686647991; cv=none; d=google.com; s=arc-20160816; b=Bm1MZBfqYhg7iCBbzBfQQghResPzvZqHUKDmCcwC9nZtPrdRlfwbwBTUCsamKoyUVB sgK8HhLMGc/R4Ojdd199pA3dJOFA1yw5RMKsbLveGizWi+ciF0SA1nG209zcZl6BCKH7 R3H6SoKsmKIy/9ThNLJW/LPM38bz4kRAR2w7iNHbfXlwRBS2wHuAeP89BzD7vbsfPMKx 4aLXDHuusatPDMFGO7ELh7+ScMpUtAsfexNF/6woA9s7YUQfakiyqJD2IGnS1nfK1nKe 8128NCAF8AINmnw2o1Y5dv21Mm/S6K5ARiPzG0vEYcrS+65qxQI1DrlCJimqgaZ+aqyd DREg== 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=8kpmJbhJaj5EhxdSXwTCDCgbxgPHMJg+6quN8bJvFxc=; b=pV6fiaK9zPXQIOGYOpYfSYfIRiM4FZh4LPI3EYKCZ3oPMhaq7+kROZUVZLwUk+Grei SWjCnDOADZIGxre4va3QkN4GyMDu+HiIGLIMbV6yG5J8hU3nQCIZOStNkeVqaT+UYDt8 LC0QR2VhbQMmmmLZnV9pUP48Rs2NslYK5Q5KmNasF1atCP577IikV+mzAYEeWOMVRicz 4s6vVrprVpZ8wyNk+4QT50NeeabiWELk0EjlLapglBqsk+9Yg0u16nDKOi8d4LfuwOZB kg3t7kipX389BTvxCbxQQACGj8fM4xXc7FZsLNyYlgvQ7Sod0wSDFrrz2N5KrBIoDSf+ b/6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MX8ZMzud; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170902f54800b001b07c3c3206si3671214plf.265.2023.06.13.02.19.37; Tue, 13 Jun 2023 02:19:51 -0700 (PDT) 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=pass header.i=@linuxfoundation.org header.s=korg header.b=MX8ZMzud; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241152AbjFMJGo (ORCPT + 99 others); Tue, 13 Jun 2023 05:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240695AbjFMJGn (ORCPT ); Tue, 13 Jun 2023 05:06:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37053E47; Tue, 13 Jun 2023 02:06:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B8B4C63104; Tue, 13 Jun 2023 09:06:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D9C0C433EF; Tue, 13 Jun 2023 09:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686647198; bh=6aJi1HDMyG+diAQWNGWHz3BblRyOIZNRXnIuek9cous=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MX8ZMzudQWLK1qvvM0UCkrYvkBHgmRLrvV92A8pE3igmIBM/l+hsjiwVFD+74sNda XRT8o3iTPprimPc5GGE1Qs2yziwkHlKpd406VssrXN8PulNiasK7HtRXgvICMdH6wK ruZv3p5UTCafY8VMVc4ATrfXk4Zn5UriT7jw/siI= Date: Tue, 13 Jun 2023 11:06:35 +0200 From: Greg Kroah-Hartman To: Roy Luo Cc: raychi@google.com, badhri@google.com, Alan Stern , Benjamin Tissoires , Michael Grzeschik , Bastien Nocera , Mathias Nyman , Matthias Kaehlcke , Flavio Suligoi , Douglas Anderson , Christophe JAILLET , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, kernel test robot Subject: Re: [PATCH v3] usb: core: add sysfs entry for usb device state Message-ID: <2023061307-oversized-wife-1f69@gregkh> References: <20230605215529.195045-1-royluo@google.com> <2023060734-survey-shady-f025@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, Jun 07, 2023 at 06:58:08PM -0700, Roy Luo wrote: > > > @@ -160,6 +160,16 @@ static ssize_t connect_type_show(struct device *dev, > > > } > > > static DEVICE_ATTR_RO(connect_type); > > > > > > +static ssize_t state_show(struct device *dev, > > > + struct device_attribute *attr, char *buf) > > > +{ > > > + struct usb_port *port_dev = to_usb_port(dev); > > > + enum usb_device_state state = READ_ONCE(port_dev->state); > > > + > > > + return sprintf(buf, "%s\n", usb_state_string(state)); > > > > I thought checkpatch would warn you that you should be using > > sysfs_emit() here, wonder why it didn't. > > > > thanks, > > > > greg k-h > > I was using sprintf() instead of sysfs_emit() because I randomly referred > to one of the nearby attributes. Looks like there are still many attributes in > port.c that uses sprintf(), any reason why we didn't replace them? > If not, I'm happy to do a clean-up so that others don't make the same mistake > as I did :D Doing whole-scale replacements across the kernel for stuff like this isn't needed, just for new stuff, using the new apis is a good idea. thanks, greg k-h