From 8668b22ae8fe45f1e76cf4f4e3d8ee048720726e Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Wed, 21 Jul 2010 16:08:34 +0000 Subject: [PATCH] Set max_cmd_len correctly depending on the size of the field. In earlier versions of Linux it was an unsigned char, and a value of 260 means 4 after a compiler warning. Added a comment to describe what is going on as well. Since this is done very infequently it should not cause performance problems and means that it will not silently fail to work if people try to use it on kernels earlier than 2.6.26. If I figure out what kernel version the change was made in we could use an ifdef. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1852 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst_local/scst_local.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 1e8868e96..81772cf87 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -988,7 +988,16 @@ static int scst_fake_lld_driver_probe(struct device *dev) hpnt->max_id = scst_local_num_tgts; hpnt->max_lun = scst_local_max_luns - 1; - hpnt->max_cmd_len = 260; + /* + * Because of a change in the size of this field around 2.6.26 + * we use this check ... it allows us to work on earlier + * kernels. If we don't, the max_cmd_size gets set to 4 (and we get + * a compiler warning) so a scan never occurs. + */ + if (sizeof(hpnt->max_cmd_len) == sizeof(unsigned char)) + hpnt->max_cmd_len = 16; + else + hpnt->max_cmd_len = 260; ret = scsi_add_host(hpnt, &scst_lcl_host->dev); if (ret) {