linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns
@ 2018-08-27 18:22 rkir
  2018-08-27 18:22 ` [PATCH 02/20] platform: goldfish: pipe: Update license rkir
                   ` (18 more replies)
  0 siblings, 19 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:22 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Some comment lines are longer than 80 symbols.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 2da567540c2d..6094ca414d9a 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -85,7 +85,10 @@ enum PipePollFlags {
 	PIPE_POLL_HUP	= 1 << 2
 };
 
-/* Possible status values used to signal errors - see goldfish_pipe_error_convert */
+/*
+ * Possible status values used to signal errors
+ * see: goldfish_pipe_error_convert
+ */
 enum PipeErrors {
 	PIPE_ERROR_INVAL  = -1,
 	PIPE_ERROR_AGAIN  = -2,
@@ -150,9 +153,9 @@ struct goldfish_pipe_command;
 
 /* A per-pipe command structure, shared with the host */
 struct goldfish_pipe_command {
-	s32 cmd;		/* PipeCmdCode, guest -> host */
-	s32 id;			/* pipe id, guest -> host */
-	s32 status;		/* command execution status, host -> guest */
+	s32 cmd;	/* PipeCmdCode, guest -> host */
+	s32 id;		/* pipe id, guest -> host */
+	s32 status;	/* command execution status, host -> guest */
 	s32 reserved;	/* to pad to 64-bit boundary */
 	union {
 		/* Parameters for PIPE_CMD_{READ,WRITE} */
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 02/20] platform: goldfish: pipe: Update license
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
@ 2018-08-27 18:22 ` rkir
  2018-08-27 18:22 ` [PATCH 03/20] platform: goldfish: pipe: Move an opening brace to the next line rkir
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:22 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

goldfish_pipe is distributed under GPL v2.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 6094ca414d9a..d2f0582f445e 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2012 Intel, Inc.
  * Copyright (C) 2013 Intel, Inc.
@@ -984,4 +985,4 @@ static struct platform_driver goldfish_pipe_driver = {
 
 module_platform_driver(goldfish_pipe_driver);
 MODULE_AUTHOR("David Turner <digit@google.com>");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 03/20] platform: goldfish: pipe: Move an opening brace to the next line
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
  2018-08-27 18:22 ` [PATCH 02/20] platform: goldfish: pipe: Update license rkir
@ 2018-08-27 18:22 ` rkir
  2018-08-27 18:22 ` [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header rkir
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:22 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Function's opening brace has to be at the
beginning of the next line.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index d2f0582f445e..4e7e100dc7a0 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -588,7 +588,8 @@ static void signalled_pipes_add_locked(struct goldfish_pipe_dev *dev,
 }
 
 static void signalled_pipes_remove_locked(struct goldfish_pipe_dev *dev,
-	struct goldfish_pipe *pipe) {
+	struct goldfish_pipe *pipe)
+{
 	if (pipe->prev_signalled)
 		pipe->prev_signalled->next_signalled = pipe->next_signalled;
 	if (pipe->next_signalled)
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
  2018-08-27 18:22 ` [PATCH 02/20] platform: goldfish: pipe: Update license rkir
  2018-08-27 18:22 ` [PATCH 03/20] platform: goldfish: pipe: Move an opening brace to the next line rkir
@ 2018-08-27 18:22 ` rkir
  2018-09-14 13:29   ` Greg KH
  2018-08-27 18:23 ` [PATCH 05/20] platform: goldfish: pipe: Update the comment for GFP_ATOMIC rkir
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 24+ messages in thread
From: rkir @ 2018-08-27 18:22 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

These are several enums that must kept in sync with the host side.
This change explicitly separates them into a dedicated header file.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c     |  69 +----------
 .../platform/goldfish/goldfish_pipe_qemu.h    | 112 ++++++++++++++++++
 2 files changed, 113 insertions(+), 68 deletions(-)
 create mode 100644 drivers/platform/goldfish/goldfish_pipe_qemu.h

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 4e7e100dc7a0..caf514aafb21 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -64,6 +64,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mm.h>
 #include <linux/acpi.h>
+#include "goldfish_pipe_qemu.h"
 
 /*
  * Update this when something changes in the driver's behavior so the host
@@ -74,74 +75,6 @@ enum {
 	PIPE_CURRENT_DEVICE_VERSION = 2
 };
 
-/*
- * IMPORTANT: The following constants must match the ones used and defined
- * in external/qemu/hw/goldfish_pipe.c in the Android source tree.
- */
-
-/* List of bitflags returned in status of CMD_POLL command */
-enum PipePollFlags {
-	PIPE_POLL_IN	= 1 << 0,
-	PIPE_POLL_OUT	= 1 << 1,
-	PIPE_POLL_HUP	= 1 << 2
-};
-
-/*
- * Possible status values used to signal errors
- * see: goldfish_pipe_error_convert
- */
-enum PipeErrors {
-	PIPE_ERROR_INVAL  = -1,
-	PIPE_ERROR_AGAIN  = -2,
-	PIPE_ERROR_NOMEM  = -3,
-	PIPE_ERROR_IO     = -4
-};
-
-/* Bit-flags used to signal events from the emulator */
-enum PipeWakeFlags {
-	PIPE_WAKE_CLOSED = 1 << 0,  /* emulator closed pipe */
-	PIPE_WAKE_READ   = 1 << 1,  /* pipe can now be read from */
-	PIPE_WAKE_WRITE  = 1 << 2  /* pipe can now be written to */
-};
-
-/* Bit flags for the 'flags' field */
-enum PipeFlagsBits {
-	BIT_CLOSED_ON_HOST = 0,  /* pipe closed by host */
-	BIT_WAKE_ON_WRITE  = 1,  /* want to be woken on writes */
-	BIT_WAKE_ON_READ   = 2,  /* want to be woken on reads */
-};
-
-enum PipeRegs {
-	PIPE_REG_CMD = 0,
-
-	PIPE_REG_SIGNAL_BUFFER_HIGH = 4,
-	PIPE_REG_SIGNAL_BUFFER = 8,
-	PIPE_REG_SIGNAL_BUFFER_COUNT = 12,
-
-	PIPE_REG_OPEN_BUFFER_HIGH = 20,
-	PIPE_REG_OPEN_BUFFER = 24,
-
-	PIPE_REG_VERSION = 36,
-
-	PIPE_REG_GET_SIGNALLED = 48,
-};
-
-enum PipeCmdCode {
-	PIPE_CMD_OPEN = 1,	/* to be used by the pipe device itself */
-	PIPE_CMD_CLOSE,
-	PIPE_CMD_POLL,
-	PIPE_CMD_WRITE,
-	PIPE_CMD_WAKE_ON_WRITE,
-	PIPE_CMD_READ,
-	PIPE_CMD_WAKE_ON_READ,
-
-	/*
-	 * TODO(zyy): implement a deferred read/write execution to allow
-	 * parallel processing of pipe operations on the host.
-	 */
-	PIPE_CMD_WAKE_ON_DONE_IO,
-};
-
 enum {
 	MAX_BUFFERS_PER_COMMAND = 336,
 	MAX_SIGNALLED_PIPES = 64,
diff --git a/drivers/platform/goldfish/goldfish_pipe_qemu.h b/drivers/platform/goldfish/goldfish_pipe_qemu.h
new file mode 100644
index 000000000000..c272e11c5433
--- /dev/null
+++ b/drivers/platform/goldfish/goldfish_pipe_qemu.h
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * IMPORTANT: The following constants must match the ones used and defined in
+ * external/qemu/include/hw/misc/goldfish_pipe.h
+ */
+
+#ifndef GOLDFISH_PIPE_QEMU_H
+#define GOLDFISH_PIPE_QEMU_H
+
+/* List of bitflags returned in status of CMD_POLL command */
+enum PipePollFlags {
+	PIPE_POLL_IN	= 1 << 0,
+	PIPE_POLL_OUT	= 1 << 1,
+	PIPE_POLL_HUP	= 1 << 2
+};
+
+/* Possible status values used to signal errors */
+enum PipeErrors {
+	PIPE_ERROR_INVAL	= -1,
+	PIPE_ERROR_AGAIN	= -2,
+	PIPE_ERROR_NOMEM	= -3,
+	PIPE_ERROR_IO		= -4
+};
+
+/* Bit-flags used to signal events from the emulator */
+enum PipeWakeFlags {
+	/* emulator closed pipe */
+	PIPE_WAKE_CLOSED		= 1 << 0,
+
+	/* pipe can now be read from */
+	PIPE_WAKE_READ			= 1 << 1,
+
+	/* pipe can now be written to */
+	PIPE_WAKE_WRITE			= 1 << 2,
+
+	/* unlock this pipe's DMA buffer */
+	PIPE_WAKE_UNLOCK_DMA		= 1 << 3,
+
+	/* unlock DMA buffer of the pipe shared to this pipe */
+	PIPE_WAKE_UNLOCK_DMA_SHARED	= 1 << 4,
+};
+
+/* Possible pipe closing reasons */
+enum PipeCloseReason {
+	/* guest sent a close command */
+	PIPE_CLOSE_GRACEFUL		= 0,
+
+	/* guest rebooted, we're closing the pipes */
+	PIPE_CLOSE_REBOOT		= 1,
+
+	/* close old pipes on snapshot load */
+	PIPE_CLOSE_LOAD_SNAPSHOT	= 2,
+
+	/* some unrecoverable error on the pipe */
+	PIPE_CLOSE_ERROR		= 3,
+};
+
+/* Bit flags for the 'flags' field */
+enum PipeFlagsBits {
+	BIT_CLOSED_ON_HOST = 0,  /* pipe closed by host */
+	BIT_WAKE_ON_WRITE  = 1,  /* want to be woken on writes */
+	BIT_WAKE_ON_READ   = 2,  /* want to be woken on reads */
+};
+
+enum PipeRegs {
+	PIPE_REG_CMD = 0,
+
+	PIPE_REG_SIGNAL_BUFFER_HIGH = 4,
+	PIPE_REG_SIGNAL_BUFFER = 8,
+	PIPE_REG_SIGNAL_BUFFER_COUNT = 12,
+
+	PIPE_REG_OPEN_BUFFER_HIGH = 20,
+	PIPE_REG_OPEN_BUFFER = 24,
+
+	PIPE_REG_VERSION = 36,
+
+	PIPE_REG_GET_SIGNALLED = 48,
+};
+
+enum PipeCmdCode {
+	/* to be used by the pipe device itself */
+	PIPE_CMD_OPEN		= 1,
+
+	PIPE_CMD_CLOSE,
+	PIPE_CMD_POLL,
+	PIPE_CMD_WRITE,
+	PIPE_CMD_WAKE_ON_WRITE,
+	PIPE_CMD_READ,
+	PIPE_CMD_WAKE_ON_READ,
+
+	/*
+	 * TODO(zyy): implement a deferred read/write execution to allow
+	 * parallel processing of pipe operations on the host.
+	 */
+	PIPE_CMD_WAKE_ON_DONE_IO,
+};
+
+#endif /* GOLDFISH_PIPE_QEMU_H */
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 05/20] platform: goldfish: pipe: Update the comment for GFP_ATOMIC
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (2 preceding siblings ...)
  2018-08-27 18:22 ` [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 06/20] platform: goldfish: pipe: Fail compilation if structs are too large rkir
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Provide an explanation why GFP_ATOMIC is needed to prevent changing it to
other values.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index caf514aafb21..0c55e657da5a 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -640,7 +640,10 @@ static int get_free_pipe_id_locked(struct goldfish_pipe_dev *dev)
 			return id;
 
 	{
-		/* Reallocate the array */
+		/* Reallocate the array.
+		 * Since get_free_pipe_id_locked runs with interrupts disabled,
+		 * we don't want to make calls that could lead to sleep.
+		 */
 		u32 new_capacity = 2 * dev->pipes_capacity;
 		struct goldfish_pipe **pipes =
 			kcalloc(new_capacity, sizeof(*pipes), GFP_ATOMIC);
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 06/20] platform: goldfish: pipe: Fail compilation if structs are too large
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (3 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 05/20] platform: goldfish: pipe: Update the comment for GFP_ATOMIC rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable rkir
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Since the driver provides no workaround prevent in cases if structs do
no fit into a memory page, it is better to fail complation to find about
the issue earlt instead of returning errors at runtime.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 0c55e657da5a..24e40deb98cc 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -64,6 +64,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mm.h>
 #include <linux/acpi.h>
+#include <linux/bug.h>
 #include "goldfish_pipe_qemu.h"
 
 /*
@@ -689,6 +690,7 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
 	 * Command buffer needs to be allocated on its own page to make sure
 	 * it is physically contiguous in host's address space.
 	 */
+	BUILD_BUG_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE);
 	pipe->command_buffer =
 		(struct goldfish_pipe_command *)__get_free_page(GFP_KERNEL);
 	if (!pipe->command_buffer) {
@@ -798,9 +800,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 	 * needs to be contained in a single physical page. The easiest choice
 	 * is to just allocate a page and place the buffers in it.
 	 */
-	if (WARN_ON(sizeof(*dev->buffers) > PAGE_SIZE))
-		return -ENOMEM;
-
+	BUILD_BUG_ON(sizeof(struct goldfish_pipe_dev_buffers) > PAGE_SIZE);
 	page = (char *)__get_free_page(GFP_KERNEL);
 	if (!page) {
 		kfree(dev->pipes);
@@ -843,9 +843,6 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
 	struct resource *r;
 	struct goldfish_pipe_dev *dev = pipe_dev;
 
-	if (WARN_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE))
-		return -ENOMEM;
-
 	/* not thread safe, but this should not happen */
 	WARN_ON(dev->base != NULL);
 
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (4 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 06/20] platform: goldfish: pipe: Fail compilation if structs are too large rkir
@ 2018-08-27 18:23 ` rkir
  2018-09-14 13:30   ` Greg KH
  2018-08-27 18:23 ` [PATCH 08/20] platform: goldfish: pipe: Replace pr_ with dev_ for logging rkir
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

There is no reason to have an array of 1.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++++------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 24e40deb98cc..e9e3e791c0d4 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -205,7 +205,7 @@ struct goldfish_pipe_dev {
 	unsigned char __iomem *base;
 };
 
-static struct goldfish_pipe_dev pipe_dev[1] = {};
+struct goldfish_pipe_dev goldfish_pipe_dev;
 
 static int goldfish_cmd_locked(struct goldfish_pipe *pipe, enum PipeCmdCode cmd)
 {
@@ -564,12 +564,12 @@ static struct goldfish_pipe *signalled_pipes_pop_front(
 
 static void goldfish_interrupt_task(unsigned long unused)
 {
-	struct goldfish_pipe_dev *dev = pipe_dev;
 	/* Iterate over the signalled pipes and wake them one by one */
 	struct goldfish_pipe *pipe;
 	int wakes;
 
-	while ((pipe = signalled_pipes_pop_front(dev, &wakes)) != NULL) {
+	while ((pipe = signalled_pipes_pop_front(&goldfish_pipe_dev, &wakes)) !=
+			NULL) {
 		if (wakes & PIPE_WAKE_CLOSED) {
 			pipe->flags = 1 << BIT_CLOSED_ON_HOST;
 		} else {
@@ -607,7 +607,7 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id)
 	unsigned long flags;
 	struct goldfish_pipe_dev *dev = dev_id;
 
-	if (dev != pipe_dev)
+	if (dev != &goldfish_pipe_dev)
 		return IRQ_NONE;
 
 	/* Request the signalled pipes from the device */
@@ -672,7 +672,7 @@ static int get_free_pipe_id_locked(struct goldfish_pipe_dev *dev)
  */
 static int goldfish_pipe_open(struct inode *inode, struct file *file)
 {
-	struct goldfish_pipe_dev *dev = pipe_dev;
+	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
 	unsigned long flags;
 	int id;
 	int status;
@@ -763,7 +763,7 @@ static const struct file_operations goldfish_pipe_fops = {
 	.release = goldfish_pipe_release,
 };
 
-static struct miscdevice goldfish_pipe_dev = {
+static struct miscdevice goldfish_pipe_miscdev = {
 	.minor = MISC_DYNAMIC_MINOR,
 	.name = "goldfish_pipe",
 	.fops = &goldfish_pipe_fops,
@@ -771,8 +771,8 @@ static struct miscdevice goldfish_pipe_dev = {
 
 static int goldfish_pipe_device_init(struct platform_device *pdev)
 {
+	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
 	char *page;
-	struct goldfish_pipe_dev *dev = pipe_dev;
 	int err = devm_request_irq(&pdev->dev, dev->irq,
 				goldfish_pipe_interrupt,
 				IRQF_SHARED, "goldfish_pipe", dev);
@@ -781,7 +781,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 		return err;
 	}
 
-	err = misc_register(&goldfish_pipe_dev);
+	err = misc_register(&goldfish_pipe_miscdev);
 	if (err) {
 		dev_err(&pdev->dev, "unable to register v2 device\n");
 		return err;
@@ -830,18 +830,16 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 
 static void goldfish_pipe_device_deinit(struct platform_device *pdev)
 {
-	struct goldfish_pipe_dev *dev = pipe_dev;
-
-	misc_deregister(&goldfish_pipe_dev);
-	kfree(dev->pipes);
-	free_page((unsigned long)dev->buffers);
+	misc_deregister(&goldfish_pipe_miscdev);
+	kfree(goldfish_pipe_dev.pipes);
+	free_page((unsigned long)goldfish_pipe_dev.buffers);
 }
 
 static int goldfish_pipe_probe(struct platform_device *pdev)
 {
 	int err;
 	struct resource *r;
-	struct goldfish_pipe_dev *dev = pipe_dev;
+	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
 
 	/* not thread safe, but this should not happen */
 	WARN_ON(dev->base != NULL);
@@ -889,7 +887,7 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
 
 static int goldfish_pipe_remove(struct platform_device *pdev)
 {
-	struct goldfish_pipe_dev *dev = pipe_dev;
+	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
 	goldfish_pipe_device_deinit(pdev);
 	dev->base = NULL;
 	return 0;
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 08/20] platform: goldfish: pipe: Replace pr_ with dev_ for logging
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (5 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 09/20] platform: goldfish: pipe: Add blank lines to separate struct members rkir
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

dev_ is preferred if struct device is available.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index e9e3e791c0d4..a61cd444e8ff 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -199,6 +199,9 @@ struct goldfish_pipe_dev {
 	/* Head of a doubly linked list of signalled pipes */
 	struct goldfish_pipe *first_signalled_pipe;
 
+	/* ptr to platform device's device struct */
+	struct device *pdev_dev;
+
 	/* Some device-specific data */
 	int irq;
 	int version;
@@ -434,7 +437,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp,
 			 * err.
 			 */
 			if (status != PIPE_ERROR_AGAIN)
-				pr_info_ratelimited("goldfish_pipe: backend error %d on %s\n",
+				dev_err_ratelimited(pipe->dev->pdev_dev,
+					"backend error %d on %s\n",
 					status, is_write ? "write" : "read");
 			break;
 		}
@@ -787,6 +791,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 		return err;
 	}
 
+	dev->pdev_dev = &pdev->dev;
 	dev->first_signalled_pipe = NULL;
 	dev->pipes_capacity = INITIAL_PIPES_CAPACITY;
 	dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes),
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 09/20] platform: goldfish: pipe: Add blank lines to separate struct members
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (6 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 08/20] platform: goldfish: pipe: Replace pr_ with dev_ for logging rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 10/20] platform: goldfish: pipe: Remove a redundant variable rkir
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

To improve readability and to be consistent with other
struct members.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index a61cd444e8ff..62422a4282f5 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -130,11 +130,13 @@ struct goldfish_pipe_dev_buffers {
 struct goldfish_pipe {
 	/* pipe ID - index into goldfish_pipe_dev::pipes array */
 	u32 id;
+
 	/* The wake flags pipe is waiting for
 	 * Note: not protected with any lock, uses atomic operations
 	 *  and barriers to make it thread-safe.
 	 */
 	unsigned long flags;
+
 	/* wake flags host have signalled,
 	 *  - protected by goldfish_pipe_dev::lock
 	 */
@@ -158,6 +160,7 @@ struct goldfish_pipe {
 
 	/* A wake queue for sleeping until host signals an event */
 	wait_queue_head_t wake_queue;
+
 	/* Pointer to the parent goldfish_pipe_dev instance */
 	struct goldfish_pipe_dev *dev;
 };
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 10/20] platform: goldfish: pipe: Remove a redundant variable
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (7 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 09/20] platform: goldfish: pipe: Add blank lines to separate struct members rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 11/20] platform: goldfish: pipe: Replace two code blocks with a function call rkir
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

The variable was not very useful.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 62422a4282f5..3d28a9be5722 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -779,7 +779,6 @@ static struct miscdevice goldfish_pipe_miscdev = {
 static int goldfish_pipe_device_init(struct platform_device *pdev)
 {
 	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
-	char *page;
 	int err = devm_request_irq(&pdev->dev, dev->irq,
 				goldfish_pipe_interrupt,
 				IRQF_SHARED, "goldfish_pipe", dev);
@@ -809,12 +808,12 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 	 * is to just allocate a page and place the buffers in it.
 	 */
 	BUILD_BUG_ON(sizeof(struct goldfish_pipe_dev_buffers) > PAGE_SIZE);
-	page = (char *)__get_free_page(GFP_KERNEL);
-	if (!page) {
+	dev->buffers = (struct goldfish_pipe_dev_buffers *)
+		__get_free_page(GFP_KERNEL);
+	if (!dev->buffers) {
 		kfree(dev->pipes);
 		return -ENOMEM;
 	}
-	dev->buffers = (struct goldfish_pipe_dev_buffers *)page;
 
 	/* Send the buffer addresses to the host */
 	{
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 11/20] platform: goldfish: pipe: Replace two code blocks with a function call
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (8 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 10/20] platform: goldfish: pipe: Remove a redundant variable rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 12/20] platform: goldfish: pipe: Remove reduntant casting rkir
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Two function calls look cleaner because the function introduces
takes case of all bit shifting and casting.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 35 ++++++++++++-----------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 3d28a9be5722..e3c09ff7867a 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -776,6 +776,14 @@ static struct miscdevice goldfish_pipe_miscdev = {
 	.fops = &goldfish_pipe_fops,
 };
 
+static void write_pa_addr(void *addr, void __iomem *portl, void __iomem *porth)
+{
+	const unsigned long paddr = __pa(addr);
+
+	writel(upper_32_bits(paddr), porth);
+	writel(lower_32_bits(paddr), portl);
+}
+
 static int goldfish_pipe_device_init(struct platform_device *pdev)
 {
 	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
@@ -816,22 +824,17 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 	}
 
 	/* Send the buffer addresses to the host */
-	{
-		u64 paddr = __pa(&dev->buffers->signalled_pipe_buffers);
-
-		writel((u32)(unsigned long)(paddr >> 32),
-			dev->base + PIPE_REG_SIGNAL_BUFFER_HIGH);
-		writel((u32)(unsigned long)paddr,
-			dev->base + PIPE_REG_SIGNAL_BUFFER);
-		writel((u32)MAX_SIGNALLED_PIPES,
-			dev->base + PIPE_REG_SIGNAL_BUFFER_COUNT);
-
-		paddr = __pa(&dev->buffers->open_command_params);
-		writel((u32)(unsigned long)(paddr >> 32),
-			dev->base + PIPE_REG_OPEN_BUFFER_HIGH);
-		writel((u32)(unsigned long)paddr,
-			dev->base + PIPE_REG_OPEN_BUFFER);
-	}
+	write_pa_addr(&dev->buffers->signalled_pipe_buffers,
+		      dev->base + PIPE_REG_SIGNAL_BUFFER,
+		      dev->base + PIPE_REG_SIGNAL_BUFFER_HIGH);
+
+	writel((u32)MAX_SIGNALLED_PIPES,
+	       dev->base + PIPE_REG_SIGNAL_BUFFER_COUNT);
+
+	write_pa_addr(&dev->buffers->open_command_params,
+		      dev->base + PIPE_REG_OPEN_BUFFER,
+		      dev->base + PIPE_REG_OPEN_BUFFER_HIGH);
+
 	return 0;
 }
 
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 12/20] platform: goldfish: pipe: Remove reduntant casting
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (9 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 11/20] platform: goldfish: pipe: Replace two code blocks with a function call rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 13/20] platform: goldfish: pipe: Remove a blank line before '}' rkir
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Casting to u32 is not required here.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index e3c09ff7867a..ff0e150d15d5 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -828,7 +828,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 		      dev->base + PIPE_REG_SIGNAL_BUFFER,
 		      dev->base + PIPE_REG_SIGNAL_BUFFER_HIGH);
 
-	writel((u32)MAX_SIGNALLED_PIPES,
+	writel(MAX_SIGNALLED_PIPES,
 	       dev->base + PIPE_REG_SIGNAL_BUFFER_COUNT);
 
 	write_pa_addr(&dev->buffers->open_command_params,
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 13/20] platform: goldfish: pipe: Remove a blank line before '}'
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (10 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 12/20] platform: goldfish: pipe: Remove reduntant casting rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 14/20] platform: goldfish: pipe: Rename 'wakeBit' to 'wake_bit' rkir
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index ff0e150d15d5..14441e7106ba 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -272,8 +272,8 @@ static int pin_user_pages(unsigned long first_page, unsigned long last_page,
 		return -EFAULT;
 	if (ret < requested_pages)
 		*iter_last_page_size = PAGE_SIZE;
-	return ret;
 
+	return ret;
 }
 
 static void release_user_pages(struct page **pages, int pages_count,
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 14/20] platform: goldfish: pipe: Rename 'wakeBit' to 'wake_bit'
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (11 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 13/20] platform: goldfish: pipe: Remove a blank line before '}' rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 15/20] platform: goldfish: pipe: Remove reduntant casting to (void) rkir
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Avoid CamelCase

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 14441e7106ba..cab1935a04c5 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -363,18 +363,18 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe,
 
 static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write)
 {
-	u32 wakeBit = is_write ? BIT_WAKE_ON_WRITE : BIT_WAKE_ON_READ;
+	u32 wake_bit = is_write ? BIT_WAKE_ON_WRITE : BIT_WAKE_ON_READ;
 
-	set_bit(wakeBit, &pipe->flags);
+	set_bit(wake_bit, &pipe->flags);
 
 	/* Tell the emulator we're going to wait for a wake event */
 	(void)goldfish_cmd(pipe,
 		is_write ? PIPE_CMD_WAKE_ON_WRITE : PIPE_CMD_WAKE_ON_READ);
 
-	while (test_bit(wakeBit, &pipe->flags)) {
+	while (test_bit(wake_bit, &pipe->flags)) {
 		if (wait_event_interruptible(
 				pipe->wake_queue,
-				!test_bit(wakeBit, &pipe->flags)))
+				!test_bit(wake_bit, &pipe->flags)))
 			return -ERESTARTSYS;
 
 		if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 15/20] platform: goldfish: pipe: Remove reduntant casting to (void)
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (12 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 14/20] platform: goldfish: pipe: Rename 'wakeBit' to 'wake_bit' rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 16/20] platform: goldfish: pipe: Rename goldfish_x to goldfish_pipe_x rkir
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Casting to (void) is no-op.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index cab1935a04c5..fb37499731a4 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -368,7 +368,7 @@ static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write)
 	set_bit(wake_bit, &pipe->flags);
 
 	/* Tell the emulator we're going to wait for a wake event */
-	(void)goldfish_cmd(pipe,
+	goldfish_cmd(pipe,
 		is_write ? PIPE_CMD_WAKE_ON_WRITE : PIPE_CMD_WAKE_ON_READ);
 
 	while (test_bit(wake_bit, &pipe->flags)) {
@@ -748,7 +748,7 @@ static int goldfish_pipe_release(struct inode *inode, struct file *filp)
 	struct goldfish_pipe_dev *dev = pipe->dev;
 
 	/* The guest is closing the channel, so tell the emulator right now */
-	(void)goldfish_cmd(pipe, PIPE_CMD_CLOSE);
+	goldfish_cmd(pipe, PIPE_CMD_CLOSE);
 
 	spin_lock_irqsave(&dev->lock, flags);
 	dev->pipes[pipe->id] = NULL;
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 16/20] platform: goldfish: pipe: Rename goldfish_x to goldfish_pipe_x
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (13 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 15/20] platform: goldfish: pipe: Remove reduntant casting to (void) rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 17/20] platform: goldfish: pipe: Fix lines to not end an opening bracket rkir
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

Add "pipe" to the pipe related function names.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index fb37499731a4..95256a5c593c 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -213,7 +213,8 @@ struct goldfish_pipe_dev {
 
 struct goldfish_pipe_dev goldfish_pipe_dev;
 
-static int goldfish_cmd_locked(struct goldfish_pipe *pipe, enum PipeCmdCode cmd)
+static int goldfish_pipe_cmd_locked(struct goldfish_pipe *pipe,
+				    enum PipeCmdCode cmd)
 {
 	pipe->command_buffer->cmd = cmd;
 	/* failure by default */
@@ -222,13 +223,13 @@ static int goldfish_cmd_locked(struct goldfish_pipe *pipe, enum PipeCmdCode cmd)
 	return pipe->command_buffer->status;
 }
 
-static int goldfish_cmd(struct goldfish_pipe *pipe, enum PipeCmdCode cmd)
+static int goldfish_pipe_cmd(struct goldfish_pipe *pipe, enum PipeCmdCode cmd)
 {
 	int status;
 
 	if (mutex_lock_interruptible(&pipe->lock))
 		return PIPE_ERROR_IO;
-	status = goldfish_cmd_locked(pipe, cmd);
+	status = goldfish_pipe_cmd_locked(pipe, cmd);
 	mutex_unlock(&pipe->lock);
 	return status;
 }
@@ -349,7 +350,7 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe,
 		pipe->command_buffer);
 
 	/* Transfer the data */
-	*status = goldfish_cmd_locked(pipe,
+	*status = goldfish_pipe_cmd_locked(pipe,
 				is_write ? PIPE_CMD_WRITE : PIPE_CMD_READ);
 
 	*consumed_size = pipe->command_buffer->rw_params.consumed_size;
@@ -368,7 +369,7 @@ static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write)
 	set_bit(wake_bit, &pipe->flags);
 
 	/* Tell the emulator we're going to wait for a wake event */
-	goldfish_cmd(pipe,
+	goldfish_pipe_cmd(pipe,
 		is_write ? PIPE_CMD_WAKE_ON_WRITE : PIPE_CMD_WAKE_ON_READ);
 
 	while (test_bit(wake_bit, &pipe->flags)) {
@@ -490,7 +491,7 @@ static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
 
 	poll_wait(filp, &pipe->wake_queue, wait);
 
-	status = goldfish_cmd(pipe, PIPE_CMD_POLL);
+	status = goldfish_pipe_cmd(pipe, PIPE_CMD_POLL);
 	if (status < 0)
 		return -ERESTARTSYS;
 
@@ -722,7 +723,7 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
 			MAX_BUFFERS_PER_COMMAND;
 	dev->buffers->open_command_params.command_buffer_ptr =
 			(u64)(unsigned long)__pa(pipe->command_buffer);
-	status = goldfish_cmd_locked(pipe, PIPE_CMD_OPEN);
+	status = goldfish_pipe_cmd_locked(pipe, PIPE_CMD_OPEN);
 	spin_unlock_irqrestore(&dev->lock, flags);
 	if (status < 0)
 		goto err_cmd;
@@ -748,7 +749,7 @@ static int goldfish_pipe_release(struct inode *inode, struct file *filp)
 	struct goldfish_pipe_dev *dev = pipe->dev;
 
 	/* The guest is closing the channel, so tell the emulator right now */
-	goldfish_cmd(pipe, PIPE_CMD_CLOSE);
+	goldfish_pipe_cmd(pipe, PIPE_CMD_CLOSE);
 
 	spin_lock_irqsave(&dev->lock, flags);
 	dev->pipes[pipe->id] = NULL;
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 17/20] platform: goldfish: pipe: Fix lines to not end an opening bracket
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (14 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 16/20] platform: goldfish: pipe: Rename goldfish_x to goldfish_pipe_x rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 18/20] platform: goldfish: pipe: Fix alignment to match parenthesis rkir
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Lines should not end with a '(' or '['

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 95256a5c593c..324129879b09 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -122,8 +122,8 @@ struct open_command_param {
 /* Device-level set of buffers shared with the host */
 struct goldfish_pipe_dev_buffers {
 	struct open_command_param open_command_params;
-	struct signalled_pipe_buffer signalled_pipe_buffers[
-		MAX_SIGNALLED_PIPES];
+	struct signalled_pipe_buffer
+		signalled_pipe_buffers[MAX_SIGNALLED_PIPES];
 };
 
 /* This data type models a given pipe instance */
@@ -373,8 +373,7 @@ static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write)
 		is_write ? PIPE_CMD_WAKE_ON_WRITE : PIPE_CMD_WAKE_ON_READ);
 
 	while (test_bit(wake_bit, &pipe->flags)) {
-		if (wait_event_interruptible(
-				pipe->wake_queue,
+		if (wait_event_interruptible(pipe->wake_queue,
 				!test_bit(wake_bit, &pipe->flags)))
 			return -ERESTARTSYS;
 
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 18/20] platform: goldfish: pipe: Fix alignment to match parenthesis
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (15 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 17/20] platform: goldfish: pipe: Fix lines to not end an opening bracket rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 19/20] platform: goldfish: pipe: Move logical ops to the end of the prev line rkir
  2018-08-27 18:23 ` [PATCH 20/20] platform: goldfish: pipe: Replace "x==NULL" to "!x" rkir
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Alignment should match open parenthesis.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 83 +++++++++++++----------
 1 file changed, 48 insertions(+), 35 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 324129879b09..02783bc59dd7 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -252,10 +252,12 @@ static int goldfish_pipe_error_convert(int status)
 	}
 }
 
-static int pin_user_pages(unsigned long first_page, unsigned long last_page,
-	unsigned int last_page_size, int is_write,
-	struct page *pages[MAX_BUFFERS_PER_COMMAND],
-	unsigned int *iter_last_page_size)
+static int pin_user_pages(unsigned long first_page,
+			  unsigned long last_page,
+			  unsigned int last_page_size,
+			  int is_write,
+			  struct page *pages[MAX_BUFFERS_PER_COMMAND],
+			  unsigned int *iter_last_page_size)
 {
 	int ret;
 	int requested_pages = ((last_page - first_page) >> PAGE_SHIFT) + 1;
@@ -267,8 +269,8 @@ static int pin_user_pages(unsigned long first_page, unsigned long last_page,
 		*iter_last_page_size = last_page_size;
 	}
 
-	ret = get_user_pages_fast(
-			first_page, requested_pages, !is_write, pages);
+	ret = get_user_pages_fast(first_page, requested_pages, !is_write,
+				  pages);
 	if (ret <= 0)
 		return -EFAULT;
 	if (ret < requested_pages)
@@ -278,7 +280,7 @@ static int pin_user_pages(unsigned long first_page, unsigned long last_page,
 }
 
 static void release_user_pages(struct page **pages, int pages_count,
-	int is_write, s32 consumed_size)
+			       int is_write, s32 consumed_size)
 {
 	int i;
 
@@ -290,12 +292,15 @@ static void release_user_pages(struct page **pages, int pages_count,
 }
 
 /* Populate the call parameters, merging adjacent pages together */
-static void populate_rw_params(
-	struct page **pages, int pages_count,
-	unsigned long address, unsigned long address_end,
-	unsigned long first_page, unsigned long last_page,
-	unsigned int iter_last_page_size, int is_write,
-	struct goldfish_pipe_command *command)
+static void populate_rw_params(struct page **pages,
+			       int pages_count,
+			       unsigned long address,
+			       unsigned long address_end,
+			       unsigned long first_page,
+			       unsigned long last_page,
+			       unsigned int iter_last_page_size,
+			       int is_write,
+			       struct goldfish_pipe_command *command)
 {
 	/*
 	 * Process the first page separately - it's the only page that
@@ -327,16 +332,20 @@ static void populate_rw_params(
 }
 
 static int transfer_max_buffers(struct goldfish_pipe *pipe,
-	unsigned long address, unsigned long address_end, int is_write,
-	unsigned long last_page, unsigned int last_page_size,
-	s32 *consumed_size, int *status)
+				unsigned long address,
+				unsigned long address_end,
+				int is_write,
+				unsigned long last_page,
+				unsigned int last_page_size,
+				s32 *consumed_size,
+				int *status)
 {
 	static struct page *pages[MAX_BUFFERS_PER_COMMAND];
 	unsigned long first_page = address & PAGE_MASK;
 	unsigned int iter_last_page_size;
 	int pages_count = pin_user_pages(first_page, last_page,
-			last_page_size, is_write,
-			pages, &iter_last_page_size);
+					 last_page_size, is_write,
+					 pages, &iter_last_page_size);
 
 	if (pages_count < 0)
 		return pages_count;
@@ -346,8 +355,8 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe,
 		return -ERESTARTSYS;
 
 	populate_rw_params(pages, pages_count, address, address_end,
-		first_page, last_page, iter_last_page_size, is_write,
-		pipe->command_buffer);
+			   first_page, last_page, iter_last_page_size, is_write,
+			   pipe->command_buffer);
 
 	/* Transfer the data */
 	*status = goldfish_pipe_cmd_locked(pipe,
@@ -374,7 +383,7 @@ static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write)
 
 	while (test_bit(wake_bit, &pipe->flags)) {
 		if (wait_event_interruptible(pipe->wake_queue,
-				!test_bit(wake_bit, &pipe->flags)))
+					     !test_bit(wake_bit, &pipe->flags)))
 			return -ERESTARTSYS;
 
 		if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
@@ -385,7 +394,9 @@ static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write)
 }
 
 static ssize_t goldfish_pipe_read_write(struct file *filp,
-	char __user *buffer, size_t bufflen, int is_write)
+					char __user *buffer,
+					size_t bufflen,
+					int is_write)
 {
 	struct goldfish_pipe *pipe = filp->private_data;
 	int count = 0, ret = -EINVAL;
@@ -400,7 +411,7 @@ static ssize_t goldfish_pipe_read_write(struct file *filp,
 		return 0;
 	/* Check the buffer range for access */
 	if (unlikely(!access_ok(is_write ? VERIFY_WRITE : VERIFY_READ,
-			buffer, bufflen)))
+				buffer, bufflen)))
 		return -EFAULT;
 
 	address = (unsigned long)buffer;
@@ -413,8 +424,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp,
 		int status;
 
 		ret = transfer_max_buffers(pipe, address, address_end, is_write,
-				last_page, last_page_size, &consumed_size,
-				&status);
+					   last_page, last_page_size,
+					   &consumed_size, &status);
 		if (ret < 0)
 			break;
 
@@ -467,19 +478,21 @@ static ssize_t goldfish_pipe_read_write(struct file *filp,
 }
 
 static ssize_t goldfish_pipe_read(struct file *filp, char __user *buffer,
-				size_t bufflen, loff_t *ppos)
+				  size_t bufflen, loff_t *ppos)
 {
 	return goldfish_pipe_read_write(filp, buffer, bufflen,
-			/* is_write */ 0);
+					/* is_write */ 0);
 }
 
 static ssize_t goldfish_pipe_write(struct file *filp,
-				const char __user *buffer, size_t bufflen,
-				loff_t *ppos)
+				   const char __user *buffer, size_t bufflen,
+				   loff_t *ppos)
 {
-	return goldfish_pipe_read_write(filp,
-			/* cast away the const */(char __user *)buffer, bufflen,
-			/* is_write */ 1);
+	/* cast away the const */
+	char __user *no_const_buffer = (char __user *)buffer;
+
+	return goldfish_pipe_read_write(filp, no_const_buffer, bufflen,
+					/* is_write */ 1);
 }
 
 static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
@@ -507,7 +520,7 @@ static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
 }
 
 static void signalled_pipes_add_locked(struct goldfish_pipe_dev *dev,
-	u32 id, u32 flags)
+				       u32 id, u32 flags)
 {
 	struct goldfish_pipe *pipe;
 
@@ -529,7 +542,7 @@ static void signalled_pipes_add_locked(struct goldfish_pipe_dev *dev,
 }
 
 static void signalled_pipes_remove_locked(struct goldfish_pipe_dev *dev,
-	struct goldfish_pipe *pipe)
+					  struct goldfish_pipe *pipe)
 {
 	if (pipe->prev_signalled)
 		pipe->prev_signalled->next_signalled = pipe->next_signalled;
@@ -805,7 +818,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
 	dev->first_signalled_pipe = NULL;
 	dev->pipes_capacity = INITIAL_PIPES_CAPACITY;
 	dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes),
-					GFP_KERNEL);
+			     GFP_KERNEL);
 	if (!dev->pipes)
 		return -ENOMEM;
 
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 19/20] platform: goldfish: pipe: Move logical ops to the end of the prev line
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (16 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 18/20] platform: goldfish: pipe: Fix alignment to match parenthesis rkir
@ 2018-08-27 18:23 ` rkir
  2018-08-27 18:23 ` [PATCH 20/20] platform: goldfish: pipe: Replace "x==NULL" to "!x" rkir
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Logical continuations should be on the previous line

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 02783bc59dd7..c892a0447a81 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -532,8 +532,8 @@ static void signalled_pipes_add_locked(struct goldfish_pipe_dev *dev,
 		return;
 	pipe->signalled_flags |= flags;
 
-	if (pipe->prev_signalled || pipe->next_signalled
-		|| dev->first_signalled_pipe == pipe)
+	if (pipe->prev_signalled || pipe->next_signalled ||
+		dev->first_signalled_pipe == pipe)
 		return;	/* already in the list */
 	pipe->next_signalled = dev->first_signalled_pipe;
 	if (dev->first_signalled_pipe)
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 20/20] platform: goldfish: pipe: Replace "x==NULL" to "!x"
  2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
                   ` (17 preceding siblings ...)
  2018-08-27 18:23 ` [PATCH 19/20] platform: goldfish: pipe: Move logical ops to the end of the prev line rkir
@ 2018-08-27 18:23 ` rkir
  18 siblings, 0 replies; 24+ messages in thread
From: rkir @ 2018-08-27 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, tkjos, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

checkpatch: Comparison to NULL could be written "!x"

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index c892a0447a81..b4a484bbcdaa 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -699,7 +699,7 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
 
 	/* Allocate new pipe kernel object */
 	struct goldfish_pipe *pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
-	if (pipe == NULL)
+	if (!pipe)
 		return -ENOMEM;
 
 	pipe->dev = dev;
@@ -865,23 +865,23 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
 	struct goldfish_pipe_dev *dev = &goldfish_pipe_dev;
 
 	/* not thread safe, but this should not happen */
-	WARN_ON(dev->base != NULL);
+	WARN_ON(dev->base);
 
 	spin_lock_init(&dev->lock);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL || resource_size(r) < PAGE_SIZE) {
+	if (!r || resource_size(r) < PAGE_SIZE) {
 		dev_err(&pdev->dev, "can't allocate i/o page\n");
 		return -EINVAL;
 	}
 	dev->base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
-	if (dev->base == NULL) {
+	if (!dev->base) {
 		dev_err(&pdev->dev, "ioremap failed\n");
 		return -EINVAL;
 	}
 
 	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (r == NULL) {
+	if (!r) {
 		err = -EINVAL;
 		goto error;
 	}
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header
  2018-08-27 18:22 ` [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header rkir
@ 2018-09-14 13:29   ` Greg KH
  0 siblings, 0 replies; 24+ messages in thread
From: Greg KH @ 2018-09-14 13:29 UTC (permalink / raw)
  To: rkir; +Cc: linux-kernel, tkjos

On Mon, Aug 27, 2018 at 11:22:59AM -0700, rkir@google.com wrote:
> --- /dev/null
> +++ b/drivers/platform/goldfish/goldfish_pipe_qemu.h
> @@ -0,0 +1,112 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2018 Google, Inc.
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.

When you have a SPDX line, you do not also need the boilerplate license
text in this file as well.  So you can remove that please.  A later
patch is fine.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
  2018-08-27 18:23 ` [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable rkir
@ 2018-09-14 13:30   ` Greg KH
  2018-09-14 16:42     ` Roman Kiryanov
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2018-09-14 13:30 UTC (permalink / raw)
  To: rkir; +Cc: linux-kernel, tkjos

On Mon, Aug 27, 2018 at 11:23:02AM -0700, rkir@google.com wrote:
> From: Roman Kiryanov <rkir@google.com>
> 
> There is no reason to have an array of 1.
> 
> Signed-off-by: Roman Kiryanov <rkir@google.com>
> ---
>  drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++++------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
> index 24e40deb98cc..e9e3e791c0d4 100644
> --- a/drivers/platform/goldfish/goldfish_pipe.c
> +++ b/drivers/platform/goldfish/goldfish_pipe.c
> @@ -205,7 +205,7 @@ struct goldfish_pipe_dev {
>  	unsigned char __iomem *base;
>  };
>  
> -static struct goldfish_pipe_dev pipe_dev[1] = {};
> +struct goldfish_pipe_dev goldfish_pipe_dev;


Why do you need a static structure at all?  Shouldn't this be tied to
the dynamic device the driver core gives you?  That way you can handle
any number of these devices without any code changes needed.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
  2018-09-14 13:30   ` Greg KH
@ 2018-09-14 16:42     ` Roman Kiryanov
  2018-09-14 19:20       ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Roman Kiryanov @ 2018-09-14 16:42 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Todd Kjos

Yes, in the later change I am going to retire this variable
completely. Could you please accept this patch as it?
On Fri, Sep 14, 2018 at 6:30 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Aug 27, 2018 at 11:23:02AM -0700, rkir@google.com wrote:
> > From: Roman Kiryanov <rkir@google.com>
> >
> > There is no reason to have an array of 1.
> >
> > Signed-off-by: Roman Kiryanov <rkir@google.com>
> > ---
> >  drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++++------------
> >  1 file changed, 13 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
> > index 24e40deb98cc..e9e3e791c0d4 100644
> > --- a/drivers/platform/goldfish/goldfish_pipe.c
> > +++ b/drivers/platform/goldfish/goldfish_pipe.c
> > @@ -205,7 +205,7 @@ struct goldfish_pipe_dev {
> >       unsigned char __iomem *base;
> >  };
> >
> > -static struct goldfish_pipe_dev pipe_dev[1] = {};
> > +struct goldfish_pipe_dev goldfish_pipe_dev;
>
>
> Why do you need a static structure at all?  Shouldn't this be tied to
> the dynamic device the driver core gives you?  That way you can handle
> any number of these devices without any code changes needed.
>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
  2018-09-14 16:42     ` Roman Kiryanov
@ 2018-09-14 19:20       ` Greg KH
  0 siblings, 0 replies; 24+ messages in thread
From: Greg KH @ 2018-09-14 19:20 UTC (permalink / raw)
  To: Roman Kiryanov; +Cc: linux-kernel, Todd Kjos

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Fri, Sep 14, 2018 at 09:42:32AM -0700, Roman Kiryanov wrote:
> Yes, in the later change I am going to retire this variable
> completely. Could you please accept this patch as it?

As you saw the email, I already did.

greg k-h

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2018-09-14 19:21 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
2018-08-27 18:22 ` [PATCH 02/20] platform: goldfish: pipe: Update license rkir
2018-08-27 18:22 ` [PATCH 03/20] platform: goldfish: pipe: Move an opening brace to the next line rkir
2018-08-27 18:22 ` [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header rkir
2018-09-14 13:29   ` Greg KH
2018-08-27 18:23 ` [PATCH 05/20] platform: goldfish: pipe: Update the comment for GFP_ATOMIC rkir
2018-08-27 18:23 ` [PATCH 06/20] platform: goldfish: pipe: Fail compilation if structs are too large rkir
2018-08-27 18:23 ` [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable rkir
2018-09-14 13:30   ` Greg KH
2018-09-14 16:42     ` Roman Kiryanov
2018-09-14 19:20       ` Greg KH
2018-08-27 18:23 ` [PATCH 08/20] platform: goldfish: pipe: Replace pr_ with dev_ for logging rkir
2018-08-27 18:23 ` [PATCH 09/20] platform: goldfish: pipe: Add blank lines to separate struct members rkir
2018-08-27 18:23 ` [PATCH 10/20] platform: goldfish: pipe: Remove a redundant variable rkir
2018-08-27 18:23 ` [PATCH 11/20] platform: goldfish: pipe: Replace two code blocks with a function call rkir
2018-08-27 18:23 ` [PATCH 12/20] platform: goldfish: pipe: Remove reduntant casting rkir
2018-08-27 18:23 ` [PATCH 13/20] platform: goldfish: pipe: Remove a blank line before '}' rkir
2018-08-27 18:23 ` [PATCH 14/20] platform: goldfish: pipe: Rename 'wakeBit' to 'wake_bit' rkir
2018-08-27 18:23 ` [PATCH 15/20] platform: goldfish: pipe: Remove reduntant casting to (void) rkir
2018-08-27 18:23 ` [PATCH 16/20] platform: goldfish: pipe: Rename goldfish_x to goldfish_pipe_x rkir
2018-08-27 18:23 ` [PATCH 17/20] platform: goldfish: pipe: Fix lines to not end an opening bracket rkir
2018-08-27 18:23 ` [PATCH 18/20] platform: goldfish: pipe: Fix alignment to match parenthesis rkir
2018-08-27 18:23 ` [PATCH 19/20] platform: goldfish: pipe: Move logical ops to the end of the prev line rkir
2018-08-27 18:23 ` [PATCH 20/20] platform: goldfish: pipe: Replace "x==NULL" to "!x" rkir

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).