platform: goldfish: pipe: Fix comments to fit 80 columns
PATCH 1/20 platform: goldfish: pipe: Fix comments to fit 80 columns
From: Roman Kiryanov <[email protected]>
Some comment lines are longer than 80 symbols.
--- drivers/platform/goldfish/goldfish_pipe.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +7 -4
@@ -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} */
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 2/20 platform: goldfish: pipe: Update license
From: Roman Kiryanov <[email protected]>
goldfish_pipe is distributed under GPL v2.
--- drivers/platform/goldfish/goldfish_pipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/goldfish/goldfish_pipe.c +2 -1
@@ -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 <[email protected]>" ); -MODULE_LICENSE ("GPL" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 3/20 platform: goldfish: pipe: Move an opening brace to the next line
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Function's opening brace has to be at the beginning of the next line.
--- drivers/platform/goldfish/goldfish_pipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/goldfish/goldfish_pipe.c +2 -1
@@ -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)
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 4/20 platform: goldfish: pipe: Separate the host interface to a separate header
In reply to [email protected]From: Roman Kiryanov <[email protected]>
These are several enums that must kept in sync with the host side. This change explicitly separates them into a dedicated header file.
--- 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
drivers/platform/goldfish/goldfish_pipe.c +1 -68
@@ -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 ,
drivers/platform/goldfish/goldfish_pipe_qemu.h new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
Re: [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header
Quoted 5 lines · On Mon, Aug 27, 2018 at 11:22:59AM -0700, [email protected] wrote:
drivers/platform/goldfish/goldfish_pipe_qemu.h new file +2
-0@@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/*
drivers/platform/goldfish/goldfish_pipe_qemu.h line 12
Quoted 10 lines
drivers/platform/goldfish/goldfish_pipe_qemu.h new file +10
-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
PATCH 5/20 platform: goldfish: pipe: Update the comment for GFP_ATOMIC
In reply to [email protected]From: Roman Kiryanov <[email protected]>
Provide an explanation why GFP_ATOMIC is needed to prevent changing it to other values.
--- drivers/platform/goldfish/goldfish_pipe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/platform/goldfish/goldfish_pipe.c +4 -1
@@ -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 );
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 6/20 platform: goldfish: pipe: Fail compilation if structs are too large
In reply to [email protected]From: Roman Kiryanov <[email protected]>
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.
--- drivers/platform/goldfish/goldfish_pipe.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +3 -6
@@ -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 );
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 7/20 platform: goldfish: pipe: Replace an array of 1 with a variable
In reply to [email protected]From: Roman Kiryanov <[email protected]>
There is no reason to have an array of 1.
--- drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +13 -15
@@ -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 ;
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
Re: [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
Quoted 14 lines · On Mon, Aug 27, 2018 at 11:23:02AM -0700, [email protected] wrote:
From: Roman Kiryanov <[email protected]>
There is no reason to have an array of 1.
Signed-off-by Roman Kiryanov <[email protected]>--- drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-)drivers/platform/goldfish/goldfish_pipe.c +0
-0
drivers/platform/goldfish/goldfish_pipe.c struct goldfish_pipe_dev { · line 208
Quoted 5 lines
drivers/platform/goldfish/goldfish_pipe.c +1
-1@@ -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
Re: [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
Yes, in the later change I am going to retire this variable completely. Could you please accept this patch as it?
Quoted 30 lines · Greg KH
Quoted 14 lines · On Mon, Aug 27, 2018 at 11:23:02AM -0700, [email protected] wrote:
From: Roman Kiryanov <[email protected]>
There is no reason to have an array of 1.
Signed-off-by Roman Kiryanov <[email protected]>--- drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-)drivers/platform/goldfish/goldfish_pipe.c +0
-0drivers/platform/goldfish/goldfish_pipe.c struct goldfish_pipe_dev { · line 208
Quoted 5 lines
drivers/platform/goldfish/goldfish_pipe.c +1
-1@@ -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
Re: [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable
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
Quoted 2 lines · Roman Kiryanov
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
PATCH 8/20 platform: goldfish: pipe: Replace pr_ with dev_ for logging
In reply to [email protected]From: Roman Kiryanov <[email protected]>
dev_ is preferred if struct device is available.
--- drivers/platform/goldfish/goldfish_pipe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/goldfish/goldfish_pipe.c +6 -1
@@ -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),
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 9/20 platform: goldfish: pipe: Add blank lines to separate struct members
In reply to [email protected]From: Roman Kiryanov <[email protected]>
To improve readability and to be consistent with other struct members.
--- drivers/platform/goldfish/goldfish_pipe.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/goldfish/goldfish_pipe.c +3 -0
@@ -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; };
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 10/20 platform: goldfish: pipe: Remove a redundant variable
In reply to [email protected]From: Roman Kiryanov <[email protected]>
The variable was not very useful.
--- drivers/platform/goldfish/goldfish_pipe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +3 -4
@@ -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 */ {
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 11/20 platform: goldfish: pipe: Replace two code blocks with a function call
In reply to [email protected]From: Roman Kiryanov <[email protected]>
Two function calls look cleaner because the function introduces takes case of all bit shifting and casting.
--- drivers/platform/goldfish/goldfish_pipe.c | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +19 -16
@@ -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 ; }
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 12/20 platform: goldfish: pipe: Remove reduntant casting
In reply to [email protected]From: Roman Kiryanov <[email protected]>
Casting to u32 is not required here.
--- drivers/platform/goldfish/goldfish_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/goldfish/goldfish_pipe.c +1 -1
@@ -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,
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 13/20 platform: goldfish: pipe: Remove a blank line before '}'
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Blank lines aren't necessary before a close brace '}'
--- drivers/platform/goldfish/goldfish_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/goldfish/goldfish_pipe.c +1 -1
@@ -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,
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 14/20 platform: goldfish: pipe: Rename 'wakeBit' to 'wake_bit'
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Avoid CamelCase
--- drivers/platform/goldfish/goldfish_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +4 -4
@@ -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))
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 15/20 platform: goldfish: pipe: Remove reduntant casting to (void)
In reply to [email protected]From: Roman Kiryanov <[email protected]>
Casting to (void) is no-op.
--- drivers/platform/goldfish/goldfish_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +2 -2
@@ -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 ;
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 16/20 platform: goldfish: pipe: Rename goldfish_x to goldfish_pipe_x
In reply to [email protected]From: Roman Kiryanov <[email protected]>
Add "pipe" to the pipe related function names.
--- drivers/platform/goldfish/goldfish_pipe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +9 -8
@@ -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 ;
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 17/20 platform: goldfish: pipe: Fix lines to not end an opening bracket
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Lines should not end with a '(' or '['
--- drivers/platform/goldfish/goldfish_pipe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +3 -4
@@ -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 ;
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 18/20 platform: goldfish: pipe: Fix alignment to match parenthesis
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Alignment should match open parenthesis.
--- drivers/platform/goldfish/goldfish_pipe.c | 83 +++++++++++++---------- 1 file changed, 48 insertions(+), 35 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +48 -35
@@ -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 ;
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 19/20 platform: goldfish: pipe: Move logical ops to the end of the prev line
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Logical continuations should be on the previous line
--- drivers/platform/goldfish/goldfish_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +2 -2
@@ -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)
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog
PATCH 20/20 platform: goldfish: pipe: Replace "x==NULL" to "!x"
In reply to [email protected]From: Roman Kiryanov <[email protected]>
checkpatch: Comparison to NULL could be written "!x"
--- drivers/platform/goldfish/goldfish_pipe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/goldfish/goldfish_pipe.c +5 -5
@@ -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; }
Signature · 1 line
2.19.0.rc0.228.g281dcd1b4d0-goog