コード例 #1
0
ファイル: test.c プロジェクト: beback1986/MyGitProject
static int hello_init(void)
{
	uint64_t a = 1048576;
	uint32_t b = 4096;

	void (* func_p)(void);
/*	unsigned int cpu = get_cpu();
	struct module *mod;
	printk("this module: %p==%p\n", &__this_module, THIS_MODULE );
	printk("module state: %d\n", THIS_MODULE->state );
	printk("module name: %s\n", THIS_MODULE->name );
	list_for_each_entry(mod, *(&THIS_MODULE->list.prev), list )
		printk(KERN_ALERT "module name: %s\n", mod->name );*/
	func_p = __symbol_get("hello_func");
	printk("func_p's addr is %p\n", func_p);
	if(!func_p){
		printk("func can not find!\n");
	}
	else{
		__symbol_put("hello_func");
		func_p();
		printk("symbol exist. p=%p\n", func_p);
	}
	printk("a/b = %u.\n", a/b);
	return 0;
}
コード例 #2
0
ファイル: vfio_platform_common.c プロジェクト: DenisLug/mptcp
static void vfio_platform_get_reset(struct vfio_platform_device *vdev,
				    struct device *dev)
{
	const char *compat;
	int (*reset)(struct vfio_platform_device *);
	int ret, i;

	ret = device_property_read_string(dev, "compatible", &compat);
	if (ret)
		return;

