From patchwork Wed Nov 25 01:10:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jin Qian X-Patchwork-Id: 57285 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2444854lbb; Tue, 24 Nov 2015 17:11:01 -0800 (PST) X-Received: by 10.98.17.152 with SMTP id 24mr27567276pfr.41.1448413860393; Tue, 24 Nov 2015 17:11:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n75si30297912pfa.94.2015.11.24.17.11.00; Tue, 24 Nov 2015 17:11:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@android.com; dmarc=fail (p=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755947AbbKYBK4 (ORCPT + 28 others); Tue, 24 Nov 2015 20:10:56 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34520 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754403AbbKYBKg (ORCPT ); Tue, 24 Nov 2015 20:10:36 -0500 Received: by padhx2 with SMTP id hx2so39126368pad.1 for ; Tue, 24 Nov 2015 17:10:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20120917; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=EnZfx2WLqmJupFM0EU4u+EiXTOoYLXEhth8XOky54iw=; b=pTMa9GGu5NkIzlt1/s2bYm5x0WW6kLJi9M1FjhAzY7JuHn5J1roawC4N6+irCYWqnI l/0XjXlQxyekOJuDozQJG0e/ltaudDO0vxH8I7NDAzG7hNxzOhBk15o5GN5USEiBRO9Y BwwcdkRCKJx2IjwHFskKsLVM51jo2hJFnjvJ8Janr5fjXmCz/d1Xfx78EwOtBC90DjQW OA6U10vRKLnDcQNx2s1nNyaazIFJJlrO4UuSyVO5ZD7VRQ56LHpXVUaxGwuqNG9q6coc A2UwjRgfqoB0r8/0uc94wig3jBQ4eS6SvIoONeuwUr2y7hISKK9UF8FtMDEieW8gGGfM HHKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=EnZfx2WLqmJupFM0EU4u+EiXTOoYLXEhth8XOky54iw=; b=Gqhm89tZ0qbtd/9YBBwJOmgbwldTVBHAFrVWPNKC1mn+OTkOHc8yHc+R8bEe4F+Xxw jOwlU3hc7dO8HTbzKyqnBVdXdSehiUZnVYKEOVwtx1cNlMTNAaqawAUBB00E3ZRkMgY1 I5UdBavyBSh+0TWSOEcNr28iiODpLsEI7uQY8g6LF/yotKrxiTP52EQIYG/AefirPqED ik1FmbpYZ5y0hnsrOvRQ20/RRBDxF2BTO7EOpUvz06XlspevOkZtCWgoWb1ruKs/vRdC 4C5IbHRb5c9+dX4MrcJVntIBf+FNr9s7VpbJgtUAkZHzM7+HOxdfEPlE7LyLdLUAFPNm i08w== X-Gm-Message-State: ALoCoQnXtifjp6s6Dnku9o5avcQWpiqCCG4vkziNwUkod39vG6VdcPUGbDVXOhQJz1UPPKUXLfVv X-Received: by 10.98.87.83 with SMTP id l80mr27390757pfb.126.1448413835602; Tue, 24 Nov 2015 17:10:35 -0800 (PST) Received: from jinqian.mtv.corp.google.com ([172.22.126.125]) by smtp.gmail.com with ESMTPSA id jj5sm17357386pac.4.2015.11.24.17.10.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Nov 2015 17:10:34 -0800 (PST) From: Jin Qian To: Greg Hackmann , Greg Kroah-Hartman , Yu Ning , Peter Senna Tschudin , Dan Carpenter , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Joe Perches , Jason Hu , linux-kernel@vger.kernel.org Cc: Jin Qian Subject: [PATCH 2/8] android_pipe: don't be clever with #define offsets Date: Tue, 24 Nov 2015 17:10:06 -0800 Message-Id: <1448413812-24289-3-git-send-email-jinqian@android.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1448413812-24289-1-git-send-email-jinqian@android.com> References: <1448413812-24289-1-git-send-email-jinqian@android.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Bennée You just make it harder to figure out when commands are being used. Signed-off-by: Alex Bennée (cherry picked from commit b765d478f67a2f6cb43c40a99114ea5ff1bcff97) Signed-off-by: Jin Qian --- drivers/platform/goldfish/goldfish_pipe.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) -- 2.6.0.rc2.230.g3dd15c0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index e7a29e2..0fb3a34 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -90,12 +90,6 @@ #define CMD_WRITE_BUFFER 4 /* send a user buffer to the emulator */ #define CMD_WAKE_ON_WRITE 5 /* tell the emulator to wake us when writing is possible */ - -/* The following commands are related to read operations, they must be - * listed in the same order than the corresponding write ones, since we - * will use (CMD_READ_BUFFER - CMD_WRITE_BUFFER) as a special offset - * in goldfish_pipe_read_write() below. - */ #define CMD_READ_BUFFER 6 /* receive a user buffer from the emulator */ #define CMD_WAKE_ON_READ 7 /* tell the emulator to wake us when reading * is possible */ @@ -272,8 +266,6 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, unsigned long irq_flags; struct goldfish_pipe *pipe = filp->private_data; struct goldfish_pipe_dev *dev = pipe->dev; - const int cmd_offset = is_write ? 0 - : (CMD_READ_BUFFER - CMD_WRITE_BUFFER); unsigned long address, address_end; int ret = 0; @@ -325,7 +317,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, /* Now, try to transfer the bytes in the current page */ spin_lock_irqsave(&dev->lock, irq_flags); - if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, + if (access_with_param(dev, + is_write ? CMD_WRITE_BUFFER : CMD_READ_BUFFER, address, avail, pipe, &status)) { gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL, dev->base + PIPE_REG_CHANNEL_HIGH); @@ -333,7 +326,7 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, gf_write_ptr((void *)address, dev->base + PIPE_REG_ADDRESS, dev->base + PIPE_REG_ADDRESS_HIGH); - writel(CMD_WRITE_BUFFER + cmd_offset, + writel(is_write ? CMD_WRITE_BUFFER : CMD_READ_BUFFER, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); } @@ -370,7 +363,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, set_bit(wakeBit, &pipe->flags); /* Tell the emulator we're going to wait for a wake event */ - goldfish_cmd(pipe, CMD_WAKE_ON_WRITE + cmd_offset); + goldfish_cmd(pipe, + is_write ? CMD_WAKE_ON_WRITE : CMD_WAKE_ON_READ); /* Unlock the pipe, then wait for the wake signal */ mutex_unlock(&pipe->lock);