dcssblk_add_store(struct device *dev, const char *buf, size_t count) 
dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 
dcssblk_add_store(struct device *dev, const char *buf, size_t count){	int rc, i;	struct dcssblk_dev_info *dev_info;	char *local_buf;	unsigned long seg_byte_size;	dev_info = NULL;	if (dev != dcssblk_root_dev) {		rc = -EINVAL;		goto out_nobuf;	}	local_buf = kmalloc(count + 1, GFP_KERNEL);	if (local_buf == NULL) {		rc = -ENOMEM;		goto out_nobuf;	}	/*	 * parse input	 */	for (i = 0; ((buf[i] != '\0') && (buf[i] != '\n') && i < count); i++) {		local_buf[i] = toupper(buf[i]);	}	local_buf[i] = '\0';	if ((i == 0) || (i > 8)) {		rc = -ENAMETOOLONG;		goto out;	}	/*	 * already loaded?	 */	down_read(&dcssblk_devices_sem);	dev_info = dcssblk_get_device_by_name(local_buf);	up_read(&dcssblk_devices_sem);	if (dev_info != NULL) {		PRINT_WARN("Segment %s already loaded!\n", local_buf);		rc = -EEXIST;		goto out;	}	/*	 * get a struct dcssblk_dev_info	 */	dev_info = kmalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL);	if (dev_info == NULL) {		rc = -ENOMEM;		goto out;	}	memset(dev_info, 0, sizeof(struct dcssblk_dev_info));	strcpy(dev_info->segment_name, local_buf);	strlcpy(dev_info->dev.bus_id, local_buf, BUS_ID_SIZE);	dev_info->dev.release = dcssblk_release_segment;	INIT_LIST_HEAD(&dev_info->lh);	dev_info->gd = alloc_disk(DCSSBLK_MINORS_PER_DISK);	if (dev_info->gd == NULL) {		rc = -ENOMEM;		goto free_dev_info;	}	dev_info->gd->major = dcssblk_major;	dev_info->gd->fops = &dcssblk_devops;	dev_info->dcssblk_queue = blk_alloc_queue(GFP_KERNEL);	dev_info->gd->queue = dev_info->dcssblk_queue;	dev_info->gd->private_data = dev_info;	dev_info->gd->driverfs_dev = &dev_info->dev;	/*	 * load the segment	 */	rc = segment_load(local_buf, SEGMENT_SHARED,				&dev_info->start, &dev_info->end);	if (rc < 0) {		dcssblk_segment_warn(rc, dev_info->segment_name);		goto dealloc_gendisk;	}	seg_byte_size = (dev_info->end - dev_info->start + 1);	set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors	PRINT_INFO("Loaded segment %s, size = %lu Byte, "		   "capacity = %lu (512 Byte) sectors\n", local_buf,		   seg_byte_size, seg_byte_size >> 9);	dev_info->segment_type = rc;	dev_info->save_pending = 0;	dev_info->is_shared = 1;	dev_info->dev.parent = dcssblk_root_dev;	/*	 * get minor, add to list	 */	down_write(&dcssblk_devices_sem);	rc = dcssblk_assign_free_minor(dev_info);	if (rc) {		up_write(&dcssblk_devices_sem);		PRINT_ERR("No free minor number available! "			  "Unloading segment...\n");		goto unload_seg;	}	sprintf(dev_info->gd->disk_name, "dcssblk%d",		dev_info->gd->first_minor);	list_add_tail(&dev_info->lh, &dcssblk_devices);	if (!try_module_get(THIS_MODULE)) {		rc = -ENODEV;		goto list_del;	}	/*	 * register the device	 */	rc = device_register(&dev_info->dev);	if (rc) {		PRINT_ERR("Segment %s could not be registered RC=%d\n",				local_buf, rc);		module_put(THIS_MODULE);		goto list_del;	}	get_device(&dev_info->dev);	rc = device_create_file(&dev_info->dev, &dev_attr_shared);	if (rc)		goto unregister_dev;	rc = device_create_file(&dev_info->dev, &dev_attr_save);	if (rc)		goto unregister_dev;	add_disk(dev_info->gd);	blk_queue_make_request(dev_info->dcssblk_queue, dcssblk_make_request);	blk_queue_hardsect_size(dev_info->dcssblk_queue, 4096);	switch (dev_info->segment_type) {		case SEG_TYPE_SR:		case SEG_TYPE_ER:		case SEG_TYPE_SC:			set_disk_ro(dev_info->gd,1);			break;		default:			set_disk_ro(dev_info->gd,0);			break;	}	PRINT_DEBUG("Segment %s loaded successfully\n", local_buf);	up_write(&dcssblk_devices_sem);	rc = count;	goto out;unregister_dev:	PRINT_ERR("device_create_file() failed!\n");	list_del(&dev_info->lh);	blk_put_queue(dev_info->dcssblk_queue);	dev_info->gd->queue = NULL;	put_disk(dev_info->gd);	device_unregister(&dev_info->dev);	segment_unload(dev_info->segment_name);	put_device(&dev_info->dev);	up_write(&dcssblk_devices_sem);	goto out;list_del:	list_del(&dev_info->lh);	up_write(&dcssblk_devices_sem);unload_seg:	segment_unload(local_buf);dealloc_gendisk:	blk_put_queue(dev_info->dcssblk_queue);	dev_info->gd->queue = NULL;	put_disk(dev_info->gd);free_dev_info:	kfree(dev_info);out:	kfree(local_buf);out_nobuf:	return rc;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e404e274f62665f3333d6a539d0d3701f678a598/dcssblk.c/clean/drivers/s390/block/dcssblk.c