lkml.org 
[lkml]   [2019]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3] media: dvb: Provide 4 devm variants
From
Date
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
2) See if they're OK with the way I implemented devm APIs
3) See what's missing to get an Ack

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;
}

\
 
 \ /
  Last update: 2019-07-22 10:14    [W:0.051 / U:1.668 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site