soc: qcom: socinfo: Don't print anything if nothing found
authorStephen Boyd <swboyd@chromium.org>
Mon, 28 Jun 2021 03:01:50 +0000 (20:01 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 19 Jul 2021 20:20:54 +0000 (15:20 -0500)
Let's skip printing anything if there's nothing to see. This makes it so
the file length is 0 instead of 1, for the newline, and helps scripts
figure out if there's anything to see in these files.

Cc: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20210628030150.2627905-1-swboyd@chromium.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/soc/qcom/socinfo.c

index b2f049faa3dfa3618edfd605883fdca4b64962b0..9faf48302f4bc012fd3ea805ea309b71bff943d6 100644 (file)
@@ -417,8 +417,8 @@ QCOM_OPEN(chip_id, qcom_show_chip_id);
 static int show_image_##type(struct seq_file *seq, void *p)              \
 {                                                                \
        struct smem_image_version *image_version = seq->private;  \
-       seq_puts(seq, image_version->type);                       \
-       seq_putc(seq, '\n');                                      \
+       if (image_version->type[0] != '\0')                       \
+               seq_printf(seq, "%s\n", image_version->type);     \
        return 0;                                                 \
 }                                                                \
 static int open_image_##type(struct inode *inode, struct file *file)     \