From patchwork Sun Sep 8 18:53:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 826526 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 11B7744C77 for ; Sun, 8 Sep 2024 18:53:54 +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=1725821636; cv=none; b=NfIzovIXxXxZRywKiIW3II4Tt7uoB30OlBiHFQhX4oj6DytGrjz7v9r4tY9o2BBjATxW6YWwc1j1GGdtxYnNb1oxdl1af0vdLkHUCP2ZrCS1TTYcjGudEr4jgn+oWax7bgMmGXpusrGPZyX9tEqoJskUY+2TAFCcJ8ClxrXE8vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725821636; c=relaxed/simple; bh=7SpYGXF9gyUbbUabUKS1OqgAmgLVILOxvs5wPjxAeKQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Wq4G6wXKtD19VteVAWMHegeXeoVJY7ay9O0k5Jbj5ffs6mYeJenfQHvYkW2C44yzpsPXXvAyIckEs3yx16zEUow4oE6UdRDgqDfmsN5ezPgh5hnGcqocnYxgC3Y7eed5L7hrahBNg/jHyTCK2dhlt0Y+dz1pWat+94cQiMEAgXs= 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=fIATNr6U; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fIATNr6U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725821633; 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; bh=EuHANs1y7PwP/ZmwVIIXiWluDY7ppr7zIuLMN7lCNv4=; b=fIATNr6Ue4eUEPcyxTR+hMhNN00g95dgnw39q7b4TfVIBzioxsCxbktEh7taV4i1dFN7yp D3iLz4M/NmAm+Vs0jJ/1xhcP5iWJyc7tQssn5mt99lMvzN9GoJ9pA9PhbrHaDW5K9Sx8a3 I2l8QjyJdNxeVmaIxagI+pBfwFZ1fNg= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-_qSgKUQbMLKrpo-mKojy0A-1; Sun, 08 Sep 2024 14:53:50 -0400 X-MC-Unique: _qSgKUQbMLKrpo-mKojy0A-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BBA0619560B0; Sun, 8 Sep 2024 18:53:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.33]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D77CE1956054; Sun, 8 Sep 2024 18:53:45 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel Cc: Hans de Goede , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Andrey Smirnov , linux-pm@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 6.11 regression fix 1/2] power: supply: Drop use_cnt check from power_supply_property_is_writeable() Date: Sun, 8 Sep 2024 20:53:36 +0200 Message-ID: <20240908185337.103696-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 power_supply_property_is_writeable() gets called from the is_visible() callback for the sysfs attributes of power_supply class devices and for the sysfs attributes of power_supply core instantiated hwmon class devices. These sysfs attributes get registered by the device_add() respectively power_supply_add_hwmon_sysfs() calls in power_supply_register(). use_cnt gets initialized to 0 and is incremented only after these calls. So when power_supply_property_is_writeable() gets called it always return -ENODEV because of use_cnt == 0. This causes all the attributes to have permissions of 444 even those which should be writable. This used to be a problem only for hwmon sysfs attributes but since commit be6299c6e55e ("power: supply: sysfs: use power_supply_property_is_writeable()") this now also impacts power_supply class sysfs attributes. Fixes: be6299c6e55e ("power: supply: sysfs: use power_supply_property_is_writeable()") Fixes: e67d4dfc9ff1 ("power: supply: Add HWMON compatibility layer") Cc: stable@vger.kernel.org Cc: Thomas Weißschuh Cc: Andrey Smirnov Signed-off-by: Hans de Goede --- The fixing of be6299c6e55e is a 6.11 regression fix, the fixing of e67d4dfc9ff1 hwmon attr never being writable is a stable series fix. This supersedes the "power: supply: sysfs: Revert use power_supply_property_is_writeable()" patch. --- drivers/power/supply/power_supply_core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 0417fb34e846..49534458a9f7 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1231,11 +1231,7 @@ EXPORT_SYMBOL_GPL(power_supply_set_property); int power_supply_property_is_writeable(struct power_supply *psy, enum power_supply_property psp) { - if (atomic_read(&psy->use_cnt) <= 0 || - !psy->desc->property_is_writeable) - return -ENODEV; - - return psy->desc->property_is_writeable(psy, psp); + return psy->desc->property_is_writeable && psy->desc->property_is_writeable(psy, psp); } EXPORT_SYMBOL_GPL(power_supply_property_is_writeable); From patchwork Sun Sep 8 18:53:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 826835 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 4A9AF174EFA for ; Sun, 8 Sep 2024 18:53:55 +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=1725821637; cv=none; b=JlOfKfQtFAt8tZDXCaMAz/6b6UrQA6xPCdJiYS7aswXZ7/fNx7GsnkWdoiWXYhQOdIk+/JNkkCrASVSGej2YZHwq3rVvtzC5uFb4e7hZz4ZCwtmrxCtRQ8j9lmdCOgN8+v+SlBO9QGSVBcZuAtlJugP5aWlw1goxwU2QJwApCxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725821637; c=relaxed/simple; bh=TXjT02nNkweRJpO5Dg7VuI6bj9MzmfhEHygdoEsmS6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K7rojFZ6AtsLSVd8ZIl3Rw18QZ8mnxdqM/61yvxBqYoOWnuTDBstFjBjEvPmr6gPFEyELmOd6znAhITiBhBI9sruwWGS14aXUs4F8cm+JmQWMP9KNvwan8/PkjoUJQzEB2/j5ts+SsW9QYNZkahUaXo2uMR0ZctGfB3Nv7V4lTI= 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=QPb50jte; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QPb50jte" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725821635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=//KSUME4WHQgSBtMhGH4ucq0GV1J/cFmQHUsvLow9Rk=; b=QPb50jteuW0mKBqrDGyHN8nRdtdTnn5q+ioQZWyX8sV+7xeyIYOikzaOLP8x62jzWeeCwI Z01M/KJKExCluDGK8VKor7F5n/XF5xNq6t3Auh3I9EmeSXsafwvlmaQWevpXvecyH7xbhS zYrW8w5+BRl1lk2WquUmDo5sQXw1u7A= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-nd4Pff0VM52M-0bsYgIP4A-1; Sun, 08 Sep 2024 14:53:52 -0400 X-MC-Unique: nd4Pff0VM52M-0bsYgIP4A-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C882A19560A5; Sun, 8 Sep 2024 18:53:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.33]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CA6A61955D44; Sun, 8 Sep 2024 18:53:48 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel Cc: Hans de Goede , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Andrey Smirnov , linux-pm@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/2] power: supply: hwmon: Fix missing temp1_max_alarm attribute Date: Sun, 8 Sep 2024 20:53:37 +0200 Message-ID: <20240908185337.103696-2-hdegoede@redhat.com> In-Reply-To: <20240908185337.103696-1-hdegoede@redhat.com> References: <20240908185337.103696-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Temp channel 0 aka temp1 can have a temp1_max_alarm attribute for power_supply devices which have a POWER_SUPPLY_PROP_TEMP_ALERT_MAX property. HWMON_T_MAX_ALARM was missing from power_supply_hwmon_info for temp channel 0, causing the hwmon temp1_max_alarm attribute to be missing from such power_supply devices. Add this to power_supply_hwmon_info to fix this. Fixes: f1d33ae806ec ("power: supply: remove duplicated argument in power_supply_hwmon_info") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede --- The original code accidentally listed HWMON_T_MIN_ALARM twice instead of having HWMON_T_MIN_ALARM + HWMON_T_MAX_ALARM. Commit f1d33ae806ec fixed this the wrong way by removing the second MIN_ALARM. --- drivers/power/supply/power_supply_hwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c index baacefbdf768..6fbbfb1c685e 100644 --- a/drivers/power/supply/power_supply_hwmon.c +++ b/drivers/power/supply/power_supply_hwmon.c @@ -318,7 +318,8 @@ static const struct hwmon_channel_info * const power_supply_hwmon_info[] = { HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MIN | - HWMON_T_MIN_ALARM, + HWMON_T_MIN_ALARM | + HWMON_T_MAX_ALARM, HWMON_T_LABEL | HWMON_T_INPUT |