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: 5975201 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EF9A4BF440 for ; Tue, 10 Mar 2015 08:35:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2EA982024F for ; Tue, 10 Mar 2015 08:35:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F777200EC for ; Tue, 10 Mar 2015 08:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbbCJI2C (ORCPT ); Tue, 10 Mar 2015 04:28:02 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:36137 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751438AbbCJI1y (ORCPT ); Tue, 10 Mar 2015 04:27:54 -0400 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>; 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 Cc: Thomas Gleixner , Pavel Machek , Kyungmin Park , Marek Szyprowski , Krzysztof Kozlowski 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 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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;