From patchwork Sun Feb 4 17:26:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13544751 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 08719249E4; Sun, 4 Feb 2024 17:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067629; cv=none; b=VgVUt5w4qbKnUdIv8QKaKqqORfwuh1JJoRKLPS3m2LaHKNhoLxGO7GtGnFRaRqmEiLppF6ybifHQGVHh1ShNcdffMpAi1Rx5SOiW0PB9hEU68NcRSKE2dNLkBQhH3b51Khv+Ik8iitEWxFZ2m0dniBG6L8em4JRCz1cAbC0iEww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067629; c=relaxed/simple; bh=83yBY9rck6+K+bEFFiUYGjSaD/z/BJ7WS//fZZE59+k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DddXjRpyKDICl6DYxW0bnU/zlXj7GZn6SSnXyZ87ZDiWe3VUOmZIE9qmWdZelFc+oKkgB5GpvpnlkbrC9BFrLDCdaKQ3nl1i7M2vKL7438LZOOErbYI+OiWwtHEgA9J/9WiJbLLTVn+ViNyCG7Ap1a68hiDr87AIGE2AV4F3lqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=lo+YLcnf; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="lo+YLcnf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1707067616; bh=83yBY9rck6+K+bEFFiUYGjSaD/z/BJ7WS//fZZE59+k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lo+YLcnfHwvLzQS0lWRbt0O8A/HkKVTTx9cjxoxp4BnCaF+tDTHNjnQb4+mmWaWwP LG55jcYg6vZ3bgOXcq1rJDHllkQdqXLaw5pWCWoB0Dq/qbYCpxtnxpCSMcR8eZaIEc JPUhv86cCi1HOOsxbq5id5x1MoqGcWCfCitXfT/E= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 04 Feb 2024 18:26:47 +0100 Subject: [PATCH 1/4] power: supply: core: fix charge_behaviour formatting Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240204-power_supply-charge_behaviour_prop-v1-1-06a20c958f96@weissschuh.net> References: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> In-Reply-To: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> To: Sebastian Reichel , Hans de Goede , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707067615; l=3685; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=83yBY9rck6+K+bEFFiUYGjSaD/z/BJ7WS//fZZE59+k=; b=//GN4ufpRA6QtLBhWpmTQ7vbg0vlaq/ZYuBZfls9xZQQXdtbiWc7f8DcS++H1Yr9WG3b+Mx/l vmnDc4L7qgtA0kgkj/5VjWwEW/+zw0lHH5e2mrO/xHXK7d/n+ae3dv+ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This property is documented to have a special format which exposes all available behaviours and the currently active one at the same time. For this special format some helpers are provided. However the default property logic in power_supply_sysfs.c is not using the helper and the default logic only prints the currently active behaviour. Adjust power_supply_sysfs.c to follow the documented format. There are currently two in-tree drivers exposing charge behaviours: thinkpad_acpi and mm8013. thinkpad_acpi is not affected by the change, as it directly uses the helpers and does not use the power_supply_sysfs.c logic. As mm8013 does not implement POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE the new logic will preserve the simple output format in this case. Fixes: 1b0b6cc8030d ("power: supply: add charge_behaviour attributes") Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_sysfs.c | 32 +++++++++++++++++++++++++++++++ include/linux/power_supply.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 977611e16373..3680cfc2e908 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -271,6 +271,32 @@ static ssize_t power_supply_show_usb_type(struct device *dev, return count; } +static ssize_t power_supply_show_charge_behaviour(struct device *dev, + struct power_supply *psy, + struct power_supply_attr *ps_attr, + union power_supply_propval *value, + char *buf) +{ + union power_supply_propval available; + int ret; + + ret = power_supply_get_property(psy, + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, + value); + if (ret < 0) + return ret; + + ret = power_supply_get_property(psy, + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE, + &available); + if (ret == -EINVAL) + return sysfs_emit(buf, "%s\n", ps_attr->text_values[value->intval]); + else if (ret < 0) + return ret; + + return power_supply_charge_behaviour_show(dev, available.intval, value->intval, buf); +} + static ssize_t power_supply_show_property(struct device *dev, struct device_attribute *attr, char *buf) { @@ -282,6 +308,8 @@ static ssize_t power_supply_show_property(struct device *dev, if (psp == POWER_SUPPLY_PROP_TYPE) { value.intval = psy->desc->type; + } else if (psp == POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR) { + value.intval = -1; } else { ret = power_supply_get_property(psy, psp, &value); @@ -308,6 +336,10 @@ static ssize_t power_supply_show_property(struct device *dev, ret = power_supply_show_usb_type(dev, psy->desc, &value, buf); break; + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: + ret = power_supply_show_charge_behaviour(dev, psy, ps_attr, + &value, buf); + break; case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER: ret = sysfs_emit(buf, "%s\n", value.strval); break; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index c0992a77feea..9a6e6b488164 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -135,6 +135,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD, /* in percents! */ POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD, /* in percents! */ POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT, POWER_SUPPLY_PROP_INPUT_POWER_LIMIT, From patchwork Sun Feb 4 17:26:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13544749 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 28B45249E8; Sun, 4 Feb 2024 17:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067628; cv=none; b=EZ7FYJXUXQWJM/Xtf3+0xJCPGadATpKP/5XAontJt9KVuxUeB7UdXbUmdD6JOAp4KWQWcerDEhxj4/sZ4fOtcMdTqo3s2uR23F1dEyuPYWz3HHsxNspwWmzJeqY4ZdB9IzSrPkI+wbRLDfc2e9IjKXLtsZzYzYsxPXROdAo0E7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067628; c=relaxed/simple; bh=jhC9MrS/DvTlCbbFDLlt5Ex7tBPY1h+Ja6j31zHqUDY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nlO350l4PLBz0TdlfPLYd8s4EzW091M/4QKycQ0xmyTRhCE5lVqZOWOQiSdMCOGH5F2Z+4tjH15i0l7ujyrNxQw2+26DPYryog4/T9N4/ZSJ9gfbRqJ0lWc8R0J/A+ODOhCCYGn0I7J+kv7ORBbSmZ9uWqc26zhrcq7KbFeCtMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=tyLZio+5; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="tyLZio+5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1707067616; bh=jhC9MrS/DvTlCbbFDLlt5Ex7tBPY1h+Ja6j31zHqUDY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tyLZio+5j4b83kcLgkgcckSZaIgFsNQpbcTS228yUnQNV8ZI6km4TWXHLG1bCwH6C CWl20AY27g3aXB2SnNMk2/QLNALVygFjQbkzndbxx/lnW6vR3eBYHOZ8zMp7BFt3DT XSsjyK7mYpPFBMTaXQmpknrPiGoEYpVRWpS8OG3g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 04 Feb 2024 18:26:48 +0100 Subject: [PATCH 2/4] power: supply: test-power: implement charge_behaviour property Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240204-power_supply-charge_behaviour_prop-v1-2-06a20c958f96@weissschuh.net> References: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> In-Reply-To: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> To: Sebastian Reichel , Hans de Goede , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707067615; l=1449; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=jhC9MrS/DvTlCbbFDLlt5Ex7tBPY1h+Ja6j31zHqUDY=; b=zSfoi6za/QSGlccGGbzM0jSxDfpkVUL9clLjL0HYWEfz4XEYhYCjmCPGJL/T6t+imjLVgXj4F SwJNzFhUwv5BECr78yk3M/Ssle1fo8sJaciCuX9QHRWxbIXPlGWbObj X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= To validate the special formatting of the "charge_behaviour" sysfs property add it to the example driver. Signed-off-by: Thomas Weißschuh Reviewed-by: Hans de Goede --- drivers/power/supply/test_power.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c index 0d0a77584c5d..4da0420996c9 100644 --- a/drivers/power/supply/test_power.c +++ b/drivers/power/supply/test_power.c @@ -123,6 +123,14 @@ static int test_power_get_battery_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = battery_current; break; + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: + val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE; + break; + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE: + val->intval = BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) + | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE) + | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE); + break; default: pr_info("%s: some properties deliberately report errors.\n", __func__); @@ -156,6 +164,8 @@ static enum power_supply_property test_power_battery_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CURRENT_NOW, + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE, }; static char *test_power_ac_supplied_to[] = { From patchwork Sun Feb 4 17:26:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13544748 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 28B82249EA; Sun, 4 Feb 2024 17:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067628; cv=none; b=jPCQTbjwN7rblAPDmUbd5r7dZdncOTNRdlYGb3xPg7rRmvXBGfhFvaIoWQi4lB232/mtOXLlQ0mPD/xtE/7minYXAEhPThO56MUt18ABENK1Q7rppb0YbfkC7AAzd770ag2fNROctgHVM5XHUIrAjWQ/iwaVfZpNt45wGIDFYtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067628; c=relaxed/simple; bh=2bfpIaHPb+FVKiLlqv6onKrx8jugClAtzAL49QT9tj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KiK54Rv1wCQuV2Cy5JWhv8TdcjTW3Oan3d46V8y/USJaJ/YpGnOkfcu5NQWjVOfs2YNIAwMvLqyiPnRb+RCADtJ8AgvoSzGv2OH6/6LZ63/l/+0fho+yHnGY+YTTeuMLVW3vfbDqeGPs4YLVgWOEWP0IJ5w8UJxyJ65s9eZEjNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=fhMew4Ad; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="fhMew4Ad" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1707067616; bh=2bfpIaHPb+FVKiLlqv6onKrx8jugClAtzAL49QT9tj8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fhMew4AdtulXYoY2VpXWRvQfvCaONA9fIk0LjMdi2qR/prFTX4jXe/5paqNJRUXoT Ofa50BkT4C7yjQdfSZ2q3CFDq5AVxx+TpEOwXRu5Vj8y+9xbcll7Gjz1A8vP7PV+oj r0rb5D5DBG64iNSuJVBX64a1iWFdMce2R4x2dZpo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 04 Feb 2024 18:26:49 +0100 Subject: [PATCH 3/4] power: supply: mm8013: implement POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240204-power_supply-charge_behaviour_prop-v1-3-06a20c958f96@weissschuh.net> References: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> In-Reply-To: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> To: Sebastian Reichel , Hans de Goede , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707067615; l=1478; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=2bfpIaHPb+FVKiLlqv6onKrx8jugClAtzAL49QT9tj8=; b=YAQ1hO1l8kQ2VYBnblYST3jQhV0wwQngktbNHMJepEyv1/a45AjNO688GAhvqu6GTPruwmRT6 WJKAK1usPsRCQSUvaXcHAkVVdbH8TBXgd/RbKNCcpOKqPQVfpGM2BS8 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The sysfs is documented to report both the current and all available behaviours. For this POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE needs to be implemented. Note that this changes the format of the sysfs file (to the documented format): Before: "auto" After: "[auto] inhibit-charge" Signed-off-by: Thomas Weißschuh Reviewed-by: Hans de Goede Reviewed-by: Konrad Dybcio --- drivers/power/supply/mm8013.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/power/supply/mm8013.c b/drivers/power/supply/mm8013.c index caa272b03564..695df8bd6cb0 100644 --- a/drivers/power/supply/mm8013.c +++ b/drivers/power/supply/mm8013.c @@ -72,6 +72,7 @@ static int mm8013_checkdevice(struct mm8013_chip *chip) static enum power_supply_property mm8013_battery_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE, POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_NOW, @@ -113,6 +114,10 @@ static int mm8013_get_property(struct power_supply *psy, else val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; break; + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE: + val->intval = BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) + | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE); + break; case POWER_SUPPLY_PROP_CHARGE_FULL: ret = regmap_read(chip->regmap, REG_FULL_CHARGE_CAPACITY, ®val); if (ret < 0) From patchwork Sun Feb 4 17:26:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13544752 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 B574F249ED; Sun, 4 Feb 2024 17:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067629; cv=none; b=dHH63r4aIK3w7nNfv8aty8iAdAjPaFLFBkh20/TRfn8BFHG9QFp4Hqznez4ugsItgGgJdv0TaHlEq+QEXWq9p2DbymZgdERne6OoyC9fDrtoqsgWJ0fxfWNObStAcrekhqCN+CtGB12GwNSe4m/rWSFjYyCyhenw0dXDKbmsNoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067629; c=relaxed/simple; bh=IxAmxaUd639konem1J0CwPySbGfu/rKfRx4PF1P1Nfs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=prDWyAgKBHPm+bEi/8724guZTUeGfeD5aJnYz3zLikrCigHTb60u8f4UXjPuMuaeqwsvotLaKLlzbn/oldfFqBg6tnpr/uDBvAeISHP1nt2ynyzz2f0S/S2rMxBxs8LgbJw1ugVv/ZZ6Wt6HrBD6w6WUufvSwNrDQVooZ24usmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=gEt+CYFa; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="gEt+CYFa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1707067616; bh=IxAmxaUd639konem1J0CwPySbGfu/rKfRx4PF1P1Nfs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gEt+CYFah1lDU279fX90PzcJZtwNiZTHhOkKgmMS+iwsL9kJdmFX+fW8UbUqEfDww +ba8M3dextPoKKVkjZUiqNRrNFwYpBX/mMD69h2h1o9klPpnZ2oN4A2P/tWg85vFGl 3/xvPDcLYmGSOGIgPLw2vMyuwhH16YNcOG9p+JMw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 04 Feb 2024 18:26:50 +0100 Subject: [PATCH 4/4] power: supply: core: drop workaround for missing POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240204-power_supply-charge_behaviour_prop-v1-4-06a20c958f96@weissschuh.net> References: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> In-Reply-To: <20240204-power_supply-charge_behaviour_prop-v1-0-06a20c958f96@weissschuh.net> To: Sebastian Reichel , Hans de Goede , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707067615; l=1735; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=IxAmxaUd639konem1J0CwPySbGfu/rKfRx4PF1P1Nfs=; b=nN0rW/JGrCJIb+/x9MMDNSXtBsocp2ba6MNqVU656ezGH4x7jbknMB4pZdT5XLMbyMKZpfAv/ xTfUVOKIqxuBsXEyAmgaOaqbxZu9C4OO3LwGLhgoc6rpM2OGRubm+X9 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= As the mm8013 driver was extended to also report that property the workaround is not needed anymore. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_sysfs.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 3680cfc2e908..3804a3bbed24 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -273,7 +273,6 @@ static ssize_t power_supply_show_usb_type(struct device *dev, static ssize_t power_supply_show_charge_behaviour(struct device *dev, struct power_supply *psy, - struct power_supply_attr *ps_attr, union power_supply_propval *value, char *buf) { @@ -289,9 +288,7 @@ static ssize_t power_supply_show_charge_behaviour(struct device *dev, ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR_AVAILABLE, &available); - if (ret == -EINVAL) - return sysfs_emit(buf, "%s\n", ps_attr->text_values[value->intval]); - else if (ret < 0) + if (ret < 0) return ret; return power_supply_charge_behaviour_show(dev, available.intval, value->intval, buf); @@ -337,8 +334,7 @@ static ssize_t power_supply_show_property(struct device *dev, &value, buf); break; case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: - ret = power_supply_show_charge_behaviour(dev, psy, ps_attr, - &value, buf); + ret = power_supply_show_charge_behaviour(dev, psy, &value, buf); break; case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER: ret = sysfs_emit(buf, "%s\n", value.strval);