Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5533424ybi; Tue, 30 Jul 2019 22:53:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7+3BgnlmIdgA/4j1wIX+pQIryJURkVnVR23j3nNNPS2Ae1ctjMmkFBLXXuxtBDKYRBlFW X-Received: by 2002:a65:5202:: with SMTP id o2mr87694031pgp.29.1564552417712; Tue, 30 Jul 2019 22:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564552417; cv=none; d=google.com; s=arc-20160816; b=zA3uiWlZN1wXvo/chzL/JmX5vsRfbQnV9dvvz2fAZBXvYYlIBMPHyxSnbN3fSCragK Fw6la+hx87nF6IrHHeyvfSxV1nZdn+mb3BHVWVWw5ROQsjhByHzJdt064VIc/GTcxekx ykaVwRuMxwEfJXCKS+B8Fth9aZjFW3UvEQC0J1a5kRaQrPweMuCJxFe/TcO8sVI3jr26 cm+fyD6/8unZp9sZob0mdAWEYyF5Pd5jQZ8u9Z4R0K+iDLiET1CC7p554TPPPOC1nAEV baTPWzxdvhJ8lLim8PlXHmVUK+48vNZ1Ce9CvKkSyofP9JrRjjBra0zuBFiVyr/VHzs2 KZkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OJB3dsm/Mq3lY/oSCoAMqSt2RuvgKtKZtqyVkn5IJVA=; b=N1yZDgwMl/fsVibM5A2H0KTai99AIWKFSF8MBVaGPdMlD9qnBYejuzn0I2WQRObdCC tF5YhKFZDblBuulM/uMaOn5pnsZNsvaWpbpxl5SxKKWEuVodUjMs++lM1Gf/QUfso9PR Jcr8zcTYMflDkaPTu+f/iNPDnhwcSciBWry4WnBsCBsokWRHp2FyCTRR2vv8B12xnYHq 5BXzAVw7rO4Nqgb3H9YbFG90y4/aMFt030TBj8RQofT6FJjtiG0stOGdWAx/1qaAW6rS U4PJijVppCnWRuoV39JjejXPHuw5nP3yj035fJ7h975hxUqAGHWyTf6Towf+xLPuQsPe 0hFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MKFGBMHT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u20si28572558plq.421.2019.07.30.22.53.22; Tue, 30 Jul 2019 22:53:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MKFGBMHT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728866AbfGaFFx (ORCPT + 99 others); Wed, 31 Jul 2019 01:05:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:49454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728819AbfGaFFx (ORCPT ); Wed, 31 Jul 2019 01:05:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 876212067D; Wed, 31 Jul 2019 05:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564549552; bh=yhXihtzLTh3cZ4DbCQLn/gpfxVbg3F2Z/64dfQ4emZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MKFGBMHTHEVfWcInQ1CNjdKFcCN/CYWnkB6Adfqyxuz/KNl45uy7XiLCQDLkm3/Hy S9Fze0QKyNNcx8WjEjeHRRyiEllyOed/UwWQN/HYSkiLdeo5yjG9X535vINv9VK2n7 3n3kOahytbd713vbUTUnnxoVg9WBe3XE5FozQsek= Date: Wed, 31 Jul 2019 07:05:49 +0200 From: Greg KH To: Kalesh Singh 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 Message-ID: <20190731050549.GA20809@kroah.com> References: <20190730225228.126044-1-kaleshsingh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190730225228.126044-1-kaleshsingh@google.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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