Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1489781rdh; Mon, 25 Sep 2023 14:37:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2V4HtSoKsRw/Fuo/san1tRHCAuTHp3lOzUgdTQX7UAc6iYhp2FXiqg8EOPBzz1Pc1MapG X-Received: by 2002:a05:6a20:5504:b0:15e:1351:f333 with SMTP id ko4-20020a056a20550400b0015e1351f333mr5170695pzb.48.1695677842852; Mon, 25 Sep 2023 14:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695677842; cv=none; d=google.com; s=arc-20160816; b=dBcdXX+g2RFOdaB1pOYqeuy4/4fAcf8NL6rAOU+fCQ2J86/M8TXJax8a8PYiVB0RBC w9a/PowCASDdqvl9y/Z7iIr64fvzg+bUepMrtnfbMbMS8/5GdeBAeotgyN8tTmbEF12r 0FvirUKIpUBTqYt0I/dmio4zxSMFNnsVa5MDRBQFKCE3u9tYRzStWprRxT1aC9xhSUQX I65mVx/PNQn0dG/yndgnTA1io5xyABEv6IogfuhFoumyn4ia6s8fzpYb8VieVTPnfUz/ MZXWBOyofG2LvQDimlhYtqrUOGz4b9BRc97HYA2vIEdCdlPmSkLjRGabQHMGJhc1s6/w Wlng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Bu0HFFNzN+SYC+kqOmOQQYu7jnB/SohgqheBtlqneSw=; fh=ZvXsIZrxryzDvS3iPCUWtyWq+2pr1UhX/tZ0585ToNk=; b=jAYp3UkpMkWaiJJ6nbVZ81u4GjJbXa+0Xz1xxSK/W+D9x3w4H9NX0KMg21M1qdpW95 YBJ6P2LAGHE6x8myO7HAcTfu7rJBCR6QQW/GVSkGbw534AxosDiL9cdcvhf0w072gpo/ 2EBizAw7aMqqklen04RmurMqk58yzWnVB2s/gxGDAlR7zp+cNv8Vc+12rO//vd/OFHdH 9h5ByWYnGOOsxTmzO9q6BB5H33MgG08TMNvl2//Ca9GwH0KEi04VDHLq+D3gE9HhuOiR zNWe4JRKDumRC2muPKs0iXAgWeTOkUYFi4r4MuDTPT3xpL12YDq9Z+3Yf4WVMZqycKeQ F6CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qc66hY+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id kt5-20020a170903088500b001bb9a1cf6casi10545880plb.405.2023.09.25.14.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 14:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qc66hY+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 36C9E804C236; Mon, 25 Sep 2023 09:30:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231409AbjIYQ3w (ORCPT + 99 others); Mon, 25 Sep 2023 12:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbjIYQ3v (ORCPT ); Mon, 25 Sep 2023 12:29:51 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C130FB for ; Mon, 25 Sep 2023 09:29:43 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4053c6f0e50so59965675e9.1 for ; Mon, 25 Sep 2023 09:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695659382; x=1696264182; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Bu0HFFNzN+SYC+kqOmOQQYu7jnB/SohgqheBtlqneSw=; b=qc66hY+Lyfqg9pdBgbbXv36sD6myTZ12CQrz1PkvZLKbB5gQARWADGpbr4vBwU2SXK nrOKm0E53jjtqL+TlAPNJ+lKaPDHoJ6bKOy3aV+Bfya5kuRj1vJyXOuOTAD7Y5aOOxrE pVjJgEcNYr4WZzZaLyZDkF2BCLwIjUKv5ocHm+EA+8Grx0dsg4g/xl35Ekt9P2GeNwrI 4st1vv9cdiLsc8zpG9dtc6GDNUqLg8KDoHjTKY0BIA9XfWLHp8+izq56OTILyu86vbo+ eMBlrjFkDy08dwGNbf/Wnf5EZPk5PxqSHkzWZV+R18VVwFOMII6bbyPO2OZYYm4v8b0+ bttw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695659382; x=1696264182; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bu0HFFNzN+SYC+kqOmOQQYu7jnB/SohgqheBtlqneSw=; b=PIbqOknlscsM8YSqVGWVBGymiDqlv2eg/vlIqvIEJ19W7xS9SKecsKrYLHxxu/ZNFg PrnJSd5aiDz5681C128bUBC4sbqDDfTYJPXl9dZ2fla1V7MERxuMt6Vi/PW7LJriQW0T 4+ADXO/a6YxbqstqmiUOQeGzt5eb8qjZY0AYRjz4Tw/ES9aSM5zH3FxCSlDwygbloeyU fEgECqQl85Ro7C9NftEWUrMdUYAmdKagWrthktr252/DOort8g+vDDgDGlAitI1PxNu9 7Ay2NbHyoyOdU+bclXrORU2Qj5wAr6wfOVjuTYqk4qj3dH58njLcmYKNLexgGwNmIp05 UaJA== X-Gm-Message-State: AOJu0Yy/SAfePrFEaq0VaElwGNsYVUwg8qu7wpTIzK2eBvBWzxWkglGp lu0tXs/WvIKt6VnZFzkV/UrhfK0/O77bx1xZ0G0= X-Received: by 2002:a05:600c:331c:b0:405:959e:dc6f with SMTP id q28-20020a05600c331c00b00405959edc6fmr1575140wmp.37.1695659381848; Mon, 25 Sep 2023 09:29:41 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:c0e1:63ab:648b:6287? ([2a05:6e02:1041:c10:c0e1:63ab:648b:6287]) by smtp.googlemail.com with ESMTPSA id v21-20020a7bcb55000000b00404719b05b5sm12708972wmj.27.2023.09.25.09.29.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Sep 2023 09:29:41 -0700 (PDT) Message-ID: <52e946a9-cfc6-3411-68c5-827bdd762af3@linaro.org> Date: Mon, 25 Sep 2023 18:29:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 4/9] ACPI: thermal: Create and populate trip points table earlier Content-Language: en-US To: "Rafael J. Wysocki" , Linux ACPI Cc: LKML , Linux PM , Zhang Rui , Srinivas Pandruvada References: <5708760.DvuYhMxLoT@kreacher> <13346091.uLZWGnKmhe@kreacher> From: Daniel Lezcano In-Reply-To: <13346091.uLZWGnKmhe@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 09:30:02 -0700 (PDT) On 12/09/2023 20:39, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Create and populate the driver's trip points table in acpi_thermal_add() > so as to allow the its data structures to be simplified going forward. > > No intentional functional impact. > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Daniel Lezcano > --- > drivers/acpi/thermal.c | 105 ++++++++++++++++++++++++------------------------- > 1 file changed, 52 insertions(+), 53 deletions(-) > > Index: linux-pm/drivers/acpi/thermal.c > =================================================================== > --- linux-pm.orig/drivers/acpi/thermal.c > +++ linux-pm/drivers/acpi/thermal.c > @@ -688,53 +688,10 @@ static void acpi_thermal_zone_sysfs_remo > } > > static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz, > - unsigned int trip_count) > + unsigned int trip_count, > + int passive_delay) > { > - struct acpi_thermal_trip *acpi_trip; > - struct thermal_trip *trip; > - int passive_delay = 0; > int result; > - int i; > - > - trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL); > - if (!trip) > - return -ENOMEM; > - > - tz->trip_table = trip; > - > - if (tz->trips.critical.valid) { > - trip->type = THERMAL_TRIP_CRITICAL; > - trip->temperature = acpi_thermal_temp(tz, tz->trips.critical.temperature); > - trip++; > - } > - > - if (tz->trips.hot.valid) { > - trip->type = THERMAL_TRIP_HOT; > - trip->temperature = acpi_thermal_temp(tz, tz->trips.hot.temperature); > - trip++; > - } > - > - acpi_trip = &tz->trips.passive.trip; > - if (acpi_trip->valid) { > - passive_delay = tz->trips.passive.tsp * 100; > - > - trip->type = THERMAL_TRIP_PASSIVE; > - trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); > - trip->priv = acpi_trip; > - trip++; > - } > - > - for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { > - acpi_trip = &tz->trips.active[i].trip; > - > - if (!acpi_trip->valid) > - break; > - > - trip->type = THERMAL_TRIP_ACTIVE; > - trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); > - trip->priv = acpi_trip; > - trip++; > - } > > tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz", > tz->trip_table, > @@ -744,10 +701,8 @@ static int acpi_thermal_register_thermal > NULL, > passive_delay, > tz->polling_frequency * 100); > - if (IS_ERR(tz->thermal_zone)) { > - result = PTR_ERR(tz->thermal_zone); > - goto free_trip_table; > - } > + if (IS_ERR(tz->thermal_zone)) > + return PTR_ERR(tz->thermal_zone); > > result = acpi_thermal_zone_sysfs_add(tz); > if (result) > @@ -766,8 +721,6 @@ remove_links: > acpi_thermal_zone_sysfs_remove(tz); > unregister_tzd: > thermal_zone_device_unregister(tz->thermal_zone); > -free_trip_table: > - kfree(tz->trip_table); > > return result; > } > @@ -886,9 +839,13 @@ static void acpi_thermal_check_fn(struct > > static int acpi_thermal_add(struct acpi_device *device) > { > + struct acpi_thermal_trip *acpi_trip; > + struct thermal_trip *trip; > struct acpi_thermal *tz; > unsigned int trip_count; > + int passive_delay = 0; > int result; > + int i; > > if (!device) > return -EINVAL; > @@ -930,9 +887,49 @@ static int acpi_thermal_add(struct acpi_ > > acpi_thermal_guess_offset(tz); > > - result = acpi_thermal_register_thermal_zone(tz, trip_count); > + trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL); > + if (!trip) > + return -ENOMEM; > + > + tz->trip_table = trip; > + > + if (tz->trips.critical.valid) { > + trip->type = THERMAL_TRIP_CRITICAL; > + trip->temperature = acpi_thermal_temp(tz, tz->trips.critical.temperature); > + trip++; > + } > + > + if (tz->trips.hot.valid) { > + trip->type = THERMAL_TRIP_HOT; > + trip->temperature = acpi_thermal_temp(tz, tz->trips.hot.temperature); > + trip++; > + } > + > + acpi_trip = &tz->trips.passive.trip; > + if (acpi_trip->valid) { > + passive_delay = tz->trips.passive.tsp * 100; > + > + trip->type = THERMAL_TRIP_PASSIVE; > + trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); > + trip->priv = acpi_trip; > + trip++; > + } > + > + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { > + acpi_trip = &tz->trips.active[i].trip; > + > + if (!acpi_trip->valid) > + break; > + > + trip->type = THERMAL_TRIP_ACTIVE; > + trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); > + trip->priv = acpi_trip; > + trip++; > + } > + > + result = acpi_thermal_register_thermal_zone(tz, trip_count, passive_delay); > if (result) > - goto free_memory; > + goto free_trips; > > refcount_set(&tz->thermal_check_count, 3); > mutex_init(&tz->thermal_check_lock); > @@ -951,6 +948,8 @@ static int acpi_thermal_add(struct acpi_ > flush_wq: > flush_workqueue(acpi_thermal_pm_queue); > acpi_thermal_unregister_thermal_zone(tz); > +free_trips: > + kfree(tz->trip_table); > free_memory: > kfree(tz); > > > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog