Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6563849ybi; Wed, 31 Jul 2019 17:05:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyFWsQAFW+qC9oH454FwyjuowdaBIU03Sl5k72kgB5jtjN6p57y2bBxa1xU1I6pR8FvmpY X-Received: by 2002:a63:d34c:: with SMTP id u12mr101790691pgi.114.1564617934164; Wed, 31 Jul 2019 17:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564617934; cv=none; d=google.com; s=arc-20160816; b=AHXay41rwnKiZWBT2dUAiM9hO59iAOSk70ouAzefsep7yeskfFJAKMoAlizLfvg0l3 DD9Dn+ozCyagc7kJhb+oup6URl6mODeadIXRB6IdXp4VhMnUKVcnYMMvZBca0WYjBhNe 3eye/FvgTVACaXN9xeKHIJ+agnjgpPrl26qWjhgDk0ReSjDQHXTdW1JTlv7qBeBYHKKb PPnvTvfRkBMsxFAJO6A7+T/1YlxAb2+5Q5VoTO73OPShmzlND4TFRx3qS3oHeMbFb2z4 7TM/Ac19EDhT6w0dIT5WvE9psjlGLtR+LCifk9Ldi3mJ502gADgfbdJnwbEvOiu5CqF+ bBvQ== 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=fvayO7XeLTy4X/5U3hiq/uu/ecirEncxcxFHnyvxXOY=; b=CLEeGj3BPRm53ytfohdlSl9fbpyQzw+3i/C+FB/FvN0wK9KSWJIo03Bvd5i5zpp3eq +CkpuioAyVcc5ELqMuxMobCOOpi5136olA9hEymV8FWBDIZyRIphowifNALHGPsP4XII LQDkLRZ+9ZR/zTh5zqbt4bMUl5wuyqGLIOZYbvI3mfY2Pzip+tVjXqX8gYua9OimF35A hJYDtf7hEbfJ29WrbmuyAL3ZGBiq5EYWmp4a6G09aF/QfAhsQAcCgdysjSU0e5Jn6rSR YMyOf2/HSqN4dwijBXgJOviObJso2oWfhJSnj0tzDA2QHBsX/VnDN4Y+m7AZeC2LI27V L3vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=MZwcDUi4; 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 t190si31869868pgd.465.2019.07.31.17.05.18; Wed, 31 Jul 2019 17:05:34 -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=MZwcDUi4; 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 S1730484AbfGaW7F (ORCPT + 99 others); Wed, 31 Jul 2019 18:59:05 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:36537 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfGaW7F (ORCPT ); Wed, 31 Jul 2019 18:59:05 -0400 Received: by mail-oi1-f194.google.com with SMTP id q4so22887314oij.3 for ; Wed, 31 Jul 2019 15:59:04 -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=fvayO7XeLTy4X/5U3hiq/uu/ecirEncxcxFHnyvxXOY=; b=MZwcDUi4tR1G4oOJB4TqUTN5aSX1GloRDcsyDdkg9pgM6Y4OOeIdzBZz+5e9apI2TF SfqkvWNFv8Hp7X83FA7vjkoOPtJiWY9tLmmHUvhcyo+lyjS1ZCHoS2x74bE1dX8YEFPl WAHZ8LyXqJ63ftyyerKaspMAHnrCjY6J5lgp3VSKoHklPJwMsP6DlW2EKdgqv2gg1OmK bdapoa0TuPAT5F5ZICJwjifRuzY7TWULCwViKgLADIwKMa1pOo9W5Mm2T4Tg4ZebCfDH RGeJxb2rwYX219Fyq3lT1DzNEDCkEitB6etiQCdh5Pm2hZyIEE7513zhXdcjE/fH7lGD wnEw== 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=fvayO7XeLTy4X/5U3hiq/uu/ecirEncxcxFHnyvxXOY=; b=hGHnETiobpRsX80dyXqCf3/NGdDwn7sY+TmAtoSHNePlkrey0R8QvgDFT9XFRPdIyY mpkun1KslNQmx9CbHArka2lv7glbevJ+Gqm41h7cj0lGf1YnjDZMUnlUWeONPQvWjV1P x6EfexvzkIu19R0Am9TKyXHfLsnXuGvOWPahAbyVNDzTLQ/+1A3he5s2iNQGNzaihc/8 8FkQ6sKcRjqAsYotNqMTvbL5nIeODE7OOXnr/JbnXVm4M7mH4TB3C2Z1Yc8ZfnQx5+gn 8I3tFd56oKbotlBwL3jVfhDHQeO8NAha2w/VVvQAgq+5Uw8utj4kM58c2Lzogg+Qq98L w9VQ== X-Gm-Message-State: APjAAAUAfX+VdjqrNgsMmMFRLxEpXWKoTg6/YA8cEfMqXd90EQmG27/g pjyOcOnJr2NG3NDmA712nQXsQ2EFZzyYqfdgmX8= X-Received: by 2002:aca:af55:: with SMTP id y82mr59277816oie.172.1564613944162; Wed, 31 Jul 2019 15:59:04 -0700 (PDT) MIME-Version: 1.0 References: <20190731215514.212215-1-trong@android.com> <32598586.Mjd66ZhNnG@kreacher> <6987393.M0uybTKmdI@kreacher> In-Reply-To: <6987393.M0uybTKmdI@kreacher> From: Tri Vo Date: Wed, 31 Jul 2019 15:58:53 -0700 Message-ID: Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs To: "Rafael J. Wysocki" Cc: Stephen Boyd , Greg Kroah-Hartman , 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 3:42 PM Rafael J. Wysocki wrote: > > On Thursday, August 1, 2019 12:31:16 AM CEST Tri Vo wrote: > > On Wed, Jul 31, 2019 at 3:17 PM Rafael J. Wysocki wrote: > > > > > > On Wednesday, July 31, 2019 11:59:32 PM CEST 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); > > > > > > So can anyone remind me why the IDA thing is needed here at all? > > > > IDA is used to generate the directory name ("ws%d", ID) that is unique > > among wakeup_sources. That is what ends up in > > /sys/class/wakeup/ws/* path. > > That's not my point (see below). > > > > > > + 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'? > > > > > > So can't we prefix the wakeup source name with something like "wakeup:" or similar here? > > > > "ws%d" here is the name in the sysfs path rather than the name of the > > wakeup source. Wakeup source name is not altered in this patch. > > > > So why wouldn't something like this suffice: > > dev = device_create_with_groups(wakeup_class, parent, MKDEV(0, 0), ws, > wakeup_source_groups, "wakeup:%s", ws->name); > > ? ws->name is inherited from the device name. IIUC device names are not guaranteed to be unique. So if different devices with the same name register wakeup sources, there is an error.