From patchwork Tue Dec 10 21:55: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: 13902116 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 601CF2397B6; Tue, 10 Dec 2024 21:56: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=1733867765; cv=none; b=OFZbhHeP6zqDdEBpL5eP7SXos074l8bt2au4AXjHJQ0LvKc+oDSMVBlRrXrzQfcqK7FAjeFMPgygVaAP/Ut5ck44ix9vmsFOUn3Aw/mu8/awl2M90Mf/i9qnp0NTyirED+KvD12x8HswqFZeStdNVE4bBILeANo62SNa/DthfAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867765; c=relaxed/simple; bh=Rkince4SbmHoWAJI8yRTlw7n74O79dIb/szqZ+k52X0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BeQg7N9wo9cE2Pvp1KbAZSOwPG9ZziRfiq+64pjQEcMFDthZeb4lWkznPjWCY+gza1ypxE+hiUpoiDxE8gUY0vPi9O3Jp7fraZbjqP/I46SGhvYEAyZqYRKq1+yfKLS3wfQVU79lMoPj/zUvJUfXoDX6gvf49ymsfClW+2Bh5Xc= 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=I+ZHRQFX; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="I+ZHRQFX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867760; bh=Rkince4SbmHoWAJI8yRTlw7n74O79dIb/szqZ+k52X0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I+ZHRQFXvnnI7tKo1uptF7DaH5A5OF2A3GrxYi29NmNFRFf+JKZoody+UDZu52gEl 1qa6yM1KgKGA84MVNEEPt9GDlkKfBa+UPJEsez0WBkh2w0+khF+GQxk/4QYtpLylxO Ilkt85jdz49W9sG2lO8FwFriG1fhy8Sgw7BPFOkg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:48 +0100 Subject: [PATCH v2 01/14] power: supply: mm8013: use accessor for driver data Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-1-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=795; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Rkince4SbmHoWAJI8yRTlw7n74O79dIb/szqZ+k52X0=; b=yRMd1OWjV5tRW6wmCgjUKhLOZqxJwf3GO3jOa8Pqda4apXT6jYmJOW7d+hrX8gSaFXH0hjEdc 42RJ3CdFFnvBj1tWrPE15HS7nJDH9T/sEpQghDNgZttfPxfE1JAdIa/ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Instead of directly accessing the structure member, use the accessor. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/mm8013.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/mm8013.c b/drivers/power/supply/mm8013.c index 5bcfaeeda3db755e05a449cbfd6f0c72162b6890..4adf2acc2779366323e52c467cff4f99ebb9d6ea 100644 --- a/drivers/power/supply/mm8013.c +++ b/drivers/power/supply/mm8013.c @@ -90,7 +90,7 @@ static int mm8013_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { - struct mm8013_chip *chip = psy->drv_data; + struct mm8013_chip *chip = power_supply_get_drvdata(psy); int ret = 0; u32 regval; From patchwork Tue Dec 10 21:55: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: 13902117 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 ED0F323874D; Tue, 10 Dec 2024 21:56:02 +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=1733867765; cv=none; b=CgjCgaZiH6BMffMtCgJ/8qGOstwC0XNEx2i4X3CbLRqh93rRsgkOTmXCmM3XAAGpshNRkpYv11Vi1ZO1rEaRJbbfz6AwKQu7XxWndVQeQ0kb+TwN1n70u0YwkOLLnZ/8kvMrQ3riAIqFnPv1fAEXbTBxOabtS1VUzc3QetZ9KZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867765; c=relaxed/simple; bh=5uH53yw6BlCKxmOXRAKHQy9Q+cvI4FT7Jj+ynXFpNQM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CT56gT+HyrCSbUWCXoTAMMtW3PTaZMqnbygHjfccPu2xac8zExFzzQ9AgVAX0JWf0hKd4SAE6DH4uVTIVUDZfxC63tHDYe468bsdjAVUgczt6WUNN8fYzv5gsJrsJWItlYky83OaiN1ZMFlu8EHulVZKTyx+JH1pAC003MchNQY= 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=KX/RgObx; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="KX/RgObx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867760; bh=5uH53yw6BlCKxmOXRAKHQy9Q+cvI4FT7Jj+ynXFpNQM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KX/RgObxrW0BNiYpvVLa9hvrzUO6r4r0z7TqzEPKALUfxmKOpTedk3J/Rq/Si5I0N cBtQQ/pIgRbrpZlZLOs/P9xLss5jQBT+GZCICJAtYuGVJFD/iKphgpN+BTMnmB63nC QsoH0/1zKnVLQW6o9Qf6h16jH4Rm9FIad7XCG3mE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:49 +0100 Subject: [PATCH v2 02/14] power: supply: core: introduce power_supply_for_each_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-2-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=2415; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=5uH53yw6BlCKxmOXRAKHQy9Q+cvI4FT7Jj+ynXFpNQM=; b=pJH1NhYDXUMVciIHIesB6HzcnMC/dW7jSlm37iJiHiKG1Vh+NxSSZAHRNhNKVUpuJlaE9ZjQu Xs4YyT3bq+IBnVn68cSFg0PfilC7kZO7Y2Q1UGBI//QAnEAtMmFyhHx X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= All existing callers of power_supply_for_each_device() want to iterate over 'struct power_supply', not 'struct device'. The power_supply_for_each_device() forces each caller to duplicate the logic to go from one to the other. Introduce power_supply_for_each_psy() to simplify the callers. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_core.c | 24 ++++++++++++++++++++++++ include/linux/power_supply.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 502b07468b93dfb7f5a6c2092588d931a7d015f2..48bc968ff6c54d4b196c3faf450ef6464cdb305d 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -122,6 +122,30 @@ int power_supply_for_each_device(void *data, int (*fn)(struct device *dev, void } EXPORT_SYMBOL_GPL(power_supply_for_each_device); +struct psy_for_each_psy_cb_data { + int (*fn)(struct power_supply *psy, void *data); + void *data; +}; + +static int psy_for_each_psy_cb(struct device *dev, void *data) +{ + struct psy_for_each_psy_cb_data *cb_data = data; + struct power_supply *psy = dev_get_drvdata(dev); + + return cb_data->fn(psy, cb_data->data); +} + +int power_supply_for_each_psy(void *data, int (*fn)(struct power_supply *psy, void *data)) +{ + struct psy_for_each_psy_cb_data cb_data = { + .fn = fn, + .data = data, + }; + + return power_supply_for_each_device(&cb_data, psy_for_each_psy_cb); +} +EXPORT_SYMBOL_GPL(power_supply_for_each_psy); + void power_supply_changed(struct power_supply *psy) { unsigned long flags; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index b98106e1a90f34bce5129317a099f363248342b9..11d54270eaa9216f3e46e129cd363a804ae8759a 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -882,6 +882,7 @@ extern int power_supply_powers(struct power_supply *psy, struct device *dev); extern void *power_supply_get_drvdata(struct power_supply *psy); extern int power_supply_for_each_device(void *data, int (*fn)(struct device *dev, void *data)); +extern int power_supply_for_each_psy(void *data, int (*fn)(struct power_supply *psy, void *data)); static inline bool power_supply_is_amp_property(enum power_supply_property psp) { From patchwork Tue Dec 10 21:55: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: 13902119 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 819112397BD; Tue, 10 Dec 2024 21:56: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=1733867765; cv=none; b=UGBNEdCnP2ygE4FKG/LzYHJL48pS8Oi8UmyvWCcP9Y3k7pfFAgGQxzdLfO2fifvYFG/RJ0kfMWZvPo64IHc4mBfAm+hkgw168VhUho9013iL26/7Xz4UvIRkiwYlNwYNOs02zuza8NgOm5Q9d1seEX2HHg+1C8UyYhUMLfMAE4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867765; c=relaxed/simple; bh=YkNrJgESTFAyTUd0+T8p/6aBvt4WlaBqGr2px019fMM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ScHG1x5GQKZZYHMfrSwkfcgFjAnMtT/3SGLSz5N/In68b4neRzGmLSmBHteYtJVZcMJ8zzxMWE8PoYyhFG1Pi3A9tfaBwEXzOsu+xhTEDKZcpm1yWqLIUwmmBf/BSdYM/1ClijRXTGpgnuVm/PubqmCwMF2dmG9hbGqhTCblbHs= 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=rFHanaGI; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="rFHanaGI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867760; bh=YkNrJgESTFAyTUd0+T8p/6aBvt4WlaBqGr2px019fMM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rFHanaGIurt+CJIWmaEcOlBWzw72EFt6GPm/55eLKUs3wLC6Qj0q59623NQ8koT6U pFao1N8NFl6Ev0TO7E0e3v7SnjCzF8Vq9e3nWq63vR3aNnLrBsfIQQs7MwrKRRyCZp bf/bEkjOvKVECN+lm9z3G+X4O28beLYMzpLgoOPQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:50 +0100 Subject: [PATCH v2 03/14] power: supply: core: use power_supply_for_each_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-3-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=6259; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=YkNrJgESTFAyTUd0+T8p/6aBvt4WlaBqGr2px019fMM=; b=1neJt9ePv378obVWBm/dOHIgWAKwhJt95BEf/gwXMTpENVvfZmOtOAOR+n9Lq96NFJTMSxp2Y U+yeHAdNv7WD2wPZK47qafwNhARVb8rhvgdB7vfzeWukT9QNSutmsGh X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Simplify the callbacks by removing the need to convert a 'struct device' into a 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_core.c | 36 +++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 48bc968ff6c54d4b196c3faf450ef6464cdb305d..9adea87c69124f7025a06fe7550892392e28cd65 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -66,10 +66,9 @@ static bool __power_supply_is_supplied_by(struct power_supply *supplier, return false; } -static int __power_supply_changed_work(struct device *dev, void *data) +static int __power_supply_changed_work(struct power_supply *pst, void *data) { struct power_supply *psy = data; - struct power_supply *pst = dev_get_drvdata(dev); if (__power_supply_is_supplied_by(psy, pst)) { if (pst->desc->external_power_changed) @@ -98,7 +97,7 @@ static void power_supply_changed_work(struct work_struct *work) if (likely(psy->changed)) { psy->changed = false; spin_unlock_irqrestore(&psy->changed_lock, flags); - power_supply_for_each_device(psy, __power_supply_changed_work); + power_supply_for_each_psy(psy, __power_supply_changed_work); power_supply_update_leds(psy); blocking_notifier_call_chain(&power_supply_notifier, PSY_EVENT_PROP_CHANGED, psy); @@ -190,11 +189,10 @@ static void power_supply_deferred_register_work(struct work_struct *work) } #ifdef CONFIG_OF -static int __power_supply_populate_supplied_from(struct device *dev, +static int __power_supply_populate_supplied_from(struct power_supply *epsy, void *data) { struct power_supply *psy = data; - struct power_supply *epsy = dev_get_drvdata(dev); struct device_node *np; int i = 0; @@ -221,20 +219,19 @@ static int power_supply_populate_supplied_from(struct power_supply *psy) { int error; - error = power_supply_for_each_device(psy, __power_supply_populate_supplied_from); + error = power_supply_for_each_psy(psy, __power_supply_populate_supplied_from); dev_dbg(&psy->dev, "%s %d\n", __func__, error); return error; } -static int __power_supply_find_supply_from_node(struct device *dev, +static int __power_supply_find_supply_from_node(struct power_supply *epsy, void *data) { struct device_node *np = data; - struct power_supply *epsy = dev_get_drvdata(dev); - /* returning non-zero breaks out of power_supply_for_each_device loop */ + /* returning non-zero breaks out of power_supply_for_each_psy loop */ if (epsy->of_node == np) return 1; @@ -246,16 +243,16 @@ static int power_supply_find_supply_from_node(struct device_node *supply_node) int error; /* - * power_supply_for_each_device() either returns its own errors or values + * power_supply_for_each_psy() either returns its own errors or values * returned by __power_supply_find_supply_from_node(). * * __power_supply_find_supply_from_node() will return 0 (no match) * or 1 (match). * - * We return 0 if power_supply_for_each_device() returned 1, -EPROBE_DEFER if + * We return 0 if power_supply_for_each_psy() returned 1, -EPROBE_DEFER if * it returned 0, or error as returned by it. */ - error = power_supply_for_each_device(supply_node, __power_supply_find_supply_from_node); + error = power_supply_for_each_psy(supply_node, __power_supply_find_supply_from_node); return error ? (error == 1 ? 0 : error) : -EPROBE_DEFER; } @@ -340,10 +337,9 @@ struct psy_am_i_supplied_data { unsigned int count; }; -static int __power_supply_am_i_supplied(struct device *dev, void *_data) +static int __power_supply_am_i_supplied(struct power_supply *epsy, void *_data) { union power_supply_propval ret = {0,}; - struct power_supply *epsy = dev_get_drvdata(dev); struct psy_am_i_supplied_data *data = _data; if (__power_supply_is_supplied_by(epsy, data->psy)) { @@ -361,7 +357,7 @@ int power_supply_am_i_supplied(struct power_supply *psy) struct psy_am_i_supplied_data data = { psy, 0 }; int error; - error = power_supply_for_each_device(&data, __power_supply_am_i_supplied); + error = power_supply_for_each_psy(&data, __power_supply_am_i_supplied); dev_dbg(&psy->dev, "%s count %u err %d\n", __func__, data.count, error); @@ -372,10 +368,9 @@ int power_supply_am_i_supplied(struct power_supply *psy) } EXPORT_SYMBOL_GPL(power_supply_am_i_supplied); -static int __power_supply_is_system_supplied(struct device *dev, void *data) +static int __power_supply_is_system_supplied(struct power_supply *psy, void *data) { union power_supply_propval ret = {0,}; - struct power_supply *psy = dev_get_drvdata(dev); unsigned int *count = data; if (!psy->desc->get_property(psy, POWER_SUPPLY_PROP_SCOPE, &ret)) @@ -396,7 +391,7 @@ int power_supply_is_system_supplied(void) int error; unsigned int count = 0; - error = power_supply_for_each_device(&count, __power_supply_is_system_supplied); + error = power_supply_for_each_psy(&count, __power_supply_is_system_supplied); /* * If no system scope power class device was found at all, most probably we @@ -415,9 +410,8 @@ struct psy_get_supplier_prop_data { union power_supply_propval *val; }; -static int __power_supply_get_supplier_property(struct device *dev, void *_data) +static int __power_supply_get_supplier_property(struct power_supply *epsy, void *_data) { - struct power_supply *epsy = dev_get_drvdata(dev); struct psy_get_supplier_prop_data *data = _data; if (__power_supply_is_supplied_by(epsy, data->psy)) @@ -442,7 +436,7 @@ int power_supply_get_property_from_supplier(struct power_supply *psy, * This function is not intended for use with a supply with multiple * suppliers, we simply pick the first supply to report the psp. */ - ret = power_supply_for_each_device(&data, __power_supply_get_supplier_property); + ret = power_supply_for_each_psy(&data, __power_supply_get_supplier_property); if (ret < 0) return ret; if (ret == 0) From patchwork Tue Dec 10 21:55:51 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: 13902128 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 E54C623EA65; Tue, 10 Dec 2024 21:56:06 +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=1733867769; cv=none; b=O/GI3iwUicpXbYs6wzHHeV3x6kO+lJNT/yVQRcuZ7+lqSdHer/vJjetnfjGp2/BNEDJuKv6x6zziCxvP1t9hxCw2MzJeaHrD3IrEGPycL0k6q73ebxOgg0MVa1LK/VQN93psGLj9eUTB1gd0Nt10E813BGUgRZJ1HcRW1BwF7FE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=goF6k+Ph7DIdoZBnI38IEZG2dxk4fykSLv1y2mFaQo8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LpV8vEzzNLwEipbXVYCZ3uZrL/cZSNbQN38Ffyx3bY4zHKjuU01UFhmi7ArSFvIbhI/hJMGImynpGT7D/WHZHE73Y+pqb8Ige0AsRFlNrwUoAcpbWX8t5CJoFM8UAdNzY9E6xrtRKY0xVIAg5zQB4XQ1FpnQjVnShDJKd13BcGk= 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=kuJEHULn; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="kuJEHULn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867760; bh=goF6k+Ph7DIdoZBnI38IEZG2dxk4fykSLv1y2mFaQo8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kuJEHULncm7WPVwlPHIzCOeaQ3SqgiS7cafhO4heh1vGrpHs5THLPPGC7ewXVeGPF zQU7M26epTlinYqlVzhWMtR8BMS+NFeVhNvgav26y+5sQDJhJ1I1Pm1vSPKWdkl0fb oicuEkepxROAfxydWbKoxPousvih+dzrJHbxW6OE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:51 +0100 Subject: [PATCH v2 04/14] power: supply: ab8500: use power_supply_for_each_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-4-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=4960; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=goF6k+Ph7DIdoZBnI38IEZG2dxk4fykSLv1y2mFaQo8=; b=Mqq0SZ/2DXKYlgInJwFx+T7fbMDjb5F12yJVrVsiM8yk9FjeBdKEqPWZ4c9BX7MTah49UpJ8r Gc7i7xTQ6xDDwZQERqsd40hpmFdplS6/57vOcRaX0aKKMyBHKuS16ET X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Simplify the callbacks by removing the need to convert a 'struct device' into a 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/ab8500_btemp.c | 5 ++--- drivers/power/supply/ab8500_chargalg.c | 5 ++--- drivers/power/supply/ab8500_charger.c | 5 ++--- drivers/power/supply/ab8500_fg.c | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index 37039e28fc4bd27844e36ee69e700fed24d5ee8d..b00c84fbc33c2abae72d104f4645ba327ad10cfd 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -540,10 +540,9 @@ static int ab8500_btemp_get_property(struct power_supply *psy, return 0; } -static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) +static int ab8500_btemp_get_ext_psy_data(struct power_supply *ext, void *data) { struct power_supply *psy; - struct power_supply *ext = dev_get_drvdata(dev); const char **supplicants = (const char **)ext->supplied_to; struct ab8500_btemp *di; union power_supply_propval ret; @@ -617,7 +616,7 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) */ static void ab8500_btemp_external_power_changed(struct power_supply *psy) { - power_supply_for_each_device(psy, ab8500_btemp_get_ext_psy_data); + power_supply_for_each_psy(psy, ab8500_btemp_get_ext_psy_data); } /* ab8500 btemp driver interrupts and their respective isr */ diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c index 14e1b448bd39b286404f31509dbe006d16390877..7a8d1feb8e905d95b010fa907a95ea7db0b3b5a4 100644 --- a/drivers/power/supply/ab8500_chargalg.c +++ b/drivers/power/supply/ab8500_chargalg.c @@ -844,10 +844,9 @@ static void handle_maxim_chg_curr(struct ab8500_chargalg *di) } } -static int ab8500_chargalg_get_ext_psy_data(struct device *dev, void *data) +static int ab8500_chargalg_get_ext_psy_data(struct power_supply *ext, void *data) { struct power_supply *psy; - struct power_supply *ext = dev_get_drvdata(dev); const char **supplicants = (const char **)ext->supplied_to; struct ab8500_chargalg *di; union power_supply_propval ret; @@ -1231,7 +1230,7 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di) int ret; /* Collect data from all power_supply class devices */ - power_supply_for_each_device(di->chargalg_psy, ab8500_chargalg_get_ext_psy_data); + power_supply_for_each_psy(di->chargalg_psy, ab8500_chargalg_get_ext_psy_data); ab8500_chargalg_end_of_charge(di); ab8500_chargalg_check_temp(di); diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index cece8d6753ac14f8970c13ce6b2d91e678733574..1042d37424f5b0351edd02b5c76e58dd447d1783 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -1894,10 +1894,9 @@ static int ab8500_charger_update_charger_current(struct ux500_charger *charger, return ret; } -static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data) +static int ab8500_charger_get_ext_psy_data(struct power_supply *ext, void *data) { struct power_supply *psy; - struct power_supply *ext = dev_get_drvdata(dev); const char **supplicants = (const char **)ext->supplied_to; struct ab8500_charger *di; union power_supply_propval ret; @@ -1961,7 +1960,7 @@ static void ab8500_charger_check_vbat_work(struct work_struct *work) struct ab8500_charger *di = container_of(work, struct ab8500_charger, check_vbat_work.work); - power_supply_for_each_device(&di->usb_chg, ab8500_charger_get_ext_psy_data); + power_supply_for_each_psy(&di->usb_chg, ab8500_charger_get_ext_psy_data); /* First run old_vbat is 0. */ if (di->old_vbat == 0) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 78871a2143de34c7e1a81882ab7105fbf19387ec..549403c6f73c1581d373c6df83cbc255ab1c2e82 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2174,10 +2174,9 @@ static int ab8500_fg_get_property(struct power_supply *psy, return 0; } -static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) +static int ab8500_fg_get_ext_psy_data(struct power_supply *ext, void *data) { struct power_supply *psy; - struct power_supply *ext = dev_get_drvdata(dev); const char **supplicants = (const char **)ext->supplied_to; struct ab8500_fg *di; struct power_supply_battery_info *bi; @@ -2402,7 +2401,7 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di) */ static void ab8500_fg_external_power_changed(struct power_supply *psy) { - power_supply_for_each_device(psy, ab8500_fg_get_ext_psy_data); + power_supply_for_each_psy(psy, ab8500_fg_get_ext_psy_data); } /** From patchwork Tue Dec 10 21:55:52 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: 13902121 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 C09B123DEA7; Tue, 10 Dec 2024 21:56:06 +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=1733867768; cv=none; b=JMaveG55n0MqHPiIlRU8bQ/lubsj/YV0YcfFbQ2CdhjugVigYJBUgrFx5oLU2qkAPzYNOiEJxNTwZwU95/KKSrlZ56MSw1ghWkgeNEQBzO0HX3bI4m0JtI0qD2awc6k2Ab+wTFSFNii/O8Qro9Io5RuqjzvEnZX2CceiXYcUK4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867768; c=relaxed/simple; bh=AnzrS0Cj4WPlkOAM/7ap8p1NV70oBJJ4Lt/P7u21PYY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D0kaiUH/DWU1A0Jb+0iwTz4pLrvpiMyXkRnwzOGPoV2e7john2qZDobl0PY2YR8sjcggziM/7Qsdyymc3hdtTK7LUW2EsWLvKKkWwl/f3GkGPMxmcgMHUEutQXrI/+QplSPTnV6k91RhMuCL8fZhLP6NyDuuQx4zKZdMCJzPW/g= 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=UMWDIFty; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="UMWDIFty" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=AnzrS0Cj4WPlkOAM/7ap8p1NV70oBJJ4Lt/P7u21PYY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UMWDIFtyzNHhcZeBzZs2pDLPkam6JHTqxLZ+RVrbIVaPAi2yZ4YyCgVJvTSm0UF6Z cpp74du1eBv6STwOnwqCddj/Cdgjc51D7XU+ykid6v4NVhN+tGqy2x7kB+WFWejyFF YV4N6NbFwv7x0JXKlayziGg0QKp7VkPDjtU1n7bM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:52 +0100 Subject: [PATCH v2 05/14] power: supply: apm_power: use power_supply_for_each_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-5-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=1267; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=AnzrS0Cj4WPlkOAM/7ap8p1NV70oBJJ4Lt/P7u21PYY=; b=XmCwtD9CQ1wN7zrxN3oO2KJWgEFJZYInDzhDz6JB4nvHsxthoj3M+iy1bSRbrRYzBZL6ee/y6 Zbgwdgpo2bnAxvyEBPLwZM4My6M/jkCxOGqwBkaGvumSu4TX9nIJx43 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Simplify the callbacks by removing the need to convert a 'struct device' into a 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/apm_power.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/apm_power.c b/drivers/power/supply/apm_power.c index 8ef1b6f1f78793a6ec0dea524c2c21f08bd6bb35..9236e007857860e1001d192d9f1a5fe7204332f8 100644 --- a/drivers/power/supply/apm_power.c +++ b/drivers/power/supply/apm_power.c @@ -42,11 +42,11 @@ struct find_bat_param { int max_energy; }; -static int __find_main_battery(struct device *dev, void *data) +static int __find_main_battery(struct power_supply *psy, void *data) { struct find_bat_param *bp = (struct find_bat_param *)data; - bp->bat = dev_get_drvdata(dev); + bp->bat = psy; if (bp->bat->desc->use_for_apm) { /* nice, we explicitly asked to report this battery. */ @@ -79,7 +79,7 @@ static void find_main_battery(void) main_battery = NULL; bp.main = main_battery; - error = power_supply_for_each_device(&bp, __find_main_battery); + error = power_supply_for_each_psy(&bp, __find_main_battery); if (error) { main_battery = bp.main; return; From patchwork Tue Dec 10 21:55:53 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: 13902122 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 E55A623EA67; Tue, 10 Dec 2024 21:56:06 +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=1733867768; cv=none; b=Ctz4YnWiEYm6rPmC8tcoK8vqkm4OfUyzMm/oViOvZKNid3mO8nh27nV+lfmFRk0yAsHAjCU7VAg1J4h/uG/wNdspPHrc7aPCrNucMPBdmzoWvL/Cz28HJQzC5ID0mhoqJBqt57OMpoCCfL8T1dtcWsUfWj2VZYUWiEDjFli8D9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867768; c=relaxed/simple; bh=ikNGjIg0Xo0i2PMFc6EBNWDFiQuRA40O5AfkzB0zdF4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bdKeQX+rghCpjWbaTG9Hdc27Uv8GZ+Vav8qlBIXV3lzIfwTi7HXV7s6zLkdPKKU8/YFFBEPQeh8xx/emFM62FYb8j9I4fEW4ProlalvuER3yU7adHXtsJTxBZkM01XHPl0RZP9ivSkAL8iw79jYvPl6FbMkGht9aA5ysym6YeEU= 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=ZPgPzDUu; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ZPgPzDUu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=ikNGjIg0Xo0i2PMFc6EBNWDFiQuRA40O5AfkzB0zdF4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZPgPzDUum9WtfYduO4RoOslR9XiLudCB4ewWhug6IjN1iD5QjIjd2tepy2lVKFKsP lEah+BJHaQUmcGfH3smhYakndFwKHMBFEnQcM6Z5M5zf0+Ch/l/JHBH2bOktelY2V5 S+hFMxdrnlVuR7o40k+rAbVUVUjkQL0vu+NDk8+Q= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:53 +0100 Subject: [PATCH v2 06/14] power: supply: core: remove power_supply_for_each_device() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-6-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=2228; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ikNGjIg0Xo0i2PMFc6EBNWDFiQuRA40O5AfkzB0zdF4=; b=JoUlKtirfDaw2mIfmreAeGCVsxS4WmWk5wmEVhJ+/pmqcM/NJEP6quKcEl5SMUv1DF02kiNiY EtaqEdzkN/FA/FIoDSiRL0Thwgt+YL9zA6x4pRxbsxSPk+8JbVlKt90 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= There are no users anymore. All potential future users are expected to use power_supply_for_each_psy(). Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_core.c | 8 +------- include/linux/power_supply.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 9adea87c69124f7025a06fe7550892392e28cd65..0cdccfd585cb49b623027a3edaf2958777d2be8a 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -115,12 +115,6 @@ static void power_supply_changed_work(struct work_struct *work) spin_unlock_irqrestore(&psy->changed_lock, flags); } -int power_supply_for_each_device(void *data, int (*fn)(struct device *dev, void *data)) -{ - return class_for_each_device(&power_supply_class, NULL, data, fn); -} -EXPORT_SYMBOL_GPL(power_supply_for_each_device); - struct psy_for_each_psy_cb_data { int (*fn)(struct power_supply *psy, void *data); void *data; @@ -141,7 +135,7 @@ int power_supply_for_each_psy(void *data, int (*fn)(struct power_supply *psy, vo .data = data, }; - return power_supply_for_each_device(&cb_data, psy_for_each_psy_cb); + return class_for_each_device(&power_supply_class, NULL, &cb_data, psy_for_each_psy_cb); } EXPORT_SYMBOL_GPL(power_supply_for_each_psy); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 11d54270eaa9216f3e46e129cd363a804ae8759a..3d67f4a6a1c934f387adde12fc96a63a99299923 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -881,7 +881,6 @@ extern int power_supply_powers(struct power_supply *psy, struct device *dev); #define to_power_supply(device) container_of(device, struct power_supply, dev) extern void *power_supply_get_drvdata(struct power_supply *psy); -extern int power_supply_for_each_device(void *data, int (*fn)(struct device *dev, void *data)); extern int power_supply_for_each_psy(void *data, int (*fn)(struct power_supply *psy, void *data)); static inline bool power_supply_is_amp_property(enum power_supply_property psp) From patchwork Tue Dec 10 21:55:54 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: 13902129 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 C1BCC23EA7E; Tue, 10 Dec 2024 21:56:07 +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=1733867769; cv=none; b=K7R/B42jOidWpoKwvoYUplY7xWHLYD2yf+qNZWpvOjeSKwWYAi7Pu6tJVjDHCi1nHBDWefZ8uo5OqmXClfTJmVS4xODxuUBI2zuE4GVSDHcxDrbvrrjfKztA4NHl2c154sjXcRwTHhMaR61yXLiLMtefDCSJ2S8shgDSQXTfx6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=4MUBctpjIhutpInrWEdlcQerzbKY4rDQAhCW3psko/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MtJyKGpwVtBid55KiPWDwGsiPRJEtEGEUxWHKTxINQZeRDzT/7IhtZ49jrbf6uJDb7lEkGh+bDxsBJrBmwXB39cXBcC4ya9i7X4xeYu5ZCZ8e1XcIzcl24GwGRsTQ+Gtkm83W3EbrDis91dSORxPFKbZoEW5JpLUFmErQsJBxxo= 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=IcrmSo9U; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="IcrmSo9U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=4MUBctpjIhutpInrWEdlcQerzbKY4rDQAhCW3psko/c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IcrmSo9UNBGk9iYn8mfde+g+K4Tg8npl1k/CRl7jKCF4J0ZkBWNeoAOeuK+NXhmvN 1a051wLHTGKQEpyxV+JalzMkZ1eh0vo4x6AVkSctoHn8WAmbcpZqyL4an5zWXdqy3v enXQt+4LQFOP4j0qAlfpdq3xpWjwXagtTzkZJlGI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:54 +0100 Subject: [PATCH v2 07/14] power: supply: core: introduce dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-7-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=1136; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=4MUBctpjIhutpInrWEdlcQerzbKY4rDQAhCW3psko/c=; b=N/2OqxZVZYHGQL66BMBWZwHwhX2oXMBM2yVsb38ObNuLma5xDe6KRpC+vNYxFFQSKWd7UDdC1 QphBTIRut2NArgnn2e0adBAsJ0nVC85FR0qkfwI8IazLt7QZcFIxQC4 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The psy core and drivers currently use dev_get_drvdata() to go from a 'struct device' to its 'struct power_supply'. This is not typesafe and or documented. Introduce a new helper to make this pattern explicit. Instead of using dev_get_drvdata(), use container_of_const() which also preserves the constness. Furthermore 'dev' does need to be dereferenced anymore and at some point the drvdata could be reused for something else. Signed-off-by: Thomas Weißschuh --- include/linux/power_supply.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 3d67f4a6a1c934f387adde12fc96a63a99299923..17fc383785bf5705ef3dbe5fdebf90843684b715 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -318,6 +318,8 @@ struct power_supply { #endif }; +#define dev_to_psy(__dev) container_of_const(__dev, struct power_supply, dev) + /* * This is recommended structure to specify static power supply parameters. * Generic one, parametrizable for different power supplies. Power supply From patchwork Tue Dec 10 21:55:55 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: 13902118 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 ACF4D2397BF; Tue, 10 Dec 2024 21:56: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=1733867765; cv=none; b=V/45DecniA29oLoHEm+QBCB1+kUMDNXoVMDv+L3II0Gk+fjzoZlGBGqwX2tjjTh3SelOScvNcCyar2bmiKFNRnhgNNorgJayo3VHEPWeolsb2Y0KoXe37iOCb2jtHcNDh6W08XZtjBPSUdRh4i/zXevbFJxD/aBtFE7Y+P1K6a8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867765; c=relaxed/simple; bh=mi0udZzZbeywpP/vrlSR3292aKI49L4o1M7uXA1k4Mk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J/pQpSMNEu6+n6tjI4cXBSxLPkuHzdx2WktSl58Rz1EQTEHVkvp4xswBkHoRxvUO130sF5B4+/ZLqVRQ6K+Oxz3zRvKCCfPrnU6OhG8gSpicH0UsNihc575yBq8gPY2ozk2JWted4BVzvBZXJyCKdiY0+yRs4EW9tYwZNvRToxM= 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=rfM4Jnur; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="rfM4Jnur" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=mi0udZzZbeywpP/vrlSR3292aKI49L4o1M7uXA1k4Mk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rfM4JnurtHNV3jTRBcxL9eW8LoXlPOJoZ29W1NyimM/LYbAVTmOBM30F6D2K8tJPe ZgbqD1N1919Xo6brFMdd2HjHsGncEeMj36nL4Irl1jNwKdihnSCAJVtwYp2ZGEpM4g b/bcnx0f8ODWHayujXqxGYWocjXEGLvYJlNyOumA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:55 +0100 Subject: [PATCH v2 08/14] power: supply: core: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-8-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=1730; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=mi0udZzZbeywpP/vrlSR3292aKI49L4o1M7uXA1k4Mk=; b=suUEFTDJNjBLoB8Ogp5P2Omj5LvrFC8N3QFPdFfm9gTAinboc0Ut+RAp8DPOcqSOsXHiXxZjo ZsXkJlbNTygDDy3bJX6MJ6LaiLUnNrI7nB6IX2ohSTUr9tbEVohut3K X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 0cdccfd585cb49b623027a3edaf2958777d2be8a..1db27afb7017c4428aa90372f7b9de03223671cf 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -123,7 +123,7 @@ struct psy_for_each_psy_cb_data { static int psy_for_each_psy_cb(struct device *dev, void *data) { struct psy_for_each_psy_cb_data *cb_data = data; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); return cb_data->fn(psy, cb_data->data); } @@ -456,7 +456,7 @@ EXPORT_SYMBOL_GPL(power_supply_set_battery_charged); static int power_supply_match_device_by_name(struct device *dev, const void *data) { const char *name = data; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); return strcmp(psy->desc->name, name) == 0; } @@ -479,7 +479,7 @@ struct power_supply *power_supply_get_by_name(const char *name) power_supply_match_device_by_name); if (dev) { - psy = dev_get_drvdata(dev); + psy = dev_to_psy(dev); atomic_inc(&psy->use_cnt); } @@ -536,7 +536,7 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np, of_node_put(power_supply_np); if (dev) { - psy = dev_get_drvdata(dev); + psy = dev_to_psy(dev); atomic_inc(&psy->use_cnt); } From patchwork Tue Dec 10 21:55:56 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: 13902123 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 E553623EA66; Tue, 10 Dec 2024 21:56:06 +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=1733867769; cv=none; b=LIxWdTHLW37XDIFmFd+jGSgN29KbEdZ8kWeGAtJM1E5ogG/kQHoeZEFVLW09fDb6jlNaRNh+vq2auNkvcjQAYil2lQsg076bqXvUJExZPO5VrWRvHFWZ5LuQm8RkYdn0PCLiZN4Y5hC2ev4ueaxWrXgYN1L+l8+YXM4X17z3b/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=FhwKSD0svgWVmDIfiDfI4K9PqSyh7QPjCU6VOQVWlzw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q8NmmwuPomqugbIpZaL/jxnCujfcIN+ysoCdiY6Duy3Z33klSCUc5pgG6/c5ULhtzlTfBDRjz3d/SKDHQ8NqiPuca4UW3F1DcjpCt8O0rFxCpFAwjU8EUMiLoS1jqfX6WtN4n2+25RxD4jzEv5b4NYsYL/k9FJmO1dgT3OzVLN4= 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=VDlq5BaF; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="VDlq5BaF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=FhwKSD0svgWVmDIfiDfI4K9PqSyh7QPjCU6VOQVWlzw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VDlq5BaFajv91gOHXJHemtIUmGC+iRNpOM+dko6mhMUQXVJ/UDjsPeEjWZPafK4iB a6SQilIUned5LzbFFVosdko1cRw8HOJIyMzeFeaCpJ2e55AwDKZoa2K3s94EBax5KA W8Dpkiqwyuu9uZikOhXh8jSRspqioFQAYXLWRXlk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:56 +0100 Subject: [PATCH v2 09/14] power: supply: sysfs: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-9-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=2083; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FhwKSD0svgWVmDIfiDfI4K9PqSyh7QPjCU6VOQVWlzw=; b=t4mVL3xoebBvZ3szYMPvkuXjk6ytDDg93vSwP3Yt9G6uSINU2a1W6Piinuiclxg6QtKygHvPZ +2XMwJc0RxYBz3wEdXLEyI/eonuDxL0EL+Dx33jRZwuw+z9PRrJcLtD X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 99bfe1f03eb8326d38c4e2831c9670313b42e425..85b5134b8552cc573724e4cd5794a598192d3137 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -274,7 +274,7 @@ static ssize_t power_supply_format_property(struct device *dev, char *buf) { ssize_t ret; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); const struct power_supply_attr *ps_attr = to_ps_attr(attr); enum power_supply_property psp = dev_attr_psp(attr); union power_supply_propval value; @@ -337,7 +337,7 @@ static ssize_t power_supply_store_property(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { ssize_t ret; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); const struct power_supply_attr *ps_attr = to_ps_attr(attr); enum power_supply_property psp = dev_attr_psp(attr); union power_supply_propval value; @@ -376,7 +376,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj, int attrno) { struct device *dev = kobj_to_dev(kobj); - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); umode_t mode = S_IRUSR | S_IRGRP | S_IROTH; if (!power_supply_attrs[attrno].prop_name) @@ -462,7 +462,7 @@ static int add_prop_uevent(const struct device *dev, struct kobj_uevent_env *env int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env) { - struct power_supply *psy = dev_get_drvdata(dev); + const struct power_supply *psy = dev_to_psy(dev); int ret = 0, j; char *prop_buf; From patchwork Tue Dec 10 21:55:57 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: 13902124 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 208B923EA6E; Tue, 10 Dec 2024 21:56:06 +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=1733867769; cv=none; b=FKgAGRvIKfKQzeEEWJR9uxEsB1gYXpRbnJzo936dbdIGnNf5FywwIZGGYBYwKXpRLPEXWGIlUld6gYIJsQKPLRB29Ntd4nep7F3LIutgPunbQDWKRM8A5GedF6SSAtj29zaXU3/fMuY2UZCRxITXVt1jDto9eXuT5qcyZH/RIPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=48p7mPpsAXRO57ND5gUhUi5Ak5EzGzJrWUgZH4nHfUE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sKfbJ5zffiQW9sEQfYyxgrC356rYaskaCHqr5iuNzSFXQNrnQZ+1cFlJ1tJHdVb+ZE9MtGWXqEWaLfxmLKJRTfWUTq+5kvs0PD0F76NNDS9kuwkL9ORLUGUF+p4goY5lJp+a5jaaMQw07lMAJFopCUh2oDLz0Agy/wKz9V4ZwpQ= 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=Eklv8FgB; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Eklv8FgB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=48p7mPpsAXRO57ND5gUhUi5Ak5EzGzJrWUgZH4nHfUE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Eklv8FgBqa3Jp8M4d1XExpC048lhEnNN1qgZHgPuykN/AFnxjpqt/ecDSFsSsslvu w7ZOTwcHxoQ7KWOgkZ2JCiunoEeUhtmsPi4UBR+zDjantjJftU4H6D+Cc/PH67K3Wr 12NWpgkaz6zGDCEYt3zAOfQz4YBru2S7IDvffE0k= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:57 +0100 Subject: [PATCH v2 10/14] power: supply: ab8500: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-10-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=5236; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=48p7mPpsAXRO57ND5gUhUi5Ak5EzGzJrWUgZH4nHfUE=; b=mGz5x8KIANpd14dVQXyo40/JRb52bDqfyR9P4Dtmm+qHpTMDFGlLJyAPJOnwdCLnqRe5hmDzZ xjTMpX4Z3ohDhAdKYBKySJVnun3IvsfkrjVhZEjsJYMyEogTOw1IOOT X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/ab8500_fg.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 549403c6f73c1581d373c6df83cbc255ab1c2e82..9dd99722667aeb81c1a3d88b40e11ca5a10ccad6 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2574,7 +2574,7 @@ static ssize_t ab8505_powercut_flagtime_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2597,7 +2597,7 @@ static ssize_t ab8505_powercut_flagtime_write(struct device *dev, { int ret; int reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); if (kstrtoint(buf, 10, ®_value)) @@ -2624,7 +2624,7 @@ static ssize_t ab8505_powercut_maxtime_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2648,7 +2648,7 @@ static ssize_t ab8505_powercut_maxtime_write(struct device *dev, { int ret; int reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); if (kstrtoint(buf, 10, ®_value)) @@ -2675,7 +2675,7 @@ static ssize_t ab8505_powercut_restart_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2698,7 +2698,7 @@ static ssize_t ab8505_powercut_restart_write(struct device *dev, { int ret; int reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); if (kstrtoint(buf, 10, ®_value)) @@ -2726,7 +2726,7 @@ static ssize_t ab8505_powercut_timer_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2749,7 +2749,7 @@ static ssize_t ab8505_powercut_restart_counter_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2772,7 +2772,7 @@ static ssize_t ab8505_powercut_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2793,7 +2793,7 @@ static ssize_t ab8505_powercut_write(struct device *dev, { int ret; int reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); if (kstrtoint(buf, 10, ®_value)) @@ -2821,7 +2821,7 @@ static ssize_t ab8505_powercut_flag_read(struct device *dev, int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2844,7 +2844,7 @@ static ssize_t ab8505_powercut_debounce_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, @@ -2867,7 +2867,7 @@ static ssize_t ab8505_powercut_debounce_write(struct device *dev, { int ret; int reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); if (kstrtoint(buf, 10, ®_value)) @@ -2894,7 +2894,7 @@ static ssize_t ab8505_powercut_enable_status_read(struct device *dev, { int ret; u8 reg_value; - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); ret = abx500_get_register_interruptible(di->dev, AB8500_RTC, From patchwork Tue Dec 10 21:55:58 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: 13902130 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 EDBB523EA87; Tue, 10 Dec 2024 21:56:07 +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=1733867769; cv=none; b=m8WU3vPDcGAe3cwDOQrtNZxC2a6L8g0uYaTIFrvWJMzTimqXYxtYFQS0yaR/4W4q5Hb11DkPQeHS/DL/17djxtqI48rIDzrEoPH98DqWD95qjDIS7LmnZQ0Bx1Vw5Wk6khOtH+XiH2SNPntJoFsVN7uOf3GPXmEz/By1eGkDXUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=8VBKzyLSPAGekr2MvdVRCAUGf5HHmqa9y4g6LCA+Gek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SgSS2H13R/ePLUskQOOlt2iy7yiAFrNpV12NMxIJ3xVTdhWBfsgBcxa/f4eVH4EM71WqZCmtS6OU7cxoR51f82nJGQNMA8bpxkG4arO5xpxZiJbgtTttyVyA4RGH3f7RphSonf2BmlxZF3bMYsO0t1ZULxm1UPFWcl8ok3krXSc= 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=CPB36e4u; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="CPB36e4u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=8VBKzyLSPAGekr2MvdVRCAUGf5HHmqa9y4g6LCA+Gek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CPB36e4u5nfp+T1dKQ2PzSqZDqAHdzLc0KAsw7fZbmqROqQJf27h7LojUff0F04m/ QNc/MWv/ko+FImh/7UNropsEXV/sf9tsbvVx0OYDxXRBfPqyu79tW6DTUGwA8zHdUT pFWXzh48J1cNw2aVd/Dd/9OLzrGyVnddQ/KkZPKA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:58 +0100 Subject: [PATCH v2 11/14] power: supply: surface_battery: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-11-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=1371; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8VBKzyLSPAGekr2MvdVRCAUGf5HHmqa9y4g6LCA+Gek=; b=kEcjg2iJ1wVPliJAiTJukoDCeoTkaiNVP9Z1WW/0NLf1pMqcPXaNtEtf0PDUKL44o4mliLzyo 8a/v2+DyaO1Cx8Mo2sGIHXX7G9apmFlizgjwi8QzbNQnJqwaQzkIZdH X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/surface_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/surface_battery.c b/drivers/power/supply/surface_battery.c index ebd1edde28f12aa7711e4ff07f8516abc8cbc946..c759add4df49dafc92538ef1316b19f186e73929 100644 --- a/drivers/power/supply/surface_battery.c +++ b/drivers/power/supply/surface_battery.c @@ -667,7 +667,7 @@ static int spwr_battery_get_property(struct power_supply *psy, enum power_supply static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct spwr_battery_device *bat = power_supply_get_drvdata(psy); int status; @@ -681,7 +681,7 @@ static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, cha static ssize_t alarm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct spwr_battery_device *bat = power_supply_get_drvdata(psy); unsigned long value; int status; From patchwork Tue Dec 10 21:55:59 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: 13902126 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 511AB23EA71; Tue, 10 Dec 2024 21:56:07 +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=1733867769; cv=none; b=q0jICyi+LxKlN11A0qwJOXupvz0/7WE+/WoWCE4C4N+zQmQHgfc6UoWsjOirTm5nfjpsSLPREGs9OzLPPWam6ab0bjUQMoWWeKXcB/tFdgA1dD8DifetZiquZwX7UUXXK7e0t9pc+0huiokaTYQ8aZwGl/nzJSbXlAn/v1IApp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=2dKqKFfjbF4q4dgVkRSJTDS4XDDuY531CCkNnNU2v/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qRr8WXMjfM3blNAe6ONQD3gkKawb870hFrGLHcNW9adbEjvZCQI7r8+BtDhcMAKvJULkmIoqQcy/C9DHgcquYA6RUMG8RJkUiLf5FcTE0xImg2lfWazcKlrvHaSWejErKN1SNKCf4hhlNt0ZSsjrZmthFrolkt6FcSijBHCp1CY= 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=W7OH3zKt; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="W7OH3zKt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=2dKqKFfjbF4q4dgVkRSJTDS4XDDuY531CCkNnNU2v/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=W7OH3zKtlXFRgYZ4Z78COkvoeJvW/RtWr/+k7ByOmlUknnTK5OTx2ggFht0VS/vDk WgdR5ouz3yy44CbyL2oIAEbBWFXpXxfwZuMujKz2KnCgS4hp6W5ED1El7hPBxSTRON dzvYjSXL7sMQ9P8FmTK42nX7AsfbVUSyeFXCgyXM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:55:59 +0100 Subject: [PATCH v2 12/14] power: supply: bq2415x_charger: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-12-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=4630; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=2dKqKFfjbF4q4dgVkRSJTDS4XDDuY531CCkNnNU2v/U=; b=iJ4gamw3zEASK9agIfjeDJ7FUg+h2iu3MQ5A1YYf8SdJLJ3ZrACkkwCTX3rhjJrf9a10Ogr4+ 0hKYhgi8tPBC6e89g+tg5lF5zKKfmcM5I+l8zJsZxwyithOZ0q12Wzw X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/bq2415x_charger.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c index 25e28dac900deae8c3ab605f1fdab53c397c8ecb..5e174242d2dec49f0dc16822ae862af77a82f3d7 100644 --- a/drivers/power/supply/bq2415x_charger.c +++ b/drivers/power/supply/bq2415x_charger.c @@ -1050,7 +1050,7 @@ static ssize_t bq2415x_sysfs_show_status(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); enum bq2415x_command command; int ret; @@ -1083,7 +1083,7 @@ static ssize_t bq2415x_sysfs_set_timer(struct device *dev, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); int ret = 0; @@ -1104,7 +1104,7 @@ static ssize_t bq2415x_sysfs_show_timer(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); if (bq->timer_error) @@ -1128,7 +1128,7 @@ static ssize_t bq2415x_sysfs_set_mode(struct device *dev, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); enum bq2415x_mode mode; int ret = 0; @@ -1180,7 +1180,7 @@ static ssize_t bq2415x_sysfs_show_mode(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); ssize_t ret = 0; @@ -1217,7 +1217,7 @@ static ssize_t bq2415x_sysfs_show_reported_mode(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); if (bq->automode < 0) @@ -1245,7 +1245,7 @@ static ssize_t bq2415x_sysfs_set_registers(struct device *dev, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); ssize_t ret = 0; unsigned int reg; @@ -1280,7 +1280,7 @@ static ssize_t bq2415x_sysfs_show_registers(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); ssize_t ret = 0; @@ -1298,7 +1298,7 @@ static ssize_t bq2415x_sysfs_set_limit(struct device *dev, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); long val; int ret; @@ -1329,7 +1329,7 @@ static ssize_t bq2415x_sysfs_show_limit(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); int ret; @@ -1357,7 +1357,7 @@ static ssize_t bq2415x_sysfs_set_enable(struct device *dev, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); enum bq2415x_command command; long val; @@ -1392,7 +1392,7 @@ static ssize_t bq2415x_sysfs_show_enable(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq2415x_device *bq = power_supply_get_drvdata(psy); enum bq2415x_command command; int ret; From patchwork Tue Dec 10 21:56:00 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: 13902125 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 5122D23EA72; Tue, 10 Dec 2024 21:56:07 +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=1733867769; cv=none; b=bvBHgrTmeG2cRuUX2nkj9NCNQkfJihsSAtMa7ZXnmS0CGe18SJxUxdaeBcjYbHME8rmhlRU/kiQ6Xd+O99ogcVGBrVC4NbwiF63dziv6ShH+CTNU8TC8CoVSDBRY7apEUe8/IWsq5UAM9Jz8veeD7QHEpz+jgwCdXNRdKgRGXKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=nIcvu1PbHs9o1TJjSMqsv4HKZSKfRqzmsx36a6kqvSs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zj2J+TeQBhJMCMfjhoJtDcRVgD8E0De15T1i+V2xrEw18AcuNi7Tt0kb4aKO/n6kFgZTLqj/++iG7RztLyfUvRV+xP9f0Bf+TWdd0/XQmUGzsJy2eZQuwloaXwGo5TtBWKUC9H2DJ7dR2SfEnjVifz664XTq//gsYNC1fh9761U= 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=WMIDN/Zm; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="WMIDN/Zm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=nIcvu1PbHs9o1TJjSMqsv4HKZSKfRqzmsx36a6kqvSs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WMIDN/ZmDrHFDL2rqB652u1UscK7mzhUqfWZjBVq5Az3E1aF5Av3CmLjD0FqUpDrc 5zKRup6c/625xNE60TfJ8McU5gmdAtoYlgKtoHVD9wgsPhlSesY7CIHxE83svDY9Se 1YU+9MwdMVL5opVbp7+JZqIMrrmJxtDkSrPeM2pk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:56:00 +0100 Subject: [PATCH v2 13/14] power: supply: bq24190_charger: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-13-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=1395; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=nIcvu1PbHs9o1TJjSMqsv4HKZSKfRqzmsx36a6kqvSs=; b=PCYmuYBtKoa9dCIIJ5iQR6/WCQiwYfJO3LwPKU6lHQBClxPRLngDpjCO2DpE0mL16fb9VaCid SRD0BzRvdFzAzQrm9bge6gjyBzg5yzyBu5YdatjJlZQ4B2M7o8GNfmT X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/bq24190_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 3b97f788496795b321c12ee69df29c701cb83031..b71e21a0196a4becace5233c1cbe89c24e2004e2 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -480,7 +480,7 @@ static struct bq24190_sysfs_field_info *bq24190_sysfs_field_lookup( static ssize_t bq24190_sysfs_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); struct bq24190_sysfs_field_info *info; ssize_t count; @@ -510,7 +510,7 @@ static ssize_t bq24190_sysfs_show(struct device *dev, static ssize_t bq24190_sysfs_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); struct bq24190_sysfs_field_info *info; int ret; From patchwork Tue Dec 10 21:56:01 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: 13902127 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 6274E23236A; Tue, 10 Dec 2024 21:56:07 +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=1733867769; cv=none; b=Pp4WjV0l0HVO4YvckZNebDoLPRK7dc+mseUsk+2cg9QFINJONN74q7VPbZ6ScLdOIXvGi/ZW5R/o8W8JP+wma4cahLIWYXjtVP/JFvTCYdXm5exAfuMNCZKsOXYVFDq6lzQnA2ZhcDbfrZFemNmkiPdcLmpjKiVpwVfKt00BgOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733867769; c=relaxed/simple; bh=YYfsTx2rAnMr87VKqCAX8bpgiZpeQGkncIQMEpK07sc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bG6FWwKBSDV8zoYP4u9YI8TXVOU0XDTwEiTrfpqBzKftGJ3FJeDZKIFuPXcSoqpwnjL8WvyRbA25DEHlsBfH0bHRrhnauCO5oIgEJwc68wLX9bcv671hJHEAKvu/yFlWPEZo9zpSpfLNFzg/5keZrX5x2yCpHm5LplUN/zXkjWA= 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=jhQ6rsEh; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="jhQ6rsEh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733867761; bh=YYfsTx2rAnMr87VKqCAX8bpgiZpeQGkncIQMEpK07sc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jhQ6rsEhqm6JQD8SWTDPwBfkgM7UYsXdoFE+RzHh81VMZz729WYXBArTeCKRLWlfm Gi5//PzQKjLTAoPTUCzsjQ8zwCXMupdRdcrQCz7vU6HimDMqpcdjBEaNWNrh0rEyJs NRw4MAA2IMtEQ1SOcfLRWXkDb8lgVly2eCVwzKF0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 10 Dec 2024 22:56:01 +0100 Subject: [PATCH v2 14/14] power: supply: bq24257_charger: use dev_to_psy() Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241210-power-supply-dev_to_psy-v2-14-9d8c9d24cfe4@weissschuh.net> References: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> In-Reply-To: <20241210-power-supply-dev_to_psy-v2-0-9d8c9d24cfe4@weissschuh.net> To: Sebastian Reichel , Linus Walleij , Maximilian Luz , =?utf-8?q?Pali_Roh=C3=A1r?= , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733867760; l=1965; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=YYfsTx2rAnMr87VKqCAX8bpgiZpeQGkncIQMEpK07sc=; b=+jfvoBiDpY9K6pnoLrb7gnIQKqzEb3DlfDqsf6iP7AovaJ+kjrCsZ58aDj31URy+kM0bpLMv9 LKqphB6enIBACKy//f/CNyuQIpfsuoNgt6i1E9EIOOPOvgFA0vIn/AJ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use the new, explicit accessor to go from a 'struct device' to its 'struct power_supply'. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/bq24257_charger.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/bq24257_charger.c b/drivers/power/supply/bq24257_charger.c index 801d0d2c5f2eae90c9c1cbbbfcfb258d257038d5..1416586f2459109b29fe57a5ee86fa3704013aac 100644 --- a/drivers/power/supply/bq24257_charger.c +++ b/drivers/power/supply/bq24257_charger.c @@ -759,7 +759,7 @@ static ssize_t bq24257_show_ovp_voltage(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq24257_device *bq = power_supply_get_drvdata(psy); return sysfs_emit(buf, "%u\n", bq24257_vovp_map[bq->init_data.vovp]); @@ -769,7 +769,7 @@ static ssize_t bq24257_show_in_dpm_voltage(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq24257_device *bq = power_supply_get_drvdata(psy); return sysfs_emit(buf, "%u\n", bq24257_vindpm_map[bq->init_data.vindpm]); @@ -779,7 +779,7 @@ static ssize_t bq24257_sysfs_show_enable(struct device *dev, struct device_attribute *attr, char *buf) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq24257_device *bq = power_supply_get_drvdata(psy); int ret; @@ -801,7 +801,7 @@ static ssize_t bq24257_sysfs_set_enable(struct device *dev, const char *buf, size_t count) { - struct power_supply *psy = dev_get_drvdata(dev); + struct power_supply *psy = dev_to_psy(dev); struct bq24257_device *bq = power_supply_get_drvdata(psy); long val; int ret;