Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047AbcCVWef (ORCPT ); Tue, 22 Mar 2016 18:34:35 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36296 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706AbcCVWeF (ORCPT ); Tue, 22 Mar 2016 18:34:05 -0400 From: Moritz Fischer To: arnd@arndb.de Cc: gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, labbott@redhat.com, gioh.kim@lge.com, sumit.semwal@linaro.org, dan.carpenter@oracle.com, sriram@marirs.net.in, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Moritz Fischer Subject: [RFC 2/2] staging: android: ion: Add of_ion_device_get function Date: Tue, 22 Mar 2016 15:33:51 -0700 Message-Id: <1458686031-31031-3-git-send-email-moritz.fischer@ettus.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1458686031-31031-1-git-send-email-moritz.fischer@ettus.com> References: <1458686031-31031-1-git-send-email-moritz.fischer@ettus.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 870 Lines: 31 Allows to obtain a reference to the global /dev/ion backing struct ion_device via devicetree. Signed-off-by: Moritz Fischer --- drivers/staging/android/ion/ion.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index e237e9f..cea264e0 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -64,6 +64,16 @@ struct ion_device { struct dentry *clients_debug_root; }; +struct ion_device *of_ion_device_get(struct device_node *node) +{ + struct miscdevice *mdev = of_misc_get(node); + + if (IS_ERR(mdev)) + return ERR_PTR(PTR_ERR(mdev)); + + return container_of(mdev, struct ion_device, dev); +} + /** * struct ion_client - a process/hw block local address space * @node: node in the tree of all clients -- 2.7.4