Changeset dc158ad in rtems


Ignore:
Timestamp:
Dec 8, 2017, 2:47:09 PM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
36304f3
Parents:
2c12262
git-author:
Sebastian Huber <sebastian.huber@…> (12/08/17 14:47:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/02/18 14:01:21)
Message:

i2c: Use self-contained mutex

Update #2843.

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dev/i2c/i2c-bus.c

    r2c12262 rdc158ad  
    88
    99/*
    10  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    3434void i2c_bus_obtain(i2c_bus *bus)
    3535{
    36   rtems_status_code sc;
    37 
    38   sc = rtems_semaphore_obtain(bus->mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    39   _Assert(sc == RTEMS_SUCCESSFUL);
    40   (void) sc;
     36  rtems_recursive_mutex_lock(&bus->mutex);
    4137}
    4238
    4339void i2c_bus_release(i2c_bus *bus)
    4440{
    45   rtems_status_code sc;
    46 
    47   sc = rtems_semaphore_release(bus->mutex);
    48   _Assert(sc == RTEMS_SUCCESSFUL);
    49   (void) sc;
     41  rtems_recursive_mutex_unlock(&bus->mutex);
    5042}
    5143
     
    287279)
    288280{
    289   rtems_status_code sc;
    290 
    291   sc = rtems_semaphore_create(
    292     rtems_build_name('I', '2', 'C', ' '),
    293     1,
    294     RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
    295     0,
    296     &bus->mutex
    297   );
    298   if (sc != RTEMS_SUCCESSFUL) {
    299     (*destroy)(bus);
    300 
    301     rtems_set_errno_and_return_minus_one(ENOMEM);
    302   }
    303 
     281  rtems_recursive_mutex_init(&bus->mutex, "I2C Bus");
    304282  bus->transfer = i2c_bus_transfer_default;
    305283  bus->set_clock = i2c_bus_set_clock_default;
     
    311289void i2c_bus_destroy(i2c_bus *bus)
    312290{
    313   rtems_status_code sc;
    314 
    315   sc = rtems_semaphore_delete(bus->mutex);
    316   _Assert(sc == RTEMS_SUCCESSFUL);
    317   (void) sc;
     291  rtems_recursive_mutex_destroy(&bus->mutex);
    318292}
    319293
  • cpukit/include/dev/i2c/i2c.h

    r2c12262 rdc158ad  
    88
    99/*
    10  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    2929#include <rtems.h>
    3030#include <rtems/seterr.h>
     31#include <rtems/thread.h>
    3132
    3233#include <sys/ioctl.h>
     
    140141   * @brief Mutex to protect the bus access.
    141142   */
    142   rtems_id mutex;
     143  rtems_recursive_mutex mutex;
    143144
    144145  /**
Note: See TracChangeset for help on using the changeset viewer.