Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1102658ybl; Fri, 6 Dec 2019 11:16:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxe9j+LcIFFb+a1pgRG3gGoSxYIGLVbydGr5SwKgw047Q/r6pGiKQL8zZxAfB66HrnHbynD X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr12774026oto.30.1575659819634; Fri, 06 Dec 2019 11:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575659819; cv=none; d=google.com; s=arc-20160816; b=ruibP4UrVvHYBzE6dO6iJS1lZAUael0zczSktqo/Ud2Hy9WqoO3UgiVe3KTdlFTt0L 8YRM/KBUztGLx0migC+id490iC5MplhpKnoBIlCZtRTZR9rO9XYLlvr3S7m8taZckgiT bEpzFJH0WYZkd6+02ElLZSwCwD5UoTS9kS2EWa6gFCoQgF10jATRwqXgUyEzXzwhiD1S 5CCMuJKzT91e/erozVLGnCFLjhe7Mcmcd6HSKOOtdTZ9uhy+AzOcwQdxBIKRzn2Bbrei IDGUeUEIE8zXaZ41Az4gIrSAKkDpx2WiDQvX+XWGv+23i4T2BGkFzqoZQJwOVY9Ka+RM CEPg== 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=dWXpOimTwenaVBdKiG9dZ3FcmpYa3OZhkX/d4LqtYMY=; b=yxDGddOKnIELFSXwATnWOk0vf3nMbBAfthQY5RbWcSUd8yFHmv/0DupTiZXZHMyNQW ahFzIG6cxn4zeB/u/SXR58cfgXw9bp1bsNXLFzdt71uVoQlvOHzoPH2vYwb/D2jwX6VS 44dntQhTOZrrwc0tR3+/jVXKZ+fHKzL9Skb4V0p+eboxkgJGfSmn7ft4j70selG/vpb2 ro+ekqflx145N3LW0UhOplZzEJGvJCJ8jn5JjMwOWXHQInlpNwsMc51SrynJNyEC/3mU gXji29rDNw8iG1+HFETlofyOAPWUuFeXyKVP+Zgca0Es3ihItVvfcwTSyVhISTLWHGhw aGQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R4THKPT9; 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 i78si7753112oib.1.2019.12.06.11.16.46; Fri, 06 Dec 2019 11:16:59 -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=@chromium.org header.s=google header.b=R4THKPT9; 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 S1726370AbfLFTPs (ORCPT + 99 others); Fri, 6 Dec 2019 14:15:48 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43727 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbfLFTPs (ORCPT ); Fri, 6 Dec 2019 14:15:48 -0500 Received: by mail-pf1-f194.google.com with SMTP id h14so3799176pfe.10 for ; Fri, 06 Dec 2019 11:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dWXpOimTwenaVBdKiG9dZ3FcmpYa3OZhkX/d4LqtYMY=; b=R4THKPT9e2z0+N0yWZKPw/8yGeOLtcWd8zEIwU/WVcengfgiuqzJ7MVVnq2qw+Brji +oo22CBINwDdoHamQKCVERZo0y5sc6U8L4nWLEzWFokuaSiy4I0u2RcbAg/twolkUK6m +m4dB9uDgCh4IqOxVSOH+FHWpQQu6YwlwB+cg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dWXpOimTwenaVBdKiG9dZ3FcmpYa3OZhkX/d4LqtYMY=; b=HwJnOCc+SvidvmD3G5N+BPTlgUBlTRMXiAwyM6XXfqKzWsyMAhSsDaXThmY2D2bXh5 YdlaV5B+IfFjBLSKE9atKn4JbeixUS7vU/Xun9vzC4YPqkYcsRXq+fa32sFeUxqWKHJF N0p5keT66F3mwtAP133ZYTchBtXXKI5TuBxKPNeJz2MtECHm15bg136+ZnsGgmJfORCH /dsWFGdfoztriq2nNixWmDu75x1w1qK3BeCDYnwlVAzbLloYPETf8Ws9hBBC/WV4nDPe jfACxkN2tTGpAcinpyy3D6GbfvzgDBTilVsC388CW+S9zGDio7TmFQTHjRI7o68n+SLJ jd0Q== X-Gm-Message-State: APjAAAV3f2HbRg7GY8lFhD21Sw91VQHKHBV5UEJ6hh+vle2LQmYaW9O2 aYIbKJLHpBZuNQxiJPxr3KLMk4lWR2E2uA== X-Received: by 2002:a63:cf41:: with SMTP id b1mr5207454pgj.53.1575659747397; Fri, 06 Dec 2019 11:15:47 -0800 (PST) Received: from localhost ([2620:15c:202:1:4fff:7a6b:a335:8fde]) by smtp.gmail.com with ESMTPSA id u1sm16718126pfn.133.2019.12.06.11.15.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2019 11:15:46 -0800 (PST) Date: Fri, 6 Dec 2019 11:15:45 -0800 From: Matthias Kaehlcke To: Wei Wang Cc: wei.vince.wang@gmail.com, Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: Re: [PATCH v3 3/3] thermal: create softlink by name for thermal_zone and cooling_device Message-ID: <20191206191545.GO228856@google.com> References: <20191205071953.121511-1-wvw@google.com> <20191205071953.121511-4-wvw@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191205071953.121511-4-wvw@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 04, 2019 at 11:19:53PM -0800, 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. This is useful, especially for systems with plenty of thermal zones :) > Signed-off-by: Wei Wang > Reviewed-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); > Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke