/* ccw_device_clear() calls csch on @cdev's subchannel. Returns: %0 on success, -ENODEV on device not operational, -EINVAL on invalid device state. Context: Interrupts disabled, ccw device lock held  */
int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
/* ccw_device_clear() calls csch on @cdev's subchannel. Returns: %0 on success, -ENODEV on device not operational, -EINVAL on invalid device state. Context: Interrupts disabled, ccw device lock held  */
int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
{
	struct subchannel *sch;
	int ret;
	if (!cdev || !cdev->dev.parent)
		return -ENODEV;
	sch = to_subchannel(cdev->dev.parent);
	if (!sch->schib.pmcw.ena)
		return -EINVAL;
	if (cdev->private->state == DEV_STATE_NOT_OPER)
		return -ENODEV;
	if (cdev->private->state != DEV_STATE_ONLINE &&
	    cdev->private->state != DEV_STATE_W4SENSE)
		return -EINVAL;
	ret = cio_clear(sch);
	if (ret == 0)
		cdev->private->intparm = intparm;
	return ret;
}