[PATCH 2/3] Inline release_id in voicecall.c

Marcel Holtmann marcel at holtmann.org
Tue Oct 27 21:59:06 PDT 2009


Hi Zhenhua,

> Move and rename alloc_next_id and release_id into atutil.c
> 
> So that they could be shared by atmodem and hfpmodem drivers.
> ---
>  drivers/atmodem/atutil.c    |   20 ++++++++++++++++++++
>  drivers/atmodem/atutil.h    |    2 ++
>  drivers/atmodem/voicecall.c |   24 ++----------------------
>  3 files changed, 24 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
> index 465d258..847a4ee 100644
> --- a/drivers/atmodem/atutil.c
> +++ b/drivers/atmodem/atutil.c
> @@ -82,3 +82,23 @@ gint at_util_call_compare(gconstpointer a,
> gconstpointer b)
>         return 0;
>  }
>  
> +unsigned int at_util_alloc_next_id(unsigned int *id_list)
> +{
> +       unsigned int i;
> +
> +       for (i = 1; i < sizeof(unsigned int) * 8; i++) {
> +               if (*id_list & (0x1 << i))
> +                       continue;
> +
> +               *id_list |= (0x1 << i);
> +               return i;
> +       }
> +
> +       return 0;
> +}
> +
> +inline void at_util_release_id(unsigned int *id_list, unsigned int
> id)
> +{
> +       *id_list &= ~(0x1 << id);
> +}

what is this? Don't use inline at all and let the compiler decide. I
also don't really understand how you think this works. There is nothing
to inline here.

And while at it. Drop the 0x1 stuff. Using 1 is much more readable.

Regards

Marcel




More information about the ofono mailing list