qla2xxx: use memory_read_from_buffer()
Subsystems (11)
PATCH 14/16 qla2xxx: use memory_read_from_buffer()
From: Akinobu Mita <[email protected]>
---
drivers/scsi/qla2xxx/qla_attr.c | 45 ++++++------------------------ 1 file changed, 10 insertions(+), 35 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c renamed from drivers/scsi/qla2xxx/qla_attr.c~qla2xxx-use-memory_read_from_buffer +10 -35
@@ -8,6 +8,7 @@#include <linux/kthread.h> #include <linux/vmalloc.h> +#include <linux/fs.h> static int qla24xx_vport_disable (struct fc_vport *,bool );
@@ -20,18 +21,12 @@ qla2x00_sysfs_read_fw_dump(struct kobjec {struct scsi_qla_host *ha =shost_priv (dev_to_shost (container_of (kobj, struct device, kobj))); -char *rbuf = (char *)ha->fw_dump;if (ha->fw_dump_reading ==0 )return 0 ; -if (off > ha->fw_dump_len) -return 0 ; -if (off + count > ha->fw_dump_len) - count = ha->fw_dump_len - off; -memcpy (buf, &rbuf[off], count); - -return (count); +return memory_read_from_buffer (buf, count, &off, ha->fw_dump, + ha->fw_dump_len); } static ssize_t
@@ -94,20 +89,13 @@ qla2x00_sysfs_read_nvram(struct kobject {struct scsi_qla_host *ha =shost_priv (dev_to_shost (container_of (kobj, struct device, kobj))); -int size = ha->nvram_size; -char *nvram_cache = ha->nvram; -if (!capable (CAP_SYS_ADMIN ) || off > size || count ==0 ) +if (!capable (CAP_SYS_ADMIN ))return 0 ; -if (off + count > size) { - size -= off; - count = size; - }/* Read NVRAM data from cache. */ -memcpy (buf, &nvram_cache[off], count); - -return count; +return memory_read_from_buffer (buf, count, &off, ha->nvram, + ha->nvram_size); } static ssize_t
@@ -175,14 +163,9 @@ qla2x00_sysfs_read_optrom(struct kobjectif (ha->optrom_state !=QLA_SREADING )return 0 ; -if (off > ha->optrom_region_size) -return 0 ; -if (off + count > ha->optrom_region_size) - count = ha->optrom_region_size - off; -memcpy (buf, &ha->optrom_buffer[off], count); - -return count; +return memory_read_from_buffer (buf, count, &off, ha->optrom_buffer, + ha->optrom_region_size); } static ssize_t
@@ -374,20 +357,12 @@ qla2x00_sysfs_read_vpd(struct kobject *k {struct scsi_qla_host *ha =shost_priv (dev_to_shost (container_of (kobj, struct device, kobj))); -int size = ha->vpd_size; -char *vpd_cache = ha->vpd; -if (!capable (CAP_SYS_ADMIN ) || off > size || count ==0 ) +if (!capable (CAP_SYS_ADMIN ))return 0 ; -if (off + count > size) { - size -= off; - count = size; - }/* Read NVRAM data from cache. */ -memcpy (buf, &vpd_cache[off], count); - -return count; +return memory_read_from_buffer (buf, count, &off, ha->vpd, ha->vpd_size); } static ssize_t
_
James Bottomley
maintainerQuoted 17 lines · On Thu, 2008-07-03 at 23:47 -0700, [email protected] wrote:
From: Akinobu Mita <[email protected]>
Signed-off-by Akinobu Mita <[email protected]>Cc Andrew Vasquez <[email protected]>Cc James E.J. Bottomley <[email protected]>Tested-by Andrew Vasquez <[email protected]>Cc Seokmann Ju <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
drivers/scsi/qla2xxx/qla_attr.c | 45 ++++++------------------------ 1 file changed, 10 insertions(+), 35 deletions(-)diff -puN
drivers/scsi/qla2xxx/qla_attr.c~qla2xxx-use-memory_read_from_bufferdrivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_attr.c line 11
Quoted 4 lines
drivers/scsi/qla2xxx/qla_attr.c renamed from drivers/scsi/qla2xxx/qla_attr.c~qla2xxx-use-memory_read_from_buffer +1
-0@@ -8,6 +8,7 @@#include <linux/kthread.h> #include <linux/vmalloc.h> +#include <linux/fs.h>
For such a micro optimisation, this is a pretty big price to pay.
Inclusion of linux/fs.h in a low level driver was always a danger signal usually it meant the driver was trying to access files or something at the very least it was a warning of a potential layering violation. Now you're trying to make it standard practice ... I really don't like that. Surely a function that does memory to memory copies belongs either in string.h with the rest of our memory copies ... or in another header that would be a usual include for the potential users.
James
PATCH 1/1 move memory_read_from_buffer() from fs.h to string.h
Quoted 9 lines · James Bottomley
For such a micro optimisation, this is a pretty big price to pay.
Inclusion of
linux/fs.hin a low level driver was always a danger signal usually it meant the driver was trying to access files or something at the very least it was a warning of a potential layering violation. Now you're trying to make it standard practice ... I really don't like that. Surely a function that does memory to memory copies belongs either instring.hwith the rest of our memory copies ... or in another header that would be a usual include for the potential users.
OK, I'll move it to linux/string.h
From: Akinobu Mita <[email protected]>
Subject: [PATCH] move memory_read_from_buffer() from fs.h to string.h
James Bottomley warns that inclusion of linux/fs.h in a low level driver was always a danger signal. This patch moves memory_read_from_buffer() from fs.h to string.h and fixes includes in existing memory_read_from_buffer() users.
--- drivers/acpi/system.c | 1 + drivers/zorro/zorro-sysfs.c | 1 - include/linux/fs.h | 2 -- include/linux/string.h | 3 +++ 4 files changed, 4 insertions(+), 3 deletions(-)
include/linux/fs.h +0 -2
@@ -2026,8 +2026,6 @@ extern void simple_release_fs(struct vfsextern ssize_t simple_read_from_buffer (void __user *to,size_t count,loff_t *ppos,const void *from,size_t available); -extern ssize_t memory_read_from_buffer (void *to,size_t count,loff_t *ppos, -const void *from,size_t available);#ifdef CONFIG_MIGRATION extern int buffer_migrate_page(struct address_space *,
include/linux/string.h +3 -0
@@ -111,5 +111,8 @@ extern void argv_free(char **argv);extern bool sysfs_streq (const char *s1,const char *s2); +extern ssize_t memory_read_from_buffer (void *to,size_t count,loff_t *ppos, +const void *from,size_t available); +#endif #endif /* _LINUX_STRING_H_ */
drivers/acpi/system.c +1 -0
@@ -26,6 +26,7 @@#include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/init.h> +#include <linux/string.h> #include <asm/uaccess.h> #include <acpi/acpi_drivers.h>
drivers/zorro/zorro-sysfs.c +0 -1
@@ -15,7 +15,6 @@#include <linux/zorro.h> #include <linux/stat.h> #include <linux/string.h> -#include <linux/fs.h> #include "zorro.h"
PATCH 1/1 fix s390-use-memory_read_from_buffer.patch
Now memory_read_from_buffer() belongs in string.h
--- arch/s390/kernel/ipl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/ipl.c +1 -1
@@ -14,7 +14,7 @@#include <linux/delay.h> #include <linux/reboot.h> #include <linux/ctype.h> -#include <linux/fs.h> +#include <linux/string.h> #include <asm/ipl.h> #include <asm/smp.h> #include <asm/setup.h>
PATCH 1/1 fix s390-cio-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/s390/cio/chp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/chp.c +1 -1
@@ -15,7 +15,7 @@#include <linux/wait.h> #include <linux/mutex.h> #include <linux/errno.h> -#include <linux/fs.h> +#include <linux/string.h> #include <asm/chpid.h> #include <asm/sclp.h>
PATCH 1/1 fix qla2xxx-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/scsi/qla2xxx/qla_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_attr.c +1 -1
@@ -8,7 +8,7 @@#include <linux/kthread.h> #include <linux/vmalloc.h> -#include <linux/fs.h> +#include <linux/string.h> static int qla24xx_vport_disable (struct fc_vport *,bool );
PATCH 1/1 fix ipr-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/scsi/ipr.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ipr.c +1 -0
@@ -71,6 +71,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/libata.h> +#include <linux/string.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/processor.h>
James Bottomley
maintainerRe: [PATCH -mm] fix ipr-use-memory_read_from_buffer.patch
Quoted 14 lines · Akinobu Mita
Now
memory_read_from_buffer()belongs instring.hSigned-off-by Akinobu Mita <[email protected]>Cc Brian King <[email protected]>Cc "James E.J. Bottomley" <[email protected]>--- drivers/scsi/ipr.c | 1 + 1 file changed, 1 insertion(+)Index:
2.6-mm/drivers/scsi/ipr.c
===================================================================
drivers/scsi/ipr.c line 77
Quoted 7 lines
drivers/scsi/ipr.c +1
-0@@ -71,6 +71,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/libata.h> +#include <linux/string.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/processor.h>
This isn't really necessary, is it? As you can see from the file being stuffed full of memcpy directives, it's already getting an implicit include of string.h from somewhere (like the rest of the SCSI drivers).
James
Re: [PATCH -mm] fix ipr-use-memory_read_from_buffer.patch
Quoted 6 lines
Quoted 6 lines
drivers/scsi/ipr.c +0
-0@@ -71,6 +71,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/libata.h>
Quoted 8 lines
drivers/scsi/ipr.c line 77
Quoted 4 lines
drivers/scsi/ipr.c +1
-0+#include <linux/string.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/processor.h> This isn't really necessary, is it? As you can see from the file being stuffed full of memcpy directives, it's already getting an implicit include of
string.hfrom somewhere (like the rest of the SCSI drivers).
Indeed. This is not necessary.
PATCH 1/1 fix dcdbas-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/firmware/dcdbas.c | 1 - 1 file changed, 1 deletion(-)
drivers/firmware/dcdbas.c +0 -1
@@ -34,7 +34,6 @@#include <linux/string.h> #include <linux/types.h> #include <linux/mutex.h> -#include <linux/fs.h> #include <asm/io.h> #include "dcdbas.h"
PATCH 1/1 fix aty-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/video/aty/radeon_base.c | 1 - 1 file changed, 1 deletion(-)
drivers/video/aty/radeon_base.c +0 -1
@@ -70,7 +70,6 @@#include <linux/pci.h> #include <linux/vmalloc.h> #include <linux/device.h> -#include <linux/fs.h> #include <asm/io.h> #include <linux/uaccess.h>
PATCH 1/1 fix firmware-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/base/firmware_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/firmware_class.c +1 -1
@@ -17,7 +17,7 @@#include <linux/bitops.h> #include <linux/mutex.h> #include <linux/kthread.h> -#include <linux/fs.h> +#include <linux/string.h> #include <linux/firmware.h> #include "base.h"
PATCH 1/1 fix dell_rbu-use-memory_read_from_buffer.patch
In reply to Akinobu MitaNow memory_read_from_buffer() belongs in string.h
--- drivers/firmware/dell_rbu.c | 1 - 1 file changed, 1 deletion(-)
drivers/firmware/dell_rbu.c +0 -1
@@ -44,7 +44,6 @@#include <linux/moduleparam.h> #include <linux/firmware.h> #include <linux/dma-mapping.h> -#include <linux/fs.h> MODULE_AUTHOR ("Abhay Salunke <[email protected]>" );MODULE_DESCRIPTION ("Driver for updating BIOS image on DELL systems" );