fixed the return value in rt_spi_bus_attach_device()

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2118 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz@gmail.com 2012-05-15 10:44:39 +00:00
parent 0ce3aa056d
commit 55f5069a5e
2 changed files with 11 additions and 8 deletions

View File

@ -8,7 +8,8 @@ rt_err_t rt_spi_bus_register(struct rt_spi_bus* bus, const char* name, const str
rt_err_t result;
result = rt_spi_bus_device_init(bus, name);
if (result != RT_EOK) return result;
if (result != RT_EOK)
return result;
/* initialize mutex lock */
rt_mutex_init(&(bus->lock), name, RT_IPC_FLAG_FIFO);
@ -22,6 +23,7 @@ rt_err_t rt_spi_bus_register(struct rt_spi_bus* bus, const char* name, const str
rt_err_t rt_spi_bus_attach_device(struct rt_spi_device* device, const char* name, const char* bus_name, void* user_data)
{
rt_err_t result;
rt_device_t bus;
/* get physical spi bus */
@ -31,9 +33,14 @@ rt_err_t rt_spi_bus_attach_device(struct rt_spi_device* device, const char* name
device->bus = (struct rt_spi_bus*)bus;
/* initialize spidev device */
rt_spidev_device_init(device, name);
result = rt_spidev_device_init(device, name);
if (result != RT_EOK)
return result;
rt_memset(&device->config, 0, sizeof(device->config));
device->parent.user_data = user_data;
return RT_EOK;
}
/* not found the host bus */

View File

@ -70,9 +70,7 @@ rt_err_t rt_spi_bus_device_init(struct rt_spi_bus* bus, const char* name)
device->control = _spi_bus_device_control;
/* register to device manager */
rt_device_register(device, name, RT_DEVICE_FLAG_RDWR);
return RT_EOK;
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR);
}
/* SPI Dev device interface, compatible with RT-Thread 0.3.x/1.0.x */
@ -143,7 +141,5 @@ rt_err_t rt_spidev_device_init(struct rt_spi_device* dev, const char* name)
device->control = _spidev_device_control;
/* register to device manager */
rt_device_register(device, name, RT_DEVICE_FLAG_RDWR);
return RT_EOK;
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR);
}