RE: [PATCH 2/8] Thermal: Create zone level APIs

From: R, Durgadoss
Date: Fri Feb 08 2013 - 03:54:20 EST


Hi Rui,

> -----Original Message-----
> From: Zhang, Rui
> Sent: Friday, February 08, 2013 1:42 PM
> To: R, Durgadoss
> Cc: linux-pm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> eduardo.valentin@xxxxxx; hongbo.zhang@xxxxxxxxxx; wni@xxxxxxxxxx
> Subject: Re: [PATCH 2/8] Thermal: Create zone level APIs
>
> On Tue, 2013-02-05 at 16:16 +0530, Durgadoss R wrote:
> > This patch adds a new thermal_zone structure to
> > thermal.h. Also, adds zone level APIs to the thermal
> > framework.
> >

[snip.]

> > +
> > +struct thermal_sensor *get_sensor_by_name(const char *name)
> > +{
> > + struct thermal_sensor *pos;
> > + struct thermal_sensor *ts = NULL;
> > +
> > + mutex_lock(&sensor_list_lock);
> > + for_each_thermal_sensor(pos) {
> > + if (!strnicmp(pos->name, name, THERMAL_NAME_LENGTH))
> {
> > + ts = pos;
> > + break;
>
> this function depends on the assumption that all the sensor names are
> unique.
> thus I prefer to go through all the list and return -EINVAL if duplicate
> names found, because in this case, the pointer returned may be not the
> sensor we want to get.

Yes, I agree with you. But I prefer having this check in the register API
itself, which then will not allow duplicates.

The reason being, we use this get* API (comparatively) a lot more than
the register APIs. And putting this check in the register APIs means doing
this check only once. Let me know what you think.

And the same for cooling devices too.

Thanks,
Durga
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—