This fixes sparse warnings:
staging/lustre/lustre/libcfs/nidstrings.c:200:11: warning: symbol 'libcfs_nnetstrfns' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:203:1: warning: symbol 'libcfs_lo_str2addr' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:210:1: warning: symbol 'libcfs_ip_addr2str' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:227:1: warning: symbol 'libcfs_ip_str2addr' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:248:1: warning: symbol 'libcfs_decnum_addr2str' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:254:1: warning: symbol 'libcfs_hexnum_addr2str' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:260:1: warning: symbol 'libcfs_num_str2addr' was not declared. Should it be static?
staging/lustre/lustre/libcfs/nidstrings.c:279:18: warning: symbol 'libcfs_lnd2netstrfns' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:292:18: warning: symbol 'libcfs_namenum2netstrfns' was not declared. Should it be static?
drivers/staging/lustre/lustre/libcfs/nidstrings.c:307:18: warning: symbol 'libcfs_name2netstrfns' was not declared. Should it be static?
Some functions had static forward declarations followed by non-static
implementations. Those forward declarations are removed and the
implementations are declared static and moved into a location that
doesn't require forward declarations.
Jeremiah Mahler [Fri, 26 Dec 2014 00:04:44 +0000 (16:04 -0800)]
staging: lustre: replace MIN with min, cast (__kernel_size_t)
Switch from MIN to min and fix the new type warning. The
warning is produced because a comparison between iov_len,
which is a __kernel_size_t, is made to kiov_len, which is an
unsigned int (include/linux/lnet/types.h). Fix the warning
by casting kiov_len to __kernel_size_t.
Jeremiah Mahler [Fri, 26 Dec 2014 00:04:43 +0000 (16:04 -0800)]
staging: lustre: replace MIN/MAX with min_t/max_t
Switch from MIN/MAX to min_t/max_t with a size_t type. The size_t type
was chosen because one operand is a size_t and all the others are
immediate integer values.
Jeremiah Mahler [Fri, 26 Dec 2014 00:04:41 +0000 (16:04 -0800)]
staging: lustre: use min/max instead of MIN/MAX, simple cases
Custom MIN/MAX operations are being used which are not as robust
as the built in min/max operations which will warn about potentially
problematic type comparisons.
For the simple cases, where no type warning is produced, simply
replace MIN/MAX with min/max.
Dan Carpenter [Mon, 22 Dec 2014 07:52:39 +0000 (10:52 +0300)]
Staging: lustre: error handling tweaks in obd_ioctl_getdata()
1) The places which called copy_from_user() were returning the number
of bytes not copied instead of -EFAULT.
2) The user could trigger a memory leak if the condition
"(hdr.ioc_len != data->ioc_len)" was true. Instead of adding a new call
to OBD_FREE_LARGE(), I created a free_buf label and changed everything
to use that label.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Spencer Baugh [Sat, 20 Dec 2014 20:48:13 +0000 (15:48 -0500)]
lustre: ptlrpc: add "ptlrpc_internal.h" to sec_gc.c
ptlrpc_internal.h contains the prototypes for sptlrpc_gc_init() and
sptlrpc_gc_fini(), which are defined in sec_gc.c.
This removes the following sparse warnings:
drivers/staging/lustre/lustre/ptlrpc/sec_gc.c:217:5: warning: symbol 'sptlrpc_gc_init' was not declared. Should it be static?
drivers/staging/lustre/lustre/ptlrpc/sec_gc.c:241:6: warning: symbol 'sptlrpc_gc_fini' was not declared. Should it be static?
Chris Rorvick [Wed, 17 Dec 2014 04:24:02 +0000 (22:24 -0600)]
drivers: staging: lustre: Track sign separately
The `mult' parameter is negated if the user data begins with a '-' so
that the final value has the appropriate sign. But `mult' is only used
if the user data does not include a "units" suffix. In this case,
`mult' is overridden with the numeric scale conveyed by the units suffix,
but retains the sign of the original value.
Having `mult' serving double-duty works but is confusing. Use a new
local variable to store the sign of the user data instead. This also
fixes a pitfall of passing 0 to `mult', expecting it to be ignored when
a units suffix is specified, but having the effect of taking the
absolute value of the user-provided data.
Signed-off-by: Chris Rorvick <chris@rorvick.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Chris Rorvick [Wed, 17 Dec 2014 04:24:01 +0000 (22:24 -0600)]
drivers: staging: lustre: Use mult if units not specified
Units can be passed to lprocfs_write_frac_u64_helper() via a suffix
(e.g., "...K", "...M", etc.) tacked onto the value. A comment states
that "specified units override the multiplier," though the multiplier is
overridden regardless. Update the conditional logic so that it only
applies when units are specified.
Signed-off-by: Chris Rorvick <chris@rorvick.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Tristan Lelong [Sun, 7 Dec 2014 00:00:30 +0000 (16:00 -0800)]
staging: lustre: replace static value with define
This patch replace the value '80' used in several files in the lustre source code
with a define LUSTRE_MDT_MAXNAMELEN.
This value is used in 4 different structures as the maximum len for a service name.
According to the comments, these names follow a convention which make it possible
to use the same define for LCS, LSS, LCF, and LSF.
Tristan Lelong [Sat, 6 Dec 2014 06:43:20 +0000 (22:43 -0800)]
staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
This patch fix a sparse warning in lustre sources
warning: incorrect type in argument 1 (different address spaces)
expected void [noderef] <asn:1>*to
got char *<noident>
This is done by adding the missing __user attribute on userland pointers inside the LPROC_SEQ_FOPS like macros:
- LPROC_SEQ_FOPS
- LPROC_SEQ_FOPS_RW_TYPE
- LPROC_SEQ_FOPS_WR_ONLY
- LDLM_POOL_PROC_WRITER
The patch also updates all the functions that are used by this macro:
- lprocfs_wr_*
- *_seq_write
as well as some helpers used by the previously modified functions (otherwise fixing the sparse warning add some new ones):
- lprocfs_write_frac_helper
- lprocfs_write_helper
- lprocfs_write_u64_helper
The patch also fixes one __user pointer direct dereference by strncmp in function fld_proc_hash_seq_write.
staging: comedi: pcl812: use common function to setup dma
The pcl812_ai_setup_dma() and pcl812_ai_setup_next_dma() functions are similar
other than the buffer switch and the inclusion of the "unread_samples" in
pcl818_ai_setup_next_dma() when calculating the dma size.
Merge these two functions by initializing the 'dma->cur_dma' in the callers
and passing '0' for the "unread_samples" when first starting the DMA.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl812: simplify the dma->size calculations
The dma->size calculations are overly complicated in this driver and the
'prealloc_bufsz' sanity checks are unnecessary.
Currently this driver determines the number of DMA "runs" needed and the size
of the "last" DMA transfer in order to perform a command. As long as there are
more "runs" required, the dma->size is set to the buffer maxsize. On the last
"run" the buffer is set to the "last" size.
Refactor the driver to use the comedi core helpers to determine the DMA size
based on the buffer maxsize and the number of samples remaining in the command.
This allows removing the 'dma_runs_to_end' and 'last_dma_run' mamebers from
the private data.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl816: use common function to setup dma
THe pcl816_ai_setup_dma() and pcl816_ai_setup_next_dma() functions are similar
other than the buffer switch and the inclusion of the "unread_samples" in
pcl818_ai_setup_next_dma() when calculating the dma size.
Merge these two functions by initializing the 'dma->cur_dma' in the callers
and passing '0' for the "unread_samples" when first starting the DMA.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl816: simplify the dma->size calculations
Currently this driver determines the number of DMA "runs" needed and the size
of the "last" DMA transfer in order to perform a command. As long as there are
more "runs" required, the dma->size is set to the buffer maxsize. On the last
"run" the buffer is set to the "last" size.
Refactor the driver to use the comedi core helpers to determine the DMA size
based on the buffer maxsize and the number of samples remaining in the command.
This allows removing the 'dma_runs_to_end' and 'last_dma_run' mamebers from
the private data.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl818: use common function to setup dma
THe pcl818_ai_setup_dma() and pcl818_ai_setup_next_dma() functions are similar
other than the buffer switch and the inclusion of the "unread_samples" in
pcl818_ai_setup_next_dma() when calculating the dma size.
Merge these two functions by initializing the 'dma->cur_dma' in the callers
and passing '0' for the "unread_samples" when first starting the DMA.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl818: simplify the dma->size calculations
Currently this driver determines the number of DMA "runs" needed and the size
of the "last" DMA transfer in order to perform a command. As long as there are
more "runs" required, the dma->size is set to the buffer maxsize. On the last
"run" the buffer is set to the "last" size.
Refactor the driver to use the comedi core helpers to determine the DMA size
based on the buffer maxsize and the number of samples remaining in the command.
This allows removing the 'dma_runs_to_end' and 'last_dma_run' mamebers from
the private data. Also remove the 'ai_data_len' member which is set but never
used.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_at_a2150: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: dt282x: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: das1800: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: das16: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl812: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl816: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl818: remove depends on ISA_DMA_API limitation
Use the new comedi_isadma module to provide the ISA DMA support. This removes
all the ISA_DMA_API code from this driver and allows the driver to be used on
platforms that don't support the ISA_DMA_API.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_isadma: introduce helper module for ISA DMA
Introduce a new helper module to consolidate all the ISA DMA code. This will
allow removing the "depends on ISA_DMA_API" from the legacy drivers that can
use DMA for async command support.
This module is complete based on the various uses of ISA DMA in the comedi
drivers.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: das1800: tidy up das1800_ai_transfer_size()
For aesthetics, pass the fill time 'ns' as a parameter to this function.
Refactor this function to calculate the transfer size in 'samples' instead
of 'bytes'. This removes the need to constantly multiply the values by the
'sample_size'. It also helps avoid any possible integer overflow issues.
Use the comedi_nsamples_left() helper to limit the samples when cmd->stop_src
is TRIG_COUNT.
Use comedi_samples_to_bytes() to return the final DMA size in bytes.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: das1800: remove hard coded 'sample_size'
Use the comedi_bytes_per_sample() helper to remove the hard coded sample_size
in suggest_transfer_size().
The helper function needs to comedi_subdevice pointer. Change the parameters
passed to suggest_transfer_size() and setup_dma() so that this pointer is
available. Rename these functions so they have namespace associated with the
driver.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_labpc_isadma: move dma programming out of labpc_drain_dma()
The external caller of labpc_drain_dma() does not enable the DMA transfer. Only
the call from handle_isa_dma() results in the programmed DMA operation getting
enabled.
For aesthetics, move the dma programming to handle_isa_dma(). Make sure the
DMA operation would actually do something (dma->size != 0) before programming
it to avoid enabling the DMA at the end of a stop_src == TRIG_COUNT command.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
According to Documentation/DMA-ISA-LPC.txt, the DMA lock needs to be
claimed before using any of the ISA DMA routines. Introduce a helper
function to disable the ISA DMA controller and add the necessary
locking calls.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
According to Documentation/DMA-ISA-LPC.txt, the DMA lock needs to be
claimed before using any of the ISA DMA routines. Introduce a helper
function to disable the ISA DMA controller and add the necessary
locking calls.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
According to Documentation/DMA-ISA-LPC.txt, the DMA lock needs to be
claimed before using any of the ISA DMA routines. Introduce a helper
function to disable the ISA DMA controller and add the necessary
locking calls.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
According to Documentation/DMA-ISA-LPC.txt, the DMA lock needs to be
claimed before using any of the ISA DMA routines. Introduce a helper
function to disable the ISA DMA controller and add the necessary
locking calls.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The DAS16 board is an ISA device not a PCI device. For aesthetics, use
dma_{alloc,free}_coherent() to allocate and free the DMA buffers instead
of the PCI versions.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
DMA is optional with this driver. Introduce a helper function to request
the DMA channel and allocate the buffers. Don't fail the driver attach
if the user passed an invalid DMA channel or the channel cannot be
requested.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The IRA and DMA are optional with this driver but both are required to
support async commands. Introduce a helper function to request the IRQ
and DMA channel and allocate the buffers. Don't fail the driver attach
if the user passed an invalid IRQ or DMA channel or they cannot be
requested.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
DMA is optional with this driver. Introduce a helper function to request
the DMA channel and allocate the buffers. Don't fail the driver attach
if the user passed an invalid DMA channel or the channel cannot be
requested.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcl816: fix short DMA transactions
When the cmd->stop_src == TRIG_COUNT the last DMA transfer might be smaller
than the buffer size. This results in invalid data being added to the async
buffer.
Add a 'size' member to the DMA descriptor and initialize it with the
actual size of the DMA transfer. Use that in interrupt and ai subdevice
(*poll) function to return the proper number of samples. Use the
comedi_bytes_to_samples() helper to convert the byte size to comedi
samples in the interrupt handler.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>