Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1470007lqe; Mon, 8 Apr 2024 09:41:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGvs01n8udUvgXmBDLIayLLQI5Ay+ZdhEjN264pOJiay22kzsjchxlwwJGdR70YjSkLbEsTs9F1vgFd6KCrHoTLvJXnowI2FXnJkIuyA== X-Google-Smtp-Source: AGHT+IHQsl+Wx2YMxmk//NwK/GY/83QOn7Y01JzQKAAx9+7kVAXmUbgkWwkEAhWhfG0VY/Dqpqd/ X-Received: by 2002:a50:d494:0:b0:56b:defb:3b59 with SMTP id s20-20020a50d494000000b0056bdefb3b59mr6057637edi.19.1712594518597; Mon, 08 Apr 2024 09:41:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712594518; cv=pass; d=google.com; s=arc-20160816; b=EmE2+Xxd2NKAjqhg+oifIW9aAxuoJlh7nGwro1O9vD1as10jAIwG6tY2xF/Htl8qAU Er4xNZxwlPBOrFyBkY0DF0W3154rD1W+tFXrrephvcX4L+ZcYr0ReFSpDGB/ELGotB38 B5ihyflCzh14qrRX8vw2i/OWdmInd9UOsmKJ+jEqztaKwe93+OfKJH6yDVeAID4PCqDc wjLuufE/0Ds/aTMCsIVGnrrxlpVmwaxNUj3twrk27HPgFo2K4Z9Bw+8bPKjsk/TTdENN fvOM3LYTl3bsrorCCSUfFMAwm1FcFuFaUrW4gl3bBgM1CkMvzsQXKOKyiPf/xiNjrxiK /3RA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=WYFhy7LtlEFaejmOfEUdc9o2AS0SlykqOVzLzKcDbrs=; fh=AH4b3eLVtLeCzW8wfDY05sYASJ0I9rteOfmeEZmAs6s=; b=SSK2g64MjpMWqmgnKn9hHPe+1mA2kuWDwFScoDnh2MD9jDBYxYeNF0veQEVuKt/YxR 1ZIQYKTmnnyFtAQZHvj2KIKPyarw9LliuAi8IDIueXm/NUHPXqHnpahnu6l/9nZDWgXr M6ryu+NoyX9S76aYsgFxiIUDc10chC5hncUW4spWycU9It4+euwJbGVd0Tci4yyXwOAE RiSzu2zg5q6AKDWS5OfoOogDRG5/L4T0AadJuZkqVCWQtd7gHoDKyPe+w1yKkpnv28OR GuLwKjJ7UtVkq9RtuIkzJPLP2CS6kwny0u6tVlc/YQTp0fT/dqTZP85VGBm7sH0CbtGY CZow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="L9j4HMk/"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-135701-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s21-20020a508d15000000b0056e51c19bf5si1992493eds.170.2024.04.08.09.41.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 09:41:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135701-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="L9j4HMk/"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-135701-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2EF151F23349 for ; Mon, 8 Apr 2024 16:41:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1F2D142E70; Mon, 8 Apr 2024 16:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L9j4HMk/" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 F15551428E3 for ; Mon, 8 Apr 2024 16:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594506; cv=none; b=NUZMaFx8d0ijV8UQzZNb4k3YpXy2KpCZCq3trQzCWwdRct9acrhxbco++1LaXsh8MWv3zLzrBLZTzEPotPgg0WenSyY9Npxl//eAw4XV/ny+5IOHvN7HU4/Hwg40pwIlEbqzYOhNqMKylgpJ5618+F8onEbuNORIHUamqZ+ZI1c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594506; c=relaxed/simple; bh=sWYvE4qmq7hVzJ0dCGaTIE5eJLwFeKcC0+RULiRIeaw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RivRQE0FgM5XKTPmjeeE1QjVmQGnKYwCMkShZWitcHpR7Ft6pyUjFReAopAVt7Ooqx1pi5Tk7ASt9XGOyOcRfg+J7rsS6YgWsnBgKnftYMgHOycTqrmIpeyzYJUYV+Z6SHyQz9XBiMjcSVWRMrwi8U+aZVa+z4Dcivmf0IYxv0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=L9j4HMk/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712594503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WYFhy7LtlEFaejmOfEUdc9o2AS0SlykqOVzLzKcDbrs=; b=L9j4HMk/4ErZ7woZpg9Hf8EIqqjWD13MDgeea3Yyt01hX1DspTtRcpn1iR4k0cKF8qPI2u RvFCo531JMS7CpQdy3AyosmERBbIjZiDOFkliLVeCB3T9CWuG8xpa1aeoLkZXjmzETSwAw WcI1mPbZusM4Q6FcHOMY02YpYp3bjoM= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-WhyQka5CNzu-eLUzHE7xcA-1; Mon, 08 Apr 2024 12:41:42 -0400 X-MC-Unique: WhyQka5CNzu-eLUzHE7xcA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a51a2113040so189784666b.0 for ; Mon, 08 Apr 2024 09:41:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712594501; x=1713199301; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WYFhy7LtlEFaejmOfEUdc9o2AS0SlykqOVzLzKcDbrs=; b=wZzf9KbBLP+ZrJNU4zwh1lv4psZwsyYo1QccPpP85TPrLbxhI3oEnWdUQULNzvFNeY fKumzYBzHa6YXWreDOOAPLNuUzLpZsgOvmCWHC0W9v5fppGArOmIwro1OxMtik2CTjGR GYroY9Z6PWvZelIQtMxiNxrT5yU6fpwH5ax27tJfwuqd717/PmPzlHmGRU2axHGh4lRe GXH4Yy2Aha3nfBAosSBGd94y7dn3qqM43/nvepc42Q+yjsRhqPYysWGI6flrkOnaIkit iCplQUlCCAS/BtfX1fnLUYMZLLrYWDAKh384aITrwcRweuvZLpMmupASRTPS9UT3/DIo DkJQ== X-Forwarded-Encrypted: i=1; AJvYcCUowy612ZVy43keOgoyg7Nd2WL5X/Wf+fLhytlZyexuNU+q7PyK7l1beq9NeanoFKSpqh+M7MeqygyW3sL2nn014auwTx0bLA/Onj2P X-Gm-Message-State: AOJu0YyADxVmSbhGFJ6Rc+LWW9nnVkB3aOvJ2e+Kc8qupCFAgujfWq/s HXxZkZeOviaBAl9A1ORhABME2WiMLCzQPqE4cfWfakIbKRNTcMtGt6Ip24+sOzIRc4s0BWgu8ry KBBFazNz8PtkckPfsgAtWCrqxGs5l7+NQChO3avP6XsG26WMrgMoFhoHIdpn2AA== X-Received: by 2002:a17:907:9810:b0:a46:f69b:49b1 with SMTP id ji16-20020a170907981000b00a46f69b49b1mr8095372ejc.46.1712594501558; Mon, 08 Apr 2024 09:41:41 -0700 (PDT) X-Received: by 2002:a17:907:9810:b0:a46:f69b:49b1 with SMTP id ji16-20020a170907981000b00a46f69b49b1mr8095351ejc.46.1712594501251; Mon, 08 Apr 2024 09:41:41 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id j20-20020a170906255400b00a51cd604c4bsm2270224ejb.149.2024.04.08.09.41.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Apr 2024 09:41:40 -0700 (PDT) Message-ID: <4e37511c-7570-4ea5-bdf9-6bdd62c63575@redhat.com> Date: Mon, 8 Apr 2024 18:41:39 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/3] ACPI: platform-profile: add platform_profile_cycle() To: Gergo Koteles , "Rafael J. Wysocki" , Len Brown , Ike Panhc , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Henrique de Moraes Holschuh , Daniel Lezcano , =?UTF-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: linux-acpi@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: Content-Language: en-US, nl From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Gergo, On 4/6/24 2:01 AM, Gergo Koteles wrote: > Some laptops have a key to switch platform profiles. > > Add a platform_profile_cycle() function to cycle between the enabled > profiles. > > Signed-off-by: Gergo Koteles Thank you for your patch, 1 small remark below, otherwise this looks good to me. Rafael, may I have your Ack for merging this through the pdx86 tree together with the rest of the series once my remark has been addressed ? > --- > drivers/acpi/platform_profile.c | 39 ++++++++++++++++++++++++++++++++ > include/linux/platform_profile.h | 1 + > 2 files changed, 40 insertions(+) > > diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c > index d418462ab791..acc606af812a 100644 > --- a/drivers/acpi/platform_profile.c > +++ b/drivers/acpi/platform_profile.c > @@ -136,6 +136,45 @@ void platform_profile_notify(void) > } > EXPORT_SYMBOL_GPL(platform_profile_notify); > > +int platform_profile_cycle(void) > +{ > + enum platform_profile_option profile; > + enum platform_profile_option next; > + int err; > + > + err = mutex_lock_interruptible(&profile_lock); > + if (err) > + return err; > + > + if (!cur_profile) { > + mutex_unlock(&profile_lock); > + return -ENODEV; > + } > + > + err = cur_profile->profile_get(cur_profile, &profile); > + if (err) { > + mutex_unlock(&profile_lock); > + return err; > + } > + > + next = find_next_bit_wrap(cur_profile->choices, > + ARRAY_SIZE(profile_names), profile + 1); > + > + if (WARN_ON(next == ARRAY_SIZE(profile_names))) { Other code in drivers/acpi/platform_profile.c uses PLATFORM_PROFILE_LAST instead of ARRAY_SIZE(profile_names) (these are guaranteed to be equal) please switch to using PLATFORM_PROFILE_LAST for consistency. Regards, Hans > + mutex_unlock(&profile_lock); > + return -EINVAL; > + } > + > + err = cur_profile->profile_set(cur_profile, next); > + mutex_unlock(&profile_lock); > + > + if (!err) > + sysfs_notify(acpi_kobj, NULL, "platform_profile"); > + > + return err; > +} > +EXPORT_SYMBOL_GPL(platform_profile_cycle); > + > int platform_profile_register(struct platform_profile_handler *pprof) > { > int err; > diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h > index e5cbb6841f3a..f5492ed413f3 100644 > --- a/include/linux/platform_profile.h > +++ b/include/linux/platform_profile.h > @@ -36,6 +36,7 @@ struct platform_profile_handler { > > int platform_profile_register(struct platform_profile_handler *pprof); > int platform_profile_remove(void); > +int platform_profile_cycle(void); > void platform_profile_notify(void); > > #endif /*_PLATFORM_PROFILE_H_*/