new_part = (struct nvram_partition *) kmalloc(sizeof(struct nvram_partition), GFP_KERNEL); 
new_part = kmalloc(sizeof(*new_part), GFP_KERNEL); 
static int nvram_create_os_partition(void){	struct list_head * p;	struct nvram_partition * part;	struct nvram_partition * new_part = NULL;	struct nvram_partition * free_part = NULL;	int seq_init[2] = { 0, 0 };	loff_t tmp_index;	long size = 0;	int rc;		/* Find a free partition that will give us the maximum needed size 	   If can't find one that will give us the minimum size needed */	list_for_each(p, &nvram_part->partition) {		part = list_entry(p, struct nvram_partition, partition);		if (part->header.signature != NVRAM_SIG_FREE)			continue;		if (part->header.length >= NVRAM_MAX_REQ) {			size = NVRAM_MAX_REQ;			free_part = part;			break;		}		if (!size && part->header.length >= NVRAM_MIN_REQ) {			size = NVRAM_MIN_REQ;			free_part = part;		}	}	if (!size) {		return -ENOSPC;	}		/* Create our OS partition */	new_part = (struct nvram_partition *)		kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);	if (!new_part) {		printk(KERN_ERR "nvram_create_os_partition: kmalloc failed\n");		return -ENOMEM;	}	new_part->index = free_part->index;	new_part->header.signature = NVRAM_SIG_OS;	new_part->header.length = size;	sprintf(new_part->header.name, "ppc64,linux");	new_part->header.checksum = nvram_checksum(&new_part->header);	rc = nvram_write_header(new_part);	if (rc <= 0) {		printk(KERN_ERR "nvram_create_os_partition: nvram_write_header \				failed (%d)\n", rc);		return rc;	}	/* make sure and initialize to zero the sequence number and the error	   type logged */	tmp_index = new_part->index + NVRAM_HEADER_LEN;	rc = ppc_md.nvram_write((char *)&seq_init, sizeof(seq_init), &tmp_index);	if (rc <= 0) {		printk(KERN_ERR "nvram_create_os_partition: nvram_write failed (%d)\n", rc);		return rc;	}		nvram_error_log_index = new_part->index + NVRAM_HEADER_LEN;	nvram_error_log_size = ((part->header.length - 1) *				NVRAM_BLOCK_LEN) - sizeof(struct err_log_info);		list_add_tail(&new_part->partition, &free_part->partition);	if (free_part->header.length <= size) {		list_del(&free_part->partition);		kfree(free_part);		return 0;	} 	/* Adjust the partition we stole the space from */	free_part->index += size * NVRAM_BLOCK_LEN;	free_part->header.length -= size;	free_part->header.checksum = nvram_checksum(&free_part->header);		rc = nvram_write_header(free_part);	if (rc <= 0) {		printk(KERN_ERR "nvram_create_os_partition: nvram_write_header "		       "failed (%d)\n", rc);		return rc;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/0339ad77c4a06fa8529db17c91f790058e18b65b/nvram.c/clean/arch/ppc64/kernel/nvram.c