	for (i = 0 ; i < ARRAY_SIZE(reset_lookup_table); i++) {
		if (!strcmp(reset_lookup_table[i].compat, compat)) {
			request_module(reset_lookup_table[i].module_name);
			reset = __symbol_get(
				reset_lookup_table[i].reset_function_name);
			if (reset) {
				vdev->reset = reset;
				return;
			}
		}
	}
}
コード例 #3
0
ファイル: memain_PCI.c プロジェクト: imrehg/meids
static int me_probe_pci(struct pci_dev* raw_dev, const struct pci_device_id* id)
{
	int err = ME_ERRNO_SUCCESS;
	struct pci_local_dev* dev;

	me_constr_t constructor = NULL;
	me_device_t* n_device = NULL;
	me_device_t* o_device = NULL;

	char constructor_name[20]="me0000_pci_constr\0";
	char module_name[16]="me0000PCI\0";

 	PDEBUG("executed.\n");

 	/// Allocate structures.
 	dev = kzalloc(sizeof(struct pci_local_dev), GFP_KERNEL);
	if (!dev)
	{
		PERROR("Can't get memory for device's instance.");
		err = -ENOMEM;
		goto ERROR;
	}

	/// Check this board
	if (me_pci_board_check(dev, raw_dev))
	{
		PERROR("NOT SUPPORTED! This is not Meilhaus board.\n");
		err = -ENODEV;
		goto ERROR;
	}

	constructor_name[2] += (char)((dev->device >> 12) & 0x000F);
	constructor_name[3] += (char)((dev->device >> 8) & 0x000F);
 	PDEBUG("constructor_name: %s\n", constructor_name);
	module_name[2] += (char)((dev->device >> 12) & 0x000F);
	module_name[3] += (char)((dev->device >> 8) & 0x000F);
	if (module_name[2] == '6')
	{// Exceptions: me61xx, me62xx, me63xx are handled by one driver.
		module_name[3] = '0';
	}
	if (module_name[2] == '4')
	{
		if (module_name[3] == '8')
		{// Exceptions: me46xx and me48xx are handled by one driver.
			module_name[3] = '6';
		}
		else if (module_name[3] == '5')
		{// Exceptions: me45xx and me47xx are handled by one driver.
			module_name[3] = '7';
		}
	}
 	PDEBUG("module_name: %s\n", module_name);

/**
	Choice:
	a) New device connected.  Add to device list.
	b) Old device reconected. Refresh device structure.
*/
	o_device = find_device_on_list(dev, ME_PLUGGED_ANY);
	if(o_device)
	{
		PDEBUG("Device already registred.\n");
		// Old device.
		if (o_device->bus.plugged == ME_PLUGGED_IN)
		{
			// Error device is already on list mark as active!
			PERROR("Device is already on list mark as active!\n");
			o_device->me_device_disconnect(o_device);
		}
	}
	else
	{
		PDEBUG("New device.\n");
	}
	constructor = (me_constr_t) __symbol_get(constructor_name);
	if (!constructor)
	{
		PDEBUG("request_module: '%s'.\n", module_name);
		if (!request_module("%s", module_name))
		{
			constructor = (me_constr_t) __symbol_get(constructor_name);
			if (!constructor)
			{
				if(o_device)
				{
					PERROR_CRITICAL("Module loaded. Failed to get %s driver module constructor!\n", module_name);
				}
				else
				{
					PERROR("Can't get %s driver module constructor.\n", module_name);
				}
				err = -ENODEV;
				goto ERROR;
			}
		}
		else
		{
			PERROR("Can't get requested module: %s.\n", module_name);
			err = -ENODEV;
			goto ERROR;
		}
	}

	n_device = (*constructor)(dev, o_device);
	if (!n_device)
	{
		PERROR("Executing '%s()' failed.\n", constructor_name);
		__symbol_put(constructor_name);
		err = -ENODEV;
		goto ERROR;
	}
	else if (!o_device)
	{
		insert_to_device_list(n_device);
	}

	if (n_device->me_device_postinit)
	{
		if (n_device->me_device_postinit(n_device, NULL))
		{
			PERROR("Error while calling me_device_postinit().\n");
			/// This error can be ignored.
		}
		else
		{
			PDEBUG("me_device_postinit() was sucessful.\n");
		}
	}
	else
	{
		PERROR("me_device_postinit() not registred!\n");
	}

ERROR:
	if (dev)
		kfree(dev);
	dev = NULL;

	return err;
}
コード例 #4
0
ファイル: docprobe.c プロジェクト: nighthawk149/fvs318g-cfw
static void __init DoC_Probe(unsigned long physadr)
{
	void __iomem *docptr;
	struct DiskOnChip *this;
	struct mtd_info *mtd;
	int ChipID;
	char namebuf[15];
	char *name = namebuf;
	char *im_funcname = NULL;
	char *im_modname = NULL;
	void (*initroutine)(struct mtd_info *) = NULL;

	docptr = ioremap(physadr, DOC_IOREMAP_LEN);

	if (!docptr)
		return;

	if ((ChipID = doccheck(docptr, physadr))) {
		if (ChipID == DOC_ChipID_Doc2kTSOP) {
			/* Remove this at your own peril. The hardware driver works but nothing prevents you from erasing bad blocks */
			printk(KERN_NOTICE "Refusing to drive DiskOnChip 2000 TSOP until Bad Block Table is correctly supported by INFTL\n");
			iounmap(docptr);
			return;
		}
		docfound = 1;
		mtd = kmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);

		if (!mtd) {
			printk(KERN_WARNING "Cannot allocate memory for data structures. Dropping.\n");
			iounmap(docptr);
			return;
		}

		this = (struct DiskOnChip *)(&mtd[1]);

		memset((char *)mtd,0, sizeof(struct mtd_info));
		memset((char *)this, 0, sizeof(struct DiskOnChip));

		mtd->priv = this;
		this->virtadr = docptr;
		this->physadr = physadr;
		this->ChipID = ChipID;
		sprintf(namebuf, "with ChipID %2.2X", ChipID);

		switch(ChipID) {
		case DOC_ChipID_Doc2kTSOP:
			name="2000 TSOP";
			im_funcname = "DoC2k_init";
			im_modname = "doc2000";
			break;

		case DOC_ChipID_Doc2k:
			name="2000";
			im_funcname = "DoC2k_init";
			im_modname = "doc2000";
			break;

		case DOC_ChipID_DocMil:
			name="Millennium";
#ifdef DOC_SINGLE_DRIVER
			im_funcname = "DoC2k_init";
			im_modname = "doc2000";
#else
			im_funcname = "DoCMil_init";
			im_modname = "doc2001";
#endif /* DOC_SINGLE_DRIVER */
			break;

		case DOC_ChipID_DocMilPlus16:
		case DOC_ChipID_DocMilPlus32:
			name="MillenniumPlus";
			im_funcname = "DoCMilPlus_init";
			im_modname = "doc2001plus";
			break;
		}

		if (im_funcname) {
			if (!request_module("%s", im_modname))
				goto fail;
			
			initroutine = __symbol_get(im_funcname);
		}
		
		if (initroutine) {
			(*initroutine)(mtd);
			symbol_put(im_funcname);
			return;
		}
fail:
		printk(KERN_NOTICE "Cannot find driver for DiskOnChip %s at 0x%lX\n", name, physadr);
		kfree(mtd);
	}
	iounmap(docptr);
}