From d5bfd287c29356012607adf6316eb9f7a7a15e16 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Wed, 22 Jul 2020 18:21:37 +0000 Subject: [PATCH] mmccam: Use a sbuf for the mmc ident function While here fix a typo. --- sys/cam/mmc/mmc_xpt.c | 58 +++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c index c1d0abeb0ade..56b3c2ff5644 100644 --- a/sys/cam/mmc/mmc_xpt.c +++ b/sys/cam/mmc/mmc_xpt.c @@ -408,27 +408,47 @@ mmc_announce_periph(struct cam_periph *periph) void mmc_print_ident(struct mmc_params *ident_data) { - printf("Relative addr: %08x\n", ident_data->card_rca); - printf("Card features: <"); - if (ident_data->card_features & CARD_FEATURE_MMC) - printf("MMC "); - if (ident_data->card_features & CARD_FEATURE_MEMORY) - printf("Memory "); - if (ident_data->card_features & CARD_FEATURE_SDHC) - printf("High-Capacity "); - if (ident_data->card_features & CARD_FEATURE_SD20) - printf("SD2.0-Conditions "); - if (ident_data->card_features & CARD_FEATURE_SDIO) - printf("SDIO "); - printf(">\n"); + struct sbuf *sb; + bool space = false; - if (ident_data->card_features & CARD_FEATURE_MEMORY) - printf("Card memory OCR: %08x\n", ident_data->card_ocr); + sb = sbuf_new_auto(); + sbuf_printf(sb, "Relative addr: %08x\n", ident_data->card_rca); + sbuf_printf(sb, "Card features: <"); + if (ident_data->card_features & CARD_FEATURE_MMC) { + sbuf_printf(sb, "MMC"); + space = true; + } + if (ident_data->card_features & CARD_FEATURE_MEMORY) { + sbuf_printf(sb, "%sMemory", space ? " " : ""); + space = true; + } + if (ident_data->card_features & CARD_FEATURE_SDHC) { + sbuf_printf(sb, "%sHigh-Capacity", space ? " " : ""); + space = true; + } + if (ident_data->card_features & CARD_FEATURE_SD20) { + sbuf_printf(sb, "%sSD2.0-Conditions", space ? " " : ""); + space = true; + } + if (ident_data->card_features & CARD_FEATURE_SDIO) { + sbuf_printf(sb, "%sSDIO", space ? " " : ""); + space = true; + } + sbuf_printf(sb, ">\n"); - if (ident_data->card_features & CARD_FEATURE_SDIO) { - printf("Card IO OCR: %08x\n", ident_data->io_ocr); - printf("Number of funcitions: %u\n", ident_data->sdio_func_count); - } + if (ident_data->card_features & CARD_FEATURE_MEMORY) + sbuf_printf(sb, "Card memory OCR: %08x\n", + ident_data->card_ocr); + + if (ident_data->card_features & CARD_FEATURE_SDIO) { + sbuf_printf(sb, "Card IO OCR: %08x\n", ident_data->io_ocr); + sbuf_printf(sb, "Number of functions: %u\n", + ident_data->sdio_func_count); + } + + sbuf_finish(sb); + printf("%s", sbuf_data(sb)); + sbuf_clear(sb); } static void