From patchwork Fri Jan 30 14:47:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5750841 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 BA8F19F302 for ; Fri, 30 Jan 2015 14:48:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04C3A201CE for ; Fri, 30 Jan 2015 14:48:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70A7920304 for ; Fri, 30 Jan 2015 14:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932843AbbA3Osc (ORCPT ); Fri, 30 Jan 2015 09:48:32 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:56263 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932833AbbA3OsZ (ORCPT ); Fri, 30 Jan 2015 09:48:25 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) 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 <0NIZ00LJCVZDL280@mailout3.w1.samsung.com>; Fri, 30 Jan 2015 14:52:25 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-f1-54cb9924ba58 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id F6.09.07834.4299BC45; Fri, 30 Jan 2015 14:45:56 +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 <0NIZ00EV0VSES470@eusync2.samsung.com>; Fri, 30 Jan 2015 14:48:20 +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 , Russell King Cc: Thomas Gleixner , Pavel Machek , Kyungmin Park , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski Subject: [PATCH v3 01/20] power_supply: Add driver private data Date: Fri, 30 Jan 2015 15:47:39 +0100 Message-id: <1422629278-12202-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1422629278-12202-1-git-send-email-k.kozlowski@samsung.com> References: <1422629278-12202-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyWRV0xTYRiG/XtW21g8FMQTYjQSxATDqJL4OaJGQjg3GkzgxqhYoAFkt0BA QwSKQUYBGTLCTIEylNFiFKmIrWVY9orKcAAJIihbJaIy7p73zfPmu/i4mFCHW3L9g8Ml0mBx oBXJx41/O4btrPON7o4blRSk9SxyoDGvnoDyzhQc4jfncMic/oGBtnuDAuWQBSSXOcLD6iwM 5Mp6EvrrTsGjxgNQuVRCQkuhEodvsyLoiZ+n4OOaAUHz5wUSsv+oOKBqTUegnhol4P3yOgFD LwpJWFG8QZC0WkDC2JAAkvrKEKg26nAYbCvdGiz8I2HirYGEWu0sBt3GQQIK5s3AmEKAsSUc Xt4fwECjzsHgV8MUcfEYmyBPJdmqZQd2slWPs+l1KwTbXDBBsYtLN9mZjCyK1VTZstNzKoJV 1ySR7PiolmS/9/ZSbHHXVfZV0eMtofwea0gdx90sr/HP+UgC/SMlUofzt/h+crmaDF0zjWrT lOKxKGdfMuJxGdqJ0TcnY7tswfRP1pPJiM8V0hWIMaQWUbshjcOUFD+gti2SPsloVOU7ljm9 wGPa07T4dsDoMcQ0a6s525YZfYGJ+6TfWeD0USZRU0Nss4B2ZRTxcdTuvUNMV3vWTs+jWaZh 9ssOC7ec9JE8MgMJStGeGrRfEuEdKvPyDRLZy8RBsohgX3vvkCA12v376nOkbD+jQzQXWe0V vBMb3YWEOFIWHaRDDBezMhdkZ25VAh9x9B2JNMRTGhEokekQh8uzjEVZoa+bRmxcw37+rjoc x5iZCm7oO1WXh670PQvQMceHbXIaqqQVt/esS51O2FUfua7AbFv9XVJ8Bno7PCYGy5KcEw5a I+cARb4oly8K8zXJFeYER8V41SiISyhs9fSYqckTTNRUF7PpljiTwZsf85QvP8Xiv3q4JIQp z36ga+9a4TI/scgWk8rE/wGQJO//1QIAAA== 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 --- 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;