Hi, sameo

> So the main point of this command queue was to cleanly get rid of the
> powered_pending stuff. And my idea was the following one: If 
> the queue is
> empty, then we queue the command and we return the 
> driver->enable return
> value. If the queue is not empty, then we just return 
> -EINPROGRESS and we
> queue the command.
> Then, whenever we dequeue, we can compare the command and the 
> actual device
> state (when we are dequeuing, the device is not in a pending 
> state) and if
> they're identical then we just skip the command.
> With this scheme, we won't need any powered_pending flag, but 
> we'd still need
> your power operation timeout.

For device enable/disable operations, how about to just use the powered_pending 
flag instead of a queue to record the device status?
As you know, we need only care about the last enable/disable request when 
device is busy, so I think we can implement it just through 
updating powered_pending flag status, and when the device enable/disable done, 
it just need check the powered_pending flag again to 
check whether it need to make another enable/disable operation.

My idea is shown below(Basing on Alok's patch):
int __connman_device_enable(struct connman_device *device)
{
        ......
        if (device->powered_pending == PENDING_DISABLE) {
                //device_queue_add(device, "enable");
                device->powered_pending = PENDING_ENABLE;
                return -EINPROGRESS;
        }
        ......
}
int __connman_device_disable(struct connman_device *device)
{
        ......
        if (device->powered_pending == PENDING_ENABLE) {
                //device_queue_add(device, "disable");
                device->powered_pending = PENDING_DISABLE;
                return -EINPROGRESS;
        }
        ......
}
void connman_device_set_powered(struct connman_device *device,
                                connman_bool_t powered)
{
        ......
done:
        /* Check whether there is another enable/disable request */
        //device->powered_pending = PENDING_NONE;
        if (powered == TRUE && powered_pending == PENDING_DISABLE)
                __connman_device_disable(device);
        else if (powered == FALSE && powered_pending == PENDING_ENABLE)
                __connman_device_enable(device);
        else
                powered_pending = PENDING_NONE;

        device->pending_timeout = 0;
        return 0;
}
So what's about your suggestions?
Thanks.
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to