Changeset 3501


Ignore:
Timestamp:
11/24/07 19:52:38 (6 years ago)
Author:
jserv
Message:

Indentation with consistent coding style of gsmd.
Remove C++ style comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/gsm/src/gsmd/machine_gta01.c

    r3497 r3501  
    3434#include <gsmd/atcmd.h> 
    3535 
    36 #define GSMD_MODEM_WAKEUP_TIMEOUT     3 
     36#define GSMD_MODEM_WAKEUP_TIMEOUT       3 
    3737#define GSMD_MODEM_POWEROFF_TIMEOUT     3         
    3838 
     
    4242} 
    4343 
    44 static struct gsmd_timer * poweroff_timer(struct gsmd *g) 
     44static struct gsmd_timer *poweroff_timer(struct gsmd *g) 
    4545{ 
    4646        struct timeval tv; 
     
    4949        DEBUGP("Create power off timer\n"); 
    5050 
    51         return gsmd_timer_create(&tv,&poweroff_timeout,g); 
     51        return gsmd_timer_create(&tv, &poweroff_timeout, g); 
    5252} 
    5353 
    5454static int gta01_power(struct gsmd *g, int power) 
    5555{ 
    56         struct gsmd_atcmd * cmd = NULL; 
     56        struct gsmd_atcmd *cmd = NULL; 
    5757 
    58         switch (power)  
    59         { 
    60                 case GSMD_MODEM_POWERUP:  
     58        switch (power) { 
     59                case GSMD_MODEM_POWERUP: 
    6160                        break; 
    6261 
    63                 case GSMD_MODEM_POWERDOWN:       
    64  
    65                         //After send AT@POFF to GSM modem, modem will not work anymore and gsmd get no response 
    66                         cmd = atcmd_fill("AT@POFF", 7+1, NULL, g, 0, poweroff_timer); 
     62                case GSMD_MODEM_POWERDOWN: 
     63                        /* After sending "AT@POFF" to GSM modem, modem will 
     64                         * soon power off, and then gsmd gets no response 
     65                         * from modem. */ 
     66                        cmd = atcmd_fill("AT@POFF", 7 + 1, NULL, 
     67                                        g, 0, poweroff_timer); 
    6768 
    6869                        if (!cmd) 
     
    7071 
    7172                        llist_add_tail(&cmd->list, &g->pending_atcmds); 
    72                         if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { 
     73                        if (llist_empty(&g->busy_atcmds) &&  
     74                                        !llist_empty(&g->pending_atcmds)) { 
    7375                                atcmd_wake_pending_queue(g); 
    7476                        } 
     
    8587{ 
    8688        DEBUGP("The wake up callback!!\n"); 
    87         return 0; 
     89        return 0; 
    8890} 
    8991 
    9092static void wakeup_timeout(struct gsmd_timer *tmr, void *data)  
    9193{ 
    92         struct gsmd *g=data; 
    93         struct gsmd_atcmd *cmd=NULL; 
    94         DEBUGP("Wakeup time out!!\n"); 
    95         if (!llist_empty(&g->busy_atcmds)) { 
    96                 cmd = llist_entry(g->busy_atcmds.next,struct gsmd_atcmd, list); 
    97         } 
    98         if (!cmd) {  
    99                 DEBUGP("ERROR!! busy_atcmds is NULL\n"); 
    100                 return; 
    101         } 
     94        struct gsmd *g = data; 
     95        struct gsmd_atcmd *cmd = NULL; 
     96        DEBUGP("Wakeup time out!!\n"); 
     97        if (!llist_empty(&g->busy_atcmds)) { 
     98                cmd = llist_entry(g->busy_atcmds.next, struct gsmd_atcmd, list); 
     99        } 
     100        if (!cmd) {  
     101                DEBUGP("ERROR!! busy_atcmds is NULL\n"); 
     102                return; 
     103        } 
    102104 
    103         if (cmd->timeout != tmr) { 
    104                 DEBUGP("ERROR!! cmd->timeout != tmr\n"); 
    105                 return; 
    106         } 
     105        if (cmd->timeout != tmr) { 
     106                DEBUGP("ERROR!! cmd->timeout != tmr\n"); 
     107                return; 
     108        } 
    107109 
    108         gsmd_timer_free(cmd->timeout); 
    109         cmd->timeout = NULL; 
     110        gsmd_timer_free(cmd->timeout); 
     111        cmd->timeout = NULL; 
    110112 
    111         // It's a wakeup command 
    112         if ( cmd->buf[0]==' ') { 
    113                 llist_del(&cmd->list); 
    114                 talloc_free(cmd); 
    115                 // discard the wakeup command, and pass the real command. 
    116                 if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { 
    117                         atcmd_wake_pending_queue(g); 
    118                 } 
    119         } else { 
    120                 DEBUGP("ERROR!! Wakeup timeout and cmd->buf is not wakeup command!! %s\n",cmd->buf); 
    121         } 
     113        /* It's a wakeup command */ 
     114        if ( cmd->buf[0] == ' ') { 
     115                llist_del(&cmd->list); 
     116                talloc_free(cmd); 
     117                /* discard the wakeup command, and pass the real command. */ 
     118                if (llist_empty(&g->busy_atcmds) && 
     119                                !llist_empty(&g->pending_atcmds)) { 
     120                        atcmd_wake_pending_queue(g); 
     121                } 
     122        } else { 
     123                DEBUGP("ERROR!! Wakeup timeout and " 
     124                                "cmd->buf is not wakeup command!! %s\n", 
     125                                cmd->buf); 
     126        } 
    122127} 
    123128 
    124129static struct gsmd_timer * wakeup_timer(struct gsmd *g) 
    125130{ 
    126         struct timeval tv; 
    127         tv.tv_sec = GSMD_MODEM_WAKEUP_TIMEOUT; 
    128         tv.tv_usec = 0; 
     131        struct timeval tv; 
     132        tv.tv_sec = GSMD_MODEM_WAKEUP_TIMEOUT; 
     133        tv.tv_usec = 0; 
    129134        DEBUGP("Create wake up timer\n"); 
    130135 
    131         return gsmd_timer_create(&tv,&wakeup_timeout,g); 
     136        return gsmd_timer_create(&tv, &wakeup_timeout, g); 
    132137} 
    133138 
    134 /// adding a null '\r' before real at command. 
     139/* adding a null '\r' before real at command. */ 
    135140static int atcmd_wakeup_modem(struct gsmd *g)  
    136141{ 
    137142        DEBUGP("try to wake up\n"); 
    138         struct gsmd_atcmd * cmd= atcmd_fill(" \r", 2, null_wakeup_cb, g, 0, wakeup_timer); 
     143        struct gsmd_atcmd *cmd = atcmd_fill(" \r", 2, null_wakeup_cb, 
     144                        g, 0, wakeup_timer); 
    139145 
    140146        llist_add_tail(&cmd->list, &g->pending_atcmds); 
    141         if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { 
     147        if (llist_empty(&g->busy_atcmds) && 
     148                        !llist_empty(&g->pending_atcmds)) { 
    142149                atcmd_wake_pending_queue(g); 
    143150        } 
     
    154161static int gta01_init(struct gsmd *g, int fd) 
    155162{ 
    156         int rc; 
    157  
    158163        /* 
    159164         * We assume that the GSM chipset can take 
Note: See TracChangeset for help on using the changeset viewer.