linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Zviagintsev <sergei@s15v.net>
To: "Dr. H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Marek Belisko <marek@goldelico.com>, Jiri Slaby <jslaby@suse.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Peter Hurley <peter@hurleysoftware.com>,
	Mark Rutland <mark.rutland@arm.com>,
	One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
	Sebastian Reichel <sre@kernel.org>, NeilBrown <neil@brown.name>,
	Grant Likely <grant.likely@linaro.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-serial@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Pawel Moll <pawel.moll@arm.com>
Subject: Re: [PATCH RFC v2 1/3] tty: serial core: provide method to search uart by phandle
Date: Tue, 30 Jun 2015 11:09:10 +0300	[thread overview]
Message-ID: <20150630080910.GC17917@localhost.localdomain> (raw)
In-Reply-To: <72C0781B-5DEC-474C-83B5-3CD6B8D68890@goldelico.com>

Hi,

On Mon, Jun 29, 2015 at 06:44:23PM +0200, Dr. H. Nikolaus Schaller wrote:
[...]
> >> +	list_for_each_entry(uart, &uart_list, head) {
> >> +		if (node != uart->dev->of_node)
> >> +			continue;
> >> +
> >> +		return uart;
> > 
> > We can easily save three lines here :)
> 
> Hm. We have copied from here:
> 
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/phy/phy.c?id=refs/tags/v4.1#n65
> 
> So please let us know how you want to save 3 lines.

Sorry for not being specific, I just meant that it could be written as

if (node == uart->dev->of_node)
	return uart;

> >> +/**
> >> + * devm_serial_get_uart_by_phandle - find the uart by phandle
> >> + * @dev - device that requests this uart
> >> + * @phandle - name of the property holding the uart phandle value
> >> + * @index - the index of the uart
> >> + *
> >> + * Returns the uart_port associated with the given phandle value,
> >> + * after getting a refcount to it, -ENODEV if there is no such uart or
> >> + * -EPROBE_DEFER if there is a phandle to the uart, but the device is
> >> + * not yet loaded. While at that, it also associates the device with
> >> + * the uart using devres. On driver detach, release function is invoked
> >> + * on the devres data, then, devres data is freed.
> > 
> > Add -ENOMEM and -EINVAL, remove -EPROBE_DEFER?
> 
> Well, if the device is not loaded it means the caller must return -EPROBE_DEFER
> anyways since it can’t complete it’s probe function.

That was my mistake, from the first sight I hadn't found where
-EPROBE_DEFER is actually returned from the code and thus decided that
kernel-doc has an error. But now I see it, thanks.

> >> +
> >> +	*ptr = uart;
> >> +	devres_add(dev, ptr);
> > 
> > What is the point of assigning value to *ptr?
> 
> Good question. I think it is necessary to store a copy of the found uart/phy instead of a reference.
> Therefore the assignment to *ptr copies into the new memory area allocated above by 
> 
> ptr = devres_alloc(devm_serial_uart_release, sizeof(*ptr), GFP_KERNEL);
> 
> This makes the dev the owner of the data - instead of unknown ownership before.
> 
> It is the same as here (but it might be wrong/unnecessary there as well):
> 
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/phy/phy.c?id=refs/tags/v4.1#n209
> 
> Maybe it has something to do with the unfinished devm_serial_uart_release().

Indeed. I haven't noticed this through the first quick look into the
code. Thank you for explanation.

  reply	other threads:[~2015-06-30  8:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28 19:46 [PATCH RFC v2 0/3] UART slave device support Marek Belisko
2015-06-28 19:46 ` [PATCH RFC v2 1/3] tty: serial core: provide method to search uart by phandle Marek Belisko
2015-06-28 21:34   ` Sergei Zviagintsev
2015-06-29 16:44     ` Dr. H. Nikolaus Schaller
2015-06-30  8:09       ` Sergei Zviagintsev [this message]
2015-07-01 18:16   ` Rob Herring
2015-07-01 19:07     ` Dr. H. Nikolaus Schaller
2015-07-02 19:08       ` Rob Herring
2015-06-28 19:46 ` [PATCH RFC v2 2/3] tty: serial_core: Add hooks for uart slave drivers Marek Belisko
2015-06-28 21:51   ` Sergei Zviagintsev
2015-06-29 16:47     ` Dr. H. Nikolaus Schaller
2015-06-28 19:46 ` [PATCH RFC v2 3/3] misc: Add w2g0004 gps receiver driver Marek Belisko
2015-06-30  8:23   ` Sergei Zviagintsev
2015-06-30  8:35     ` Dr. H. Nikolaus Schaller

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=20150630080910.GC17917@localhost.localdomain \
    --to=sergei@s15v.net \
    --cc=arnd@arndb.de \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hns@goldelico.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=marek@goldelico.com \
    --cc=mark.rutland@arm.com \
    --cc=neil@brown.name \
    --cc=pawel.moll@arm.com \
    --cc=peter@hurleysoftware.com \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).