forked from Minki/linux
scsi: mptfusion: Use snprintf() instead of open coded divisions
Numbers up to 100 snprintf() prints without using a division. Besides that the code looks more readable. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
61dfb8a5fb
commit
332b4b2a6f
@ -2481,24 +2481,13 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
|
||||
else
|
||||
karg.host_no = -1;
|
||||
|
||||
/* Reformat the fw_version into a string
|
||||
*/
|
||||
karg.fw_version[0] = ioc->facts.FWVersion.Struct.Major >= 10 ?
|
||||
((ioc->facts.FWVersion.Struct.Major / 10) + '0') : '0';
|
||||
karg.fw_version[1] = (ioc->facts.FWVersion.Struct.Major % 10 ) + '0';
|
||||
karg.fw_version[2] = '.';
|
||||
karg.fw_version[3] = ioc->facts.FWVersion.Struct.Minor >= 10 ?
|
||||
((ioc->facts.FWVersion.Struct.Minor / 10) + '0') : '0';
|
||||
karg.fw_version[4] = (ioc->facts.FWVersion.Struct.Minor % 10 ) + '0';
|
||||
karg.fw_version[5] = '.';
|
||||
karg.fw_version[6] = ioc->facts.FWVersion.Struct.Unit >= 10 ?
|
||||
((ioc->facts.FWVersion.Struct.Unit / 10) + '0') : '0';
|
||||
karg.fw_version[7] = (ioc->facts.FWVersion.Struct.Unit % 10 ) + '0';
|
||||
karg.fw_version[8] = '.';
|
||||
karg.fw_version[9] = ioc->facts.FWVersion.Struct.Dev >= 10 ?
|
||||
((ioc->facts.FWVersion.Struct.Dev / 10) + '0') : '0';
|
||||
karg.fw_version[10] = (ioc->facts.FWVersion.Struct.Dev % 10 ) + '0';
|
||||
karg.fw_version[11] = '\0';
|
||||
/* Reformat the fw_version into a string */
|
||||
snprintf(karg.fw_version, sizeof(karg.fw_version),
|
||||
"%.2hhu.%.2hhu.%.2hhu.%.2hhu",
|
||||
ioc->facts.FWVersion.Struct.Major,
|
||||
ioc->facts.FWVersion.Struct.Minor,
|
||||
ioc->facts.FWVersion.Struct.Unit,
|
||||
ioc->facts.FWVersion.Struct.Dev);
|
||||
|
||||
/* Issue a config request to get the device serial number
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user