Skip to content

Commit

Permalink
fixup! drivers/sdmmc: store SDMMC devs in XFA
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Sep 12, 2023
1 parent 7103611 commit 31402de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions drivers/include/sdmmc/sdmmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1391,29 +1391,29 @@ typedef struct sdmmc_dev {
* @brief SDIO/SD/MMC device descriptor references as read-only XFA
*
* The array contains the references to all SDIO/SD/MMC device descriptors.
* The i-th device in this array can then be accessed with `sdmmc_dev_xfa[i]`.
* The i-th device in this array can then be accessed with `sdmmc_devs[i]`.
* The number of SDIO/SD/MMC device descriptor references defined in this array
* is `XFA_LEN(sdmmc_dev_xfa)`, see @ref SDMMC_NUMOF.
* is `XFA_LEN(sdmmc_devs)`, see @ref SDMMC_NUMOF.
*
* @warning To ensure to have the references to all SDIO/SD/MMC device
* descriptors in this array, the low-level SDIO/SD/MMC peripheral
* drivers must define the references to their SDIO/SD/MMC
* device descriptors as XFA members by using the macro
* `XFA_CONST(sdmmc_dev_xfa, 0)` as shown in the example below.
* `XFA_CONST(sdmmc_devs, 0)` as shown in the example below.
*
* For example, if the low-level
* SDIO/SD/MMC peripheral driver defines an MCU-specific SDIO/SD/MMC
* device descriptor structure `_mcu_sdmmc_dev_t` and defines the device
* descriptors in an array `_mcu_sdmmc_dev`, it must define the references
* to them as members of the XFA `sdmmc_dev_xfa` as follows:
* to them as members of the XFA `sdmmc_devs` as follows:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
* typedef struct {
* sdmmc_dev_t sdmmc_dev; // Inherited sdmmc_dev_t struct
* const sdmmc_conf_t *config; // SDIO/SD/MMC peripheral config
* ...
* } _mcu_sdmmc_dev_t;
*
* static _mcu_sdmmc_dev_t _sdmmc_devs[] = {
* static _mcu_sdmmc_dev_t _mcu_sdmmc_devs[] = {
* {
* ...
* },
Expand All @@ -1422,27 +1422,27 @@ typedef struct sdmmc_dev {
* },
* };
*
* XFA_CONST(sdmmc_dev_xfa, 0) sdmmc_dev_t * const _sdmmc_1 = (sdmmc_dev_t * const)&_sdmmc_devs[0];
* XFA_CONST(sdmmc_dev_xfa, 0) sdmmc_dev_t * const _sdmmc_2 = (sdmmc_dev_t * const)&_sdmmc_devs[1];
* XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_1 = (sdmmc_dev_t * const)&_mcu_sdmmc_devs[0];
* XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_2 = (sdmmc_dev_t * const)&_mcu_sdmmc_devs[1];
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
#if !DOXYGEN
XFA_USE_CONST(sdmmc_dev_t * const, sdmmc_dev_xfa);
XFA_USE_CONST(sdmmc_dev_t * const, sdmmc_devs);
#else
sdmmc_dev_t sdmmc_dev_xfa[];
sdmmc_dev_t sdmmc_devs[];
#endif

/**
* @brief Number of SDIO/SD/MMC devices defined
*/
#define SDMMC_NUMOF XFA_LEN(sdmmc_dev_t *, sdmmc_dev_xfa)
#define SDMMC_NUMOF XFA_LEN(sdmmc_dev_t *, sdmmc_devs)

/**
* @brief Retrieve SDIO/SD/MMC device descriptor reference from device index
*
* The function converts the device index to the corresponding SDIO/SD/MMC
* device descriptor. See also @ref sdmmc_dev_xfa.
* device descriptor. See also @ref sdmmc_devs.
*
* @param[in] num SDIO/SD/MMC peripheral index
*
Expand All @@ -1452,7 +1452,7 @@ sdmmc_dev_t sdmmc_dev_xfa[];
*/
static inline sdmmc_dev_t *sdmmc_get_dev(unsigned num)
{
return (num < SDMMC_NUMOF) ? sdmmc_dev_xfa[num] : NULL;
return (num < SDMMC_NUMOF) ? sdmmc_devs[num] : NULL;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion drivers/sdmmc/sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ typedef struct __attribute__((packed)) {
} sdmmc_sw_status_t;

/* Definition of the XFA for the SDIO/SD/MMC device descriptor references */
XFA_INIT_CONST(sdmmc_dev_t * const, sdmmc_dev_xfa);
XFA_INIT_CONST(sdmmc_dev_t * const, sdmmc_devs);

/* forward declaration of internal functions */
static int _send_cmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg,
Expand Down

0 comments on commit 31402de

Please sign in to comment.