Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3804206ybl; Sun, 8 Dec 2019 23:51:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzRfwz45B9iSRXJ0zV9bQ5v9GFUotY3mQj9dtgkeCr4m4myCbN6Ra7sYr8OBs0v5TQaAxfy X-Received: by 2002:aca:5657:: with SMTP id k84mr23180577oib.113.1575877888606; Sun, 08 Dec 2019 23:51:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575877888; cv=none; d=google.com; s=arc-20160816; b=QnEtUMM+GrbAZr2TDBtH0Ve0rm+oiaEmc/GThbqmxvhuffTSWY/nhwhSmBjDfxjxYF TqL/jbD7vs6rd1wZjFjaq6yKw7QTHgEBYMsRmqEzUwXuAE+NoeCsxBQifGRFjWvo0DUH Y1ktrhRN18jVFOQB+uEGbzt/ITBUIX7K7BM7FFe+cpViEsCzXGiRtDGfNd5YqqeJ8SRD yfFdfypssZ0HL5lDmxOINIFWSrt69cg6mRynjdCPNimkGmo8xOKJ3hodDivc/xXceMow vj5ZmdkwWsGTWRfyU0sVcDbuEmjVQDL7ocrOQ2TCT75r2srUdRlscUbUre4b6Dr1wgEf VSlA== 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=dMbLKo7IRv/SL96161v8eDNqnLEfqzax2XOuOcQOqhc=; b=o7ogAthsHg2cR+3f7cCpT5hxQ9Xo5sf2MYwVND2gIPU343PuNajF55DRIsahTAF1WC nRZiBUl5i9Ewzo2tWQNYlIvZIyXson9AM+pz9KhKva81ae4X9+FlIZ2GTo3FPchqTnc5 eDXP24owSTtx4UjHgi/TQzdMb7S64Z9f2w2XRjSU8cWoIz9ueud6QcYg0L9jkgPOsuP1 Q2ruFW8WCmZ1DE8TrtzDYO+ubXK4OepHEbg3dmdqP0u/zLev5oXwSi6FaPCqC9IW8870 n+GvZHe6/YEtKjPalDyjvuCGHTnttvMpcDSvY45o+iUHfqz4K9eEbZnljbUzcF6/YJKP nKyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=FTja3MW3; 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 j23si10876234otr.48.2019.12.08.23.51.17; Sun, 08 Dec 2019 23:51:28 -0800 (PST) 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=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=FTja3MW3; 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 S1727212AbfLIHmk (ORCPT + 99 others); Mon, 9 Dec 2019 02:42:40 -0500 Received: from mail-vs1-f67.google.com ([209.85.217.67]:38210 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbfLIHmk (ORCPT ); Mon, 9 Dec 2019 02:42:40 -0500 Received: by mail-vs1-f67.google.com with SMTP id y195so9578214vsy.5 for ; Sun, 08 Dec 2019 23:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dMbLKo7IRv/SL96161v8eDNqnLEfqzax2XOuOcQOqhc=; b=FTja3MW3/ER9SYeVjIOLRZSMzRDeb50kqmk6eqJEMPd2U9IzUhtVVfEeckJNCnm5VW a+M/0AEPoBvlPc+PpIaJr+ielIXYcVqYKmrW6HbMb47XxhJrkr9AiJUZVtuL7SJcmjGB GkTM8sB2Jrc4D6EvrI66m03YAfC8iu9VIusI7hqy4McY2wM3WjU3J1K1Ym32zh6JFxpa jDUFu0O5010GL/7Ui98dWTseQgWrSrkSUYWAyWW0bZGylp1YwK5HL3J9WvMuZ4EMbt/6 FpJb6N8GZFkj0XyKYh8T2E5Axi3DKK5l34sxMRvbgfVo9t8iGYNxD962aDoY1twgASQc FCGg== 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=dMbLKo7IRv/SL96161v8eDNqnLEfqzax2XOuOcQOqhc=; b=BRzO5+fIvO+NenqAEJXR7t81sKEUNEl9SUYHkdasvXcf6xtBfQPYTt1HQONGUdhhWG NbD47UbMk0FaU/b4TGJAwgGE4MODuS69wUkg+SsRY+e9xW/LnxWUsk5l3YkEL+G1MugG 8SiNDWP4xB6AYlmMYh0Dz5ppyQEckIiG/Y5WG2uopK8Y2ezhLojKblVP1AqYpSxrrSZ9 4xW/JodoZ9B60fv0SW8Wf8RjaB+JgIFduFJNOcGOT+Fqa0wDBQU8dJx/6gZFkeQPsekV HiBCTJd2xCpWO0z8dSnXjcyrI4063CBGwQvA8olkOlDfqJ7gOFJTKryyW4ILF2ZA09jx kEuw== X-Gm-Message-State: APjAAAUYir96gCYmUsQgcPBJBlHWn3wJ255+imPv5F8eKzl9WC+ELbK4 j0B7oIYmO/CBoXQwe5cM4E1Bzfwvyxy0ZMXy5auy4RHUm203VA== X-Received: by 2002:a67:f8cf:: with SMTP id c15mr19585797vsp.27.1575877358692; Sun, 08 Dec 2019 23:42:38 -0800 (PST) MIME-Version: 1.0 References: <20191205071953.121511-1-wvw@google.com> <20191205071953.121511-4-wvw@google.com> In-Reply-To: <20191205071953.121511-4-wvw@google.com> From: Amit Kucheria Date: Mon, 9 Dec 2019 13:12:27 +0530 Message-ID: Subject: Re: [PATCH v3 3/3] thermal: create softlink by name for thermal_zone and cooling_device To: Wei Wang Cc: Wei Wang , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Linux PM list , LKML 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 Thu, Dec 5, 2019 at 12:50 PM Wei Wang wrote: > > The paths thermal_zone%d and cooling_device%d are not intuitive and the > numbers are subject to change due to device tree change. This usually > leads to tree traversal in userspace code. > The patch creates `tz-by-name' and `cdev-by-name' for thermal zone and > cooling_device respectively. > > Signed-off-by: Wei Wang > Reviewed-by: Amit Kucheria Tested-by: Amit Kucheria > --- > drivers/thermal/thermal_core.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 9db7f72e70f8..7872bd527f3f 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #define CREATE_TRACE_POINTS > #include > @@ -46,6 +47,8 @@ static DEFINE_MUTEX(poweroff_lock); > > static atomic_t in_suspend; > static bool power_off_triggered; > +static struct kobject *cdev_link_kobj; > +static struct kobject *tz_link_kobj; > > static struct thermal_governor *def_governor; > > @@ -999,9 +1002,15 @@ __thermal_cooling_device_register(struct device_node *np, > return ERR_PTR(result); > } > > - /* Add 'this' new cdev to the global cdev list */ > + /* Add 'this' new cdev to the global cdev list and create link*/ > mutex_lock(&thermal_list_lock); > list_add(&cdev->node, &thermal_cdev_list); > + if (!cdev_link_kobj) > + cdev_link_kobj = kobject_create_and_add("cdev-by-name", > + cdev->device.kobj.parent); > + if (!cdev_link_kobj || sysfs_create_link(cdev_link_kobj, > + &cdev->device.kobj, cdev->type)) > + dev_err(&cdev->device, "Failed to create cdev-by-name link\n"); > mutex_unlock(&thermal_list_lock); > > /* Update binding information for 'this' new cdev */ > @@ -1167,6 +1176,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) > } > } > } > + if (cdev_link_kobj) > + sysfs_remove_link(cdev_link_kobj, cdev->type); > > mutex_unlock(&thermal_list_lock); > > @@ -1354,6 +1365,12 @@ thermal_zone_device_register(const char *type, int trips, int mask, > > mutex_lock(&thermal_list_lock); > list_add_tail(&tz->node, &thermal_tz_list); > + if (!tz_link_kobj) > + tz_link_kobj = kobject_create_and_add("tz-by-name", > + tz->device.kobj.parent); > + if (!tz_link_kobj || sysfs_create_link(tz_link_kobj, > + &tz->device.kobj, tz->type)) > + dev_err(&tz->device, "Failed to create tz-by-name link\n"); > mutex_unlock(&thermal_list_lock); > > /* Bind cooling devices for this zone */ > @@ -1425,6 +1442,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) > } > } > } > + if (tz_link_kobj) > + sysfs_remove_link(tz_link_kobj, tz->type); > > mutex_unlock(&thermal_list_lock); > > -- > 2.24.0.393.g34dc348eaf-goog >