From: Alex Bennée Date: Thu, 19 Jun 2014 14:05:27 +0000 (+0100) Subject: android_pipe: don't be clever with #define offsets X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b765d478f67a2f6cb43c40a99114ea5ff1bcff97;p=platform%2Fkernel%2Flinux-arm64.git android_pipe: don't be clever with #define offsets You just make it harder to figure out when commands are being used. Signed-off-by: Alex Bennée Conflicts: drivers/platform/goldfish/goldfish_pipe.c Change-Id: I0ed4f1cba98116d0b0c3936e8b232e45d9beaa7a --- diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 670b9b94f74..00b10952dfb 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -93,12 +93,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 */ @@ -279,8 +273,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; @@ -332,8 +324,9 @@ 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, - address, avail, pipe, &status)) { + if (access_with_param(dev, + is_write ? CMD_WRITE_BUFFER : CMD_READ_BUFFER, + address, avail, pipe, &status)) { writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); #ifdef CONFIG_64BIT writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); @@ -343,8 +336,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, #ifdef CONFIG_64BIT writel((u32)((u64)address >> 32), dev->base + PIPE_REG_ADDRESS_HIGH); #endif - writel(CMD_WRITE_BUFFER + cmd_offset, - dev->base + PIPE_REG_COMMAND); + writel(is_write ? CMD_WRITE_BUFFER : CMD_READ_BUFFER, + dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); } spin_unlock_irqrestore(&dev->lock, irq_flags); @@ -380,7 +373,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);