linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Marc Gonzalez <marc.w.gonzalez@free.fr>
Cc: "Ezequiel Garcia" <ezequiel@collabora.com>,
	"Brad Love" <brad@nextdimension.cc>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	linux-media <linux-media@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	"Guenter Roeck" <linux@roeck-us.net>
Subject: Re: [PATCH v3] media: dvb: Provide 4 devm variants
Date: Thu, 15 Aug 2019 14:02:30 +0100	[thread overview]
Message-ID: <20190815130230.nhetv5zj4pqjxqj7@gofer.mess.org> (raw)
In-Reply-To: <64344008-4077-9948-4482-0878279b50e8@free.fr>

On Mon, Jul 22, 2019 at 10:13:56AM +0200, Marc Gonzalez wrote:
> On 21/07/2019 17:02, Ezequiel Garcia wrote:
> 
> > On Thu, 2019-07-18 at 15:03 +0200, Marc Gonzalez wrote:
> >
> >> Provide devm variants for automatic resource release on device removal.
> >> Makes error-handling in probe() simpler, thus less error-prone.
> >> Once all resources are devmanaged, remove() is no longer needed.
> > 
> > I think it would be better to add this API as part of a series
> > that also uses it.
> 
> I have an outstanding RFC for a new driver:
> 
> 	https://patchwork.kernel.org/patch/11040435/
> 
> Locally, I've updated the probe function to use the proposed devm functions.
> 
> I was mainly hoping to get initial feedback from the maintainers.
> 1) See if they're OK with devm APIs

devm_ has some lifetime issues, wrt to disconnect. However, for a platform
device it is fine.

> 2) See if they're OK with the way I implemented devm APIs

Looks good to me.

> 3) See what's missing to get an Ack

Please submit both this patch and a the driver as a series.

Thanks,

Sean

> 
> static int tsif_probe(struct platform_device *pdev)
> {
> 	int err, virq;
> 	struct tsif *tsif;
> 	struct resource *res;
> 	struct dvb_frontend *fe;
> 	struct dvb_adapter *adap;
> 	struct device *dev = &pdev->dev;
> 	short num = DVB_UNSET;
> 
> 	fe = dvb_get_demod_fe(dev->of_node);
> 	if (!fe)
> 		return -ENXIO;
> 
> 	tsif = devm_kzalloc(dev, sizeof(*tsif), GFP_KERNEL);
> 	if (!tsif)
> 		return -ENOMEM;
> 
> 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsif0");
> 	tsif->base = devm_ioremap_resource(dev, res);
> 	if (IS_ERR(tsif->base))
> 		return PTR_ERR(tsif->base);
> 
> 	virq = platform_get_irq_byname(pdev, "tsif0");
> 	err = devm_request_irq(dev, virq, tsif_isr, IRQF_SHARED, "tsif", tsif);
> 	if (err)
> 		return err;
> 
> 	tsif->clk = devm_clk_get(dev, "iface");
> 	if (IS_ERR(tsif->clk))
> 		return PTR_ERR(tsif->clk);
> 
> 	err = devm_clk_prepare_enable(dev, tsif->clk);
> 	if (err)
> 		return err;
> 
> 	adap = &tsif->adapter;
> 	err = devm_dvb_register_adapter(dev, adap, "tsif", THIS_MODULE, &num);
> 	if (err) return err;
> 
> 	/* Not sure the diff between filter and feed? */
> 	tsif->demux.filternum = 16; /*** Dunno what to put here ***/
> 	tsif->demux.feednum = 16;	/*** Dunno what to put here ***/
> 	tsif->demux.start_feed = noop;
> 	tsif->demux.stop_feed = noop;
> 	err = devm_dvb_dmx_init(dev, &tsif->demux);
> 	if (err) return err;
> 
> 	/* What relation to dvb_demux.filternum??? */
> 	/* Do I need this object?? */
> 	tsif->dmxdev.filternum = 16;
> 	tsif->dmxdev.demux = &tsif->demux.dmx;
> 	err = devm_dvb_dmxdev_init(dev, &tsif->dmxdev, adap);
> 	if (err) return err;
> 
> 	err = devm_dvb_register_frontend(dev, adap, fe);
> 	if (err) return err;
> 
> 	writel_relaxed(TSIF_START + ENABLE_IRQ, tsif->base + TSIF_STS_CTL);
> 	devm_add_action(dev, stop_tsif, tsif);
> 	INIT_WORK(&tsif->work, handle_pkt);
> 
> 	return 0;
> }

      reply	other threads:[~2019-08-15 13:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 13:03 [PATCH v3] media: dvb: Provide 4 devm variants Marc Gonzalez
2019-07-21 15:02 ` Ezequiel Garcia
2019-07-22  8:13   ` Marc Gonzalez
2019-08-15 13:02     ` Sean Young [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=20190815130230.nhetv5zj4pqjxqj7@gofer.mess.org \
    --to=sean@mess.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=brad@nextdimension.cc \
    --cc=ezequiel@collabora.com \
    --cc=j.neuschaefer@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=marc.w.gonzalez@free.fr \
    --cc=mchehab@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).