Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp159597lqp; Sat, 8 Jun 2024 10:03:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+NtsR16M/dQ39SGOMwpI2+g+lSjzmIc1YR2M7j/Qh9n1wiFT8qM/f8rLGDVv/sv6qBQoFy2Guh4UvcpYR3euDqncrmfRN914e65qGJA== X-Google-Smtp-Source: AGHT+IH8tU6oUBFeGFLbrwcT5ZidNySlcg0NBESMhugzIzozyID8FxathwNWffFsF3Nyy/4cPDLO X-Received: by 2002:a67:fc43:0:b0:48c:3e33:998f with SMTP id ada2fe7eead31-48c3e339b69mr2092132137.31.1717866198635; Sat, 08 Jun 2024 10:03:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717866198; cv=pass; d=google.com; s=arc-20160816; b=pLBRzrjcDQOyU9QWRMyNjQO/LTuDyXSrjrEQCuGyuI17GLiy+LedGFLpbIRJnHcAwp tKn4EWyugOdS80ldwaFpn6gPlZFnXkUsZO/C76hYqisx/buQa67lJft8UMyjw2WmpXQR 8/OMMEcc5uuI2u8rdarCUj2v8E8azSuq2H8nVudWt/saRI7D7WajYydsJVmC/tEcR8Y/ ayoAodPUrm+NWCgjKPELdbQIJ8HDa30jPp5PuppYXCFRItcaNQrCagKQwLARtdPI7E44 qKXu1uks0iE5T782AAPouURGWvwHspprwZV0vg1XQb57cdfP327eAf4cY2ZZklynXaT1 POGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=rAJ9Ud+0EaAEVpt/9FikL8yHtZ2ZifeYq2sHJh5jXI8=; fh=BN6DWQc+MnlWEWgYy95bHRVZTOsE4rQbaiINtEblXjM=; b=QrvMq/0CXCUsj14H68F+8xd0lwR5gl2xireDXqTLR/e6m9TsHxg4nIwhZfc8ijz8rA iDFQVfdx/8YVKA9p1yTpixkx8y9QFR2wpNOrDoyINoiIu4DVBZ0EFRSghncm+KRMC+lE 9g6dW++Px0JTPFYIXmKbs8/bV6i/rLSu5r1bEUhaGbjQqlt+kYbTGZBNMdS/26W9w0aA wuYWhiBryCHFPqXCNj23VUeAcL4jrISwx7JprPq4PKJT6VBN3SRGiKCf8yRq2hN6FvhF Ib15H+3LpRH/iodKiLVTWML4KV7M6xWuAlWAV2D6rEvTjYkys8FsWv3DDYwvBEPQqRpC bxHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=ABe7Kc3s; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net dmarc=pass fromdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-207149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207149-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=weissschuh.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ada2fe7eead31-48c1a1eabe6si1407885137.350.2024.06.08.10.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 10:03:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=ABe7Kc3s; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net dmarc=pass fromdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-207149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207149-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=weissschuh.net 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 49CB71C20AFA for ; Sat, 8 Jun 2024 17:03:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF7A117B510; Sat, 8 Jun 2024 17:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ABe7Kc3s" 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 8E0C21E4A6; Sat, 8 Jun 2024 17:03: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=1717866189; cv=none; b=Po/mlruE7ljLrvFgZiOse0I+LtKwNbUhwk+pTSrfIAGpmAQQp8dXOO+ttItv/gfsbEC04rpuFAnvBOCzwp1VzPLzuK7a9MEBeZfWPAb3cenDpiDbLDhDNgjqhcsWS85waMA7YPS3yFlRV/TF7rU/O6VDZPmL3774ayR7rO2Fak4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717866189; c=relaxed/simple; bh=aueIvf1hpPSoXzp5MDugHfujuyMFd0wpUQBGOz+woqM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SS8awZXQxEQf50Q5w8oXVPiKOE5z/C++1Q2tNpuClLC17bP9RRzUout92gxSxnpvuX5uBe2pLaFSSjZrUKxxfizNbYSsqvXKmpDVVpv/FYBLCOVMWWn5KcInQh56lohqsbyLm8+v+melOfXX9YvaulUVcoCXtkkxdb849ffoIJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=ABe7Kc3s; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717866175; bh=aueIvf1hpPSoXzp5MDugHfujuyMFd0wpUQBGOz+woqM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ABe7Kc3swRWGza89hhw/QA4ntSQ27MCPhSzAk/lmH7UDsh3k8O4lpkioyPTBXKL2r iiYcEWm0MHoLKRns/qfLWT/6+g4riVrK+XWi5lQvK4u7AI07E847dyKWaJ8JN8vr85 5lh8qB4MqsZlMGGyx83QkFFBUV+5FB0Zr633l704= Date: Sat, 8 Jun 2024 19:02:53 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Armin Wolf Cc: Sebastian Reichel , Jeremy Soller , System76 Product Development , Hans de Goede , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: Re: [PATCH RFC 0/6] power: supply: extension API Message-ID: References: <20240606-power-supply-extensions-v1-0-b45669290bdc@weissschuh.net> <41964782-222c-45fa-846e-3656eff5b3a9@gmx.de> <86cafef5-8a41-46c8-8ee6-6b25dd165b58@t-8ch.de> <992978fb-d74c-4da7-a103-9b623b78d889@gmx.de> 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: <992978fb-d74c-4da7-a103-9b623b78d889@gmx.de> On 2024-06-08 18:27:07+0000, Armin Wolf wrote: > Am 07.06.24 um 12:26 schrieb Thomas Weißschuh: > > > On 2024-06-07 01:10:02+0000, Armin Wolf wrote: > > > Am 06.06.24 um 16:50 schrieb Thomas Weißschuh: > > > > > > > Introduce a mechanism for drivers to extend the properties implemented > > > > by a power supply. > > > > > > > > [0] https://lore.kernel.org/lkml/20240528-cros_ec-charge-control-v2-0-81fb27e1cff4@weissschuh.net/ > > > Nice, i love this proposal! > > Good to hear! > > > > > I agree that the hwmon update functionality will need some changes in the hwmon core to work, > > > but there would be at least one driver benefiting from this (dell-wmi-ddv). Maybe we can add > > > support for this at a later point in time. > > Surely. Alternatively we could re-register the hwmon device after an > > extension was added. > > > > > The possibility of registering multiple power supply extensions on a single power supply will > > > be necessary to support battery charge control on Dell notebooks in the future. This is because > > > there will be two drivers on Dell notebooks which register battery extensions: dell-wmi-ddv and > > > dell-laptop (when support for battery charge control is supported someday). > > > > > > How difficult would it be to support such scenarios? If its very difficult, then maybe we can implement > > > this later when the need arises. > > It's not really difficult. The problem is in the callback functions > > going from a 'struct power_supply' back to the correct extension struct > > for use with container_of() to access the drivers private data. > > > > But we can add a marker member to 'struct power_supply_ext' with which > > the callback can figure out which of the registered extensions is its > > own. Something like "led_hw_trigger_type" in the LED subsystem. > > Maybe we can do the same thing as the battery hook API and just pass a pointer to > the power_supply_ext instance to the callbacks. They then can use container_of() > to access the drivers private data if the struct power_supply_ext is embedded > inside the private data struct. That indeed sounds like the obvious thing to do. I tried very hard to keep the callback signatures exactly the same as in power_supply_desc and didn't even see this possibility. > > > > > And some documentation about how conflicts are to be resolved. > > > > Thomas > > Sound like a plan, i suggest that extensions be prevented from registering with > a power supply containing conflicting properties or containing extensions with > conflicting properties. Ack. > As a side note, maybe there is a way to make power_supply_update_groups() available > for other power supply drivers? Afaik the ACPI battery driver would benefit from this too. I'll take a look and spin that into its own series. Or as you seem to know that driver better, I'd be happy if you did. > Thanks, > Armin Wolf > > > > > Signed-off-by: Thomas Weißschuh > > > > --- > > > > Thomas Weißschuh (6): > > > > power: supply: sysfs: use power_supply_property_is_writeable() > > > > power: supply: core: avoid iterating properties directly > > > > power: supply: core: implement extension API > > > > power: supply: core: add locking around extension access > > > > power: supply: test-power: implement a power supply extension > > > > platform/x86: system76: Use power_supply extension API > > > > > > > > drivers/platform/x86/system76_acpi.c | 83 +++++++++--------- > > > > drivers/power/supply/power_supply.h | 9 ++ > > > > drivers/power/supply/power_supply_core.c | 136 ++++++++++++++++++++++++++++-- > > > > drivers/power/supply/power_supply_hwmon.c | 48 +++++------ > > > > drivers/power/supply/power_supply_sysfs.c | 39 ++++++--- > > > > drivers/power/supply/test_power.c | 102 ++++++++++++++++++++++ > > > > include/linux/power_supply.h | 25 ++++++ > > > > 7 files changed, 357 insertions(+), 85 deletions(-) > > > > --- > > > > base-commit: 2df0193e62cf887f373995fb8a91068562784adc > > > > change-id: 20240602-power-supply-extensions-07d949f509d9