From patchwork Thu Mar 12 07:44:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5991381 Return-Path: X-Original-To: patchwork-linux-input@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 79993BF90F for ; Thu, 12 Mar 2015 07:46:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83C372034B for ; Thu, 12 Mar 2015 07:46:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8799B203A0 for ; Thu, 12 Mar 2015 07:46:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753277AbbCLHpx (ORCPT ); Thu, 12 Mar 2015 03:45:53 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:8801 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbbCLHo6 (ORCPT ); Thu, 12 Mar 2015 03:44:58 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NL300DC29POB950@mailout1.w1.samsung.com>; Thu, 12 Mar 2015 07:49:00 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-67-5501436529d9 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 31.FA.07834.56341055; Thu, 12 Mar 2015 07:42:29 +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 <0NL300KWS9IOZC60@eusync2.samsung.com>; Thu, 12 Mar 2015 07:44:54 +0000 (GMT) From: Krzysztof Kozlowski To: Jiri Kosina , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RESEND PATCH v6 03/22] power_supply: Add driver private data Date: Thu, 12 Mar 2015 08:44:01 +0100 Message-id: <1426146260-30081-4-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1426146260-30081-1-git-send-email-k.kozlowski@samsung.com> References: <1426146260-30081-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjluLIzCtJLcpLzFFi42I5/e/4Fd1UZ8ZQg/ZTChaTnrxntpi4cjKz xe45i1ksXr8wtLj56RurxeVdc9gsPvceYbQ48W0ak8Xp3SUOnB6fV71i9dg56y67x+YVWh6b VnWyefRtWcXocWbBEXaPz5vkAtijuGxSUnMyy1KL9O0SuDKOH2phL1goVPFvxnKWBsY9/F2M HBwSAiYS33dWdjFyApliEhfurWfrYuTiEBJYyijx7f9JVginj0li18sJbCBVbALGEpuXLwGr EhGYzyTRv+oEK0iCWcBQ4ue7P+wgtrCAm8T+3qnMIDaLgKrEv+eHwGxeAXeJyS+esUGsk5M4 eWwyK8gVnAIeEq8X8YCEhYBKZi77xD6BkXcBI8MqRtHU0uSC4qT0XEO94sTc4tK8dL3k/NxN jJCw+7KDcfExq0OMAhyMSjy8EX0MoUKsiWXFlbmHGCU4mJVEeDmsGEOFeFMSK6tSi/Lji0pz UosPMTJxcEo1ME7eaC56tFxlxbXp2QUedjWT/9ZllbnOsF11Q7r/wjWvv9fWJ/ktiDTvrX1u z/pzqaSPnfT2N4LGwdk/FJLuep8WPx+2v25RtmDx3wWzpvr1lt64qMjjnL9I/XbKQ461ijoO m9/8SaxtWHdGVf/L1ggJD8YXM+fc4rlV9eLjhuwZysbzZe3WnlViKc5INNRiLipOBABwc+ZI GQIAAA== Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@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;