From patchwork Tue Mar 10 08:27:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5975141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 10F2A9F318 for ; Tue, 10 Mar 2015 08:35:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CC362024F for ; Tue, 10 Mar 2015 08:35:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51FD020220 for ; Tue, 10 Mar 2015 08:35:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVFZZ-0007B2-F8; Tue, 10 Mar 2015 08:31:29 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVFWW-0004Pn-2Z for linux-arm-kernel@lists.infradead.org; Tue, 10 Mar 2015 08:28:26 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKZ009W5MD1XE00@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 10 Mar 2015 08:31:50 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-f5-54feaa74df10 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id ED.BC.07834.47AAEF45; Tue, 10 Mar 2015 08:25:24 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NKZ0033KM64IB70@eusync4.samsung.com>; Tue, 10 Mar 2015 08:27:49 +0000 (GMT) From: Krzysztof Kozlowski To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , "Rafael J. Wysocki" , Len Brown , Jiri Kosina , David Herrmann , Cezary Jackiewicz , Darren Hart , Support Opensource , Milo Kim , Linus Walleij , Samuel Ortiz , Lee Jones , linux-arm-kernel@lists.infradead.org, Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Daniel Mack , Haojian Zhuang , Robert Jarzmik , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, patches@opensource.wolfsonmicro.com, ac100@lists.launchpad.net, linux-tegra@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH v6 03/22] power_supply: Add driver private data Date: Tue, 10 Mar 2015 09:27:07 +0100 Message-id: <1425976046-20973-4-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1425976046-20973-1-git-send-email-k.kozlowski@samsung.com> References: <1425976046-20973-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAy3Ra0hTcRgG8P47Z+ccl8PDvB38IDkRQspLBr6VVvSlv2A38kMkUlOHF9TJ pqJCKKKVl7y0FBMzRWu2mOkmktdkOi95wRRXXiM08b68JKK50tm353n4wfvhZQhRPenERMUl SOVxkhgxJSAHzL3Gswlqc5DX3oET5A/94kFNXy4JGQfLJDyfNxHQNrhHQ/WYA+RUeUHROyUB I3W+UNLgCK3l1SSsLHrDUMYqDd9/GxA0/1ij4MUfFQ9UHQUItHNGPkxs7vBhrKWcgq1n3Qiy t8so0HTP0KDaqyNhtLPyEK/9pWDms4GC922LBAwOjPKhbNUWBnL5MNCaAO1ZXwjQaYsJ2K2f 4191xbWbnni2o4vEBXVbfNxcNkPjn4VKGutq3bFWnU3haWMbhdeHh2lc0X8H62rSsCFvmsRL RfsUNnWMU7hx/AmJ8xvV6LbDfYFfuDQmKkkq97z8UBDZq8+k46tEyeZSFZmO2mxykBXDsec5 zZSOPs4O3MjsByoHCRgR+wZxn5qX0HHJ53HlKxqLolgfTqeqsSg71sBwe6ZF+qgQ7Cji5ub7 LcqWvcJt1C6QR5lk3bgFY4NlF7LXuXFj1v97zlx/j5J/lK1YzG1vT1q86NDMjG6gQiSsRCfU yF6aGBavCI2I9fZQSGIViXERHmGyWC06/vL2R1Tdc1GPWAaJrYUTweYgEV+SpEiJ1SOOIcR2 QkPB4SQMl6SkSuWyB/LEGKlCj3iMlVM6Ss12YZZtxp1kxcqpR9ElhPlpiOmuUaMdvhThIn+b 6WLqUkffC1NWGM45iwNC8r4Feibf9L9wbcVm8qA9xO1Vnv1O1Etr5sbJpgCeXWDvZta+T/D6 kkzQ5Lsudz0lu7UZ6Thi99ivobGv1NP5a6i3/kzL6TSrnd0qodJ997V/R6eYVERKvN0JuULy D2AN5qnDAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150310_012820_318364_CB114A74 X-CRM114-Status: GOOD ( 10.33 ) X-Spam-Score: -5.0 (-----) Cc: Krzysztof Kozlowski , Thomas Gleixner , Kyungmin Park , Pavel Machek , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow drivers to store private data inside power_supply structure for later usage in power supply operations. Usage of driver private data is necessary to access driver's state container object from power supply calls (like get_property()) if struct 'power_supply' is a stored there as a pointer, for example: struct some_driver_info { struct i2c_client *client; struct power_supply *power_supply; ... } In such case one cannot use container_of() and must store pointer to state container as private data. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel Acked-by: Pavel Machek --- drivers/power/power_supply_core.c | 6 ++++++ include/linux/power_supply.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 44c810456212..1c0978f961ea 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -674,6 +674,12 @@ void power_supply_unregister(struct power_supply *psy) } EXPORT_SYMBOL_GPL(power_supply_unregister); +void *power_supply_get_drvdata(struct power_supply *psy) +{ + return psy->drv_data; +} +EXPORT_SYMBOL_GPL(power_supply_get_drvdata); + static int __init power_supply_class_init(void) { power_supply_class = class_create(THIS_MODULE, "power_supply"); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index f606d6b4bd56..e30d85c0158d 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -209,6 +209,9 @@ struct power_supply { /* For APM emulation, think legacy userspace. */ int use_for_apm; + /* Driver private data */ + void *drv_data; + /* private */ struct device *dev; struct work_struct changed_work; @@ -285,6 +288,7 @@ extern int devm_power_supply_register_no_ws(struct device *parent, extern void power_supply_unregister(struct power_supply *psy); extern int power_supply_powers(struct power_supply *psy, struct device *dev); +extern void *power_supply_get_drvdata(struct power_supply *psy); /* For APM emulation, think legacy userspace. */ extern struct class *power_supply_class;