Changeset 551:f9b73af24bca

Show
Ignore:
Timestamp:
05/31/08 21:31:49 (7 months ago)
Author:
Maxime Petazzoni <maxime.petazzoni@…>
Branch:
default
Message:

Remove some trailing whitespaces. Emacs victor.

Location:
nxos
Files:
16 modified

Legend:

Unmodified
Added
Removed
  • nxos/base/_fs.c

    r539 r551  
    2626fs_file_t *nx__fs_get_file(fs_fd_t fd) { 
    2727  NX_ASSERT(fd < FS_MAX_OPENED_FILES); 
    28    
     28 
    2929  if (!fdset[fd].used) { 
    3030    return NULL; 
     
    4949      volatile U32 *metadata = &(FLASH_BASE_PTR[i*EFC_PAGE_WORDS]); 
    5050      union U32tochar nameconv; 
    51        
     51 
    5252      memcpy(nameconv.integers, 
    5353             (void *)(metadata + FS_FILENAME_OFFSET), 
     
    5858        return FS_ERR_NO_ERROR; 
    5959      } 
    60        
     60 
    6161      /* Otherwise jump over the file and continue searching. */ 
    6262      else { 
     
    7474fs_err_t nx__fs_find_last_origin(U32 *origin) { 
    7575  U32 candidate = 0, i; 
    76    
     76 
    7777  for (i=FS_PAGE_START; i<FS_PAGE_END; i++) { 
    7878    if (nx__fs_page_has_magic(i)) { 
     
    8484    } 
    8585  } 
    86    
     86 
    8787  if (candidate) { 
    8888    *origin = candidate; 
    8989    return FS_ERR_NO_ERROR; 
    9090  } 
    91    
     91 
    9292  return FS_ERR_FILE_NOT_FOUND; 
    9393} 
     
    9595fs_err_t nx__fs_find_next_origin(U32 start, U32 *origin) { 
    9696  U32 i; 
    97    
     97 
    9898  for (i=start; i<FS_PAGE_END; i++) { 
    9999    if (nx__fs_page_has_magic(i)) { 
     
    102102    } 
    103103  } 
    104     
     104 
    105105  return FS_ERR_FILE_NOT_FOUND; 
    106106} 
     
    110110U32 nx__fs_get_file_page_count(size_t size) { 
    111111  U32 pages; 
    112    
     112 
    113113  /* Compute page occupation. */ 
    114114  size += FS_FILE_METADATA_BYTES; 
     
    117117    pages++; 
    118118  } 
    119      
     119 
    120120  return pages; 
    121121} 
     
    127127fs_perm_t nx__fs_get_file_perms_from_metadata(volatile U32 *metadata) { 
    128128  U8 perms = (*metadata & FS_FILE_PERMS_MASK) >> 20; 
    129    
     129 
    130130  if (perms & FS_FILE_PERM_MASK_READWRITE) { 
    131131    return FS_PERM_READWRITE; 
     
    133133    return FS_PERM_EXECUTABLE; 
    134134  } 
    135    
     135 
    136136  /* Defaults to read-only. */ 
    137137  return FS_PERM_READONLY; 
     
    146146 
    147147  memset(metadata, 0, FS_FILE_METADATA_BYTES); 
    148    
     148 
    149149  memset(nameconv.chars, 0, 32); 
    150150  memcpy(nameconv.chars, name, MIN(strlen(name), 31)); 
     
    164164      break; 
    165165  } 
    166   
     166 
    167167  /* File size. */ 
    168168  metadata[0] += (size & FS_FILE_SIZE_MASK); 
    169169 
    170170  /* Insert here in metadata[1] what would be relevant (future). */ 
    171   
     171 
    172172  /* File name. */ 
    173173  memcpy(metadata + FS_FILENAME_OFFSET, nameconv.integers, FS_FILENAME_LENGTH); 
     
    178178  U32 diff, i; 
    179179  size_t size; 
    180    
     180 
    181181  diff = origin - file->origin; 
    182182 
    183183  /* Move the file's data. */ 
    184184  size = nx__fs_get_file_page_count(file->size); 
    185    
     185 
    186186  for (i=file->origin; i<size; i++) { 
    187187    nx__efc_read_page(i, page_data); 
     
    192192    } 
    193193  } 
    194    
     194 
    195195  file->origin = origin; 
    196196  file->rbuf.page += diff; 
    197197  file->wbuf.page += diff; 
    198    
     198 
    199199  return FS_ERR_NO_ERROR; 
    200200} 
     
    203203  U32 origin, start; 
    204204  size_t size; 
    205    
     205 
    206206  size = nx__fs_get_file_page_count(file->size); 
    207    
     207 
    208208  /* First, look at the end of the flash for free space. */ 
    209209  if (nx__fs_find_last_origin(&origin) == FS_ERR_NO_ERROR) { 
     
    216216    } 
    217217  } 
    218    
     218 
    219219  start = FS_PAGE_START; 
    220220  while (nx__fs_find_next_origin(start, &origin) != FS_ERR_FILE_NOT_FOUND) { 
     
    227227                  &(FLASH_BASE_PTR[origin*EFC_PAGE_WORDS]))); 
    228228  } 
    229    
     229 
    230230  return FS_ERR_NO_SPACE_LEFT_ON_DEVICE; 
    231231} 
  • nxos/base/defrag.c

    r542 r551  
    3737  NX_ASSERT(len < EFC_PAGES); 
    3838  NX_ASSERT(dest - source <= len); 
    39    
     39 
    4040  while (len--) { 
    4141    data = FLASH_BASE_PTR[source*EFC_PAGE_WORDS]; 
     
    4343      return DEFRAG_ERR_FLASH_ERROR; 
    4444    } 
    45      
     45 
    4646    source++; 
    4747    dest++; 
    4848  } 
    49    
     49 
    5050  return DEFRAG_ERR_NO_ERROR; 
    5151} 
     
    5858  U32 origin; 
    5959  fs_err_t err; 
    60    
     60 
    6161  err = nx__fs_find_file_origin(name, &origin); 
    6262  if (err == FS_ERR_NO_ERROR) { 
    6363    return nx_defrag_for_file_by_origin(origin); 
    6464  } 
    65    
     65 
    6666  /* Fall back to simple defrag. */ 
    6767  return nx_defrag_simple(); 
     
    7070defrag_err_t nx_defrag_for_file_by_origin(U32 origin) { 
    7171  nx_defrag_move_region(origin, 1, 1); // TBR 
    72   
     72 
    7373  return DEFRAG_ERR_NO_ERROR; 
    7474} 
  • nxos/base/drivers/_efc.c

    r537 r551  
    3030 
    3131  nx_systick_wait_ms(EFC_THROTTLE_TIMER); 
    32    
     32 
    3333  /* Write the page data to the flash in-memory mapping. */ 
    3434  for (i=0 ; i<EFC_PAGE_WORDS ; i++) { 
     
    4343    ret = *AT91C_MC_FSR; 
    4444  } while (!(ret & AT91C_MC_FRDY)); 
    45    
     45 
    4646  /* Check the command result by reading the status register 
    4747   * only once to avoid the bits being cleared. 
  • nxos/base/drivers/_efc.h

    r549 r551  
    2323/** @defgroup efcinternal Embedded Flash Controller driver 
    2424 * 
    25  * The flash driver provides a software interface to the on-board  
     25 * The flash driver provides a software interface to the on-board 
    2626 * flash memory through the embedded flash controller. 
    2727 */ 
  • nxos/base/drivers/i2c.c

    r502 r551  
    721721        i2c_set_bus_state(sensor, I2C_IDLE); 
    722722        p->txn_state = TXN_WAITING; 
    723   
     723 
    724724        /* When the sub-transaction is done, decrement i2c_txn_count. 
    725725         * If it reaches 0, disable the I2C interrupt. 
  • nxos/base/drivers/sound.c

    r490 r551  
    6666   * there is data available to send. 
    6767   */ 
    68   *AT91C_SSC_TCMR = (AT91C_SSC_CKS_DIV + 
    69                      AT91C_SSC_CKO_CONTINOUS + 
     68  *AT91C_SSC_TCMR = (AT91C_SSC_CKS_DIV 
     69                     AT91C_SSC_CKO_CONTINOUS 
    7070                     AT91C_SSC_START_CONTINOUS); 
    7171 
  • nxos/base/fs.c

    r539 r551  
    3333  volatile U32 *metadata = &(FLASH_BASE_PTR[origin*EFC_PAGE_WORDS]); 
    3434  fs_file_t *file; 
    35    
     35 
    3636  file = nx__fs_get_file(fd); 
    3737  NX_ASSERT(file != NULL); 
    38    
     38 
    3939  file->origin = origin; 
    4040  file->size = nx__fs_get_file_size_from_metadata(metadata); 
    4141  file->perms = nx__fs_get_file_perms_from_metadata(metadata); 
    42    
     42 
    4343  file->rbuf.page = file->rbuf.pos = 0; 
    4444  file->wbuf.page = file->wbuf.pos = 0; 
     
    5353  U32 origin; 
    5454  fs_err_t err; 
    55    
     55 
    5656  err = nx__fs_find_file_origin(name, &origin); 
    5757  if (err != FS_ERR_NO_ERROR) { 
    5858    return err; 
    5959  } 
    60    
     60 
    6161  return nx_fs_init_fd(origin, fd); 
    6262} 
     
    8585  if (origin >= EFC_PAGES) { 
    8686    /* TODO: search for an available page on the flash. */ 
    87      
     87 
    8888    return FS_ERR_NO_SPACE_LEFT_ON_DEVICE; 
    8989  } 
    90    
     90 
    9191  /* Bootstrap the metadata to the flash page. */ 
    9292  nx__fs_create_metadata(FS_PERM_READWRITE, name, 0, metadata); 
     
    9696    return FS_ERR_FLASH_ERROR; 
    9797  } 
    98    
     98 
    9999  return nx_fs_init_fd(origin, fd); 
    100100} 
     
    123123  file = &(fdset[slot]); 
    124124  file->used = TRUE; 
    125    
     125 
    126126  switch (mode) { 
    127127    case FS_FILE_MODE_CREATE: 
     
    134134      file->wbuf.pos = FS_FILE_METADATA_BYTES; 
    135135      file->wbuf.page = file->origin; 
    136        
     136 
    137137      file->rbuf = file->wbuf; 
    138138      break; 
     
    143143      } 
    144144 
    145       nx__efc_read_page(file->origin, file->wbuf.data.raw);       
     145      nx__efc_read_page(file->origin, file->wbuf.data.raw); 
    146146      file->wbuf.pos = FS_FILE_METADATA_BYTES; 
    147147      file->wbuf.page = file->origin; 
     
    152152      err = nx_fs_open_by_name(name, slot); 
    153153      if (err != FS_ERR_NO_ERROR) { 
    154         break;  
     154        break; 
    155155      } 
    156        
     156 
    157157      /* Put writing position at the end of the file. */ 
    158158      file->wbuf.page = file->origin 
     
    160160      nx__efc_read_page(file->wbuf.page, file->wbuf.data.raw); 
    161161      file->wbuf.pos = (FS_FILE_METADATA_BYTES + file->size) % EFC_PAGE_BYTES; 
    162        
     162 
    163163      file->rbuf.page = file->origin; 
    164       nx__efc_read_page(file->rbuf.page, file->rbuf.data.raw);       
     164      nx__efc_read_page(file->rbuf.page, file->rbuf.data.raw); 
    165165      file->rbuf.pos = FS_FILE_METADATA_BYTES; 
    166166 
     
    170170      break; 
    171171  } 
    172    
     172 
    173173  if (err == FS_ERR_NO_ERROR) { 
    174174    *fd = slot; 
     
    177177    file->used = FALSE; 
    178178  } 
    179    
     179 
    180180  return err; 
    181181} 
     
    189189    return -1; 
    190190  } 
    191    
     191 
    192192  return file->size; 
    193193} 
     
    253253    if (err != FS_ERR_NO_ERROR) 
    254254      return err; 
    255      
     255 
    256256    file->wbuf.page++; 
    257257    file->wbuf.pos = 0; 
     
    263263 
    264264  file->wbuf.data.bytes[file->wbuf.pos++] = byte; 
    265    
     265 
    266266  /* Increment the size of the file if necessary */ 
    267267  if (file->wbuf.page == file->origin + pages) { 
     
    278278fs_err_t nx_fs_flush(fs_fd_t fd) { 
    279279  fs_file_t *file; 
    280    
     280 
    281281  file = nx__fs_get_file(fd); 
    282282  if (!file) { 
     
    303303  fs_file_t *file; 
    304304  fs_err_t err; 
    305    
    306   file = nx__fs_get_file(fd); 
    307   if (!file) { 
    308     return FS_ERR_INVALID_FD; 
    309   } 
    310    
     305 
     306  file = nx__fs_get_file(fd); 
     307  if (!file) { 
     308    return FS_ERR_INVALID_FD; 
     309  } 
     310 
    311311  err = nx_fs_flush(fd); 
    312312  if (err != FS_ERR_NO_ERROR) { 
     
    327327fs_perm_t nx_fs_get_perms(fs_fd_t fd) { 
    328328  fs_file_t *file; 
    329    
     329 
    330330  file = nx__fs_get_file(fd); 
    331331  if (!file) { 
     
    338338fs_err_t nx_fs_set_perms(fs_fd_t fd, fs_perm_t perms) { 
    339339  fs_file_t *file; 
    340    
    341   file = nx__fs_get_file(fd); 
    342   if (!file) { 
    343     return FS_ERR_INVALID_FD; 
    344   } 
    345    
     340 
     341  file = nx__fs_get_file(fd); 
     342  if (!file) { 
     343    return FS_ERR_INVALID_FD; 
     344  } 
     345 
    346346  file->perms = perms; 
    347    
     347 
    348348  return FS_ERR_NO_ERROR; 
    349349} 
     
    354354  U32 page, end; 
    355355  U32 erase[EFC_PAGE_WORDS] = {0}; 
    356    
    357   file = nx__fs_get_file(fd); 
    358   if (!file) { 
    359     return FS_ERR_INVALID_FD; 
    360   } 
    361    
     356 
     357  file = nx__fs_get_file(fd); 
     358  if (!file) { 
     359    return FS_ERR_INVALID_FD; 
     360  } 
     361 
    362362  /* Remove file marker and potential in-file marker-alike. */ 
    363363  end = file->origin + nx__fs_get_file_page_count(file->size); 
     
    370370    } 
    371371  } 
    372    
     372 
    373373  file->used = FALSE; 
    374374  return FS_ERR_NO_ERROR; 
     
    411411  if (files) { 
    412412  } 
    413    
     413 
    414414  if (used) { 
    415415  } 
    416    
     416 
    417417  if (free_pages) { 
    418418  } 
    419    
     419 
    420420  if (wasted) { 
    421421  } 
  • nxos/base/fs.h

    r536 r551  
    8484  bool used;                     /**< Denotes fd usage. */ 
    8585  char name[FS_FILENAME_LENGTH]; /**< The file name. */ 
    86    
     86 
    8787  U32 origin;                    /**< File origin page on the flash */ 
    8888  size_t size;                   /**< The file size. */ 
    89    
     89 
    9090  fs_perm_t perms;               /**< File permissions. */ 
    91    
     91 
    9292  fs_buffer_t rbuf;              /**< Read buffer. */ 
    9393  fs_buffer_t wbuf;              /**< Write buffer. */ 
  • nxos/base/lib/gui/gui.c

    r535 r551  
    1919 
    2020  NX_ASSERT(strlen(menu.title) > 0); 
    21    
     21 
    2222  for (i=0; menu.entries[i]; count++, i++); 
    2323  NX_ASSERT(count > 0); 
     
    5858        nx_display_string(". "); 
    5959 
    60       nx_display_string(menu.entries[i]);  
     60      nx_display_string(menu.entries[i]); 
    6161      nx_display_end_line(); 
    6262    } 
     
    8585        break; 
    8686    } 
    87   } while (!done);  
     87  } while (!done); 
    8888 
    8989 
  • nxos/base/lib/rcmd/_rcmd.c

    r549 r551  
    4545      return RCMD_ERR_NO_ERROR; 
    4646    } 
    47        
     47 
    4848    i++; 
    4949  } 
     
    5555  int ntokens, indices[RCMD_MAX_TOKENS], subind[NXT_N_MOTORS], i; 
    5656  char *spec; 
    57    
     57 
    5858  bool active[NXT_N_MOTORS] = {FALSE}; 
    5959  S32 speeds[NXT_N_MOTORS]; 
    6060  U32 durations[NXT_N_MOTORS]; 
    61      
     61 
    6262  nx__rcmd_tokenize(line, RCMD_TOKEN_SEPARATOR, &ntokens, indices); 
    6363 
     
    6565    return RCMD_ERR_INCORRECT_ARGC; 
    6666  } 
    67    
     67 
    6868  /* Parse motors spec. */ 
    6969  spec = line + indices[1]; 
     
    7777    } 
    7878  } 
    79    
     79 
    8080  /* Parse speeds spec. */ 
    8181  spec = line + indices[2]; 
     
    8787      speeds[i] = atos32(spec + subind[i]); 
    8888    } 
    89      
     89 
    9090    if (speeds[i] > 100 || speeds[i] < -100) { 
    9191      return RCMD_ERR_INVALID_PARAMETER; 
     
    102102      durations[i] = atou32(spec + subind[i]); 
    103103    } 
    104      
     104 
    105105    if (speeds[i] != 0 && durations[i] == 0) { 
    106106      return RCMD_ERR_INVALID_PARAMETER; 
    107107    } 
    108108  } 
    109    
     109 
    110110  /* Activate motors. */ 
    111111  for (i=0; i<NXT_N_MOTORS; i++) { 
     
    126126rcmd_err_t nx__rcmd_print(char *line) { 
    127127  int ntokens, indices[RCMD_MAX_TOKENS], i; 
    128    
    129   nx__rcmd_tokenize(line, RCMD_TOKEN_SEPARATOR, &ntokens, indices); 
    130    
     128 
     129  nx__rcmd_tokenize(line, RCMD_TOKEN_SEPARATOR, &ntokens, indices); 
     130 
    131131  for (i=1; i<ntokens; i++) { 
    132132    nx_display_string(line + indices[i]); 
     
    143143  char c; 
    144144  c = line[0]; 
    145    
     145 
    146146  nx_display_clear(); 
    147147  return RCMD_ERR_NO_ERROR; 
     
    151151  int ntokens, indices[RCMD_MAX_TOKENS]; 
    152152  U32 freq, duration; 
    153    
    154   nx__rcmd_tokenize(line, RCMD_TOKEN_SEPARATOR, &ntokens, indices); 
    155    
     153 
     154  nx__rcmd_tokenize(line, RCMD_TOKEN_SEPARATOR, &ntokens, indices); 
     155 
    156156  if (ntokens < rcmd_commands[RCMD_CMD_PLAY].argc) { 
    157157    return RCMD_ERR_INCORRECT_ARGC; 
    158158  } 
    159