From patchwork Wed Dec 21 00:49:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5910 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C6A5C23E03 for ; Wed, 21 Dec 2011 00:50:09 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id BD709A18458 for ; Wed, 21 Dec 2011 00:50:09 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id c11so4023605eaa.11 for ; Tue, 20 Dec 2011 16:50:09 -0800 (PST) Received: by 10.204.129.24 with SMTP id m24mr1539485bks.89.1324428609564; Tue, 20 Dec 2011 16:50:09 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs26514bkc; Tue, 20 Dec 2011 16:50:09 -0800 (PST) Received: by 10.50.217.168 with SMTP id oz8mr482172igc.24.1324428606743; Tue, 20 Dec 2011 16:50:06 -0800 (PST) Received: from e35.co.us.ibm.com (e35.co.us.ibm.com. [32.97.110.153]) by mx.google.com with ESMTPS id hn5si1692536icc.87.2011.12.20.16.50.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 16:50:06 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.153 as permitted sender) client-ip=32.97.110.153; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.153 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Dec 2011 17:50:05 -0700 Received: from d03relay05.boulder.ibm.com (9.17.195.107) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Dec 2011 17:50:04 -0700 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBL0o32E068984; Tue, 20 Dec 2011 17:50:03 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBL0o2EC029037; Tue, 20 Dec 2011 17:50:02 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBL0o1R0029014; Tue, 20 Dec 2011 17:50:01 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id F11891E74FD; Tue, 20 Dec 2011 16:50:00 -0800 (PST) From: John Stultz To: Greg KH Cc: Bjorn Bringert , Brian Swetland , Colin Cross , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Dima Zavin , Robert Love , Greg KH , John Stultz Subject: [PATCH 2/7] ashmem: Implement read(2) in ashmem driver Date: Tue, 20 Dec 2011 16:49:49 -0800 Message-Id: <1324428595-9253-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1324428595-9253-1-git-send-email-john.stultz@linaro.org> References: <1324428595-9253-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11122100-6148-0000-0000-0000021CDA39 From: Bjorn Bringert Bug: 2595601 Change-Id: I47c0016f594f9354fb8658ccb26e3d395bcb137b Signed-off-by: Bjorn Bringert [jstultz: Tweaked commit subject] CC: Brian Swetland CC: Colin Cross CC: Arve Hjønnevåg CC: Dima Zavin CC: Robert Love CC: Greg KH Signed-off-by: John Stultz --- drivers/staging/android/ashmem.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 5775c6c..6f1a0bb 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -211,6 +211,32 @@ static int ashmem_release(struct inode *ignored, struct file *file) return 0; } +static ssize_t ashmem_read(struct file *file, char __user *buf, + size_t len, loff_t *pos) +{ + struct ashmem_area *asma = file->private_data; + int ret = 0; + + mutex_lock(&ashmem_mutex); + + /* If size is not set, or set to 0, always return EOF. */ + if (asma->size == 0) { + goto out; + } + + if (!asma->file) { + ret = -EBADF; + goto out; + } + + ret = asma->file->f_op->read(asma->file, buf, len, pos); + +out: + mutex_unlock(&ashmem_mutex); + return ret; +} + + static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) { struct ashmem_area *asma = file->private_data; @@ -612,6 +638,7 @@ static struct file_operations ashmem_fops = { .owner = THIS_MODULE, .open = ashmem_open, .release = ashmem_release, + .read = ashmem_read, .mmap = ashmem_mmap, .unlocked_ioctl = ashmem_ioctl, .compat_ioctl = ashmem_ioctl,