Changeset 7a4e8e7c in rtems for c/src/libchip


Ignore:
Timestamp:
Oct 26, 2007, 9:54:28 AM (12 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 4.9, master
Children:
99e65f9c
Parents:
c47890c
Message:

corrected bug in libchip/i2c/spi-flash-m25p40

Location:
c/src/libchip/i2c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/libchip/i2c/spi-flash-m25p40.c

    rc47890c r7a4e8e7c  
    1717\*===============================================================*/
    1818/*
    19  * FIXME: currently, this driver only supports read accesses
    20  * write/erase accesses are to be completed
     19 * FIXME: currently, this driver only supports read/write accesses
     20 * erase accesses are to be completed
    2121 */
    2222
     
    109109  int                   ret_cnt = 0;
    110110  /*
    111    * FIXME: check arguments
    112    */
    113   if (rc == RTEMS_SUCCESSFUL) {
     111   * check arguments
     112   */
     113  if (rc == RTEMS_SUCCESSFUL) {
     114    if ((cnt <= 0)                      ||
     115        (cnt > M25P40_TOTAL_SIZE)       ||
     116        (off > (M25P40_TOTAL_SIZE-cnt))) {
     117      rc = RTEMS_INVALID_SIZE;
     118    }
     119    else if (buf == NULL) {
     120      rc = RTEMS_INVALID_ADDRESS;
     121    }
    114122  }
    115123  /*
     
    127135                             &spi_flash_m25p40_tfr_mode);
    128136  }
     137
     138  /*
     139   * address device
     140   */
     141  if (rc == RTEMS_SUCCESSFUL) {
     142    rc = rtems_libi2c_send_addr(minor,TRUE);
     143  }
     144
    129145  /*
    130146   * send write_enable command
     
    151167    }
    152168    /*
    153      * select device, set transfer mode, address device
     169     * select device, set transfer mode
    154170     */
    155171    if (rc == RTEMS_SUCCESSFUL) {
    156172      rc = rtems_libi2c_send_start(minor);
    157173    }
     174
     175    /*
     176     * address device
     177     */
     178    if (rc == RTEMS_SUCCESSFUL) {
     179      rc = rtems_libi2c_send_addr(minor,TRUE);
     180    }
     181
    158182    /*
    159183     * set transfer mode
     
    237261  int                   ret_cnt = 0;
    238262  /*
    239    * FIXME: check arguments
    240    */
    241   if (rc == RTEMS_SUCCESSFUL) {
     263   * check arguments
     264   */
     265  if (rc == RTEMS_SUCCESSFUL) {
     266    if ((cnt <= 0)                      ||
     267        (cnt > M25P40_TOTAL_SIZE)       ||
     268        (off > (M25P40_TOTAL_SIZE-cnt))) {
     269      rc = RTEMS_INVALID_SIZE;
     270    }
     271    else if (buf == NULL) {
     272      rc = RTEMS_INVALID_ADDRESS;
     273    }
    242274  }
    243275  /*
  • c/src/libchip/i2c/spi-flash-m25p40.h

    rc47890c r7a4e8e7c  
    1717\*===============================================================*/
    1818/*
    19  * FIXME: currently, this driver only supports read accesses
    20  * write/erase accesses are to be completed
     19 * FIXME: currently, this driver only supports read/write accesses
     20 * erase accesses are to be completed
    2121 */
    2222
Note: See TracChangeset for help on using the changeset viewer.