lkml.org 
[lkml]   [2019]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] thermal: sun50i: add thermal driver for h6
Hello,

On Fri, May 17, 2019 at 01:51:56AM +0800, Frank Lee wrote:
> > > +static int tsens_probe(struct platform_device *pdev)
> > > +{
> > > + struct tsens_device *tmdev;
> > > + struct device *dev = &pdev->dev;
> > > + int ret;
> > > +
> > > + tmdev = devm_kzalloc(dev, sizeof(*tmdev), GFP_KERNEL);
> > > + if (!tmdev)
> > > + return -ENOMEM;
> > > +
> > > + tmdev->dev = dev;
> > > + tmdev->chip = of_device_get_match_data(&pdev->dev);
> > > + if (!tmdev->chip)
> > > + return -EINVAL;
> > > +
> > > + ret = tsens_init(tmdev);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = tsens_register(tmdev);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = tmdev->chip->enable(tmdev);
> > > + if (ret)
> > > + return ret;
> > >
> > > + platform_set_drvdata(pdev, tmdev);
> >
> > Your registration should be the very last thing you do. Otherwise, you
> > have a small window where the get_temp callback can be called, but the
> > driver will not be functional yet.
> No. Anyway, ths data qcquisition is ms level.

Tz code can change in the future, and call the get_temp callback during
registration, and this would break. It's better to be correct, than make
dangerous assumptions. So platform_set_drvdata should be done somewhere
prior to init_resource.

Enable should be after register though. Because otherwise you may be calling
tz update on non-registered tz from an interrupt handler.

> > > + return ret;
> > > +}
> > > +

regards,
o.

\
 
 \ /
  Last update: 2019-05-16 23:12    [W:0.135 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site