On 7/27/19 5:37 AM, Douglas Gilbert wrote: > Replace SCSI_LOG_TIMEOUT macros with SG_LOG macros across the driver. > The definition of SG_LOG calls SCSI_LOG_TIMEOUT if given and derived > pointers are non-zero, calls pr_info otherwise. SG_LOGS additionally > prints the sg device name and the thread id. The thread id is very > useful, even in single threaded invocations because the driver not > only uses the invocer's thread but also uses work queues and the > main callback (i.e. sg_rq_end_io()) may hit any thread. Some > interesting cases arise when the callback hits its invocer's > thread. > > SG_LOGS takes 48 bytes on the stack to build this printf format > string: "sg%u: tid=%d" whose size is clearly bounded above by > the maximum size of those two integers. > Protecting against the 'current' pointer being zero is for safety > and the case where the boot device is SCSI and the sg driver is > built into the kernel. Also when debugging, getting a message > from a compromised kernel can be very useful in pinpointing the > location of the failure. > > The simple fact that the SG_LOG macro is shorter than > SCSI_LOG_TIMEOUT macro allow more error message "payload" per line. > > Also replace #if and #ifdef conditional compilations with > the IS_ENABLED macro. > > Signed-off-by: Douglas Gilbert <dgilbert@xxxxxxxxxxxx> > --- > drivers/scsi/sg.c | 252 +++++++++++++++++++++++----------------------- > 1 file changed, 125 insertions(+), 127 deletions(-) > Reviewed-by: Hannes Reinecke <hare@xxxxxxxx> Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@xxxxxxx +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)