SCSI: possible cleanups
PATCH 1/1 SCSI: possible cleanups
Before I'm getting flamed to death:
This patch contains possible cleanups. If parts of this patch conflict with pending changes these parts of my patch have to be dropped.
This patch contains the following possible cleanups:
- make needlessly global code static
- remove or #if 0 the following unused functions:
- scsi.h: print_driverbyte
- scsi.h: print_hostbyte
- constants.c: scsi_print_hostbyte
- constants.c: scsi_print_driverbyte
- scsi_scan.c: scsi_scan_single_target
- remove the following unneeded EXPORT_SYMBOL's:
- constants.c: __scsi_print_sense
- hosts.c: scsi_host_lookup
- scsi.c: scsi_device_cancel
- scsi_error.c: scsi_normalize_sense
- scsi_error.c: scsi_sense_desc_find
- scsi_lib.c: scsi_device_resume
- scsi_scan.c: scsi_rescan_device
- scsi_scan.c: scsi_scan_single_target
---
drivers/scsi/constants.c | 56 ------------------------------------- drivers/scsi/hosts.c | 3 - drivers/scsi/scsi.c | 9 +++-- drivers/scsi/scsi.h | 8 ----- drivers/scsi/scsi_debug.c | 2 - drivers/scsi/scsi_error.c | 6 +-- drivers/scsi/scsi_lib.c | 5 +-- drivers/scsi/scsi_priv.h | 4 -- drivers/scsi/scsi_scan.c | 3 + drivers/scsi/scsi_sysfs.c | 4 +- include/scsi/scsi_dbg.h | 5 --- include/scsi/scsi_device.h | 1 include/scsi/scsi_eh.h | 3 - include/scsi/scsi_host.h | 2 - 14 files changed, 16 insertions(+), 95 deletions(-)
drivers/scsi/scsi.h renamed from drivers/scsi/scsi.h.old +0 -8
@@ -80,14 +80,6 @@ {return scsi_print_req_sense (devclass, req); } -static inline void print_driverbyte (int scsiresult) -{ -return scsi_print_driverbyte (scsiresult); -} -static inline void print_hostbyte (int scsiresult) -{ -return scsi_print_hostbyte (scsiresult); -}static inline void print_status (unsigned char status) {return scsi_print_status (status);
include/scsi/scsi_dbg.h renamed from include/scsi/scsi_dbg.h.old +0 -5
@@ -8,11 +8,6 @@extern void __scsi_print_command (unsigned char *);extern void scsi_print_sense (const char *,struct scsi_cmnd *);extern void scsi_print_req_sense (const char *,struct scsi_request *); -extern void __scsi_print_sense (const char *name, -const unsigned char *sense_buffer, -int sense_len); -extern void scsi_print_driverbyte (int ); -extern void scsi_print_hostbyte (int );extern void scsi_print_status (unsigned char );extern int scsi_print_msg (const unsigned char *);extern const char *scsi_sense_key_string (unsigned char );
drivers/scsi/constants.c renamed from drivers/scsi/constants.c.old +1 -55
71 lines not on this page · raw message
drivers/scsi/hosts.c renamed from drivers/scsi/hosts.c.old +1 -2
@@ -56,7 +56,7 @@* @shost: pointer to struct Scsi_Host * recovery: recovery requested to run. **/ -void scsi_host_cancel (struct Scsi_Host *shost,int recovery) +static void scsi_host_cancel (struct Scsi_Host *shost,int recovery) {struct scsi_device *sdev;
@@ -362,7 +362,6 @@return shost; } -EXPORT_SYMBOL (scsi_host_lookup);/** * scsi_host_get - inc a Scsi_Host ref count
drivers/scsi/scsi_priv.h renamed from drivers/scsi/scsi_priv.h.old +0 -4
@@ -66,8 +66,6 @@extern int scsi_dispatch_cmd (struct scsi_cmnd *cmd);extern int scsi_setup_command_freelist (struct Scsi_Host *shost);extern void scsi_destroy_command_freelist (struct Scsi_Host *shost); -extern void scsi_done (struct scsi_cmnd *cmd); -extern int scsi_retry_command (struct scsi_cmnd *cmd);extern int scsi_insert_special_req (struct scsi_request *sreq,int );extern void scsi_init_cmd_from_req (struct scsi_cmnd *cmd,struct scsi_request *sreq);
@@ -141,7 +139,6 @@#endif /* CONFIG_SYSCTL */ /* scsi_sysfs.c */ -extern void scsi_device_dev_release (struct device *);extern int scsi_sysfs_add_sdev (struct scsi_device *);extern int scsi_sysfs_add_host (struct Scsi_Host *);extern int scsi_sysfs_register (void );
@@ -150,7 +147,6 @@extern int scsi_sysfs_target_initialize (struct scsi_device *);extern struct scsi_transport_template blank_transport_template; -extern struct class sdev_class;extern struct bus_type scsi_bus_type;/*
drivers/scsi/scsi.c renamed from drivers/scsi/scsi.c.old +5 -4
@@ -68,6 +68,8 @@#include "scsi_priv.h" #include "scsi_logging.h" +static void scsi_done (struct scsi_cmnd *cmd); +static int scsi_retry_command (struct scsi_cmnd *cmd);/* * Definitions and constants.
@@ -90,7 +92,7 @@/* * Data declarations. */ -unsigned long scsi_pid; +static unsigned long scsi_pid;static unsigned long serial_number;/*
@@ -733,7 +735,7 @@* * This function is interrupt context safe. */ -void scsi_done (struct scsi_cmnd *cmd) +static void scsi_done (struct scsi_cmnd *cmd) {/* * We don't have to worry about this one timing out any more.
@@ -829,7 +831,7 @@* level drivers should not become re-entrant as a result of * this. */ -int scsi_retry_command (struct scsi_cmnd *cmd) +static int scsi_retry_command (struct scsi_cmnd *cmd) {/* * Restore the SCSI command state.
@@ -1215,7 +1217,6 @@return 0 ; } -EXPORT_SYMBOL (scsi_device_cancel);#ifdef CONFIG_HOTPLUG_CPU static int scsi_cpu_notify(struct notifier_block *self,
drivers/scsi/scsi_debug.c renamed from drivers/scsi/scsi_debug.c.old +1 -1
@@ -1783,7 +1783,7 @@device_initcall (scsi_debug_init);module_exit (scsi_debug_exit); -void pseudo_0_release (struct device * dev) +static void pseudo_0_release (struct device * dev) {if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)printk (KERN_INFO "scsi_debug: pseudo_0_release() called\n" );
include/scsi/scsi_eh.h renamed from include/scsi/scsi_eh.h.old +0 -3
@@ -45,9 +45,6 @@return ((sshdr->response_code >=0x70 ) && (sshdr->response_code &1 )); } -extern const u8 *scsi_sense_desc_find (const u8 * sense_buffer,int sb_len, -int desc_type); -extern int scsi_get_sense_info_fld (const u8 * sense_buffer,int sb_len,u64 * info_out);
drivers/scsi/scsi_error.c renamed from drivers/scsi/scsi_error.c.old +2 -4
@@ -1931,7 +1931,6 @@return 1 ; } -EXPORT_SYMBOL (scsi_normalize_sense);int scsi_request_normalize_sense (struct scsi_request *sreq,struct scsi_sense_hdr *sshdr)
@@ -1964,8 +1963,8 @@* Return value: * pointer to start of (first) descriptor if found else NULL **/ -const u8 *scsi_sense_desc_find (const u8 * sense_buffer,int sb_len, -int desc_type) +static const u8 *scsi_sense_desc_find (const u8 * sense_buffer,int sb_len, +int desc_type) {int add_sen_len, add_len, desc_len, k;const u8 * descp;
@@ -1988,7 +1987,6 @@ }return NULL ; } -EXPORT_SYMBOL (scsi_sense_desc_find);/** * scsi_get_sense_info_fld - attempts to get information field from
include/scsi/scsi_device.h renamed from include/scsi/scsi_device.h.old +0 -1
@@ -223,7 +223,6 @@extern int scsi_device_set_state (struct scsi_device *sdev,enum scsi_device_state state);extern int scsi_device_quiesce (struct scsi_device *sdev); -extern void scsi_device_resume (struct scsi_device *sdev);extern void scsi_target_quiesce (struct scsi_target *);extern void scsi_target_resume (struct scsi_target *);extern const char *scsi_device_state_name (enum scsi_device_state );
drivers/scsi/scsi_lib.c renamed from drivers/scsi/scsi_lib.c.old +2 -3
@@ -44,7 +44,7 @@#endif #define SP (x) { x, "sgpool-" #x } -struct scsi_host_sg_pool scsi_sg_pools[] = { +static struct scsi_host_sg_pool scsi_sg_pools[] = {SP (8 ),SP (16 ),SP (32 ),
@@ -1817,14 +1817,13 @@* * Must be called with user context, may sleep. **/ -void +static void scsi_device_resume (struct scsi_device *sdev) {if (scsi_device_set_state (sdev,SDEV_RUNNING ))return ;scsi_run_queue (sdev->request_queue); } -EXPORT_SYMBOL (scsi_device_resume);static void device_quiesce_fn (struct scsi_device *sdev,void *data)
include/scsi/scsi_host.h renamed from include/scsi/scsi_host.h.old +0 -2
@@ -569,8 +569,6 @@extern struct Scsi_Host *scsi_host_alloc (struct scsi_host_template *,int );extern int __must_check scsi_add_host (struct Scsi_Host *,struct device *);extern void scsi_scan_host (struct Scsi_Host *); -extern void scsi_scan_single_target (struct Scsi_Host *,unsigned int , -unsigned int );extern void scsi_rescan_device (struct device *);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);
drivers/scsi/scsi_scan.c renamed from drivers/scsi/scsi_scan.c.old +2 -1
@@ -1101,7 +1101,6 @@module_put (drv->owner); } } -EXPORT_SYMBOL (scsi_rescan_device);/** * scsi_scan_target - scan a target id, possibly including all LUNs on the
@@ -1238,12 +1237,14 @@* @chan: channel to scan * @id: target id to scan **/ +#if 0 void scsi_scan_single_target (struct Scsi_Host *shost,unsigned int chan,unsigned int id) {scsi_scan_host_selected (shost, chan, id,SCAN_WILD_CARD ,1 ); }EXPORT_SYMBOL (scsi_scan_single_target); +#endif /* 0 */ void scsi_forget_host (struct Scsi_Host *shost) {
drivers/scsi/scsi_sysfs.c renamed from drivers/scsi/scsi_sysfs.c.old +2 -2
@@ -150,7 +150,7 @@put_device (&sdev->sdev_gendev); } -void scsi_device_dev_release (struct device *dev) +static void scsi_device_dev_release (struct device *dev) {struct scsi_device *sdev;struct device *parent;
@@ -188,7 +188,7 @@put_device (parent); } -struct class sdev_class = { +static struct class sdev_class = { .name ="scsi_device" , .release = scsi_device_cls_release, };
Quoted 9 lines · Adrian Bunk
Before I'm getting flamed to death:
This patch contains possible cleanups. If parts of this patch conflict with pending changes these parts of my patch have to be dropped.This patch contains the following possible cleanups:
- make needlessly global code static
- remove or #if 0 the following unused functions:
-scsi.h:print_driverbyte
-scsi.h:print_hostbyte
these two please kill.
Quoted 2 lines
-
constants.c:scsi_print_hostbyte
-constants.c:scsi_print_driverbyte
these we'll probably keep for now.
Quoted 1 line
-
scsi_scan.c:scsi_scan_single_target
this one will grow a user soon, but maybe it'll be completely rewritten before.
Quoted 2 lines
- remove the following unneeded EXPORT_SYMBOL's:
-constants.c:__scsi_print_sense
this was put in for a drivea and makes sense as API.
Quoted 1 line
-
hosts.c:scsi_host_lookup
we should probably kill this export.
Quoted 2 lines
-
scsi.c:scsi_device_cancel
-scsi_lib.c:scsi_device_resume
dito.
Quoted 2 lines
-
scsi_error.c:scsi_normalize_sense
-scsi_error.c:scsi_sense_desc_find
st is expected to use these soon.
Quoted 1 line
-
scsi_scan.c:scsi_rescan_device
aacraid was going to use that one, Mark, any chance to get a patch anytime soon?
Quoted 1 line
-
scsi_scan.c:scsi_scan_single_target
as mentioned above we'll need this one soon.
Quoted 6 lines · Christoph Hellwig
...
Quoted 2 lines
-
constants.c:scsi_print_hostbyte
-constants.c:scsi_print_driverbytethese we'll probably keep for now.
...
keep = #if 0 ?
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 9 lines · Adrian Bunk
Quoted 6 lines · Christoph Hellwig
...
Quoted 2 lines
-
constants.c:scsi_print_hostbyte
-constants.c:scsi_print_driverbytethese we'll probably keep for now.
...keep = #if 0 ?
In this case yes, for the others case I want to keep them beeing built.
PATCH 1/1 SCSI: cleanups
Updated patch:
<-- snip -->
This patch contains the following cleanups:
- make needlessly global code static
- remove the following unused functions:
- scsi.h: print_driverbyte
- scsi.h: print_hostbyte
- #if 0 the following unused functions:
- constants.c: scsi_print_hostbyte
- constants.c: scsi_print_driverbyte
- remove the following unneeded EXPORT_SYMBOL's:
- hosts.c: scsi_host_lookup
- scsi.c: scsi_device_cancel
- scsi_lib.c: scsi_device_resume
---
drivers/scsi/constants.c | 4 ++++ drivers/scsi/hosts.c | 3 +-- drivers/scsi/scsi.c | 9 +++++---- drivers/scsi/scsi.h | 8 -------- drivers/scsi/scsi_debug.c | 2 +- drivers/scsi/scsi_lib.c | 5 ++--- drivers/scsi/scsi_priv.h | 4 ---- drivers/scsi/scsi_sysfs.c | 4 ++-- include/scsi/scsi_dbg.h | 2 -- include/scsi/scsi_device.h | 1 - 10 files changed, 15 insertions(+), 27 deletions(-)
drivers/scsi/scsi.h renamed from drivers/scsi/scsi.h.old +0 -8
@@ -80,14 +80,6 @@ {return scsi_print_req_sense (devclass, req); } -static inline void print_driverbyte (int scsiresult) -{ -return scsi_print_driverbyte (scsiresult); -} -static inline void print_hostbyte (int scsiresult) -{ -return scsi_print_hostbyte (scsiresult); -}static inline void print_status (unsigned char status) {return scsi_print_status (status);
include/scsi/scsi_dbg.h renamed from include/scsi/scsi_dbg.h.old +0 -2
@@ -11,8 +11,6 @@extern void __scsi_print_sense (const char *name,const unsigned char *sense_buffer,int sense_len); -extern void scsi_print_driverbyte (int ); -extern void scsi_print_hostbyte (int );extern void scsi_print_status (unsigned char );extern int scsi_print_msg (const unsigned char *);extern const char *scsi_sense_key_string (unsigned char );
drivers/scsi/constants.c renamed from drivers/scsi/constants.c.old +4 -0
@@ -1393,6 +1393,8 @@ }EXPORT_SYMBOL (scsi_print_command); +#if 0 +#ifdef CONFIG_SCSI_CONSTANTS static const char * hostbyte_table[]={
@@ -1446,3 +1448,5 @@printk ("Driverbyte=0x%02x " ,driver_byte (scsiresult)); }#endif + +#endif /* 0 */
drivers/scsi/hosts.c renamed from drivers/scsi/hosts.c.old +1 -2
@@ -56,7 +56,7 @@* @shost: pointer to struct Scsi_Host * recovery: recovery requested to run. **/ -void scsi_host_cancel (struct Scsi_Host *shost,int recovery) +static void scsi_host_cancel (struct Scsi_Host *shost,int recovery) {struct scsi_device *sdev;
@@ -362,7 +362,6 @@return shost; } -EXPORT_SYMBOL (scsi_host_lookup);/** * scsi_host_get - inc a Scsi_Host ref count
drivers/scsi/scsi_priv.h renamed from drivers/scsi/scsi_priv.h.old +0 -4
@@ -66,8 +66,6 @@extern int scsi_dispatch_cmd (struct scsi_cmnd *cmd);extern int scsi_setup_command_freelist (struct Scsi_Host *shost);extern void scsi_destroy_command_freelist (struct Scsi_Host *shost); -extern void scsi_done (struct scsi_cmnd *cmd); -extern int scsi_retry_command (struct scsi_cmnd *cmd);extern int scsi_insert_special_req (struct scsi_request *sreq,int );extern void scsi_init_cmd_from_req (struct scsi_cmnd *cmd,struct scsi_request *sreq);
@@ -141,7 +139,6 @@#endif /* CONFIG_SYSCTL */ /* scsi_sysfs.c */ -extern void scsi_device_dev_release (struct device *);extern int scsi_sysfs_add_sdev (struct scsi_device *);extern int scsi_sysfs_add_host (struct Scsi_Host *);extern int scsi_sysfs_register (void );
@@ -150,7 +147,6 @@extern int scsi_sysfs_target_initialize (struct scsi_device *);extern struct scsi_transport_template blank_transport_template; -extern struct class sdev_class;extern struct bus_type scsi_bus_type;/*
drivers/scsi/scsi.c renamed from drivers/scsi/scsi.c.old +5 -4
@@ -68,6 +68,8 @@#include "scsi_priv.h" #include "scsi_logging.h" +static void scsi_done (struct scsi_cmnd *cmd); +static int scsi_retry_command (struct scsi_cmnd *cmd);/* * Definitions and constants.
@@ -90,7 +92,7 @@/* * Data declarations. */ -unsigned long scsi_pid; +static unsigned long scsi_pid;static unsigned long serial_number;/*
@@ -733,7 +735,7 @@* * This function is interrupt context safe. */ -void scsi_done (struct scsi_cmnd *cmd) +static void scsi_done (struct scsi_cmnd *cmd) {/* * We don't have to worry about this one timing out any more.
@@ -829,7 +831,7 @@* level drivers should not become re-entrant as a result of * this. */ -int scsi_retry_command (struct scsi_cmnd *cmd) +static int scsi_retry_command (struct scsi_cmnd *cmd) {/* * Restore the SCSI command state.
@@ -1215,7 +1217,6 @@return 0 ; } -EXPORT_SYMBOL (scsi_device_cancel);#ifdef CONFIG_HOTPLUG_CPU static int scsi_cpu_notify(struct notifier_block *self,
drivers/scsi/scsi_debug.c renamed from drivers/scsi/scsi_debug.c.old +1 -1
@@ -1783,7 +1783,7 @@device_initcall (scsi_debug_init);module_exit (scsi_debug_exit); -void pseudo_0_release (struct device * dev) +static void pseudo_0_release (struct device * dev) {if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)printk (KERN_INFO "scsi_debug: pseudo_0_release() called\n" );
include/scsi/scsi_device.h renamed from include/scsi/scsi_device.h.old +0 -1
@@ -223,7 +223,6 @@extern int scsi_device_set_state (struct scsi_device *sdev,enum scsi_device_state state);extern int scsi_device_quiesce (struct scsi_device *sdev); -extern void scsi_device_resume (struct scsi_device *sdev);extern void scsi_target_quiesce (struct scsi_target *);extern void scsi_target_resume (struct scsi_target *);extern const char *scsi_device_state_name (enum scsi_device_state );
drivers/scsi/scsi_lib.c renamed from drivers/scsi/scsi_lib.c.old +2 -3
@@ -44,7 +44,7 @@#endif #define SP (x) { x, "sgpool-" #x } -struct scsi_host_sg_pool scsi_sg_pools[] = { +static struct scsi_host_sg_pool scsi_sg_pools[] = {SP (8 ),SP (16 ),SP (32 ),
@@ -1817,14 +1817,13 @@* * Must be called with user context, may sleep. **/ -void +static void scsi_device_resume (struct scsi_device *sdev) {if (scsi_device_set_state (sdev,SDEV_RUNNING ))return ;scsi_run_queue (sdev->request_queue); } -EXPORT_SYMBOL (scsi_device_resume);static void device_quiesce_fn (struct scsi_device *sdev,void *data)
drivers/scsi/scsi_sysfs.c renamed from drivers/scsi/scsi_sysfs.c.old +2 -2
@@ -150,7 +150,7 @@put_device (&sdev->sdev_gendev); } -void scsi_device_dev_release (struct device *dev) +static void scsi_device_dev_release (struct device *dev) {struct scsi_device *sdev;struct device *parent;
@@ -188,7 +188,7 @@put_device (parent); } -struct class sdev_class = { +static struct class sdev_class = { .name ="scsi_device" , .release = scsi_device_cls_release, };
Quoted 1 line · Adrian Bunk
Before I'm getting flamed to death:
Adrian,
I have a few comments below.
Quoted 7 lines
This patch contains possible cleanups. If parts of this patch conflict with pending changes these parts of my patch have to be dropped.
This patch contains the following possible cleanups:
- make needlessly global code static
- remove or #if 0 the following unused functions:
-scsi.h:print_driverbyte
-scsi.h:print_hostbyte
The names of the above are too general so they should go as soon as practical.
Quoted 2 lines
-
constants.c:scsi_print_hostbyte
-constants.c:scsi_print_driverbyte
I'm a bit surprised nothing else is using the above two.
Quoted 6 lines
-
scsi_scan.c:scsi_scan_single_target
- remove the following unneeded EXPORT_SYMBOL's:
-constants.c:__scsi_print_sense
-hosts.c:scsi_host_lookup
-scsi.c:scsi_device_cancel
-scsi_error.c:scsi_normalize_sense
I introduced scsi_normalize_sense() recently, Christoph H. proposed it should be static but Luben Tuikov (aic7xxx maintainer) said he wished to use it in the future. Hence it was left global.
Quoted 1 line
-
scsi_error.c:scsi_sense_desc_find
A pending patch on st from Kai M. will be using scsi_sense_desc_find(). I presume others will be using it in the future (e.g. SAT returns ATA status via a sense data descriptor with no corresponding fixed format representation).
Quoted 3 lines
-
scsi_lib.c:scsi_device_resume
-scsi_scan.c:scsi_rescan_device
-scsi_scan.c:scsi_scan_single_target
Doug Gilbert
Quoted 7 lines · Douglas Gilbert
Quoted 1 line
-
scsi_error.c:scsi_normalize_senseI introduced
scsi_normalize_sense()recently, Christoph H. proposed it should be static but Luben Tuikov (aic7xxx maintainer) said he wished to use it in the future. Hence it was left global.
Hi guys,
I think the idea of normalized sense is very good. Basically the question is if LLDD would submit normalized sense to SCSI Core or whether they would submit a pointer to raw sense data as returned by the device and let SCSI Core decipher it.
If the former, then it should be global, if the latter then it should be static to SCSI Core.
Luben
Quoted 11 lines · Luben Tuikov
Quoted 7 lines · Douglas Gilbert
Quoted 1 line
-
scsi_error.c:scsi_normalize_senseI introduced
scsi_normalize_sense()recently, Christoph H. proposed it should be static but Luben Tuikov (aic7xxx maintainer) said he wished to use it in the future. Hence it was left global.Hi guys,
Quoted 8 lines
I think the idea of normalized sense is very good. Basically the question is if LLDD would submit normalized sense to SCSI Core or whether they would submit a pointer to raw sense data as returned by the device and let SCSI Core decipher it.
If the former, then it should be global, if the latter then it should be static to SCSI Core.
Doing it in the core means less duplication and avoiding updating all drivers.
Quoted 2 lines · Christoph Hellwig
Doing it in the core means less duplication and avoiding updating all drivers.
I agree.
Luben