From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4708C43603 for ; Fri, 12 Mar 2021 17:04:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0A4765039 for ; Fri, 12 Mar 2021 17:04:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232627AbhCLRDn (ORCPT ); Fri, 12 Mar 2021 12:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbhCLRDd (ORCPT ); Fri, 12 Mar 2021 12:03:33 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2839C061765 for ; Fri, 12 Mar 2021 09:03:32 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id g8so4223807wmd.4 for ; Fri, 12 Mar 2021 09:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MotLWcKEAwk5d5cO6koO4+5PW/4j89nsIKT3D/mQf/k=; b=uMtJEddo/apKTRPUpOe2gBO64mOi6Yx8nCGsweTIrjBzQqQHeNSzCxx/SPxRKio4u/ U7BV3QGxk6DASUj8myYOxUyrTFoT0pzakXnV8hbPTE7UZLt8yQo6eO0viDSTU/qaC+qZ lAoe28FX8HqNtbXukl0zwTGL4OX+KSa8C2OmK0ccHrs5LCmDFJe2rV4Ww0DbK6pnELrM 1AS2u3vIxkWOA0mcbPVdGfdmDhRDHoJW/s6iv3ZGb9GdkAow2LIVMtyOg32zhRYQRFKf TgaV0+CUAVYL+D78Y0BYs3HcqjHPo5WlYL/UKYYu1vUrzjF1noh3lUSHqaw0uwUShVS4 scsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MotLWcKEAwk5d5cO6koO4+5PW/4j89nsIKT3D/mQf/k=; b=TPQ6Jocx235M3Vn5QGQ8h0LmH5vQsIyP5P0F/V0/58F4yCjZBQUC7yr8LAodjwpALi 5xmswLHamyNl4oji76u5uZhvV3hkklpgvN5BQtOLvazqJY/+4bJIJLikw98yoKVSXJlk TxLGXkPQBLZevH7gPgARco/8WsKs1xDTW/88mc8Kf3qgOaSzZIcsVcGXYc4NnVgFN8Ve giZrz0+DOJwtqmMZ5GLCuwWi6lNQGRYHi95vuBdW9DdpT5HqL4vonAizmr2i4a+qEW/o envtuj9jfvJIxsUbDahgUR3jNEv/roO9dgkBRiTNE0UUG3/jahFdmwbJ9AIJfwlQGmCL SpXQ== X-Gm-Message-State: AOAM533qMN1H8tsaQZVocXoBbqJECXEXVfwy6N0yvYedh/aOGkMOIRVo WGMA8oF5LJlT5vYeeQg/KtLyxQ== X-Google-Smtp-Source: ABdhPJxKajnxOKuPd+qw3KDRxr/khkMZ8IayzUVFqFSw+JlCxAg9QeT2CwDLpQsCx59ySooB/RWvow== X-Received: by 2002:a1c:4182:: with SMTP id o124mr14271973wma.61.1615568611445; Fri, 12 Mar 2021 09:03:31 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id 1sm2854681wmj.2.2021.03.12.09.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:31 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Zhang Rui , Amit Kucheria Subject: [PATCH v2 3/5] thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering Date: Fri, 12 Mar 2021 18:03:14 +0100 Message-Id: <20210312170316.3138-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210312170316.3138-1-daniel.lezcano@linaro.org> References: <20210312170316.3138-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the naming of a cooling device is just a cooling technique followed by a number. When there are multiple cooling devices using the same technique, it is impossible to clearly identify the related device as this one is just a number. For instance: thermal-devfreq-0 thermal-devfreq-1 etc ... The 'thermal' prefix is redundant with the subsystem namespace. This patch removes the 'thermal' prefix and changes the number by the device name. So the naming above becomes: devfreq-5000000.gpu devfreq-1d84000.ufshc etc ... Signed-off-by: Daniel Lezcano --- V2: - Removed idr.h header - Used kasprintf instead of fixed buffer length on the stack - Fixed typo in the log --- drivers/thermal/devfreq_cooling.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index fed3121ff2a1..fb250ac16f50 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -25,11 +24,8 @@ #define HZ_PER_KHZ 1000 #define SCALE_ERROR_MITIGATION 100 -static DEFINE_IDA(devfreq_ida); - /** * struct devfreq_cooling_device - Devfreq cooling device - * @id: unique integer value corresponding to each * devfreq_cooling_device registered. * @cdev: Pointer to associated thermal cooling device. * @devfreq: Pointer to associated devfreq device. @@ -51,7 +47,6 @@ static DEFINE_IDA(devfreq_ida); * @em_pd: Energy Model for the associated Devfreq device */ struct devfreq_cooling_device { - int id; struct thermal_cooling_device *cdev; struct devfreq *devfreq; unsigned long cooling_state; @@ -363,7 +358,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, struct thermal_cooling_device *cdev; struct device *dev = df->dev.parent; struct devfreq_cooling_device *dfc; - char dev_name[THERMAL_NAME_LENGTH]; + char *name; int err, num_opps; dfc = kzalloc(sizeof(*dfc), GFP_KERNEL); @@ -407,30 +402,27 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, if (err < 0) goto free_table; - err = ida_simple_get(&devfreq_ida, 0, 0, GFP_KERNEL); - if (err < 0) + cdev = ERR_PTR(-ENOMEM); + name = kasprintf(GFP_KERNEL, "devfreq-%s", dev_name(dev)); + if (!name) goto remove_qos_req; - dfc->id = err; - - snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id); - - cdev = thermal_of_cooling_device_register(np, dev_name, dfc, + cdev = thermal_of_cooling_device_register(np, name, dfc, &devfreq_cooling_ops); + kfree(name); + if (IS_ERR(cdev)) { err = PTR_ERR(cdev); dev_err(dev, "Failed to register devfreq cooling device (%d)\n", err); - goto release_ida; + goto remove_qos_req; } dfc->cdev = cdev; return cdev; -release_ida: - ida_simple_remove(&devfreq_ida, dfc->id); remove_qos_req: dev_pm_qos_remove_request(&dfc->req_max_freq); free_table: @@ -527,7 +519,6 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev) dev = dfc->devfreq->dev.parent; thermal_cooling_device_unregister(dfc->cdev); - ida_simple_remove(&devfreq_ida, dfc->id); dev_pm_qos_remove_request(&dfc->req_max_freq); em_dev_unregister_perf_domain(dev); -- 2.17.1