mraa.c: fix style of lookup functions
This patch has no changes in function. It fixes three style issues to be more readable and in line to the rest of the codebase: - return types are declared on a separate line - reversal of Yoda conditionals - initialize for loop variable inside loop declaration - Fix styling of pwm lookup doxygen Signed-off-by: Tapani Utriainen <tapani@technexion.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
9545a2e320
commit
dc1255ad75
@@ -258,11 +258,11 @@ int mraa_i2c_lookup(const char* i2c_name);
|
|||||||
int mraa_spi_lookup(const char* spi_name);
|
int mraa_spi_lookup(const char* spi_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get PWM index by PWM name, board must be initialised.
|
* Get PWM index by PWM name, board must be initialised.
|
||||||
*
|
*
|
||||||
* @param pwm_name: Name of PWM. Eg:PWM0
|
* @param pwm_name: Name of PWM. Eg:PWM0
|
||||||
* @return int of MRAA index for PWM or -1 if not found.
|
* @return int of MRAA index for PWM or -1 if not found.
|
||||||
*/
|
*/
|
||||||
int mraa_pwm_lookup(const char* pwm_name);
|
int mraa_pwm_lookup(const char* pwm_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -280,12 +280,12 @@ getSpiLookup(std::string spi_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get PWM index by PWM name, board must be initialised.
|
* Get PWM index by PWM name, board must be initialised.
|
||||||
*
|
*
|
||||||
* @param pwm_name: Name of PWM. Eg:PWM0
|
* @param pwm_name: Name of PWM. Eg:PWM0
|
||||||
* @throws std::invalid_argument if name is not found
|
* @throws std::invalid_argument if name is not found
|
||||||
* @return int of MRAA index for PWM
|
* @return int of MRAA index for PWM
|
||||||
*/
|
*/
|
||||||
inline int
|
inline int
|
||||||
getPwmLookup(std::string pwm_name)
|
getPwmLookup(std::string pwm_name)
|
||||||
{
|
{
|
||||||
|
|||||||
40
src/mraa.c
40
src/mraa.c
@@ -819,8 +819,11 @@ mraa_get_pin_name(int pin)
|
|||||||
return (char*) current_plat->pins[pin].name;
|
return (char*) current_plat->pins[pin].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mraa_gpio_lookup(const char* pin_name)
|
int
|
||||||
|
mraa_gpio_lookup(const char* pin_name)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (plat == NULL) {
|
if (plat == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -829,17 +832,19 @@ int mraa_gpio_lookup(const char* pin_name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
for (i = 0; i < plat->gpio_count; i++) {
|
||||||
for (; i < plat->gpio_count; i++) {
|
if (strcmp(pin_name, plat->pins[i].name) == 0) {
|
||||||
if (0 == strcmp(pin_name, plat->pins[i].name)) {
|
|
||||||
return plat->pins[i].gpio.pinmap;
|
return plat->pins[i].gpio.pinmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mraa_i2c_lookup(const char* i2c_name)
|
int
|
||||||
|
mraa_i2c_lookup(const char* i2c_name)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (plat == NULL) {
|
if (plat == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -848,17 +853,19 @@ int mraa_i2c_lookup(const char* i2c_name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
for (i = 0; i < plat->i2c_bus_count; i++) {
|
||||||
for (; i < plat->i2c_bus_count; i++) {
|
if (strcmp(i2c_name, plat->i2c_bus[i].name) == 0) {
|
||||||
if (0 == strcmp(i2c_name, plat->i2c_bus[i].name)) {
|
|
||||||
return plat->i2c_bus[i].bus_id;
|
return plat->i2c_bus[i].bus_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mraa_spi_lookup(const char* spi_name)
|
int
|
||||||
|
mraa_spi_lookup(const char* spi_name)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (plat == NULL) {
|
if (plat == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -867,17 +874,19 @@ int mraa_spi_lookup(const char* spi_name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
for (i = 0; i < plat->spi_bus_count; i++) {
|
||||||
for (; i < plat->spi_bus_count; i++) {
|
if (strcmp(spi_name, plat->spi_bus[i].name) == 0) {
|
||||||
if (0 == strcmp(spi_name, plat->spi_bus[i].name)) {
|
|
||||||
return plat->spi_bus[i].bus_id;
|
return plat->spi_bus[i].bus_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mraa_pwm_lookup(const char* pwm_name)
|
int
|
||||||
|
mraa_pwm_lookup(const char* pwm_name)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (plat == NULL) {
|
if (plat == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -886,9 +895,8 @@ int mraa_pwm_lookup(const char* pwm_name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
for (i = 0; i < plat->pwm_dev_count; i++) {
|
||||||
for (; i < plat->pwm_dev_count; i++) {
|
if (strcmp(pwm_name, plat->pwm_dev[i].name) == 0) {
|
||||||
if (0 == strcmp(pwm_name, plat->pwm_dev[i].name)) {
|
|
||||||
return plat->pwm_dev[i].index;
|
return plat->pwm_dev[i].index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user