diff options
| author | Bernard Xiong <[email protected]> | 2018-06-10 17:59:17 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2018-06-10 17:59:17 +0800 |
| commit | 884fb70fe9973eaf01a7df04941cbcb0475ba8d5 (patch) | |
| tree | 7c8e3f42629e46b3d7ecb0c8507f67934d9fae47 /components/drivers/mtd | |
| parent | bca65f30a90857287dc1371ddbc8d5f165691c7f (diff) | |
[Kernel] Add device ops feature.
Diffstat (limited to 'components/drivers/mtd')
| -rw-r--r-- | components/drivers/mtd/mtd_nand.c | 16 | ||||
| -rw-r--r-- | components/drivers/mtd/mtd_nor.c | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/components/drivers/mtd/mtd_nand.c b/components/drivers/mtd/mtd_nand.c index 8cd0a03d5d..bf22d889ce 100644 --- a/components/drivers/mtd/mtd_nand.c +++ b/components/drivers/mtd/mtd_nand.c @@ -69,6 +69,18 @@ static rt_err_t _mtd_control(rt_device_t dev, int cmd, void *args) return RT_EOK; } +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops mtd_nand_ops = +{ + _mtd_init, + _mtd_open, + _mtd_close, + _mtd_read, + _mtd_write, + _mtd_control +}; +#endif + rt_err_t rt_mtd_nand_register_device(const char *name, struct rt_mtd_nand_device *device) { @@ -79,12 +91,16 @@ rt_err_t rt_mtd_nand_register_device(const char *name, /* set device class and generic device interface */ dev->type = RT_Device_Class_MTD; +#ifdef RT_USING_DEVICE_OPS + dev->ops = &mtd_nand_ops; +#else dev->init = _mtd_init; dev->open = _mtd_open; dev->read = _mtd_read; dev->write = _mtd_write; dev->close = _mtd_close; dev->control = _mtd_control; +#endif dev->rx_indicate = RT_NULL; dev->tx_complete = RT_NULL; diff --git a/components/drivers/mtd/mtd_nor.c b/components/drivers/mtd/mtd_nor.c index 72bbc5a873..8f37e95f09 100644 --- a/components/drivers/mtd/mtd_nor.c +++ b/components/drivers/mtd/mtd_nor.c @@ -65,6 +65,18 @@ static rt_err_t _mtd_control(rt_device_t dev, int cmd, void *args) return RT_EOK; } +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops mtd_nor_ops = +{ + _mtd_init, + _mtd_open, + _mtd_close, + _mtd_read, + _mtd_write, + _mtd_control +}; +#endif + rt_err_t rt_mtd_nor_register_device(const char *name, struct rt_mtd_nor_device *device) { @@ -75,12 +87,16 @@ rt_err_t rt_mtd_nor_register_device(const char *name, /* set device class and generic device interface */ dev->type = RT_Device_Class_MTD; +#ifdef RT_USING_DEVICE_OPS + dev->ops = &mtd_nor_ops; +#else dev->init = _mtd_init; dev->open = _mtd_open; dev->read = _mtd_read; dev->write = _mtd_write; dev->close = _mtd_close; dev->control = _mtd_control; +#endif dev->rx_indicate = RT_NULL; dev->tx_complete = RT_NULL; |
