From patchwork Mon Feb 23 11:47:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5864191 Return-Path: X-Original-To: patchwork-linux-acpi@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 6DCAA9F269 for ; Mon, 23 Feb 2015 11:48:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 884BA2068D for ; Mon, 23 Feb 2015 11:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 770862061F for ; Mon, 23 Feb 2015 11:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752212AbbBWLr7 (ORCPT ); Mon, 23 Feb 2015 06:47:59 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:54046 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbbBWLrz (ORCPT ); Mon, 23 Feb 2015 06:47:55 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NK800FK73MJTOA0@mailout3.w1.samsung.com>; Mon, 23 Feb 2015 11:51:56 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-f9-54eb12d38032 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id B1.97.26295.3D21BE45; Mon, 23 Feb 2015 11:45:23 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NK8001843FJ0A90@eusync2.samsung.com>; Mon, 23 Feb 2015 11:47:51 +0000 (GMT) From: Krzysztof Kozlowski To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Len Brown , Jiri Kosina , David Herrmann , Cezary Jackiewicz , Darren Hart , Support Opensource , Milo Kim , Julian Andres Klode , Marc Dietrich , Greg Kroah-Hartman , 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, 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 Cc: Thomas Gleixner , Pavel Machek , Kyungmin Park , Marek Szyprowski , Krzysztof Kozlowski Subject: [PATCH v4 01/20] power_supply: Add driver private data Date: Mon, 23 Feb 2015 12:47:22 +0100 Message-id: <1424692061-30624-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1424692061-30624-1-git-send-email-k.kozlowski@samsung.com> References: <1424692061-30624-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyWReUiTcRjH/e099joavc2jN42oYRFSXhk9SFhQ4Ev0h0IHCaVThwrOY3ND JcjUInVeaQdiHjmdtznzampmTjPvGWbikWnkWd6omeb0v+/zfD/f5/vHQ2ECLW5B+QeGiqWB ogAhycM7ttu+nO0XzN6wG6o6A4ldCxxQfYrHIerfDA5PJ/9gUN+5yYXcfnOIy7GDlMJUDKJz y0noLbsAzysOQ/5iFgnajFwcZqfsoStqjgtjqzoEdePzJKRtqTmgbkxCoJkYIODb0hoB/e8y SFhOaEEQu5JOQmnLCBdie3IQqDfLcNA3Ze8m5ndIGPmsI6G4fgqDzg49AelzJtART0CHNhQa HvVhUKl5hsH6mwni8im2YMmWHW38iLNJZcsEW5c+wmUXFu+xP5NTuWxlgTU7OaMmWE1RLMkO D9ST7O/ubi6b2e7Gvn9VsguoHrA65TDOTqf8JV2PuPMu+ogD/BViqa2zJ88vX/WLDM4QhG2N vsUjUc3BOGRMMbQjo2vrIva1OdM7Wk7GIR4loPMQU9M5iwyGgE7kME1ZIQZN0ueYSrVqDzKl W42ZD6UJHMOA0XrETEy2c+MQRZnQlxhdsdwQwOmTTOYPzd4hPu3C9C5NcPfbjjHtramEATem WWasWrHf5cIkVKShZMTPRkZFyEws9w6WeflKHGxkIolMHuhr4x0k0aD9h6/WorxWp2ZEU0h4 gP9dMXNDQIgUsnBJM2IoTGjKt9zYXfF9ROERYmmQh1QeIJY1Iw5lbBGJIk2vNYgHrjz2qF3s 9nfb0NreVTpFTBe7z10ftFKGHR980V0RvfNa/3K5JtciwUFQff9o8nnr7QhC6ryyHWNTbVZy R/dkWqVNu+mVanRLvGZr1nOCV2snnbNS5nhWOX49vWokuf3QpczikH5gfWh81TKksEfeJ1Qq VDHDzXVXXa2EuMxPZG+NSWWi/wWPiIrOAgAA 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 694e8cddd5c1..84ef3f40e7bf 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -629,6 +629,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 096dbced02ac..a5743f24e03e 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; @@ -281,6 +284,7 @@ extern int 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;