Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6539431ybi; Wed, 31 Jul 2019 16:36:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxag31GuxIk7Tt7VhAPKWYQL3dYRXw8u0Oy2cfZE9/d+SKrpP/SiMRANfMR8qM3DFbTrA7I X-Received: by 2002:a17:902:bb81:: with SMTP id m1mr39136017pls.125.1564616190429; Wed, 31 Jul 2019 16:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564616190; cv=none; d=google.com; s=arc-20160816; b=B8nMJSxzCdzOOYKkCePpkbR/FJTcvlJWIhGn5GBmoIOyZj8q50WX004EPwvPsEPM9y RkeIE7vGywa9A7qhhyJU1yA8+7lAS+fZkAV8mqM2afidq04VGvUsWmmH9O1ZkgaOi57s ofg/EtL6NPCz8VoNv1vdFrJRRmL/tJ2gW+ZopLaSimLrn6ZGNkLJtEUfVGQt1EkL1MA3 jzcY/v+AyKUfp2o+ZpANhvJCQn83fwEioHVpbWPqq64zopJ6Ho3nS4pRxBCPITJ26L9U 5T5KHSJBeu1Rku+lbY4zDJh1Q8TR4lv91WhI2502b4rlUvY/v6/Koz/prGFsKwNM+MPq aHVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=a10evfwAD+Hsk/+rS/a81Pg1X9pPEg2+w8iwbXmndgQ=; b=IDuDD/fZiqtOzq70scLyZ6a4psAHqvd1FFcQ12p9bzuDlMjhbtaT8n9Apt/ZeO2qSY HxUtxSwOt4YBPhYxQoapINLtxx+99kqr1X/4gW8984C/XYmaJp/efHSfFULHbIvtkXa6 XRCQ8Xy7QFokOEsSUs4HyOUIqxC+N+uEcwuRWvSbcavkZsOU72IPuVtf8KJHbiNl7oSp HmhkIgpi6fkdk/96oOfFSgKrAlxycg3nA88EH7iljMTOHX+HbHGYuNpDRnTKzBZAH3CG OVtirRzEW6ffU7jDJdkuulURxqLL5rdfk3kWW/S4G6qtcgKYjUrrJrNWcVYcM1sDJwq4 lpBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=AvBrsDTt; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si10310173pgh.570.2019.07.31.16.36.14; Wed, 31 Jul 2019 16:36:30 -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=@android.com header.s=20161025 header.b=AvBrsDTt; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731332AbfGaWRM (ORCPT + 99 others); Wed, 31 Jul 2019 18:17:12 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:44866 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731311AbfGaWRJ (ORCPT ); Wed, 31 Jul 2019 18:17:09 -0400 Received: by mail-ot1-f67.google.com with SMTP id b7so21721741otl.11 for ; Wed, 31 Jul 2019 15:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a10evfwAD+Hsk/+rS/a81Pg1X9pPEg2+w8iwbXmndgQ=; b=AvBrsDTtKVpWZKlZbwnKzPkf5f+TVBYWFzf95aUmvH4n1Y3VKfDf4QBLp497o5oNQa YtDnI0+1LbWrRUtm5jKc0nHT39Bt5sSRWT6KDy3dDgednsrf7PwJIfNhsaFdB2SpMIuF MFrRtn3UtjIsRdnPQOtECJcu8vefrAjVfVfvmwTClIOKyyjA3NWKATjgtq5kzbF21EVQ R9J/qCIo6Vjrf2ICh3xxxXS5u/gYrD+fqwxddeBeNFLlrWnEV6GD6azfEUdlnO6YBVJj VjjbGt8WGMq2iEk+OieRyUAX9ivRDxQuiuU6HrRxE1mSvOKtgcLkRD7jM9LvzX+eJ3zv TS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a10evfwAD+Hsk/+rS/a81Pg1X9pPEg2+w8iwbXmndgQ=; b=OfH3itdAQ6phawYqnV4TG9sUExwPPC87Lko8sxsd0TG6YvAAZYG0GovkMkQb5r+hLy 4okDvXdWynb7axtdFbLRfKQzSOK9E7ww3w5eOrlUDgKNWXb7gvNpNREtx0Y/SWgri7mN zWFDgSRjeiGn4Et43HxBfKUSGMeinYK+1LD670mdZ4sdc8VbM0ogQo3E1GVx7KEnSElZ yMzbuPUuBvxaHLf8xK8uGH7eJGMc5+Tvve9h6GPScgipomp7rTMTrxp8ufSnSWG7bW9X VAZHhUKtnZDrVcUJujzi9GOTeEsIUme8PzOO+eiVXgGwJt4OFw6+AnuvxTWQ1YQSdL3O ELDA== X-Gm-Message-State: APjAAAVFErGUZr3VNz0Xj8OQFtzYlptJr5Lt2wCdS96ydL8MrqlvxJ5s Viak79mzgz5hoB4E7lCO90XcbH4XWBA0oaz66Rc= X-Received: by 2002:a9d:4b02:: with SMTP id q2mr56683404otf.312.1564611428275; Wed, 31 Jul 2019 15:17:08 -0700 (PDT) MIME-Version: 1.0 References: <20190731215514.212215-1-trong@android.com> <5d420f45.1c69fb81.35877.3d86@mx.google.com> In-Reply-To: <5d420f45.1c69fb81.35877.3d86@mx.google.com> From: Tri Vo Date: Wed, 31 Jul 2019 15:16:57 -0700 Message-ID: Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs To: Stephen Boyd Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Viresh Kumar , "Rafael J. Wysocki" , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , LKML , Linux PM , "Cc: Android Kernel" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 2:59 PM Stephen Boyd wrote: > > 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 virtual). > > + * @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 = ida_alloc(&wakeup_ida, GFP_KERNEL); > > + if (id < 0) > > + return id; > > + ws->id = id; > > + > > + dev = 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'? I don't really have an opinion on this. Rafael seems to prefer "ws", and he's the maintainer :) > > > + ws->id); > > + if (IS_ERR(dev)) { > > + ida_free(&wakeup_ida, ws->id); > > + return PTR_ERR(dev); > > + } > > + > > + ws->dev = dev; > > + return 0; > > +} > > +EXPORT_SYMBOL_GPL(wakeup_source_sysfs_add); > > + > > +/** > > + * wakeup_source_sysfs_remove - Remove wakeup_source attributes from sysfs. > > + * @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()? oops > > > +} > > +EXPORT_SYMBOL_GPL(wakeup_source_sysfs_remove); > > + > > +static int __init wakeup_sources_sysfs_init(void) > > +{ > > + wakeup_class = 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. will do