On Tue, Jul 30, 2019 at 03:52:28PM -0700, Kalesh Singh wrote: > +#define suspend_attr(_name) \ > +static ssize_t _name##_show(struct kobject *kobj, \ > + struct kobj_attribute *attr, char *buf) \ > +{ \ > + int index; \ > + enum suspend_stat_step step; \ > + char *last_failed_stat = NULL; \ > + \ > + if (strcmp(attr->attr.name, "last_failed_dev") == 0) { \ > + index = suspend_stats._name + REC_FAILED_NUM - 1; \ > + index %= REC_FAILED_NUM; \ > + last_failed_stat = suspend_stats.failed_devs[index]; \ > + return sprintf(buf, "%s\n", last_failed_stat); \ > + } else if (strcmp(attr->attr.name, "last_failed_step") == 0) { \ > + index = suspend_stats._name + REC_FAILED_NUM - 1; \ > + index %= REC_FAILED_NUM; \ > + step = suspend_stats.failed_steps[index]; \ > + last_failed_stat = suspend_step_name(step); \ > + return sprintf(buf, "%s\n", last_failed_stat); \ > + } else if (strcmp(attr->attr.name, "last_failed_errno") == 0) { \ > + index = suspend_stats._name + REC_FAILED_NUM - 1; \ > + index %= REC_FAILED_NUM; \ > + return sprintf(buf, "%d\n", suspend_stats.errno[index]);\ > + } \
For these 3 "special" ones, just have your own show function, no need to cram it into this macro, making a bunch of unused code be generated all the time. thanks, greg k-h