From nobody Fri Dec 19 14:22:23 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 6D97527FB3E; Wed, 5 Nov 2025 18:29:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367343; cv=pass; b=YdYu9+qvXFMV//S5euxPIPRH1TE4Za+gyIVIq8x/A+0mN+A/HDkXr7CwlLImL6zsqF0s66e2S/2IvMsOePxtypAVYQ+X7gi8Qrk9LkQ8glBZ6/HFech0uqAICpgo057hK8qynY/N1kQ1ca03Swn4PMM/FW9P6jYsUMlXI67ruWM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367343; c=relaxed/simple; bh=SU/bsUwM+HoPIs92Ouw+DFCvPKGPGahFo6YRpSY/4LI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k0U2gZkvOGKRSOlsBmRJnBhQGpKOBtMk5wMklPXuZydlIsUCazXnd4L7DDnN8z4OYPsfcMeJE9dazGfn4m8TE66YM7HteyjeZQaf7d8xvHWqVxjCRv6aFWSCBAURA1sz4u03GpXhrBX/vwVC6V8q+fGvZJuOIYvdw+8c6rKw28s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b=TX8ysI6q; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b="TX8ysI6q" ARC-Seal: i=1; a=rsa-sha256; t=1762367327; cv=none; d=zohomail.com; s=zohoarc; b=DaNxRoIk5ACShAi6mWew7AbY9Ztesm/u85EnBqaBhJIgGHWKj47Fcd8n4D+1aZlHQBLGddNfTopjA9M14VP4LUEr64NpccqidNPrYapjmuoaz9msuTuFkqAZajGf5cIz43zsqrrZmnJMEr2YCU3xycm9zwipMGzNyWrFFXC7df8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762367327; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=IGLjGXhNn4DguPrtx8t3L9/KLNA0+GEhlRcyDGItUWg=; b=DsK6DwKyybvReC0kzi570g4fEm/IR2LrEstUtkZ4BP69Bi6VN3VTr/RlkAZW8MB4TUdzfjni/oMGI9ybm/xcJLijD2GxiV/1AuCtcOAC/xx4KMk3FyDql12B/Qbhb85WYzo5o4Tod8lPo1Ggb0dW93SPIz4lyAv1trnW2IDt+N8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1762367327; s=zmail; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=IGLjGXhNn4DguPrtx8t3L9/KLNA0+GEhlRcyDGItUWg=; b=TX8ysI6qnTySqQJbmQQn+SGRXCU5QxFk12KFwcR81HoiXGnU6Q9xT9Jb2L5ymy1O TIFlC2MQaVCHwodDv+SObxjlFx8Ew9eVA08hu3EpNuC4IQcraS8ips0WFIJPe+9JmR+ PlvLZbmD9qbwtGiry4g8vol8DBZ7vwxg4Uy3n/bA= Received: by mx.zohomail.com with SMTPS id 1762367325249927.5777512192999; Wed, 5 Nov 2025 10:28:45 -0800 (PST) From: Rong Zhang To: Ike Panhc , Mark Pearson , "Derek J. Clark" , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: Rong Zhang , Jelle van der Waa , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot , Julia Lawall Subject: [PATCH v2 1/4] platform/x86: ideapad-laptop: Use str_on_off() helper Date: Thu, 6 Nov 2025 02:28:24 +0800 Message-ID: <20251105182832.104946-2-i@rong.moe> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105182832.104946-1-i@rong.moe> References: <20251105182832.104946-1-i@rong.moe> 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-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Use the str_on_off() helper instead of open-coding the same operation. This improves code readability. No functional change intended. Reported-by: kernel test robot Reported-by: Julia Lawall Closes: https://lore.kernel.org/r/202510311551.xjWbHTrm-lkp@intel.com/ Suggested-by: Ilpo J=C3=A4rvinen Link: https://lore.kernel.org/r/2bae2ea7-2ef9-0cfa-0c2c-39a7043b2aa5@linux.= intel.com/ Signed-off-by: Rong Zhang --- Changes in v2: - Include a seperated patch into this series (thanks Ilpo J=C3=A4rvinen) - Fix missing include (ditto) - Reword commit message - Link to previous patch: https://lore.kernel.org/r/20251031184435.44819-= 1-i@rong.moe/ --- drivers/platform/x86/lenovo/ideapad-laptop.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platfor= m/x86/lenovo/ideapad-laptop.c index fcebfbaf0460..b61ed6993990 100644 --- a/drivers/platform/x86/lenovo/ideapad-laptop.c +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -462,25 +463,25 @@ static int debugfs_status_show(struct seq_file *s, vo= id *data) if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) seq_printf(s, "Backlight now: %lu\n", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) - seq_printf(s, "BL power value: %s (%lu)\n", value ? "on" : "off", value); + seq_printf(s, "BL power value: %s (%lu)\n", str_on_off(value), value); =20 seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D\n"); =20 if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) - seq_printf(s, "Radio status: %s (%lu)\n", value ? "on" : "off", value); + seq_printf(s, "Radio status: %s (%lu)\n", str_on_off(value), value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) - seq_printf(s, "Wifi status: %s (%lu)\n", value ? "on" : "off", value); + seq_printf(s, "Wifi status: %s (%lu)\n", str_on_off(value), value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) - seq_printf(s, "BT status: %s (%lu)\n", value ? "on" : "off", value); + seq_printf(s, "BT status: %s (%lu)\n", str_on_off(value), value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) - seq_printf(s, "3G status: %s (%lu)\n", value ? "on" : "off", value); + seq_printf(s, "3G status: %s (%lu)\n", str_on_off(value), value); =20 seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D\n"); =20 if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) - seq_printf(s, "Touchpad status: %s (%lu)\n", value ? "on" : "off", value= ); + seq_printf(s, "Touchpad status: %s (%lu)\n", str_on_off(value), value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) - seq_printf(s, "Camera status: %s (%lu)\n", value ? "on" : "off", value= ); + seq_printf(s, "Camera status: %s (%lu)\n", str_on_off(value), value); =20 seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D\n"); =20 --=20 2.51.0 From nobody Fri Dec 19 14:22:23 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 AD2D727F015; Wed, 5 Nov 2025 18:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367341; cv=pass; b=Nmc4Fl1ULCcj3zwsnpzQNZAZFVjZbVlLhRSpXnwVpts7bMhrW1lZ7JgET+A2reellxQYFkw48c5qdMy5FlzxukOOMhocRdbcCVMx9rrXQChq7+PI9dRNYlca+BBP8jzTPfwoS5VRjabF/xNT63wgueRQYcO/M1CAe6TYNwqjs6s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367341; c=relaxed/simple; bh=cMSGx8V60nHc34s+S/0joZ3mCb4GZB5oKc+z5R+RlWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j1Youk0iGHPZVqzHKOE1ApYV6pXU6By+7Z820XYO3OavC3YpyMSkt6g7HtdvhcHHd7c96Rsm5XM+vB7KxYAoZDiCCP0NBr0CJQvdc0P8jJJOWWsh8SftnNPqcCvxjCp30W54WzEATCIw1huXQhYkuKgSbkiYnVtwuQupBuA4VhM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b=5Cdjip2e; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b="5Cdjip2e" ARC-Seal: i=1; a=rsa-sha256; t=1762367329; cv=none; d=zohomail.com; s=zohoarc; b=eXS3l8nmW2GhEuYdyhWaSbFNfxPoDQLuhDeYTmWznyoXGU4/gjwmSS/BF7x1Q6jWWaBrct8mxnaRz+1Fr2pTM9B2voNyu1wwoxUwKddA9heCTDyW/t1kyrhS1kvAATJASOn4JsD0G33ax4g8/hHWtb+fRbPU0yghEkK8wjtkp/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762367329; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=CYHMVlgKRsRYa2COI4q7NL+gqe5epB4h6Z/tKVtbD9w=; b=bV68SoJT5UG/q/BkMD5/bH9CSY8GtrW6Emg8iOe5iVggKnV69vysX50XnYeveubVJx4Ri46KgO3xS/4XsIhKnfhviM3PO0tXgkQKgdKND0tX6TXlhNtCdeOQ3kIHxQtbhS/0U6tIataXsyuynOUQnyaIoSMuVgeZYkdtGrPuzok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1762367328; s=zmail; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=CYHMVlgKRsRYa2COI4q7NL+gqe5epB4h6Z/tKVtbD9w=; b=5Cdjip2ezyFufOBH9HSYH5yKbQD0vc8UGhPG1dO/hRMAvR+LTUDzW4iVS2A5YEjf Z7K7MmwT0okJg8BMnjmKaxd5konGGSeabWDDnhKcZx7aEAAd016EcWFB9EuZgHbGm6h c8KD2BgStgi2pa1eP4gYLcsNvI8hv7n7qXki6bbI= Received: by mx.zohomail.com with SMTPS id 1762367327796540.5222222982911; Wed, 5 Nov 2025 10:28:47 -0800 (PST) From: Rong Zhang To: Ike Panhc , Mark Pearson , "Derek J. Clark" , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: Rong Zhang , Jelle van der Waa , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] platform/x86: ideapad-laptop: Protect GBMD/SBMC calls with mutex Date: Thu, 6 Nov 2025 02:28:25 +0800 Message-ID: <20251105182832.104946-3-i@rong.moe> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105182832.104946-1-i@rong.moe> References: <20251105182832.104946-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" The upcoming changes for Rapid Charge support require two consecutive SBMC calls to switch charge_types. Hence, a mutex is required. No functional change intended. Signed-off-by: Rong Zhang Acked-by: Ike Panhc --- Changes in v2: - Rebase on top of the newly added [PATCH v2 1/4] - Reword commit message --- drivers/platform/x86/lenovo/ideapad-laptop.c | 91 ++++++++++++-------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platfor= m/x86/lenovo/ideapad-laptop.c index b61ed6993990..141de6335740 100644 --- a/drivers/platform/x86/lenovo/ideapad-laptop.c +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c @@ -159,6 +159,7 @@ struct ideapad_rfk_priv { struct ideapad_private { struct acpi_device *adev; struct mutex vpc_mutex; /* protects the VPC calls */ + struct mutex gbmd_sbmc_mutex; /* protects GBMD/SBMC calls */ struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; struct ideapad_rfk_priv rfk_priv[IDEAPAD_RFKILL_DEV_NUM]; struct platform_device *platform_device; @@ -456,37 +457,40 @@ static int debugfs_status_show(struct seq_file *s, vo= id *data) struct ideapad_private *priv =3D s->private; unsigned long value; =20 - guard(mutex)(&priv->vpc_mutex); - - if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) - seq_printf(s, "Backlight max: %lu\n", value); - if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) - seq_printf(s, "Backlight now: %lu\n", value); - if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) - seq_printf(s, "BL power value: %s (%lu)\n", str_on_off(value), value); - - seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D\n"); - - if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) - seq_printf(s, "Radio status: %s (%lu)\n", str_on_off(value), value); - if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) - seq_printf(s, "Wifi status: %s (%lu)\n", str_on_off(value), value); - if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) - seq_printf(s, "BT status: %s (%lu)\n", str_on_off(value), value); - if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) - seq_printf(s, "3G status: %s (%lu)\n", str_on_off(value), value); + scoped_guard(mutex, &priv->vpc_mutex) { + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) + seq_printf(s, "Backlight max: %lu\n", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) + seq_printf(s, "Backlight now: %lu\n", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) + seq_printf(s, "BL power value: %s (%lu)\n", str_on_off(value), value); + + seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D\n"); + + if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) + seq_printf(s, "Radio status: %s (%lu)\n", str_on_off(value), value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) + seq_printf(s, "Wifi status: %s (%lu)\n", str_on_off(value), value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) + seq_printf(s, "BT status: %s (%lu)\n", str_on_off(value), value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) + seq_printf(s, "3G status: %s (%lu)\n", str_on_off(value), value); + + seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D\n"); + + if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) + seq_printf(s, "Touchpad status: %s (%lu)\n", str_on_off(value), value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) + seq_printf(s, "Camera status: %s (%lu)\n", str_on_off(value), value); + } =20 seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D\n"); =20 - if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) - seq_printf(s, "Touchpad status: %s (%lu)\n", str_on_off(value), value); - if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) - seq_printf(s, "Camera status: %s (%lu)\n", str_on_off(value), value); - - seq_puts(s, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D\n"); + scoped_guard(mutex, &priv->gbmd_sbmc_mutex) { + if (!eval_gbmd(priv->adev->handle, &value)) + seq_printf(s, "GBMD: %#010lx\n", value); + } =20 - if (!eval_gbmd(priv->adev->handle, &value)) - seq_printf(s, "GBMD: %#010lx\n", value); if (!eval_hals(priv->adev->handle, &value)) seq_printf(s, "HALS: %#010lx\n", value); =20 @@ -623,9 +627,11 @@ static ssize_t conservation_mode_show(struct device *d= ev, =20 show_conservation_mode_deprecation_warning(dev); =20 - err =3D eval_gbmd(priv->adev->handle, &result); - if (err) - return err; + scoped_guard(mutex, &priv->gbmd_sbmc_mutex) { + err =3D eval_gbmd(priv->adev->handle, &result); + if (err) + return err; + } =20 return sysfs_emit(buf, "%d\n", !!test_bit(GBMD_CONSERVATION_STATE_BIT, &r= esult)); } @@ -644,6 +650,8 @@ static ssize_t conservation_mode_store(struct device *d= ev, if (err) return err; =20 + guard(mutex)(&priv->gbmd_sbmc_mutex); + err =3D exec_sbmc(priv->adev->handle, state ? SBMC_CONSERVATION_ON : SBMC= _CONSERVATION_OFF); if (err) return err; @@ -2008,15 +2016,22 @@ static int ideapad_psy_ext_set_prop(struct power_su= pply *psy, const union power_supply_propval *val) { struct ideapad_private *priv =3D ext_data; + unsigned long op; =20 switch (val->intval) { case POWER_SUPPLY_CHARGE_TYPE_LONGLIFE: - return exec_sbmc(priv->adev->handle, SBMC_CONSERVATION_ON); + op =3D SBMC_CONSERVATION_ON; + break; case POWER_SUPPLY_CHARGE_TYPE_STANDARD: - return exec_sbmc(priv->adev->handle, SBMC_CONSERVATION_OFF); + op =3D SBMC_CONSERVATION_OFF; + break; default: return -EINVAL; } + + guard(mutex)(&priv->gbmd_sbmc_mutex); + + return exec_sbmc(priv->adev->handle, op); } =20 static int ideapad_psy_ext_get_prop(struct power_supply *psy, @@ -2029,9 +2044,11 @@ static int ideapad_psy_ext_get_prop(struct power_sup= ply *psy, unsigned long result; int err; =20 - err =3D eval_gbmd(priv->adev->handle, &result); - if (err) - return err; + scoped_guard(mutex, &priv->gbmd_sbmc_mutex) { + err =3D eval_gbmd(priv->adev->handle, &result); + if (err) + return err; + } =20 if (test_bit(GBMD_CONSERVATION_STATE_BIT, &result)) val->intval =3D POWER_SUPPLY_CHARGE_TYPE_LONGLIFE; @@ -2293,6 +2310,10 @@ static int ideapad_acpi_add(struct platform_device *= pdev) if (err) return err; =20 + err =3D devm_mutex_init(&pdev->dev, &priv->gbmd_sbmc_mutex); + if (err) + return err; + err =3D ideapad_check_features(priv); if (err) return err; --=20 2.51.0 From nobody Fri Dec 19 14:22:23 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 0EEC2283FD8; Wed, 5 Nov 2025 18:29:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367343; cv=pass; b=WmUdh2zb6KYc/HCEa7QZMK5F0hToZXQxCkHweC0lL8NrhamUssy/rydJjRfw1zqVBtpJSVoVU/ML5vxn7QtGUardxa+aDksIVgeLZ6ovwrC3Xh6jIgNdpSYOAFiHoF/nx9LXgK8noUzn1W/PkeEsWKyeJvr98+ZRZ6QwJl5Vh54= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367343; c=relaxed/simple; bh=0M/zSniN3qMu1HqTBrGFXjVoSi/2BAL580AJHmFGo+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=teeOwpbPv5unEY6rY/ZbAkjmAm7dwtsxe2OudGGWw1sDJ0sGRJ9ucT5JK5Ng2tcdIkgSkN7o7ogSZgzHTddxV5wFbi/YaYCOvg0nIfI2IieVqbqdku0Y1Vyl+cmci7MP0jAzbils6/2z46aNkZvj8LYTC2LevvyOWS9nHfkCLg4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b=QvaGwuQz; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b="QvaGwuQz" ARC-Seal: i=1; a=rsa-sha256; t=1762367333; cv=none; d=zohomail.com; s=zohoarc; b=JsadDCogTFRyfmCdsQX6ElAsNmxl3+JaALVUToeIcophndSMQSv9rAUspcw5bluClSG3Zz8uXBscbUXChF4ateY2yqpoOA7lJvh/3+2yzJxPmDa+u93vS1nAJqGwIpbQ5axbaQj0PuZbc5WNPY/Ro4VSL/jkGJnFkSaw1b18hYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762367333; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=jTIQjW75WnSAB3hTzD784oNiqNOk9Cf0wbfrxh9ebBw=; b=nspvj9rvWTtPlLy9l4yU6fCgTecQrQbhTROHIUuwtpmMYOSp1cB9EFMWUgp5KD91OVOVohGnRWhre9N1Yalcmu0i/naRg8g4NZlUzpx4htBrZBt/rXH8DYIvn/qdPHIJDx0wZg5+It9CmtT5Ibn69XM9GPKXTyXJGn2xYL53JXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1762367332; s=zmail; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=jTIQjW75WnSAB3hTzD784oNiqNOk9Cf0wbfrxh9ebBw=; b=QvaGwuQzdlJz76mmOHOP1bWes5Ra5hn1iHFAY+2mv480urJBE1N3Y2OOpBqRxjWu j7ZswpV07i85zxT8E2lVlZijLumxxIkCXaeeK76e605B47Vn19ijfTYKfVn9CKcm5VV F16ECX4w59cQWOnXJMQgx0HRf+AmZRTRGUHjA00U= Received: by mx.zohomail.com with SMTPS id 1762367330314783.5958658807923; Wed, 5 Nov 2025 10:28:50 -0800 (PST) From: Rong Zhang To: Ike Panhc , Mark Pearson , "Derek J. Clark" , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: Rong Zhang , Jelle van der Waa , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] platform/x86: ideapad-laptop: Support multiple power_supply_ext definitions Date: Thu, 6 Nov 2025 02:28:26 +0800 Message-ID: <20251105182832.104946-4-i@rong.moe> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105182832.104946-1-i@rong.moe> References: <20251105182832.104946-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Some recent devices supports more charge_types. To properly support these device without breaking the existing ones, we need to define multiple power_supply_ext for different GBMD/SBMC interface revisions. No functional change intended. Signed-off-by: Rong Zhang --- Changes in v2: - New patch in the series. --- drivers/platform/x86/lenovo/ideapad-laptop.c | 35 +++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platfor= m/x86/lenovo/ideapad-laptop.c index 141de6335740..af89063108be 100644 --- a/drivers/platform/x86/lenovo/ideapad-laptop.c +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c @@ -168,6 +168,7 @@ struct ideapad_private { struct ideapad_dytc_priv *dytc; struct dentry *debug; struct acpi_battery_hook battery_hook; + const struct power_supply_ext *battery_ext; unsigned long cfg; unsigned long r_touchpad_val; struct { @@ -2070,29 +2071,36 @@ static const enum power_supply_property ideapad_pow= er_supply_props[] =3D { POWER_SUPPLY_PROP_CHARGE_TYPES, }; =20 -static const struct power_supply_ext ideapad_battery_ext =3D { - .name =3D "ideapad_laptop", - .properties =3D ideapad_power_supply_props, - .num_properties =3D ARRAY_SIZE(ideapad_power_supply_props), - .charge_types =3D (BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) | - BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE)), - .get_property =3D ideapad_psy_ext_get_prop, - .set_property =3D ideapad_psy_ext_set_prop, - .property_is_writeable =3D ideapad_psy_prop_is_writeable, -}; +#define DEFINE_IDEAPAD_POWER_SUPPLY_EXTENSION(_name, _charge_types) \ + static const struct power_supply_ext _name =3D { \ + .name =3D "ideapad_laptop", \ + .properties =3D ideapad_power_supply_props, \ + .num_properties =3D ARRAY_SIZE(ideapad_power_supply_props), \ + .charge_types =3D _charge_types, \ + .get_property =3D ideapad_psy_ext_get_prop, \ + .set_property =3D ideapad_psy_ext_set_prop, \ + .property_is_writeable =3D ideapad_psy_prop_is_writeable, \ + } + +DEFINE_IDEAPAD_POWER_SUPPLY_EXTENSION(ideapad_battery_ext_v1, + (BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) | + BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE)) +); =20 static int ideapad_battery_add(struct power_supply *battery, struct acpi_b= attery_hook *hook) { struct ideapad_private *priv =3D container_of(hook, struct ideapad_privat= e, battery_hook); =20 - return power_supply_register_extension(battery, &ideapad_battery_ext, + return power_supply_register_extension(battery, priv->battery_ext, &priv->platform_device->dev, priv); } =20 static int ideapad_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook) { - power_supply_unregister_extension(battery, &ideapad_battery_ext); + struct ideapad_private *priv =3D container_of(hook, struct ideapad_privat= e, battery_hook); + + power_supply_unregister_extension(battery, priv->battery_ext); =20 return 0; } @@ -2118,6 +2126,9 @@ static int ideapad_check_features(struct ideapad_priv= ate *priv) =20 if (acpi_has_method(handle, "GBMD") && acpi_has_method(handle, "SBMC")) { priv->features.conservation_mode =3D true; + + priv->battery_ext =3D &ideapad_battery_ext_v1; + priv->battery_hook.add_battery =3D ideapad_battery_add; priv->battery_hook.remove_battery =3D ideapad_battery_remove; priv->battery_hook.name =3D "Ideapad Battery Extension"; --=20 2.51.0 From nobody Fri Dec 19 14:22:23 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 6041729B20A; Wed, 5 Nov 2025 18:29:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367347; cv=pass; b=IJ5WYkegSz5Z+uUQu8Dd5FfCnWZ6MGDo1XNE9sjk2i6x1sU2hsJFDt7RDIE5Q3gxR8ILSML1vgkNnPsI+EF7bMid9q+t/vrUB77Xvufq1m/f65n2n9GPMzSvve0ris/c6ITEm+flY5L4aVLdf/k+sH+E9cquZSFaA8jJXN25lqg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367347; c=relaxed/simple; bh=SP9DJtu7N8EqjJ5q4+cKj9Sp14WcXw2riWPPvAqiZNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cgsxot8C+VuMDlNxZzEDQE/NqcRaVR7bMtkE39FneWV9htOUVLPJtuLUDprvj98VS2NvdHhfqK059XUmYoAAXXyTtZvsubHz7EOncsOGtlFUIo5aXHyiyxJYt3pw+5M+nuEQE4O9LJPBldPPRF6+F3lfuXO7kCp0WAGYAQOWRBg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b=rP8EPIxh; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rong.moe header.i=i@rong.moe header.b="rP8EPIxh" ARC-Seal: i=1; a=rsa-sha256; t=1762367335; cv=none; d=zohomail.com; s=zohoarc; b=BILcZYVYuugZKFGOIyJ5cWA8gYjtYiCRuEp0rU/ZpK/CllzJI6VhmDOKXo2pETMamkGIyjZV+0uV004cMkLuz1L9uJrJpzPjP34ghyeeRQ1gxxpfK61WrjEIjNpkJus6n22ogfROuiQwYhU07XDtXt5BZzSONmxo+d9rDotyHV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762367335; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=heRqixjpdK13FLzt14CVLv05ZUNb4t7GiTIZBNsJ1mg=; b=M4uXLJaKLMciTAbXgHwzCH9gUqqQAGgvaxyZEgfbNTxY5Wcm3lrgsM/Hje6WM2p1Q8k6QdWcC3Z8iFGzrinlOceNGD7dgBpZXvWRWk39IMgCw2KmVKnVNCKius+4W72aqDAKL5z3E/gqvOGOj2vTPYS5gsOK2pMfuqy/M9gM6d0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1762367334; s=zmail; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=heRqixjpdK13FLzt14CVLv05ZUNb4t7GiTIZBNsJ1mg=; b=rP8EPIxh1zcXwauqenyraeTcjbq+8AMxEJEsVuAPIpfJDAibgAZPj8vgsRGL5U/x eVcPOjRR/vS1yQffEGvn/xTXoi8xIHMEMKSEyiou0uRI6ovX9wssg3ChUFXmeQsqUYz 4qMVqATAosyj7bRWuU/Dc/om1ZJvezCt7Zj7guq0= Received: by mx.zohomail.com with SMTPS id 1762367332867537.8609062000411; Wed, 5 Nov 2025 10:28:52 -0800 (PST) From: Rong Zhang To: Ike Panhc , Mark Pearson , "Derek J. Clark" , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: Rong Zhang , Jelle van der Waa , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] platform/x86: ideapad-laptop: Add charge_types:Fast (Rapid Charge) Date: Thu, 6 Nov 2025 02:28:27 +0800 Message-ID: <20251105182832.104946-5-i@rong.moe> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105182832.104946-1-i@rong.moe> References: <20251105182832.104946-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" The GBMD/SBMC interface on recent devices supports Rapid Charge mode (charge_types: Fast) in addition to Conservation Mode (charge_types: Long_Life). Query the GBMD interface on probe to determine if a device supports Rapid Charge. If so, expose these two modes while carefully maintaining their mutually exclusive state, which aligns with the behavior of manufacturer utilities on Windows. Signed-off-by: Rong Zhang Acked-by: Ike Panhc Reviewed-by: Mark Pearson --- Changes in v2: - Only expose Rapid Charge on devices that support it (thanks Jelle van der Waa) - Reword commit message --- drivers/platform/x86/lenovo/ideapad-laptop.c | 105 ++++++++++++++++--- 1 file changed, 89 insertions(+), 16 deletions(-) diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platfor= m/x86/lenovo/ideapad-laptop.c index af89063108be..5171a077f62c 100644 --- a/drivers/platform/x86/lenovo/ideapad-laptop.c +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c @@ -63,13 +63,27 @@ enum { CFG_OSD_CAM_BIT =3D 31, }; =20 +/* + * There are two charge modes supported by the GBMD/SBMC interface: + * - "Rapid Charge": increase power to speed up charging + * - "Conservation Mode": stop charging at 60-80% (depends on model) + * + * The interface doesn't prohibit enabling both modes at the same time. + * However, doing so is essentially meaningless, and the manufacturer util= ities + * on Windows always make them mutually exclusive. + */ + enum { + GBMD_RAPID_CHARGE_STATE_BIT =3D 2, GBMD_CONSERVATION_STATE_BIT =3D 5, + GBMD_RAPID_CHARGE_SUPPORTED_BIT =3D 17, }; =20 enum { SBMC_CONSERVATION_ON =3D 3, SBMC_CONSERVATION_OFF =3D 5, + SBMC_RAPID_CHARGE_ON =3D 7, + SBMC_RAPID_CHARGE_OFF =3D 8, }; =20 enum { @@ -172,6 +186,7 @@ struct ideapad_private { unsigned long cfg; unsigned long r_touchpad_val; struct { + bool rapid_charge : 1; bool conservation_mode : 1; bool dytc : 1; bool fan_mode : 1; @@ -634,6 +649,10 @@ static ssize_t conservation_mode_show(struct device *d= ev, return err; } =20 + /* + * For backward compatibility, ignore Rapid Charge while reporting the + * state of Conservation Mode. + */ return sysfs_emit(buf, "%d\n", !!test_bit(GBMD_CONSERVATION_STATE_BIT, &r= esult)); } =20 @@ -653,6 +672,16 @@ static ssize_t conservation_mode_store(struct device *= dev, =20 guard(mutex)(&priv->gbmd_sbmc_mutex); =20 + /* + * Prevent mutually exclusive modes from being set at the same time, + * but do not disable Rapid Charge while disabling Conservation Mode. + */ + if (priv->features.rapid_charge && state) { + err =3D exec_sbmc(priv->adev->handle, SBMC_RAPID_CHARGE_OFF); + if (err) + return err; + } + err =3D exec_sbmc(priv->adev->handle, state ? SBMC_CONSERVATION_ON : SBMC= _CONSERVATION_OFF); if (err) return err; @@ -2017,14 +2046,24 @@ static int ideapad_psy_ext_set_prop(struct power_su= pply *psy, const union power_supply_propval *val) { struct ideapad_private *priv =3D ext_data; - unsigned long op; + unsigned long op1, op2; + int err; =20 switch (val->intval) { + case POWER_SUPPLY_CHARGE_TYPE_FAST: + if (WARN_ON(!priv->features.rapid_charge)) + return -EINVAL; + + op1 =3D SBMC_CONSERVATION_OFF; + op2 =3D SBMC_RAPID_CHARGE_ON; + break; case POWER_SUPPLY_CHARGE_TYPE_LONGLIFE: - op =3D SBMC_CONSERVATION_ON; + op1 =3D SBMC_RAPID_CHARGE_OFF; + op2 =3D SBMC_CONSERVATION_ON; break; case POWER_SUPPLY_CHARGE_TYPE_STANDARD: - op =3D SBMC_CONSERVATION_OFF; + op1 =3D SBMC_RAPID_CHARGE_OFF; + op2 =3D SBMC_CONSERVATION_OFF; break; default: return -EINVAL; @@ -2032,7 +2071,14 @@ static int ideapad_psy_ext_set_prop(struct power_sup= ply *psy, =20 guard(mutex)(&priv->gbmd_sbmc_mutex); =20 - return exec_sbmc(priv->adev->handle, op); + /* If !rapid_charge, op1 must be SBMC_RAPID_CHARGE_OFF. Skip it. */ + if (priv->features.rapid_charge) { + err =3D exec_sbmc(priv->adev->handle, op1); + if (err) + return err; + } + + return exec_sbmc(priv->adev->handle, op2); } =20 static int ideapad_psy_ext_get_prop(struct power_supply *psy, @@ -2042,6 +2088,7 @@ static int ideapad_psy_ext_get_prop(struct power_supp= ly *psy, union power_supply_propval *val) { struct ideapad_private *priv =3D ext_data; + bool is_rapid_charge, is_conservation; unsigned long result; int err; =20 @@ -2051,7 +2098,19 @@ static int ideapad_psy_ext_get_prop(struct power_sup= ply *psy, return err; } =20 - if (test_bit(GBMD_CONSERVATION_STATE_BIT, &result)) + is_rapid_charge =3D (priv->features.rapid_charge && + test_bit(GBMD_RAPID_CHARGE_STATE_BIT, &result)); + is_conservation =3D test_bit(GBMD_CONSERVATION_STATE_BIT, &result); + + if (unlikely(is_rapid_charge && is_conservation)) { + dev_err(&priv->platform_device->dev, + "unexpected charge_types: both [Fast] and [Long_Life] are enabled\n"); + return -EINVAL; + } + + if (is_rapid_charge) + val->intval =3D POWER_SUPPLY_CHARGE_TYPE_FAST; + else if (is_conservation) val->intval =3D POWER_SUPPLY_CHARGE_TYPE_LONGLIFE; else val->intval =3D POWER_SUPPLY_CHARGE_TYPE_STANDARD; @@ -2087,6 +2146,12 @@ DEFINE_IDEAPAD_POWER_SUPPLY_EXTENSION(ideapad_batter= y_ext_v1, BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE)) ); =20 +DEFINE_IDEAPAD_POWER_SUPPLY_EXTENSION(ideapad_battery_ext_v2, + (BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) | + BIT(POWER_SUPPLY_CHARGE_TYPE_FAST) | + BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE)) +); + static int ideapad_battery_add(struct power_supply *battery, struct acpi_b= attery_hook *hook) { struct ideapad_private *priv =3D container_of(hook, struct ideapad_privat= e, battery_hook); @@ -2125,17 +2190,25 @@ static int ideapad_check_features(struct ideapad_pr= ivate *priv) priv->features.fan_mode =3D true; =20 if (acpi_has_method(handle, "GBMD") && acpi_has_method(handle, "SBMC")) { - priv->features.conservation_mode =3D true; - - priv->battery_ext =3D &ideapad_battery_ext_v1; - - priv->battery_hook.add_battery =3D ideapad_battery_add; - priv->battery_hook.remove_battery =3D ideapad_battery_remove; - priv->battery_hook.name =3D "Ideapad Battery Extension"; - - err =3D devm_battery_hook_register(&priv->platform_device->dev, &priv->b= attery_hook); - if (err) - return err; + /* Not acquiring gbmd_sbmc_mutex as race condition is impossible on init= */ + if (!eval_gbmd(handle, &val)) { + priv->features.conservation_mode =3D true; + priv->features.rapid_charge =3D test_bit(GBMD_RAPID_CHARGE_SUPPORTED_BI= T, + &val); + + priv->battery_ext =3D priv->features.rapid_charge + ? &ideapad_battery_ext_v2 + : &ideapad_battery_ext_v1; + + priv->battery_hook.add_battery =3D ideapad_battery_add; + priv->battery_hook.remove_battery =3D ideapad_battery_remove; + priv->battery_hook.name =3D "Ideapad Battery Extension"; + + err =3D devm_battery_hook_register(&priv->platform_device->dev, + &priv->battery_hook); + if (err) + return err; + } } =20 if (acpi_has_method(handle, "DYTC")) --=20 2.51.0