linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Kalesh Singh <kaleshsingh@google.com>
Cc: rjw@rjwysocki.net, trong@google.com, trong@android.com,
	sspatil@google.com, hridya@google.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH] PM/sleep: Expose suspend stats in sysfs
Date: Wed, 31 Jul 2019 07:05:49 +0200	[thread overview]
Message-ID: <20190731050549.GA20809@kroah.com> (raw)
In-Reply-To: <20190730225228.126044-1-kaleshsingh@google.com>

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

  reply	other threads:[~2019-07-31  5:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 22:52 [PATCH] PM/sleep: Expose suspend stats in sysfs Kalesh Singh
2019-07-31  5:05 ` Greg KH [this message]
2019-07-31 21:29   ` [PATCH v2] " Kalesh Singh
2019-08-01  6:19     ` Greg KH
2019-08-01 16:34       ` Kalesh Singh
2019-08-05 18:29         ` Tri Vo
2019-08-26  9:14     ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190731050549.GA20809@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=hridya@google.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sspatil@google.com \
    --cc=trong@android.com \
    --cc=trong@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).