Re: [PATCH v4 5/5] soc: qcom: socinfo: Expose image information
From: Bjorn Andersson
Date: Fri Mar 01 2019 - 14:51:05 EST
On Sun 24 Feb 22:50 PST 2019, Vaishali Thakkar wrote:
> +#define IMAGE_SHOW_OEM(attr) \
> +static int show_ ##attr## _oem(struct seq_file *seq, void *p) \
> +{ \
> + struct smem_image_version *image_version = seq->private; \
> + seq_puts(seq, image_version->oem); \
> + seq_puts(seq, "\n"); \
> + return 0; \
> +} \
> +static int open_ ##attr## _oem(struct inode *inode, struct file *file) \
> +{ \
> + return single_open(file, show_ ##attr## _oem, inode->i_private); \
> +} \
> + \
> +static const struct file_operations qcom_ ##attr## _oem_ops = { \
> + .open = open_ ##attr## _oem, \
> + .read = seq_read, \
> + .llseek = seq_lseek, \
> + .release = single_release, \
> +}
> +
> +#define DEBUGFS_IMAGE_OEM(fname, attr, index) \
> +debugfs_create_file(__stringify(fname), 0400, qcom_socinfo->attr, \
> + &smem_image_version[index], &qcom_ ##attr## _oem_ops)
> +
> +#define IMAGE_SHOW(name) \
> + IMAGE_SHOW_NAME(name); \
> + IMAGE_SHOW_VARIANT(name); \
> + IMAGE_SHOW_OEM(name) \
> +
> +IMAGE_SHOW(boot);
Given that you pass &smem_image_version[index] as "data" it seems that
these instances will only differ in the function name. So you should be
able to have one set of these functions to handle all the images.
> +IMAGE_SHOW(tz);
> +IMAGE_SHOW(rpm);
> +IMAGE_SHOW(apps);
> +IMAGE_SHOW(mpss);
> +IMAGE_SHOW(adsp);
> +IMAGE_SHOW(cnss);
> +IMAGE_SHOW(video);
> +
Regards,
Bjorn