ANDROID: Use standard logging functions in goldfish_pipe

Bug: 72717639
bug: 66884503
Change-Id: Ifb784f6ebc5a7ef8981a6dbd4d3f6065b9347db3
Signed-off-by: Roman Kiryanov <rkir@google.com>
This commit is contained in:
Roman Kiryanov
2018-03-20 13:29:19 -07:00
committed by Amit Pundir
parent 45b5bcc4b1
commit ec9c6105fe
2 changed files with 21 additions and 21 deletions

View File

@@ -77,14 +77,6 @@
#define MAX_PAGES_TO_GRAB 32
#define DEBUG 0
#if DEBUG
#define DPRINT(...) { printk(KERN_ERR __VA_ARGS__); }
#else
#define DPRINT(...)
#endif
/* This data type models a given pipe instance */
struct goldfish_pipe {
struct goldfish_pipe_dev *dev;
@@ -276,17 +268,17 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
ret = get_user_pages_fast(first_page, requested_pages,
!is_write, pages);
DPRINT("%s: requested pages: %d %d %p\n", __FUNCTION__,
ret, requested_pages, first_page);
pr_debug("%s: requested pages: %d %ld %p\n", __func__, ret,
requested_pages, (void*)first_page);
if (ret == 0) {
DPRINT("%s: error: (requested pages == 0) (wanted %d)\n",
__FUNCTION__, requested_pages);
pr_err("%s: error: (requested pages == 0) (wanted %ld)\n",
__func__, requested_pages);
mutex_unlock(&pipe->lock);
return ret;
}
if (ret < 0) {
DPRINT("%s: (requested pages < 0) %d \n",
__FUNCTION__, requested_pages);
pr_err("%s: (requested pages < 0) %ld \n",
__func__, requested_pages);
mutex_unlock(&pipe->lock);
return ret;
}
@@ -301,8 +293,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
xaddr_prev = xaddr_i;
num_contiguous_pages++;
} else {
DPRINT("%s: discontinuous page boundary: %d pages instead\n",
__FUNCTION__, page_i);
pr_err("%s: discontinuous page boundary: %d pages instead\n",
__func__, page_i);
break;
}
}
@@ -353,8 +345,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
* ABI relies on this behavior.
*/
if (status != PIPE_ERROR_AGAIN)
pr_info_ratelimited("goldfish_pipe: backend returned error %d on %s\n",
status, is_write ? "write" : "read");
pr_err_ratelimited("goldfish_pipe: backend returned error %d on %s\n",
status, is_write ? "write" : "read");
ret = 0;
break;
}
@@ -524,7 +516,8 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
pipe->dev = dev;
mutex_init(&pipe->lock);
DPRINT("%s: call. pipe_dev pipe_dev=0x%lx new_pipe_addr=0x%lx file=0x%lx\n", __FUNCTION__, pipe_dev, pipe, file);
pr_debug("%s: call. pipe_dev dev=%p new_pipe_addr=%p file=%p\n",
__func__, dev, pipe, file);
/* spin lock init, write head of list, i guess */
init_waitqueue_head(&pipe->wake_queue);
@@ -548,7 +541,7 @@ static int goldfish_pipe_release(struct inode *inode, struct file *filp)
{
struct goldfish_pipe *pipe = filp->private_data;
DPRINT("%s: call. pipe=0x%lx file=0x%lx\n", __FUNCTION__, pipe, filp);
pr_debug("%s: call. pipe=%p file=%p\n", __func__, pipe, filp);
/* The guest is closing the channel, so tell the emulator right now */
goldfish_cmd(pipe, CMD_CLOSE);
kfree(pipe);

View File

@@ -46,6 +46,7 @@
* exchange is properly mapped during a transfer.
*/
#include <linux/printk.h>
#include "goldfish_pipe.h"
@@ -440,7 +441,7 @@ static ssize_t goldfish_pipe_read_write(struct file *filp,
* err.
*/
if (status != PIPE_ERROR_AGAIN)
pr_info_ratelimited(
pr_err_ratelimited(
"goldfish_pipe: backend error %d on %s\n",
status, is_write ? "write" : "read");
break;
@@ -694,6 +695,7 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
pipe->command_buffer =
(struct goldfish_pipe_command *)__get_free_page(GFP_KERNEL);
if (!pipe->command_buffer) {
pr_err("Could not alloc pipe command buffer!\n");
status = -ENOMEM;
goto err_pipe;
}
@@ -702,6 +704,7 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
id = get_free_pipe_id_locked(dev);
if (id < 0) {
pr_err("Could not get free pipe id!\n");
status = id;
goto err_id_locked;
}
@@ -718,10 +721,12 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
status = goldfish_cmd_locked(pipe, PIPE_CMD_OPEN);
spin_unlock_irqrestore(&dev->lock, flags);
if (status < 0) {
pr_err("Could not tell host of new pipe! status=%d", status);
goto err_cmd;
}
/* All is done, save the pipe into the file's private data field */
file->private_data = pipe;
pr_debug("%s on 0x%p\n", __func__, pipe);
return 0;
err_cmd:
@@ -741,6 +746,8 @@ static int goldfish_pipe_release(struct inode *inode, struct file *filp)
struct goldfish_pipe *pipe = filp->private_data;
struct goldfish_pipe_dev *dev = pipe->dev;
pr_debug("%s on 0x%p\n", __func__, pipe);
/* The guest is closing the channel, so tell the emulator right now */
(void)goldfish_cmd(pipe, PIPE_CMD_CLOSE);