aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Gordon <david.s.gordon@intel.com>2015-06-30 17:58:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-30 22:44:59 -0400
commit2a1bf8f93b33992bb0457512b28d046e279bbd7e (patch)
tree48db340683a7c617dd70c66a282f43d85c2714ad
parent4dc7daf843f3914c9c0c7efb71b8f251c9c4636f (diff)
lib/scatterlist: mark input buffer parameters as 'const'
The 'buf' parameter of sg(p)copy_from_buffer() can and should be const-qualified, although because of the shared implementation of _to_buffer() and _from_buffer(), we have to cast this away internally. This means that callers who have a 'const' buffer containing the data to be copied to the sg-list no longer have to cast away the const-ness themselves. It also enables improved coverage by code analysis tools. Signed-off-by: Dave Gordon <david.s.gordon@intel.com> Cc: Akinobu Mita <akinobu.mita@gmail.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/scatterlist.h4
-rw-r--r--lib/scatterlist.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 50a8486c524b..505d0481df1e 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -266,12 +266,12 @@ int sg_alloc_table_from_pages(struct sg_table *sgt,
266 gfp_t gfp_mask); 266 gfp_t gfp_mask);
267 267
268size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, 268size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
269 void *buf, size_t buflen); 269 const void *buf, size_t buflen);
270size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents, 270size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
271 void *buf, size_t buflen); 271 void *buf, size_t buflen);
272 272
273size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents, 273size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
274 void *buf, size_t buflen, off_t skip); 274 const void *buf, size_t buflen, off_t skip);
275size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents, 275size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
276 void *buf, size_t buflen, off_t skip); 276 void *buf, size_t buflen, off_t skip);
277 277
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 965c36e7a5a4..317b62c6da3c 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -701,9 +701,9 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
701 * 701 *
702 **/ 702 **/
703size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, 703size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
704 void *buf, size_t buflen) 704 const void *buf, size_t buflen)
705{ 705{
706 return sg_copy_buffer(sgl, nents, buf, buflen, 0, false); 706 return sg_copy_buffer(sgl, nents, (void *)buf, buflen, 0, false);
707} 707}
708EXPORT_SYMBOL(sg_copy_from_buffer); 708EXPORT_SYMBOL(sg_copy_from_buffer);
709 709
@@ -736,9 +736,9 @@ EXPORT_SYMBOL(sg_copy_to_buffer);
736 * 736 *
737 **/ 737 **/
738size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents, 738size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
739 void *buf, size_t buflen, off_t skip) 739 const void *buf, size_t buflen, off_t skip)
740{ 740{
741 return sg_copy_buffer(sgl, nents, buf, buflen, skip, false); 741 return sg_copy_buffer(sgl, nents, (void *)buf, buflen, skip, false);
742} 742}
743EXPORT_SYMBOL(sg_pcopy_from_buffer); 743EXPORT_SYMBOL(sg_pcopy_from_buffer);
744 744