Changeset dccd351 in rtems


Ignore:
Timestamp:
Aug 20, 2008, 5:30:07 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
ccec63e
Parents:
85bca3f
Message:

2008-08-20 Sebastian Huber <sebastian.huber@…>

  • libchip/i2c/spi-sd-card.c: Fixed integer conversion warnings.
Location:
c/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/ChangeLog

    r85bca3f rdccd351  
     12008-08-20      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * libchip/i2c/spi-sd-card.c: Fixed integer conversion warnings.
     4
    152008-08-19      Joel Sherrill <joel.sherrill@OARcorp.com>
    26
  • c/src/libchip/i2c/spi-sd-card.c

    r85bca3f rdccd351  
    3737static inline uint16_t sd_card_get_uint16( const uint8_t *s)
    3838{
    39         return ((uint16_t) s [0] << 8) | ((uint16_t) s [1]);
     39        return (uint16_t) ((s [0] << 8) | s [1]);
    4040}
    4141
    4242static inline uint32_t sd_card_get_uint32( const uint8_t *s)
    4343{
    44         return ((uint32_t) s [0] << 24) | ((uint32_t) s [1] << 16) | ((uint32_t) s [2] << 8) | ((uint32_t) s [3]);
     44        return ((uint32_t) s [0] << 24) | ((uint32_t) s [1] << 16) | ((uint32_t) s [2] << 8) | (uint32_t) s [3];
    4545}
    4646
    4747static inline void sd_card_put_uint16( uint16_t v, uint8_t *s)
    4848{
    49         *s++ = v >> 8;
    50         *s   = v;
     49        *s++ = (uint8_t) (v >> 8);
     50        *s   = (uint8_t) (v);
    5151}
    5252
    5353static inline void sd_card_put_uint32( uint32_t v, uint8_t *s)
    5454{
    55         *s++ = v >> 24;
    56         *s++ = v >> 16;
    57         *s++ = v >> 8;
    58         *s   = v;
     55        *s++ = (uint8_t) (v >> 24);
     56        *s++ = (uint8_t) (v >> 16);
     57        *s++ = (uint8_t) (v >> 8);
     58        *s   = (uint8_t) (v);
    5959}
    6060
     
    117117 */
    118118
    119 #define SD_CARD_COMMAND_SET_COMMAND( c, cmd) (c) [1] = 0x40 + ((cmd) & 0x3f)
     119#define SD_CARD_COMMAND_SET_COMMAND( c, cmd) (c) [1] = (uint8_t) (0x40 + ((cmd) & 0x3f))
    120120#define SD_CARD_COMMAND_SET_ARGUMENT( c, arg) sd_card_put_uint32( (arg), &((c) [2]))
    121121#define SD_CARD_COMMAND_SET_CRC7( c, crc7) ((c) [6] = (crc7) << 1)
     
    169169#define SD_CARD_CSD_GET_SPEC_VERS( csd) (((csd) [0] >> 2) & 0xf)
    170170#define SD_CARD_CSD_GET_TAAC( csd) ((csd) [1])
    171 #define SD_CARD_CSD_GET_NSAC( csd) ((csd) [2])
     171#define SD_CARD_CSD_GET_NSAC( csd) ((uint32_t) (csd) [2])
    172172#define SD_CARD_CSD_GET_TRAN_SPEED( csd) ((csd) [3])
    173 #define SD_CARD_CSD_GET_C_SIZE( csd) ((((csd) [6] & 0x3) << 10) + ((csd) [7] << 2) + (((csd) [8] >> 6) & 0x3))
     173#define SD_CARD_CSD_GET_C_SIZE( csd) ((((uint32_t) (csd) [6] & 0x3) << 10) + ((uint32_t) (csd) [7] << 2) + (((uint32_t) (csd) [8] >> 6) & 0x3))
    174174#define SD_CARD_CSD_GET_C_SIZE_MULT( csd) ((((csd) [9] & 0x3) << 1) + (((csd) [10] >> 7) & 0x1))
    175 #define SD_CARD_CSD_GET_READ_BLK_LEN( csd) ((csd) [5] & 0xf)
     175#define SD_CARD_CSD_GET_READ_BLK_LEN( csd) ((uint32_t) (csd) [5] & 0xf)
    176176#define SD_CARD_CSD_GET_WRITE_BLK_LEN( csd) ((((csd) [12] & 0x3) << 2) + (((csd) [13] >> 6) & 0x3))
    177177
     
    201201{
    202202        uint32_t size = SD_CARD_CSD_GET_C_SIZE( csd);
    203         uint32_t mult = 1 << (SD_CARD_CSD_GET_C_SIZE_MULT( csd) + 2);
     203        uint32_t mult = 1U << (SD_CARD_CSD_GET_C_SIZE_MULT( csd) + 2);
    204204        return (size + 1) * mult;
    205205}
     
    207207static inline uint32_t sd_card_capacity( const uint8_t *csd)
    208208{
    209         uint32_t block_size = 1 << SD_CARD_CSD_GET_READ_BLK_LEN( csd);
     209        uint32_t block_size = 1U << SD_CARD_CSD_GET_READ_BLK_LEN( csd);
    210210        return sd_card_block_number( csd) * block_size;
    211211}
     
    284284{
    285285        uint64_t ac = sd_card_access_time( csd);
    286         ac = (ac * (uint64_t) transfer_speed) / 8000000000ULL;
    287286        uint32_t n = SD_CARD_CSD_GET_NSAC( csd) * 100;
    288         return n + ac;
     287        ac = (ac * transfer_speed) / 8000000000ULL;
     288        return n + (uint32_t) ac;
    289289}
    290290
     
    331331{
    332332        int rv = 0;
    333         rtems_libi2c_read_write_t rw = { rd_buf : e->response, wr_buf : e->command, byte_cnt : SD_CARD_COMMAND_SIZE };
     333        rtems_libi2c_read_write_t rw = {
     334                .rd_buf = e->response,
     335                .wr_buf = e->command,
     336                .byte_cnt = SD_CARD_COMMAND_SIZE
     337        };
    334338        int r = 0;
    335339
     
    595599                rv = sd_card_send_command( e, SD_CARD_CMD_READ_SINGLE_BLOCK, start_address);
    596600                CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Send: SD_CARD_CMD_READ_SINGLE_BLOCK");
    597                 rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, (uint8_t *) r->bufs [0].buffer, e->block_size);
     601                rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, (uint8_t *) r->bufs [0].buffer, (int) e->block_size);
    598602                CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Read: SD_CARD_CMD_READ_SINGLE_BLOCK");
    599603        } else {
     
    612616#endif /* DEBUG */
    613617
    614                         rv = sd_card_read( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ, (uint8_t *) r->bufs [i].buffer, e->block_size);
     618                        rv = sd_card_read( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ, (uint8_t *) r->bufs [i].buffer, (int) e->block_size);
    615619                        CLEANUP_RV( rv, sd_card_disk_block_read_stop_cleanup, "Read block");
    616620                }
     
    682686                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_BLOCK, start_address);
    683687                CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Send: SD_CARD_CMD_WRITE_BLOCK");
    684                 rv = sd_card_write( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE, (uint8_t *) r->bufs [0].buffer, e->block_size);
     688                rv = sd_card_write( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE, (uint8_t *) r->bufs [0].buffer, (int) e->block_size);
    685689                CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Write: SD_CARD_CMD_WRITE_BLOCK");
    686690        } else {
     
    699703#endif /* DEBUG */
    700704
    701                         rv = sd_card_write( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE, (uint8_t *) r->bufs [i].buffer, e->block_size);
     705                        rv = sd_card_write( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE, (uint8_t *) r->bufs [i].buffer, (int) e->block_size);
    702706                        CLEANUP_RV( rv, sd_card_disk_block_write_stop_cleanup, "Write block");
    703707                }
     
    917921        e->transfer_mode.baudrate = transfer_speed;
    918922        e->n_ac_max = sd_card_max_access_time( block, transfer_speed);
    919         read_block_size = 1 << SD_CARD_CSD_GET_READ_BLK_LEN( block);
     923        read_block_size = 1U << SD_CARD_CSD_GET_READ_BLK_LEN( block);
    920924        e->block_size_shift = SD_CARD_CSD_GET_READ_BLK_LEN( block);
    921         write_block_size = 1 << e->block_size_shift;
     925        write_block_size = 1U << e->block_size_shift;
    922926        if (read_block_size < write_block_size) {
    923927                SYSLOG_ERROR( "Read block size smaller than write block size\n");
     
    945949
    946950        /* Create disk device */
    947         dev = rtems_filesystem_make_dev_t( sd_card_disk_major, e->table_index);
     951        dev = rtems_filesystem_make_dev_t( sd_card_disk_major, (rtems_device_minor_number) e->table_index);
    948952        sc = rtems_disk_io_initialize();
    949953        CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Initialize RTEMS disk IO");
    950         sc = rtems_disk_create_phys( dev, e->block_size, e->block_number, sd_card_disk_ioctl, e->disk_device_name);
     954        sc = rtems_disk_create_phys( dev, (int) e->block_size, (int) e->block_number, sd_card_disk_ioctl, e->disk_device_name);
    951955        CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Create disk device");
    952956
     
    989993        /* Check arguments */
    990994        block_size_mask = e->block_size - 1;
    991         block_count = rw->count >> e->block_size_shift;
    992         start_block = rw->offset >> e->block_size_shift;
     995        block_count = (uint32_t) rw->count >> e->block_size_shift;
     996        start_block = (uint32_t) rw->offset >> e->block_size_shift;
    993997        if (rw->offset & block_size_mask) {
    994998                DO_CLEANUP_SC( RTEMS_INVALID_ADDRESS, sc, sd_card_driver_read_cleanup, "Invalid offset");
     
    10011005        } else if (block_count == 1) {
    10021006                /* Single block read */
    1003                 rv = sd_card_send_command( e, SD_CARD_CMD_READ_SINGLE_BLOCK, rw->offset);
     1007                rv = sd_card_send_command( e, SD_CARD_CMD_READ_SINGLE_BLOCK, (uint32_t) rw->offset);
    10041008                CLEANUP_RVSC( rv, sc, sd_card_driver_read_cleanup, "Send: SD_CARD_CMD_READ_SINGLE_BLOCK");
    1005                 rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, (uint8_t *) rw->buffer, e->block_size);
     1009                rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, (uint8_t *) rw->buffer, (int) e->block_size);
    10061010                CLEANUP_RVSC( rv, sc, sd_card_driver_read_cleanup, "Read: SD_CARD_CMD_READ_SINGLE_BLOCK");
    10071011
    10081012                /* Set moved bytes counter */
    1009                 rw->bytes_moved = rv;
     1013                rw->bytes_moved = (uint32_t) rv;
    10101014        } else {
    10111015                /* Start multiple block read */
    1012                 rv = sd_card_send_command( e, SD_CARD_CMD_READ_MULTIPLE_BLOCK, rw->offset);
     1016                rv = sd_card_send_command( e, SD_CARD_CMD_READ_MULTIPLE_BLOCK, (uint32_t) rw->offset);
    10131017                CLEANUP_RVSC( rv, sc, sd_card_driver_read_stop_cleanup, "Send: SD_CARD_CMD_READ_MULTIPLE_BLOCK");
    10141018
    10151019                /* Multiple block read */
    10161020                for (i = 0; i < block_count; ++i) {
    1017                         rv = sd_card_read( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ, (uint8_t *) rw->buffer + (i << e->block_size_shift), e->block_size);
     1021                        rv = sd_card_read( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ, (uint8_t *) rw->buffer + (i << e->block_size_shift), (int) e->block_size);
    10181022                        CLEANUP_RVSC( rv, sc, sd_card_driver_read_stop_cleanup, "Read block");
    10191023
    10201024                        /* Update moved bytes counter */
    1021                         rw->bytes_moved += rv;
     1025                        rw->bytes_moved += (uint32_t) rv;
    10221026                }
    10231027
     
    10701074        /* Check arguments */
    10711075        block_size_mask = e->block_size - 1;
    1072         block_count = rw->count >> e->block_size_shift;
    1073         start_block = rw->offset >> e->block_size_shift;
     1076        block_count = (uint32_t) rw->count >> e->block_size_shift;
     1077        start_block = (uint32_t) rw->offset >> e->block_size_shift;
    10741078        if (rw->offset & block_size_mask) {
    10751079                DO_CLEANUP_SC( RTEMS_INVALID_ADDRESS, sc, sd_card_driver_write_cleanup, "Invalid offset");
     
    10821086        } else if (block_count == 1) {
    10831087                /* Single block write */
    1084                 rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_BLOCK, rw->offset);
     1088                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_BLOCK, (uint32_t) rw->offset);
    10851089                CLEANUP_RVSC( rv, sc, sd_card_driver_write_cleanup, "Send: SD_CARD_CMD_WRITE_BLOCK");
    1086                 rv = sd_card_write( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE, (uint8_t *) rw->buffer, e->block_size);
     1090                rv = sd_card_write( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE, (uint8_t *) rw->buffer, (int) e->block_size);
    10871091                CLEANUP_RVSC( rv, sc, sd_card_driver_write_cleanup, "Write: SD_CARD_CMD_WRITE_BLOCK");
    10881092
    10891093                /* Set moved bytes counter */
    1090                 rw->bytes_moved = rv;
     1094                rw->bytes_moved = (uint32_t) rv;
    10911095        } else {
    10921096                /* Start multiple block write */
    1093                 rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_MULTIPLE_BLOCK, rw->offset);
     1097                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_MULTIPLE_BLOCK, (uint32_t) rw->offset);
    10941098                CLEANUP_RVSC( rv, sc, sd_card_driver_write_stop_cleanup, "Send: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
    10951099
    10961100                /* Multiple block write */
    10971101                for (i = 0; i < block_count; ++i) {
    1098                         rv = sd_card_write( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE, (uint8_t *) rw->buffer + (i << e->block_size_shift), e->block_size);
     1102                        rv = sd_card_write( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE, (uint8_t *) rw->buffer + (i << e->block_size_shift), (int) e->block_size);
    10991103                        CLEANUP_RVSC( rv, sc, sd_card_driver_write_stop_cleanup, "Write: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
    11001104
    11011105                        /* Update moved bytes counter */
    1102                         rw->bytes_moved += rv;
     1106                        rw->bytes_moved += (uint32_t) rv;
    11031107                }
    11041108
Note: See TracChangeset for help on using the changeset viewer.