diff options
author | James.Smart@Emulex.Com <James.Smart@Emulex.Com> | 2005-10-28 20:29:32 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-10-29 11:21:26 -0400 |
commit | 93a20f74450ca3402b3ba89fb490114cf6f2d353 (patch) | |
tree | fd0285b3d699c350dc82fbb815d05cad26a19243 | |
parent | f91b392c4d20fcd2684587c0a091123c0409959c (diff) |
[SCSI] lpfc: Restore HEX safe bahavior of the sysfs xxx_store functions.
Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 98326811739a..89e8222bc7cc 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -291,6 +291,18 @@ lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | |||
291 | phba->cfg_##attr);\ | 291 | phba->cfg_##attr);\ |
292 | } | 292 | } |
293 | 293 | ||
294 | #define lpfc_param_hex_show(attr) \ | ||
295 | static ssize_t \ | ||
296 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | ||
297 | { \ | ||
298 | struct Scsi_Host *host = class_to_shost(cdev);\ | ||
299 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];\ | ||
300 | int val = 0;\ | ||
301 | val = phba->cfg_##attr;\ | ||
302 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ | ||
303 | phba->cfg_##attr);\ | ||
304 | } | ||
305 | |||
294 | #define lpfc_param_init(attr, default, minval, maxval) \ | 306 | #define lpfc_param_init(attr, default, minval, maxval) \ |
295 | static int \ | 307 | static int \ |
296 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ | 308 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ |
@@ -329,8 +341,10 @@ lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ | |||
329 | struct Scsi_Host *host = class_to_shost(cdev);\ | 341 | struct Scsi_Host *host = class_to_shost(cdev);\ |
330 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];\ | 342 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];\ |
331 | int val=0;\ | 343 | int val=0;\ |
332 | if (sscanf(buf, "%d", &val) != 1)\ | 344 | if (!isdigit(buf[0]))\ |
333 | return -EPERM;\ | 345 | return -EINVAL;\ |
346 | if (sscanf(buf, "%i", &val) != 1)\ | ||
347 | return -EINVAL;\ | ||
334 | if (lpfc_##attr##_set(phba, val) == 0) \ | 348 | if (lpfc_##attr##_set(phba, val) == 0) \ |
335 | return strlen(buf);\ | 349 | return strlen(buf);\ |
336 | else \ | 350 | else \ |
@@ -362,6 +376,25 @@ lpfc_param_store(name)\ | |||
362 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ | 376 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
363 | lpfc_##name##_show, lpfc_##name##_store) | 377 | lpfc_##name##_show, lpfc_##name##_store) |
364 | 378 | ||
379 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ | ||
380 | static int lpfc_##name = defval;\ | ||
381 | module_param(lpfc_##name, int, 0);\ | ||
382 | MODULE_PARM_DESC(lpfc_##name, desc);\ | ||
383 | lpfc_param_hex_show(name)\ | ||
384 | lpfc_param_init(name, defval, minval, maxval)\ | ||
385 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) | ||
386 | |||
387 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ | ||
388 | static int lpfc_##name = defval;\ | ||
389 | module_param(lpfc_##name, int, 0);\ | ||
390 | MODULE_PARM_DESC(lpfc_##name, desc);\ | ||
391 | lpfc_param_hex_show(name)\ | ||
392 | lpfc_param_init(name, defval, minval, maxval)\ | ||
393 | lpfc_param_set(name, defval, minval, maxval)\ | ||
394 | lpfc_param_store(name)\ | ||
395 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ | ||
396 | lpfc_##name##_show, lpfc_##name##_store) | ||
397 | |||
365 | static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); | 398 | static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
366 | static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); | 399 | static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
367 | static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); | 400 | static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
@@ -403,7 +436,7 @@ static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR, | |||
403 | # LOG_LIBDFC 0x2000 LIBDFC events | 436 | # LOG_LIBDFC 0x2000 LIBDFC events |
404 | # LOG_ALL_MSG 0xffff LOG all messages | 437 | # LOG_ALL_MSG 0xffff LOG all messages |
405 | */ | 438 | */ |
406 | LPFC_ATTR_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask"); | 439 | LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask"); |
407 | 440 | ||
408 | /* | 441 | /* |
409 | # lun_queue_depth: This parameter is used to limit the number of outstanding | 442 | # lun_queue_depth: This parameter is used to limit the number of outstanding |