Sascha:

>> I think theres no value in having the FLAG_REGISTERED flag and this
>> function.
>
> I think it sneaked in before I was using the mutex to prevent the list
> of devices from changing during a lookup.  Fixed.

I take that back.  What having that flag lets one do is error recovery
that looks like this:

for (wchan = 0; wchan < NCHAN; wchan++) {
    ret = pwm_register(&x->p[wchan], ... );
    if (ret) goto error;
}

...

error:
for (wchan = 0; wchan < NCHAN; wchan++) {
    if (pwm_is_registered(&x->p[wchan]))
        pwm_unregister(&x->p[wchan]);
}


Without pwm_is_registered() the driver must itself keep track of which
devices were successfully registered and which ones weren't---
something the internals of the API already knows.

True, in the above example it's simply a matter of always registering
in increasing channel order AND preserving the wchan value if an error
occurs.  And then having an "errchan" index that counts from zero up
to the last successfully-registered channel in the error loop.

The pwm_is_registered() function does work of tracking successful
device registrations, and therefore leads to simpler code in device
drivers.  In particular, the error paths are simpler (and less
redundant across drivers) than without pwm_is_registered().

So I think pwm_is_registered() is a keeper.



b.g.
-- 
Bill Gatliff
b...@billgatliff.com
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to