All pastes #443125 Raw Edit

matteo

public c v1 · immutable
·published 2007-04-16 17:23 UTC
rendered paste body
// the code:int shim_osLoadFWImageOLD(unsigned char *ptr){  unsigned int bytesRead;  mm_segment_t  oldfs;    static struct file *filp;  unsigned int imageLength=0x4ffff;           dprintf(4, "tn7dsl_read_dsp()\n");  dprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);    filp=filp_open(DSP_FIRMWARE_PATH                                  ,00,O_RDONLY);        if(filp ==NULL)  {    printk("Failed: Could not open DSP binary file\n");          return -1;  }        if (filp->f_op->read==NULL)          return -1;  /* File(system) doesn't allow reads */        /* Now read bytes from postion "StartPos" */        filp->f_pos = 0;  oldfs = get_fs();        set_fs(KERNEL_DS);        bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);  dprintf(4,"file length = %d\n", bytesRead);  set_fs(oldfs);        /* Close the file */        fput(filp);       return bytesRead;}static struct device avsar = {	.bus_id    = "vlynq",};int shim_osLoadFWImage(unsigned char *ptr){	const char *file = "ar0700xx";	const struct firmware *fw_entry;	printk("requesting firmware image '%s'\n", file);	if(request_firmware(&fw_entry, file, &avsar)) {/*		printk(KERN_ERR				"avsar: Firmware not available\n");		return -1;*/		printk(KERN_ERR				"avsar: Firmware not available, calling old function...\n");		return shim_osLoadFWImageOLD(ptr);	}	if(fw_entry->size > 0x4ffff) {			printk(KERN_ERR			"avsar: Firmware too big (%d bytes), calling old function...\n", fw_entry->size);			return -1;		}	memcpy(ptr, fw_entry->data, fw_entry->size);	release_firmware(fw_entry);	return fw_entry->size;}/* the result:requesting firmware image 'ar0700xx'BUG: warning at lib/kref.c:32/kref_get()Call Trace:[<9410a940>] dump_stack+0x8/0x34[<941fc068>] kref_get+0x44/0xdc[<941fb188>] kobject_get+0x20/0x34[<941b7380>] sysfs_create_link+0xec/0x16c[<9422c830>] class_device_add+0x254/0x560[<942309a0>] _request_firmware+0x170/0x494[<c010bbdc>] shim_osLoadFWImage+0x50/0xf0 [tiatm][<c01135a0>] dslhal_api_dslStartup+0x100/0x320 [tiatm][<c010c494>] tn7dsl_init+0x50/0x65c [tiatm][<c00a0180>] tn7atm_detect+0x180/0x54c [tiatm][<94148c14>] sys_init_module+0x1628/0x18a0[<9410cc00>] stack_done+0x20/0x3cfw_register_class_device: class_device_register failedavsar: Firmware not available, calling old function... */