Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1371671lqd; Thu, 25 Apr 2024 13:31:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQzHnYczrEqS20BFtHcPX68lOX2alfINBeLwmyw84ojC0quUkQEa304rXXjyG7x08CCBsKubnEgoFdCB13gedDgS22rHl8ek5+JE4bMQ== X-Google-Smtp-Source: AGHT+IHqZjdw4WlPbpnWNURjLLiFo/30/CH1Vyc5EZ/AmRyXRwDe0XKw2+eAHFQQU7BMXZ4RXFC+ X-Received: by 2002:a05:620a:98c:b0:78b:cfdc:b0fc with SMTP id x12-20020a05620a098c00b0078bcfdcb0fcmr748224qkx.21.1714077084506; Thu, 25 Apr 2024 13:31:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714077084; cv=pass; d=google.com; s=arc-20160816; b=mRowvC9u9VozvXXUh7uSkn8oQduaDCBUasRnUbJkJydnsCbwTULDwFjignFXZafhlp 6nr+ZoEGWaaIyyfUGRFzn5/s1f8Hu41VrBZ40eEsBbTuIg3/MS+dgEq67HRYo6Rm5U2N 1k6MCb1g3xSpcYysIP0d6omfW3qM8kDGRscx5gecqzrdvl+EpUjz4ISPU8aGYAl6TdLg 5/d26IWlf8J3I0dWhMI0w4RneX6DbX7DKimGNfU6EKrFXSyJhAuVeub2+0f4SBQbZ3Vu NWU2H52DzkovM97OjXfzWodeuWfEvoZG+EbL6hCjGJML3khLe/RvusOJb3i79BMQDQ+z Pwfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=e7madoGDiQb/CUl1wDXflXubn/gStLn3yM/aUvmPnUQ=; fh=h9nNuJWR4ctz4+GxKcJXmDY5jwsz2gCTobzLEpm29x4=; b=K35m3GB8dmC7rACF3u7zEc86Sox4N/U07TuN4rUfTiT7YM+6TLAqeS+KcghdAQOWb2 D677R3BIUURF15iKZw949EkTBqSKEWMa1Qjoj5VgipmOl1O6+b6UiTPnnQBrsk8TiOYe WTCiqaLgq0RBqlCWD3oiQy4CacH1rZe0P0s1+D43GcZnqfMdSvYIrSBdGRBk4IgfSNp6 xkp91QuCIO+PAWKyngUB13baLWZOa0p5UGt6eInEJ1cOl/l74ZakqVkuFer4KULc5NFl BMwz1GCR6bY0ihGiR1tQqxDqtgX7G/fJppxPo4bQDsEPVoOQyBv95vRL+BdSAPXfXOkQ qBZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DzsWM7X4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159141-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159141-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vw2-20020a05620a564200b0079086c500b5si6399958qkn.99.2024.04.25.13.31.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 13:31:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159141-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DzsWM7X4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159141-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159141-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3DCC51C20FD5 for ; Thu, 25 Apr 2024 20:31:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEFC639ADD; Thu, 25 Apr 2024 20:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DzsWM7X4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D67FF631; Thu, 25 Apr 2024 20:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714077076; cv=none; b=If+X7nva/sJYryWZMxb3GvjUBw0gMXqUoUuFmwTNR2xibRg9ld34bieydSRxy5M9h0jtwKhiN94K/whDihze/+EaxU6Z6su1eeNOdj7CyqrIjJx6/4M7PEEzNVb/J3GITWyHnV9LmCz1nJI7d2HjkeV2fszAsbtIv2z+3EkLDDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714077076; c=relaxed/simple; bh=Os/ETrNyhqvrY0Al2gTdoVvSC4IYDspRfev++Ei3nXk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FeS3pZxGflTswBskb4NGiE5PPzs9v6y4dA2xsz+HC3MSwMdnqbCdhkIhWGGvkWifcJiDXYkiSZHbz60UW4MfsmnyNu/VbAuerlvkqVsA9AaCBgcaD+7B58tumIo0Ibvf6ZuFTLqsvGkU+Y4jMW6xKWSZA4uBqugdbLON5YPFbr4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DzsWM7X4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46694C113CC; Thu, 25 Apr 2024 20:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714077076; bh=Os/ETrNyhqvrY0Al2gTdoVvSC4IYDspRfev++Ei3nXk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DzsWM7X4G54YvQRbsLkWUUuW6W5vNovWQIF0gpDFSwm8vrb06tXukhWaR9DOs7DH0 Yr5kjn+9GEiX7dhQUX5uQ99bp2nao4usQL1XHDdayCCq/QAu65OxNga/zSJ6ntYBLx RASjvV9bPVVLDV7ezYeSTx2/gHWJ35Q+dl6zWAwxjeo1FocK4ZETUyL5NjXYe34si5 tmIPafoKkN+yukJiHFQzHfedK1JOalgAsH6bOsU3wHSa/WrMXkfxrd9fh9IY6UfA1c MZPh2qYpzmXD4rfligEiNvnWgX5Dv23v/LVhK6fsWp2OmHhsDr3fF8o3X0Qf8WNO5l PlyPoKTwPrjuA== Received: by pali.im (Postfix) id DD30070C; Thu, 25 Apr 2024 22:31:13 +0200 (CEST) Date: Thu, 25 Apr 2024 22:31:13 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Lyndon Sanche Cc: Matthew Garrett , Hans de Goede , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com Subject: Re: [PATCH] platform/x86: dell-laptop: Implement platform_profile Message-ID: <20240425203113.eokpgdjj6hmxhdj3@pali> References: <20240425172758.67831-1-lsanche@lyndeno.ca> <20240425201213.apwdxazbdbjddtpr@pali> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 On Thursday 25 April 2024 14:27:32 Lyndon Sanche wrote: > On Thu, Apr 25, 2024, at 2:12 PM, Pali Rohár wrote: > > On Thursday 25 April 2024 11:27:57 Lyndon Sanche wrote: > >> +int thermal_init(void) > >> +{ > >> + int ret; > >> + int supported_modes; > >> + > >> + ret = thermal_get_supported_modes(&supported_modes); > >> + > >> + if (ret != 0 || supported_modes == 0) > >> + return -ENXIO; > >> + > >> + thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); > >> + if (!thermal_handler) > >> + return -ENOMEM; > >> + thermal_handler->profile_get = thermal_platform_profile_get; > >> + thermal_handler->profile_set = thermal_platform_profile_set; > >> + > >> + if ((supported_modes >> DELL_QUIET) & 1) > >> + set_bit(PLATFORM_PROFILE_QUIET, thermal_handler->choices); > >> + if ((supported_modes >> DELL_COOL_BOTTOM) & 1) > >> + set_bit(PLATFORM_PROFILE_COOL, thermal_handler->choices); > >> + if ((supported_modes >> DELL_BALANCED) & 1) > >> + set_bit(PLATFORM_PROFILE_BALANCED, thermal_handler->choices); > >> + if ((supported_modes >> DELL_PERFORMANCE) & 1) > >> + set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices); > >> + > >> + platform_profile_register(thermal_handler); > >> + > >> + return 0; > >> +} > >> + > >> +void thermal_cleanup(void) > >> +{ > >> + platform_profile_remove(); > >> + kfree(thermal_handler); > >> +} > >> + > >> static struct led_classdev mute_led_cdev = { > >> .name = "platform::mute", > >> .max_brightness = 1, > >> @@ -2266,6 +2480,11 @@ static int __init dell_init(void) > >> mute_led_registered = true; > >> } > >> > >> + // Do not fail module if thermal modes not supported, > >> + // just skip > >> + if (thermal_init() != 0) > >> + pr_warn("Unable to setup platform_profile, skipping"); > > > > I think that -ENOMEM error should be failure of the loading the driver. > > It does not make sense to continue of memory allocation failed. > > > > On the other hand when the thermal modes are not support (e.g. old > > Latitude models) then there should not be a warning message. It is > > expected that on systems without thermal modes the setup fails. > > Thank you for your feedback. > > I agree with your suggestion. -ENOMEM would indicate something bigger is amiss. I can add a check: > > If -ENOMEM, fail driver. > If anything other error, skip, but do not show a message. > > Lyndon Maybe you can simplify it more. thermal_init() could return 0 also for the case when thermal modes are not supported. And dell_init() then can unconditionally fail when thermal_init() returns non-zero value. It has benefit that in case thermal_init() is extended in future for some other fatal error, it would not be required to update also caller to handle another error (and not just ENOMEM).