From patchwork Fri Dec 9 04:45:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5550 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 DB45E23E03 for ; Fri, 9 Dec 2011 04:46:09 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id C3FF3A1801B for ; Fri, 9 Dec 2011 04:46:09 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id 17so3421035bke.11 for ; Thu, 08 Dec 2011 20:46:09 -0800 (PST) Received: by 10.204.156.208 with SMTP id y16mr2844502bkw.72.1323405969534; Thu, 08 Dec 2011 20:46: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.129.2 with SMTP id hg2cs107008bkc; Thu, 8 Dec 2011 20:46:09 -0800 (PST) Received: by 10.68.72.39 with SMTP id a7mr2245044pbv.96.1323405967157; Thu, 08 Dec 2011 20:46:07 -0800 (PST) Received: from e36.co.us.ibm.com (e36.co.us.ibm.com. [32.97.110.154]) by mx.google.com with ESMTPS id h6si3059427pbf.133.2011.12.08.20.46.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Dec 2011 20:46:07 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.154 as permitted sender) client-ip=32.97.110.154; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.154 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Dec 2011 21:46:04 -0700 Received: from d03relay03.boulder.ibm.com (9.17.195.228) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Dec 2011 21:45:43 -0700 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB94jgBd121194; Thu, 8 Dec 2011 21:45:43 -0700 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB94jgn7017374; Thu, 8 Dec 2011 21:45:42 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pB94jgOu017338; Thu, 8 Dec 2011 21:45:42 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 5AA4A1E74FF; Thu, 8 Dec 2011 20:45:41 -0800 (PST) From: John Stultz To: Brian Swetland 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 4/9] ashmem: Implement read(2) in ashmem driver Date: Thu, 8 Dec 2011 20:45:03 -0800 Message-Id: <1323405908-26046-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1323405908-26046-1-git-send-email-john.stultz@linaro.org> References: <1323405908-26046-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11120904-3352-0000-0000-000001430AEB 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 | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 60b2431..13cfb11 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -211,6 +211,31 @@ 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; @@ -607,6 +632,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,