Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6478449ybi; Wed, 31 Jul 2019 15:20:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSAJheq1xkiciCq5sl05WcOWROgWgUURZo5wgp5IBRFM+Fn+gibMaOO7LEbJYHPBYkMCy5 X-Received: by 2002:a62:8344:: with SMTP id h65mr49693997pfe.85.1564611645470; Wed, 31 Jul 2019 15:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564611645; cv=none; d=google.com; s=arc-20160816; b=kT3RGiO60APlImVAqkBg49BZto0apIghAv9BE0xVxuj83mzUk+s+c7RYDE2JTyvx+y 2dnk4xL1iLeVslzAiv6Fgm4UdkJydu8Cr778RKohW6+7Ki0KoEyDdk7Z4vklhHaX5wJR 0Pm8EaucWOFAg/wT9YBLvdlkArg3WH1W4aT8dFDOyaV9F6Tex/o8xkTShsl6Qe70/sxA eE/DYfqQBXTowoanAAW6uYEFoN0KlQrvIIWTxLvH5eRgmMwegHW1NXHd1egrgLIk37FN lREtkjmJ8ZnKbIIcpM0Q89+pDFQnDmEQpC36OHABsBXP5zcN4tjmY/PhOvb03xEKZcYW XcnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:subject:to:from:cc :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=IlRwSSoXPkPO8ZlfGQyrA2PVh0oI2jbeG8M+xqYWNuc=; b=fzBHDv/ueuXAA78YqOCfJcsZmqwyjJ2vNVzkEnVRK77ua23Y9UwkTkO5QbaZDiN8Qt SwtkaNJ/HaUO2TjN/C9AdFPGBwt7dZ7MmD/bEgOhb6I5DlI/HthdA+RgB+Jd1p6qeHX5 qztYhm5mqt4HlD8vGYQ3maj7eFsejrySUufTre6sTdAoUsO5S6pgWeWLZJ7K4GDOGuvT fLcIxLII9Ut8lusuvjf+s8pw0tSOE0lvU5T9JCEmLH70k363ckDX9fDXJT/2zpAngy03 HL8/Qkn+xCQvPIZ9mdDAFSSzuXhn7YqjNHfXaEx/w0mZSufLJqyBgYMMd2MX4wowG/e4 Th3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=n3A6uLsc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn22si31689371plb.422.2019.07.31.15.20.30; Wed, 31 Jul 2019 15:20:45 -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=@chromium.org header.s=google header.b=n3A6uLsc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730344AbfGaV7f (ORCPT + 99 others); Wed, 31 Jul 2019 17:59:35 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33798 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbfGaV7f (ORCPT ); Wed, 31 Jul 2019 17:59:35 -0400 Received: by mail-pf1-f195.google.com with SMTP id b13so32614971pfo.1 for ; Wed, 31 Jul 2019 14:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:cc:from:to:subject:user-agent:date; bh=IlRwSSoXPkPO8ZlfGQyrA2PVh0oI2jbeG8M+xqYWNuc=; b=n3A6uLscWmFreF939tyOlPubPIYDf44Y3GSbMd5VGwmGbOLz9PMLsYyy6hnO/F5hv7 HRy2Eq8dQckDsTk18S0fC9yE3YBQk2EeHDpNnOb5HFGvC/FFwabnJ4NyZjZOxhGFbpDJ KsRbZRE0bAvaZy7+ZMWdBaHcQQyv7phuAIuXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:cc:from:to:subject :user-agent:date; bh=IlRwSSoXPkPO8ZlfGQyrA2PVh0oI2jbeG8M+xqYWNuc=; b=MqVZmCoTgEkOS24ymSAHjbVy2qastS011OG5/gbyu3vXBtbHG4PwLYEYlbtsqpPnA4 f+kkmbCXE1tfaBjwJz7lx9HVYVNF9yf39Cxg2/bp1NEnAi9nAX9ufirRmGutnN4bYyUO 7H2UC7sfwnA/vuFhmV+d6wVlECiO2qUN4Z66uI9SLDcYEKuD/g7AI/rjgUCR1+nfk7kz 1h5LzfOjc/cKolQ2cpa17D6gz5Hff6AgbyVCE96BaxEyfJSE5J74e2bBl1heyd7mBKs7 Bjn5i77CmuvCF+CG64jHpRJC4AFm04xxfByveQFthOiPSLuli36fDhDb7VS0S5asKCTZ yy/A== X-Gm-Message-State: APjAAAV1wwBOiSaodE/gi4qR93gXThfJNi1BjP2DNYNYnhyOjyn+Bd4Y pC7HFsa1Zwa1OKF8CDYETf3oJA== X-Received: by 2002:a63:184b:: with SMTP id 11mr55358650pgy.112.1564610374310; Wed, 31 Jul 2019 14:59:34 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id i14sm108093300pfk.0.2019.07.31.14.59.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 14:59:33 -0700 (PDT) Message-ID: <5d420f45.1c69fb81.35877.3d86@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190731215514.212215-1-trong@android.com> References: <20190731215514.212215-1-trong@android.com> Cc: rafael@kernel.org, hridya@google.com, sspatil@google.com, kaleshsingh@google.com, ravisadineni@chromium.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, kernel-team@android.com, Tri Vo From: Stephen Boyd To: Tri Vo , gregkh@linuxfoundation.org, rjw@rjwysocki.net, viresh.kumar@linaro.org Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs User-Agent: alot/0.8.1 Date: Wed, 31 Jul 2019 14:59:32 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Tri Vo (2019-07-31 14:55:14) > +/** > + * wakeup_source_sysfs_add - Add wakeup_source attributes to sysfs. > + * @parent: Device given wakeup source is associated with (or NULL if vi= rtual). > + * @ws: Wakeup source to be added in sysfs. > + */ > +int wakeup_source_sysfs_add(struct device *parent, struct wakeup_source = *ws) > +{ > + struct device *dev; > + int id; > + > + id =3D ida_alloc(&wakeup_ida, GFP_KERNEL); > + if (id < 0) > + return id; > + ws->id =3D id; > + > + dev =3D device_create_with_groups(wakeup_class, parent, MKDEV(0, = 0), ws, > + wakeup_source_groups, "ws%d", I thought the name was going to still be 'wakeupN'? > + ws->id); > + if (IS_ERR(dev)) { > + ida_free(&wakeup_ida, ws->id); > + return PTR_ERR(dev); > + } > + > + ws->dev =3D dev; > + return 0; > +} > +EXPORT_SYMBOL_GPL(wakeup_source_sysfs_add); > + > +/** > + * wakeup_source_sysfs_remove - Remove wakeup_source attributes from sys= fs. > + * @ws: Wakeup source to be removed from sysfs. > + */ > +void wakeup_source_sysfs_remove(struct wakeup_source *ws) > +{ > + device_unregister(ws->dev); > + ida_simple_remove(&wakeup_ida, ws->id); Should be ida_free()? > +} > +EXPORT_SYMBOL_GPL(wakeup_source_sysfs_remove); > + > +static int __init wakeup_sources_sysfs_init(void) > +{ > + wakeup_class =3D class_create(THIS_MODULE, "wakeup"); > + > + return PTR_ERR_OR_ZERO(wakeup_class); > +} > + > +postcore_initcall(wakeup_sources_sysfs_init); Style nitpick: Stick the initcall to the function it calls by dropping the extra newline between them.