public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: drop misleading usb_set_intfdata() kernel doc
Date: Mon, 12 Dec 2022 14:40:14 +0100	[thread overview]
Message-ID: <Y5cvPulXceujfZv6@hovoldconsulting.com> (raw)
In-Reply-To: <2a2935e6-ae3c-85d9-a2e9-f42fb4ca7d59@suse.com>

On Mon, Dec 12, 2022 at 02:27:46PM +0100, Oliver Neukum wrote:
> On 12.12.22 14:14, Johan Hovold wrote:
> > On Mon, Dec 12, 2022 at 12:13:54PM +0100, Oliver Neukum wrote:

> > And in this case there was also no kernel doc for usb_get_intfdata()
> > which is equally self documenting. Why add redundant docs for only one
> > of these functions?
> 
> Because knowing that one of them exists makes the other much more
> obvious.

I doubt anyone finds out about this function by reading generated kernel
documentation. You look at a driver, grep the function and look at the
single-line implementation.

Driver data is such as integral part of the driver model so it's kinda
hard to miss. Still dev_set_drvdata() also has no kernel doc either.
 
> > I'd rather drop this particular documentation which was added due to a
> > misunderstanding then go down the rabbit hole of adding mindless kernel
> > doc to every helper we have.
> 
> Yes, but those are not the alternatives.
> Removing the perfectly good part of the kerneldoc is a needless regression,
> albeit a minor one.

But it was never perfectly good. It claims that a driver "should" use it,
when it may not need to (think simple driver using devres) and talks
about driver core resetting the pointer which is irrelevant.

> > Yes. The (device group) attributes are removed by driver core before
> > ->remove() is called, otherwise you'd have an even bigger issue with the
> > driver data itself which is typically deallocated before the pointer is
> 
> So what happens if user space calls read() or write() on an existing fd?
> Sorry, but this is an issue we need to be sure about.

No need to be sorry, and I've looked at this before. kernfs handles the
serialisation.

But as I mentioned above, this is again irrelevant for the question at
hand as the driver data is freed before the pointer is set to NULL.

Johan

  reply	other threads:[~2022-12-12 13:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11 12:06 [PATCH] USB: drop misleading usb_set_intfdata() kernel doc Johan Hovold
2022-12-12 10:19 ` Oliver Neukum
2022-12-12 10:31   ` Johan Hovold
2022-12-12 11:13     ` Oliver Neukum
2022-12-12 13:14       ` Johan Hovold
2022-12-12 13:27         ` Oliver Neukum
2022-12-12 13:40           ` Johan Hovold [this message]
2022-12-12 14:04             ` Oliver Neukum
2022-12-12 14:14               ` Johan Hovold
2022-12-12 15:25                 ` Alan Stern
2022-12-12 16:08                   ` Johan Hovold
2022-12-12 16:39                     ` Alan Stern

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=Y5cvPulXceujfZv6@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=oneukum@suse.com \
    /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