On 09/01/13 18:49, Christoph Hellwig wrote:
On Tue, Aug 20, 2013 at 02:08:39PM +0200, Bart Van Assche wrote:
Changing the state of a SCSI device via sysfs into "cancel",
"cancel-offline" or "deleted" prevents removal of these devices by
scsi_remove_host(). Hence do not allow this.
Looks good modulo a minor style nipick below.
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
+ if (state == 0 || state == SDEV_CANCEL ||
+ state == SDEV_CANCEL_OFFLINE || state == SDEV_DEL ||
+ scsi_device_set_state(sdev, state) != 0)
return -EINVAL;
Doing a switch on the state would be a lot more readable here:
switch (state) {
case 0:
case SDEV_CANCEL:
case SDEV_CANCEL_OFFLINE:
case SDEV_DEL:
ret = -EINVAL;
break;
default:
ret = scsi_device_set_state(sdev, state);
}
if (ret)
return ret;
return count;
}
Do you agree with changing switch (state) into switch ((int)state) ?
Without that additional change gcc reports the following warning:
drivers/scsi/scsi_sysfs.c: In function ‘store_state_field’:
drivers/scsi/scsi_sysfs.c:640:2: warning: case value ‘0’ not in
enumerated type ‘enum scsi_device_state’ [-Wswitch]
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html