Linux USB
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Roy Luo <royluo@google.com>
Cc: raychi@google.com, badhri@google.com,
	Alan Stern <stern@rowland.harvard.edu>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Michael Grzeschik <m.grzeschik@pengutronix.de>,
	Bastien Nocera <hadess@hadess.net>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Matthias Kaehlcke <mka@chromium.org>,
	Flavio Suligoi <f.suligoi@asem.it>,
	Douglas Anderson <dianders@chromium.org>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH v3] usb: core: add sysfs entry for usb device state
Date: Tue, 13 Jun 2023 11:06:35 +0200	[thread overview]
Message-ID: <2023061307-oversized-wife-1f69@gregkh> (raw)
In-Reply-To: <CA+zupgymZusMgecUyD8f2-AnoT3OR_O_wjy6uTxjZgSv9BLHLw@mail.gmail.com>

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

      reply	other threads:[~2023-06-13  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 21:55 [PATCH v3] usb: core: add sysfs entry for usb device state Roy Luo
2023-06-07 18:32 ` Alan Stern
2023-06-07 19:06 ` Greg Kroah-Hartman
2023-06-08  1:35   ` Roy Luo
2023-06-08  1:58     ` Roy Luo
2023-06-13  9:06       ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2023061307-oversized-wife-1f69@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=badhri@google.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dianders@chromium.org \
    --cc=f.suligoi@asem.it \
    --cc=hadess@hadess.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.grzeschik@pengutronix.de \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mka@chromium.org \
    --cc=oliver.sang@intel.com \
    --cc=raychi@google.com \
    --cc=royluo@google.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox