From patchwork Fri Feb 27 08:19:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5898371 Return-Path: X-Original-To: patchwork-linux-pm@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 DB483BF440 for ; Fri, 27 Feb 2015 08:20:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BE7F2021A for ; Fri, 27 Feb 2015 08:20:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 263872022A for ; Fri, 27 Feb 2015 08:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754707AbbB0IUe (ORCPT ); Fri, 27 Feb 2015 03:20:34 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:44030 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753430AbbB0IUb (ORCPT ); Fri, 27 Feb 2015 03:20:31 -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 <0NKF00ADI8OVVR70@mailout3.w1.samsung.com>; Fri, 27 Feb 2015 08:24:31 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-53-54f02836662f Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 0A.67.26295.63820F45; Fri, 27 Feb 2015 08:17:58 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NKF007VV8HM7X70@eusync1.samsung.com>; Fri, 27 Feb 2015 08:20:26 +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 v5 01/20] power_supply: Add driver private data Date: Fri, 27 Feb 2015 09:19:42 +0100 Message-id: <1425025201-15926-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1425025201-15926-1-git-send-email-k.kozlowski@samsung.com> References: <1425025201-15926-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyXRaUjTcRgH8H77n5OG/+bRXyFfjJTSvFL0QSp9I/0igiJ7U3QsXSp5tXmk FImW4MwrLVI8kk1nllpbUOq0mueammmKgVqmhvd9hKXl8e77wOfL98XDEuJ60pYNjYiWySOk YRLajDRttvY4ex2aD3D7NcZDRse8ANRtaSQkbUyS8Gh0jgB9+zoDqh5rUJa4QfbzHAKSVdU0 dFV5w5PX+6FsoZiGugIVCVPj7tCRNM3A95VmBDXDMzTk/tUIQNOQiUA70kfBt8VVCnpqC2hY Sm9CkLqcT0Nl0yADqZ9LEGjWq0jo/vBsqzHzj4bBT800vNCPE9Bu6qYgf9oCTGkUmOqiof7B FwJ02scE/H41Qvk54PJFVzzU0EjizKolCtfkDzJ4fuEKHsvKYbCu3BGPTmoorK1IpfFAn57G s52dDC4ynsPvC19uAfU93PxwgMQT2X/oszYXzY4FycJCY2Vy1xPXzEJaDfeZqBLx7c2nGjIR 6c2VSMjynCe/olIKdrM13zVUTSuRGSvmShFfVWQU7B4ZAt40nUluK5rz4HUa9Y6y5FqE/MfK 9B1FcN2IHxk1MkrEshacL99qOr1dIDl7vtiYymxnEXeS7yxLoXfn7HhjSw61nYUc5mc38naM eMtUl6yhLCR6hvZUICtZTGCU4npw+FEXhTRcERMR7BIYGa5Fuy9feYdKW3wMiGORZK8I8/MB Ykoaq4gPNyCeJSSWIjQ8FyAWBUnjE2TyyKvymDCZwoAErNA2Ee2L83jz1a/R6abV4VP6G/0i iVtkXmeDU2xartwrpcO83zBu0hT4R6UlaxKbilx1vb0TNhcKvaz1Y863Lrm/XfZRj9eHJuRT G6rzRZ4egaGm5qnjSr1d3MrQUu2Bu8HaI+kzKT98LxfcgX5OF2s/4y8VeredWTU6bDr/PIjX yrwlpCJE6u5IyBXS/3w0MpnQAgAA Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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;