Changeset 868ca746 in rtems


Ignore:
Timestamp:
Jan 2, 2018, 3:40:21 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
a59a6182
Parents:
f9027ccf
git-author:
Sebastian Huber <sebastian.huber@…> (01/02/18 15:40:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/07/18 07:58:29)
Message:

libblock: Use self-contained mutex for sparse disk

Update #2843.

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/sparse-disk.h

    rf9027ccf r868ca746  
    2828#include <rtems.h>
    2929#include <rtems/diskdevs.h>
     30#include <rtems/thread.h>
    3031
    3132#ifdef __cplusplus
     
    5152
    5253struct rtems_sparse_disk {
    53   rtems_id                         mutex;
     54  rtems_mutex                      mutex;
    5455  rtems_blkdev_bnum                blocks_with_buffer;
    5556  size_t                           used_count;
  • cpukit/libblock/src/sparse-disk.c

    rf9027ccf r868ca746  
    5959  const uint8_t                                                     fill_pattern )
    6060{
    61   rtems_status_code sc;
    6261  rtems_blkdev_bnum i;
    6362
     
    7978  sd->delete_handler = sparse_disk_delete;
    8079
    81   sc                 = rtems_semaphore_create(
    82     rtems_build_name( 'S', 'P', 'A', 'R' ),
    83     1,
    84     RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY,
    85     0,
    86     &sd->mutex
    87     );
    88 
    89   if ( sc != RTEMS_SUCCESSFUL ) {
    90     return sc;
    91   }
     80  rtems_mutex_init( &sd->mutex, "Sparse Disk" );
    9281
    9382  data                  += sizeof( rtems_sparse_disk );
     
    237226  size_t                  buff_size;
    238227  unsigned int            bytes_handled;
    239   rtems_status_code       sc;
    240 
    241   sc = rtems_semaphore_obtain(sparse_disk->mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    242   if (sc != RTEMS_SUCCESSFUL) {
    243       rtems_fatal_error_occurred( 0xdeadbeef );
    244   }
     228
     229  rtems_mutex_lock( &sparse_disk->mutex );
    245230
    246231  for ( req_buffer = 0;
     
    272257  }
    273258
    274   sc = rtems_semaphore_release( sparse_disk->mutex );
    275   if (sc != RTEMS_SUCCESSFUL) {
    276       rtems_fatal_error_occurred( 0xdeadbeef );
    277   }
     259  rtems_mutex_unlock( &sparse_disk->mutex );
    278260
    279261  if ( 0 > rv )
     
    290272static int sparse_disk_ioctl( rtems_disk_device *dd, uint32_t req, void *argp )
    291273{
    292   rtems_status_code  sc;
    293274  rtems_sparse_disk *sd = rtems_disk_get_driver_data( dd );
    294275
     
    304285    }
    305286  } else if ( RTEMS_BLKIO_DELETED == req ) {
    306     sc = rtems_semaphore_delete( sd->mutex );
    307 
    308     if ( RTEMS_SUCCESSFUL != sc )
    309       rtems_fatal_error_occurred( 0xdeadbeef );
    310 
    311     sd->mutex = RTEMS_ID_NONE;
     287    rtems_mutex_destroy( &sd->mutex );
    312288
    313289    if ( NULL != sd->delete_handler )
Note: See TracChangeset for help on using the changeset viewer.