Xilinx: hwicap: cleanup
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 1202437061-12691-1-git-send-email-stephen.neuendorffer@xilinx.com
PATCH 1/1 Xilinx: hwicap: cleanup
Fix some missing __user tags and incorrect section tags. Convert semaphores to mutexes.
Make probed_devices re-entrancy and error condition safe. Fix some backwards memcpys.
Some other minor cleanups.
Use kerneldoc format.
---
Grant, Since it appears that the driver will stay in as-is, here are the updates against mainline, based on Jiri's comments.
--- drivers/char/xilinx_hwicap/buffer_icap.c | 80 ++++++++++---------- drivers/char/xilinx_hwicap/fifo_icap.c | 60 +++++++------- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 113 ++++++++++++++++------------ drivers/char/xilinx_hwicap/xilinx_hwicap.h | 24 +++--- 4 files changed, 148 insertions(+), 129 deletions(-)
drivers/char/xilinx_hwicap/buffer_icap.c +40 -40
@@ -73,8 +73,8 @@#define XHI_BUFFER_START 0/** -* buffer_icap_get_status: Get the contents of the status register. -* @parameter base_address: is the base address of the device +* buffer_icap_get_status - Get the contents of the status register. +* @base_address: is the base address of the device * * The status register contains the ICAP status and the done bit. *
@@ -94,9 +94,9 @@ static inline u32 buffer_icap_get_status(void __iomem *base_address) }/** -* buffer_icap_get_bram: Reads data from the storage buffer bram. -* @parameter base_address: contains the base address of the component. -* @parameter offset: The word offset from which the data should be read. +* buffer_icap_get_bram - Reads data from the storage buffer bram. +* @base_address: contains the base address of the component. +* @offset: The word offset from which the data should be read. * * A bram is used as a configuration memory cache. One frame of data can * be stored in this "storage buffer".
@@ -108,8 +108,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address, }/** -* buffer_icap_busy: Return true if the icap device is busy -* @parameter base_address: is the base address of the device +* buffer_icap_busy - Return true if the icap device is busy +* @base_address: is the base address of the device * * The queries the low order bit of the status register, which * indicates whether the current configuration or readback operation
@@ -121,8 +121,8 @@ static inline bool buffer_icap_busy(void __iomem *base_address) }/** -* buffer_icap_busy: Return true if the icap device is not busy -* @parameter base_address: is the base address of the device +* buffer_icap_busy - Return true if the icap device is not busy +* @base_address: is the base address of the device * * The queries the low order bit of the status register, which * indicates whether the current configuration or readback operation
@@ -134,9 +134,9 @@ static inline bool buffer_icap_done(void __iomem *base_address) }/** -* buffer_icap_set_size: Set the size register. -* @parameter base_address: is the base address of the device -* @parameter data: The size in bytes. +* buffer_icap_set_size - Set the size register. +* @base_address: is the base address of the device +* @data: The size in bytes. * * The size register holds the number of 8 bit bytes to transfer between * bram and the icap (or icap to bram).
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void __iomem *base_address, }/** -* buffer_icap_mSetoffsetReg: Set the bram offset register. -* @parameter base_address: contains the base address of the device. -* @parameter data: is the value to be written to the data register. +* buffer_icap_mSetoffsetReg - Set the bram offset register. +* @base_address: contains the base address of the device. +* @data: is the value to be written to the data register. * * The bram offset register holds the starting bram address to transfer * data from during configuration or write data to during readback.
@@ -162,9 +162,9 @@ static inline void buffer_icap_set_offset(void __iomem *base_address, }/** -* buffer_icap_set_rnc: Set the RNC (Readback not Configure) register. -* @parameter base_address: contains the base address of the device. -* @parameter data: is the value to be written to the data register. +* buffer_icap_set_rnc - Set the RNC (Readback not Configure) register. +* @base_address: contains the base address of the device. +* @data: is the value to be written to the data register. * * The RNC register determines the direction of the data transfer. It * controls whether a configuration or readback take place. Writing to
@@ -178,10 +178,10 @@ static inline void buffer_icap_set_rnc(void __iomem *base_address, }/** -* buffer_icap_set_bram: Write data to the storage buffer bram. -* @parameter base_address: contains the base address of the component. -* @parameter offset: The word offset at which the data should be written. -* @parameter data: The value to be written to the bram offset. +* buffer_icap_set_bram - Write data to the storage buffer bram. +* @base_address: contains the base address of the component. +* @offset: The word offset at which the data should be written. +* @data: The value to be written to the bram offset. * * A bram is used as a configuration memory cache. One frame of data can * be stored in this "storage buffer".
@@ -193,10 +193,10 @@ static inline void buffer_icap_set_bram(void __iomem *base_address, }/** -* buffer_icap_device_read: Transfer bytes from ICAP to the storage buffer. -* @parameter drvdata: a pointer to the drvdata. -* @parameter offset: The storage buffer start address. -* @parameter count: The number of words (32 bit) to read from the +* buffer_icap_device_read - Transfer bytes from ICAP to the storage buffer. +* @drvdata: a pointer to the drvdata. +* @offset: The storage buffer start address. +* @count: The number of words (32 bit) to read from the * device (ICAP). **/ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
@@ -227,10 +227,10 @@ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata, };/** -* buffer_icap_device_write: Transfer bytes from ICAP to the storage buffer. -* @parameter drvdata: a pointer to the drvdata. -* @parameter offset: The storage buffer start address. -* @parameter count: The number of words (32 bit) to read from the +* buffer_icap_device_write - Transfer bytes from ICAP to the storage buffer. +* @drvdata: a pointer to the drvdata. +* @offset: The storage buffer start address. +* @count: The number of words (32 bit) to read from the * device (ICAP). **/ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
@@ -261,8 +261,8 @@ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata, };/** -* buffer_icap_reset: Reset the logic of the icap device. -* @parameter drvdata: a pointer to the drvdata. +* buffer_icap_reset - Reset the logic of the icap device. +* @drvdata: a pointer to the drvdata. * * Writing to the status register resets the ICAP logic in an internal * version of the core. For the version of the core published in EDK,
@@ -274,10 +274,10 @@ void buffer_icap_reset(struct hwicap_drvdata *drvdata) }/** -* buffer_icap_set_configuration: Load a partial bitstream from system memory. -* @parameter drvdata: a pointer to the drvdata. -* @parameter data: Kernel address of the partial bitstream. -* @parameter size: the size of the partial bitstream in 32 bit words. +* buffer_icap_set_configuration - Load a partial bitstream from system memory. +* @drvdata: a pointer to the drvdata. +* @data: Kernel address of the partial bitstream. +* @size: the size of the partial bitstream in 32 bit words. **/ int buffer_icap_set_configuration (struct hwicap_drvdata *drvdata,u32 *data,u32 size)
@@ -333,10 +333,10 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, };/** -* buffer_icap_get_configuration: Read configuration data from the device. -* @parameter drvdata: a pointer to the drvdata. -* @parameter data: Address of the data representing the partial bitstream -* @parameter size: the size of the partial bitstream in 32 bit words. +* buffer_icap_get_configuration - Read configuration data from the device. +* @drvdata: a pointer to the drvdata. +* @data: Address of the data representing the partial bitstream +* @size: the size of the partial bitstream in 32 bit words. **/ int buffer_icap_get_configuration (struct hwicap_drvdata *drvdata,u32 *data,u32 size)
drivers/char/xilinx_hwicap/fifo_icap.c +30 -30
133 lines not on this page · raw message
drivers/char/xilinx_hwicap/xilinx_hwicap.c +66 -47
339 lines not on this page · raw message
drivers/char/xilinx_hwicap/xilinx_hwicap.h +12 -12
@@ -48,9 +48,9 @@ struct hwicap_drvdata {u8 write_buffer[4 ];u32 read_buffer_in_use;/* Always in [0,3] */ u8 read_buffer[4 ]; -u32 mem_start;/* phys. address of the control registers */ -u32 mem_end;/* phys. address of the control registers */ -u32 mem_size; +resource_size_t mem_start;/* phys. address of the control registers */ +resource_size_t mem_end;/* phys. address of the control registers */ +resource_size_t mem_size;void __iomem *base_address;/* virt. address of the control registers */ struct device *dev;
@@ -61,7 +61,7 @@ struct hwicap_drvdata {const struct config_registers *config_regs;void *private_data;bool is_open; -struct semaphore sem; +struct mutex sem; };struct hwicap_driver_config {
@@ -164,29 +164,29 @@ struct config_registers {#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL/** -* hwicap_type_1_read: Generates a Type 1 read packet header. -* @parameter: Register is the address of the register to be read back. +* hwicap_type_1_read - Generates a Type 1 read packet header. +* @register: is the address of the register to be read back. * * Generates a Type 1 read packet header, which is used to indirectly * read registers in the configuration logic. This packet must then * be sent through the icap device, and a return packet received with * the information. **/ -static inline u32 hwicap_type_1_read (u32 Register) +static inline u32 hwicap_type_1_read (u32 register) {return (XHI_TYPE_1 <<XHI_TYPE_SHIFT ) | - (Register <<XHI_REGISTER_SHIFT ) | + (register <<XHI_REGISTER_SHIFT ) | (XHI_OP_READ <<XHI_OP_SHIFT ); }/** -* hwicap_type_1_write: Generates a Type 1 write packet header -* @parameter: Register is the address of the register to be read back. +* hwicap_type_1_write - Generates a Type 1 write packet header +* @register: is the address of the register to be read back. **/ -static inline u32 hwicap_type_1_write (u32 Register) +static inline u32 hwicap_type_1_write (u32 register) {return (XHI_TYPE_1 <<XHI_TYPE_SHIFT ) | - (Register <<XHI_REGISTER_SHIFT ) | + (register <<XHI_REGISTER_SHIFT ) | (XHI_OP_WRITE <<XHI_OP_SHIFT ); }
Signature · 1 line
1.5.3.4-dirty
Quoted 8 lines · Stephen Neuendorffer
Fix some missing
__usertags and incorrect section tags.
Convert semaphores to mutexes.
Makeprobed_devicesre-entrancy and error condition safe. Fix some backwards memcpys.
Some other minor cleanups.
Use kerneldoc format.Signed-off-by Stephen Neuendorffer <[email protected]>
Thanks Steven, some more comments below.
Quoted 19 lines
---
Grant, Since it appears that the driver will stay in as-is, here are the updates against mainline, based on Jiri's comments.
---drivers/char/xilinx_hwicap/buffer_icap.c | 80 ++++++++++---------- drivers/char/xilinx_hwicap/fifo_icap.c | 60 +++++++------- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 113 ++++++++++++++++------------ drivers/char/xilinx_hwicap/xilinx_hwicap.h | 24 +++--- 4 files changed, 148 insertions(+), 129 deletions(-)diff --git
a/drivers/char/xilinx_hwicap/buffer_icap.cb/drivers/char/xilinx_hwicap/buffer_icap.cindex dfea2bd..2c5d17d 100644
---a/drivers/char/xilinx_hwicap/buffer_icap.c
+++b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void__iomem*base_address,
}
Quoted 5 lines
/**
- *buffer_icap_mSetoffsetReg: Set the bram offset register.
- * @parameterbase_address: contains the base address of the device.
- * @parameter data: is the value to be written to the data register.
+ *buffer_icap_mSetoffsetReg- Set the bram offset register.
This is the only function that is still in camel case; it should probably be changed also... In fact, this functions doesn't seem to be used at all. Can it just be removed? Are there any other unused functions in this driver?
Quoted 10 lines
diff --git
a/drivers/char/xilinx_hwicap/xilinx_hwicap.cb/drivers/char/xilinx_hwicap/xilinx_hwicap.cindex 24f6aef..eddaa26 100644
---a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -344,7 +345,7 @@ inthwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
}static
ssize_t
-hwicap_read(struct file *file, char *buf,size_tcount,loff_t*ppos) +hwicap_read(struct file *file,__userchar *buf,size_tcount,loff_t*ppos)
This looks like it should be 'char __user *buf' instead of '__user char *buf'.
Quoted 7 lines
{ struct hwicap_drvdata *drvdata = file->private_data; ssize_t bytes_to_read = 0;static
ssize_t
-hwicap_write(struct file *file, const char *buf, +hwicap_write(struct file *file, const__userchar *buf,
size_tcount,loff_t*ppos)
Ditto on placement of __user
Quoted 7 lines
@@ -549,8 +556,7 @@ static int
hwicap_release(struct inode *inode, struct file *file)int i; int status = 0;- if (
down_interruptible(&drvdata->sem))
- return-ERESTARTSYS;
+mutex_lock(&drvdata->sem);
Why not mutex_lock_interruptible()? (goes for all cases of mutex_lock())
Cheers,
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Stephen, when you address these comments, please double check the lkml address. It was misspelled when you sent this patch.
Cheers,
g.
Quoted 9 lines · Grant Likely
Quoted 7 lines · Stephen Neuendorffer
Fix some missing
__usertags and incorrect section tags.
Convert semaphores to mutexes.
Makeprobed_devicesre-entrancy and error condition safe. Fix some backwards memcpys.
Some other minor cleanups.
Use kerneldoc format.
Quoted 3 lines
Quoted 1 line
Signed-off-by Stephen Neuendorffer <[email protected]>Thanks Steven, some more comments below.
^^^^^^
Oops, sorry about the spelling.
g.
Quoted 78 lines
Quoted 19 lines
---
Grant, Since it appears that the driver will stay in as-is, here are the updates against mainline, based on Jiri's comments.
---drivers/char/xilinx_hwicap/buffer_icap.c | 80 ++++++++++---------- drivers/char/xilinx_hwicap/fifo_icap.c | 60 +++++++------- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 113 ++++++++++++++++------------ drivers/char/xilinx_hwicap/xilinx_hwicap.h | 24 +++--- 4 files changed, 148 insertions(+), 129 deletions(-)diff --git
a/drivers/char/xilinx_hwicap/buffer_icap.cb/drivers/char/xilinx_hwicap/buffer_icap.cindex dfea2bd..2c5d17d 100644
---a/drivers/char/xilinx_hwicap/buffer_icap.c
+++b/drivers/char/xilinx_hwicap/buffer_icap.cQuoted 8 lines
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void
__iomem*base_address,
}/**
- *buffer_icap_mSetoffsetReg: Set the bram offset register.
- * @parameterbase_address: contains the base address of the device.
- * @parameter data: is the value to be written to the data register.
+ *buffer_icap_mSetoffsetReg- Set the bram offset register.This is the only function that is still in camel case; it should probably be changed also... In fact, this functions doesn't seem to be used at all. Can it just be removed? Are there any other unused functions in this driver?
Quoted 11 lines
diff --git
a/drivers/char/xilinx_hwicap/xilinx_hwicap.cb/drivers/char/xilinx_hwicap/xilinx_hwicap.cindex 24f6aef..eddaa26 100644
---a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++b/drivers/char/xilinx_hwicap/xilinx_hwicap.c@@ -344,7 +345,7 @@ int
hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
}static
ssize_t
-hwicap_read(struct file *file, char *buf,size_tcount,loff_t*ppos) +hwicap_read(struct file *file,__userchar *buf,size_tcount,loff_t*ppos)This looks like it should be 'char
__user*buf' instead of '__userchar *buf'.Quoted 8 lines
{ struct hwicap_drvdata *drvdata = file->private_data; ssize_t bytes_to_read = 0;static
ssize_t
-hwicap_write(struct file *file, const char *buf, +hwicap_write(struct file *file, const__userchar *buf,
size_tcount,loff_t*ppos)Ditto on placement of
__userQuoted 7 lines
@@ -549,8 +556,7 @@ static int
hwicap_release(struct inode *inode, struct file *file)int i; int status = 0;- if (
down_interruptible(&drvdata->sem))
- return-ERESTARTSYS;
+mutex_lock(&drvdata->sem);Why not
mutex_lock_interruptible()? (goes for all cases ofmutex_lock())Cheers,
g.--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 4 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Grant Likely
Quoted 3 lines
Sent: Saturday, February 23, 2008 10:17 PM
To: Stephen Neuendorffer
Cc: [email protected]; git-dev; [email protected];
Quoted 12 lines
Subject: Re: [PATCH] Xilinx: hwicap: cleanup
=20Quoted 8 lines · Stephen Neuendorffer
Fix some missing
__usertags and incorrect section tags.
Convert semaphores to mutexes.
Makeprobed_devicesre-entrancy and error condition safe. Fix some backwards memcpys.
Some other minor cleanups.
Use kerneldoc format.Signed-off-by Stephen Neuendorffer
Quoted 7 lines
=20
Thanks Steven, some more comments below.
=20Quoted 4 lines
---
Grant, Since it appears that the driver will stay in as-is, here
are
Quoted 3 lines
Quoted 3 lines
the updates against mainline, based on Jiri's comments.
---drivers/char/xilinx_hwicap/buffer_icap.c | 80
++++++++++----------
Quoted 2 lines
Quoted 2 lines
drivers/char/xilinx_hwicap/fifo_icap.c | 60 +++++++------- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 113
++++++++++++++++------------
Quoted 4 lines
Quoted 4 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.h | 24 +++--- 4 files changed, 148 insertions(+), 129 deletions(-)diff --git
a/drivers/char/xilinx_hwicap/buffer_icap.c
b/drivers/char/xilinx_hwicap/buffer_icap.c
Quoted 4 lines
Quoted 4 lines
index dfea2bd..2c5d17d 100644
---a/drivers/char/xilinx_hwicap/buffer_icap.c
+++b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void
__iomem *base_address,
Quoted 5 lines
Quoted 5 lines
}/**
- *buffer_icap_mSetoffsetReg: Set the bram offset register.
- * @parameterbase_address: contains the base address of the
device.
Quoted 1 line
Quoted 1 line
- * @parameter data: is the value to be written to the data
register.
Quoted 6 lines
Quoted 1 line
+ *
buffer_icap_mSetoffsetReg- Set the bram offset register.=20
This is the only function that is still in camel case; it should probably be changed also... In fact, this functions doesn't seem to be used at all. Can it just be removed? Are there any other unused functions in this driver?
Actually, it's just the comment that still had the old name.. Fixed it.
-Wall reports one unused static:
drivers/char/xilinx_hwicap/xilinx_hwicap.c:240: warning:
'hwicap_command_capture' defined but not used
I'd intended to leave this in, but I'm thinking it can be done by userspace code using this driver, so I took it out too.
In verifying this, I discovered that I had inserted a variable names 'register', which doesn't work... Fixed that too.
Quoted 6 lines
Quoted 1 line
diff --git
a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
b/drivers/char/xilinx_hwicap/xilinx_hwicap.cQuoted 4 lines
index 24f6aef..eddaa26 100644
---a/drivers/char/xilinx_hwicap/xilinx_hwicap.c+++b/drivers/char/xilinx_hwicap/xilinx_hwicap.c@@ -344,7 +345,7 @@ int hwicap_initialize_hwicap(struct
hwicap_drvdata *drvdata)
Quoted 4 lines
Quoted 4 lines
}static
ssize_t
-hwicap_read(struct file *file, char *buf,size_tcount,loff_t
*ppos)
Quoted 1 line
Quoted 1 line
+hwicap_read(struct file *file,
__userchar *buf,size_tcount,
loff_t *ppos)
Quoted 2 lines
=20
This looks like it should be 'char__user*buf' instead of '__user
char *buf'.
Fixed.
=20
Quoted 9 lines
Quoted 7 lines
{ struct hwicap_drvdata *drvdata =3D file->private_data; ssize_t bytes_to_read =3D 0;static
ssize_t
-hwicap_write(struct file *file, const char *buf, +hwicap_write(struct file *file, const__userchar *buf,
size_tcount,loff_t*ppos)=20
Ditto on placement of__user
Fixed.
Quoted 2 lines
=20
Quoted 1 line
@@ -549,8 +556,7 @@ static int hwicap_release(struct inode *inode,
struct file *file)
Quoted 8 lines
Quoted 6 lines
int i; int status =3D 0;- if (
down_interruptible(&drvdata->sem))
- return-ERESTARTSYS;
+mutex_lock(&drvdata->sem);=20
Why notmutex_lock_interruptible()? (goes for all cases of
mutex_lock())
It's not clear to me how to get 'correct' behavior in these functions if the interrupt happens. For instance in probe/setup, if the mutex_lock is interrupted, it doesn't appear that there is anything to do other than return an error code that no device is present? I think this was suggested by Jiri...
Steve
PATCH v2 1/1 Xilinx: hwicap: cleanup
Fix some missing __user tags and incorrect section tags. Convert semaphores to mutexes.
Make probed_devices re-entrancy and error condition safe. Fix some backwards memcpys.
Some other minor cleanups.
Use kerneldoc format.
[v2]__user char => char __user
removed unused hwicap_command_capture
Fixed a comment that didn't match the function name fixed argument with 'register' keyword.
---
Grant, Since it appears that the driver will stay in as-is, here are the updates against mainline, based on Jiri's comments.
--- drivers/char/xilinx_hwicap/buffer_icap.c | 80 ++++++++-------- drivers/char/xilinx_hwicap/fifo_icap.c | 60 ++++++------ drivers/char/xilinx_hwicap/xilinx_hwicap.c | 138 +++++++++++++--------------- drivers/char/xilinx_hwicap/xilinx_hwicap.h | 24 +++--- 4 files changed, 144 insertions(+), 158 deletions(-)
drivers/char/xilinx_hwicap/buffer_icap.c +40 -40
@@ -73,8 +73,8 @@#define XHI_BUFFER_START 0/** -* buffer_icap_get_status: Get the contents of the status register. -* @parameter base_address: is the base address of the device +* buffer_icap_get_status - Get the contents of the status register. +* @base_address: is the base address of the device * * The status register contains the ICAP status and the done bit. *
@@ -94,9 +94,9 @@ static inline u32 buffer_icap_get_status(void __iomem *base_address) }/** -* buffer_icap_get_bram: Reads data from the storage buffer bram. -* @parameter base_address: contains the base address of the component. -* @parameter offset: The word offset from which the data should be read. +* buffer_icap_get_bram - Reads data from the storage buffer bram. +* @base_address: contains the base address of the component. +* @offset: The word offset from which the data should be read. * * A bram is used as a configuration memory cache. One frame of data can * be stored in this "storage buffer".
@@ -108,8 +108,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address, }/** -* buffer_icap_busy: Return true if the icap device is busy -* @parameter base_address: is the base address of the device +* buffer_icap_busy - Return true if the icap device is busy +* @base_address: is the base address of the device * * The queries the low order bit of the status register, which * indicates whether the current configuration or readback operation
@@ -121,8 +121,8 @@ static inline bool buffer_icap_busy(void __iomem *base_address) }/** -* buffer_icap_busy: Return true if the icap device is not busy -* @parameter base_address: is the base address of the device +* buffer_icap_busy - Return true if the icap device is not busy +* @base_address: is the base address of the device * * The queries the low order bit of the status register, which * indicates whether the current configuration or readback operation
@@ -134,9 +134,9 @@ static inline bool buffer_icap_done(void __iomem *base_address) }/** -* buffer_icap_set_size: Set the size register. -* @parameter base_address: is the base address of the device -* @parameter data: The size in bytes. +* buffer_icap_set_size - Set the size register. +* @base_address: is the base address of the device +* @data: The size in bytes. * * The size register holds the number of 8 bit bytes to transfer between * bram and the icap (or icap to bram).
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void __iomem *base_address, }/** -* buffer_icap_mSetoffsetReg: Set the bram offset register. -* @parameter base_address: contains the base address of the device. -* @parameter data: is the value to be written to the data register. +* buffer_icap_set_offset - Set the bram offset register. +* @base_address: contains the base address of the device. +* @data: is the value to be written to the data register. * * The bram offset register holds the starting bram address to transfer * data from during configuration or write data to during readback.
@@ -162,9 +162,9 @@ static inline void buffer_icap_set_offset(void __iomem *base_address, }/** -* buffer_icap_set_rnc: Set the RNC (Readback not Configure) register. -* @parameter base_address: contains the base address of the device. -* @parameter data: is the value to be written to the data register. +* buffer_icap_set_rnc - Set the RNC (Readback not Configure) register. +* @base_address: contains the base address of the device. +* @data: is the value to be written to the data register. * * The RNC register determines the direction of the data transfer. It * controls whether a configuration or readback take place. Writing to
@@ -178,10 +178,10 @@ static inline void buffer_icap_set_rnc(void __iomem *base_address, }/** -* buffer_icap_set_bram: Write data to the storage buffer bram. -* @parameter base_address: contains the base address of the component. -* @parameter offset: The word offset at which the data should be written. -* @parameter data: The value to be written to the bram offset. +* buffer_icap_set_bram - Write data to the storage buffer bram. +* @base_address: contains the base address of the component. +* @offset: The word offset at which the data should be written. +* @data: The value to be written to the bram offset. * * A bram is used as a configuration memory cache. One frame of data can * be stored in this "storage buffer".
@@ -193,10 +193,10 @@ static inline void buffer_icap_set_bram(void __iomem *base_address, }/** -* buffer_icap_device_read: Transfer bytes from ICAP to the storage buffer. -* @parameter drvdata: a pointer to the drvdata. -* @parameter offset: The storage buffer start address. -* @parameter count: The number of words (32 bit) to read from the +* buffer_icap_device_read - Transfer bytes from ICAP to the storage buffer. +* @drvdata: a pointer to the drvdata. +* @offset: The storage buffer start address. +* @count: The number of words (32 bit) to read from the * device (ICAP). **/ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
@@ -227,10 +227,10 @@ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata, };/** -* buffer_icap_device_write: Transfer bytes from ICAP to the storage buffer. -* @parameter drvdata: a pointer to the drvdata. -* @parameter offset: The storage buffer start address. -* @parameter count: The number of words (32 bit) to read from the +* buffer_icap_device_write - Transfer bytes from ICAP to the storage buffer. +* @drvdata: a pointer to the drvdata. +* @offset: The storage buffer start address. +* @count: The number of words (32 bit) to read from the * device (ICAP). **/ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
@@ -261,8 +261,8 @@ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata, };/** -* buffer_icap_reset: Reset the logic of the icap device. -* @parameter drvdata: a pointer to the drvdata. +* buffer_icap_reset - Reset the logic of the icap device. +* @drvdata: a pointer to the drvdata. * * Writing to the status register resets the ICAP logic in an internal * version of the core. For the version of the core published in EDK,
@@ -274,10 +274,10 @@ void buffer_icap_reset(struct hwicap_drvdata *drvdata) }/** -* buffer_icap_set_configuration: Load a partial bitstream from system memory. -* @parameter drvdata: a pointer to the drvdata. -* @parameter data: Kernel address of the partial bitstream. -* @parameter size: the size of the partial bitstream in 32 bit words. +* buffer_icap_set_configuration - Load a partial bitstream from system memory. +* @drvdata: a pointer to the drvdata. +* @data: Kernel address of the partial bitstream. +* @size: the size of the partial bitstream in 32 bit words. **/ int buffer_icap_set_configuration (struct hwicap_drvdata *drvdata,u32 *data,u32 size)
@@ -333,10 +333,10 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, };/** -* buffer_icap_get_configuration: Read configuration data from the device. -* @parameter drvdata: a pointer to the drvdata. -* @parameter data: Address of the data representing the partial bitstream -* @parameter size: the size of the partial bitstream in 32 bit words. +* buffer_icap_get_configuration - Read configuration data from the device. +* @drvdata: a pointer to the drvdata. +* @data: Address of the data representing the partial bitstream +* @size: the size of the partial bitstream in 32 bit words. **/ int buffer_icap_get_configuration (struct hwicap_drvdata *drvdata,u32 *data,u32 size)
drivers/char/xilinx_hwicap/fifo_icap.c +30 -30
133 lines not on this page · raw message
drivers/char/xilinx_hwicap/xilinx_hwicap.c +62 -76
347 lines not on this page · raw message
drivers/char/xilinx_hwicap/xilinx_hwicap.h +12 -12
@@ -48,9 +48,9 @@ struct hwicap_drvdata {u8 write_buffer[4 ];u32 read_buffer_in_use;/* Always in [0,3] */ u8 read_buffer[4 ]; -u32 mem_start;/* phys. address of the control registers */ -u32 mem_end;/* phys. address of the control registers */ -u32 mem_size; +resource_size_t mem_start;/* phys. address of the control registers */ +resource_size_t mem_end;/* phys. address of the control registers */ +resource_size_t mem_size;void __iomem *base_address;/* virt. address of the control registers */ struct device *dev;
@@ -61,7 +61,7 @@ struct hwicap_drvdata {const struct config_registers *config_regs;void *private_data;bool is_open; -struct semaphore sem; +struct mutex sem; };struct hwicap_driver_config {
@@ -164,29 +164,29 @@ struct config_registers {#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL/** -* hwicap_type_1_read: Generates a Type 1 read packet header. -* @parameter: Register is the address of the register to be read back. +* hwicap_type_1_read - Generates a Type 1 read packet header. +* @reg: is the address of the register to be read back. * * Generates a Type 1 read packet header, which is used to indirectly * read registers in the configuration logic. This packet must then * be sent through the icap device, and a return packet received with * the information. **/ -static inline u32 hwicap_type_1_read (u32 Register) +static inline u32 hwicap_type_1_read (u32 reg) {return (XHI_TYPE_1 <<XHI_TYPE_SHIFT ) | - (Register <<XHI_REGISTER_SHIFT ) | + (reg <<XHI_REGISTER_SHIFT ) | (XHI_OP_READ <<XHI_OP_SHIFT ); }/** -* hwicap_type_1_write: Generates a Type 1 write packet header -* @parameter: Register is the address of the register to be read back. +* hwicap_type_1_write - Generates a Type 1 write packet header +* @reg: is the address of the register to be read back. **/ -static inline u32 hwicap_type_1_write (u32 Register) +static inline u32 hwicap_type_1_write (u32 reg) {return (XHI_TYPE_1 <<XHI_TYPE_SHIFT ) | - (Register <<XHI_REGISTER_SHIFT ) | + (reg <<XHI_REGISTER_SHIFT ) | (XHI_OP_WRITE <<XHI_OP_SHIFT ); }
Signature · 1 line
1.5.3.4-dirty
Quoted 7 lines · Stephen Neuendorffer
Fix some missing
__usertags and incorrect section tags.
Convert semaphores to mutexes.
Makeprobed_devicesre-entrancy and error condition safe. Fix some backwards memcpys.
Some other minor cleanups.
Use kerneldoc format.
Quoted 8 lines
[v2]
__userchar => char__user
removed unusedhwicap_command_capture
Fixed a comment that didn't match the function name fixed argument with 'register' keyword.Signed-off-by Stephen Neuendorffer <[email protected]>
Josh, can you please pick this up?
Thanks,
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 8 lines · Stephen Neuendorffer
Quoted 1 line
Quoted 1 line
@@ -549,8 +556,7 @@ static int hwicap_release(struct inode *inode,
struct file *file)
Quoted 6 lines
Quoted 6 lines
int i; int status = 0;- if (
down_interruptible(&drvdata->sem))
- return-ERESTARTSYS;
+mutex_lock(&drvdata->sem);
Quoted 8 lines
Quoted 1 line
Why not
mutex_lock_interruptible()? (goes for all cases of
mutex_lock())It's not clear to me how to get 'correct' behavior in these functions if the interrupt happens. For instance in probe/setup, if the
mutex_lockis interrupted, it doesn't appear that there is anything to do other than return an error code that no device is present? I think this was suggested by Jiri...
Yeah, since ERESTARTSYS would be ignored from f_op->release (see __fput()), drv->probe (see really_probe() and probe_failed label); not even talking about void return value functions. In those cases, the device won't be de/initialized and might result in unwanted behaviour (multiple modprobes for one device, rmmod/insmod need if you hit the path in release etc.).