Re: [PWM v3: 1/3] PWM: Implement a generic PWM framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
bgat@xxxxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Gstreamer Embedded]     [Linux MMC Devel]     [U-Boot V2]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux ARM Kernel]     [Linux OMAP]     [Linux SCSI]

  Powered by Linux