Shell b73396681a
[bsp/allwinner] feat: porting to RT_USING_DEVICE_OPS (#9142)
* [bsp/allwinner] feat: porting to RT_USING_DEVICE_OPS

This patch ports the codebase to use the RT_USING_DEVICE_OPS structure,
which is required by v5.1.0 Smart kernel, improves modularity and makes
it easier to manage device operations by consolidating them into a
single structure, enhancing maintainability and future scalability.

Changes:
- Added RT_USING_DEVICE_OPS conditionals to partition.c and drv_sdmmc.c.
- Defined rt_device_ops structures for partition and sdmmc drivers.
- Updated device initialization to use the ops structure if defined.
- Replaced direct function calls with rt_dev_control, rt_dev_read, and
  rt_dev_write macros where applicable.
- Removed redundant us_delay function from os.c.

Signed-off-by: Shell <smokewood@qq.com>

* feat: update configuration

* feat: fixup compiler warning

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-07-09 13:35:03 +08:00

45 lines
1.2 KiB
C

/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-11-11 JasonHu first version
*/
#ifndef DRV_SDMMC_H__
#define DRV_SDMMC_H__
#include <rtdef.h>
#include <rtdevice.h>
#define SDMMC_CARD_NR 2
#define SDMMC_DEV_NAME_DEF "sdmmc0"
struct dev_sdmmc
{
int host_id; /* host id for each card device */
struct rt_device_blk_geometry geometry; /* block geometry */
};
void sd_mmc1_init(void);
void sd_mmc1_deinit(void);
#ifdef RT_USING_DEVICE_OPS
#define rt_dev_has_control(dev) (dev)->ops->control
#define rt_dev_control(dev, cmd, args) (dev)->ops->control(dev, cmd, args)
#define rt_dev_read(dev, pos, buffer, size) (dev)->ops->read(dev, pos, buffer, size)
#define rt_dev_write(dev, pos, buffer, size) (dev)->ops->write(dev, pos, buffer, size)
#else
#define rt_dev_has_control(dev) (dev)->control
#define rt_dev_control(dev, cmd, args) (dev)->control(dev, cmd, args)
#define rt_dev_read(dev, pos, buffer, size) (dev)->read(dev, pos, buffer, size)
#define rt_dev_write(dev, pos, buffer, size) (dev)->write(dev, pos, buffer, size)
#endif
#endif