linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Marc Gonzalez <marc.w.gonzalez@free.fr>
Cc: "Sean Young" <sean@mess.org>, "Brad Love" <brad@nextdimension.cc>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	linux-media <linux-media@vger.kernel.org>,
	"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>
Subject: Re: [PATCH v1] media: dvb: Add devm_dvb_register_adapter
Date: Fri, 12 Jul 2019 18:26:43 +0200	[thread overview]
Message-ID: <20190712162618.GK22408@latitude> (raw)
In-Reply-To: <a69ec163-8515-2e86-e2e7-0da61beda6e1@free.fr>

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

Hi,

some comments below.

On Fri, Jul 12, 2019 at 04:19:20PM +0200, Marc Gonzalez wrote:
> Add devm* variant for automagic resource release.

S-o-b missing.

> +int devm_dvb_register_adapter(struct device *dev, struct dvb_adapter *adap,
> +		const char *name, struct module *module, short *adapter_nums)
> +{
> +	int v1, v2;
> +
> +	v1 = dvb_register_adapter(adap, name, module, dev, adapter_nums);
> +	if (v1 < 0)
> +		return v1;
> +
> +	v2 = devm_add_action_or_reset(dev, unregister_adapter, adap);
> +	if (v2 < 0)
> +		return v2;
> +
> +	return v1;
> +}
> +EXPORT_SYMBOL(devm_dvb_register_adapter);

What non-negative numbers can dvb_register_adapter and
devm_add_action_or_reset return, and what are their meanings? Why should
devm_dvb_register_adapter return the (non-negative) return value of
dvb_register_adapter?
(I really don't know, because I'm not familiar with the media/DVB subsystem)

*If* the non-negative return values don't matter, I'd simplify the code
to something like this:

	int res;

	res = dvb_register_adapter(adap, name, module, dev, adapter_nums);
	if (res < 0)
		return res;

	res = devm_add_action_or_reset(dev, unregister_adapter, adap);
	if (res < 0)
		return res;

	return 0;

(or even 'return devm_add_action_or_reset(...)' directly)


> +int devm_dvb_register_adapter(struct device *dev, struct dvb_adapter *adap,
> +		const char *name, struct module *module, short *adapter_nums);

I think this function should also be added to
Documentation/driver-model/devres.rst (previously called devres.txt),
considering that most (or all?) devm_ functions are listed there.


Thanks,
Jonthan Neuschäfer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-07-12 16:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 14:19 [PATCH v1] media: dvb: Add devm_dvb_register_adapter Marc Gonzalez
2019-07-12 16:26 ` Jonathan Neuschäfer [this message]
2019-07-15 10:50   ` Marc Gonzalez

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=20190712162618.GK22408@latitude \
    --to=j.neuschaefer@gmx.net \
    --cc=bjorn.andersson@linaro.org \
    --cc=brad@nextdimension.cc \
    --cc=linux-media@vger.kernel.org \
    --cc=marc.w.gonzalez@free.fr \
    --cc=mchehab@kernel.org \
    --cc=sean@mess.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).