Beispiel #1
0
int parport_device_proc_register(struct pardevice *device)
{
	struct parport_device_sysctl_table *t;
	struct parport * port = device->port;
	
	t = kmalloc(sizeof(*t), GFP_KERNEL);
	if (t == NULL)
		return -ENOMEM;
	memcpy(t, &parport_device_sysctl_template, sizeof(*t));

	t->dev_dir[0].child = t->parport_dir;
	t->parport_dir[0].child = t->port_dir;
	t->port_dir[0].procname = port->name;
	t->port_dir[0].ctl_name = port->number + 1; /* nb 0 isn't legal here */
	t->port_dir[0].child = t->devices_root_dir;
	t->devices_root_dir[0].child = t->device_dir;

#ifdef CONFIG_PARPORT_1284

	t->device_dir[0].ctl_name =
		parport_device_num(port->number, port->muxport,
				   device->daisy)
		+ 1;  /* nb 0 isn't legal here */ 

#else /* No IEEE 1284 support */

	/* parport_device_num isn't available. */
	t->device_dir[0].ctl_name = 1;
	
#endif /* IEEE 1284 support or not */

	t->device_dir[0].procname = device->name;
	t->device_dir[0].extra1 = device;
	t->device_dir[0].child = t->vars;
	t->vars[0].data = &device->timeslice;

	t->sysctl_header = register_sysctl_table(t->dev_dir, 0);
	if (t->sysctl_header == NULL) {
		kfree(t);
		t = NULL;
	}
	device->sysctl_table = t;
	return 0;
}
Beispiel #2
0
void coda_sysctl_init()
{
	reset_coda_vfs_stats();
	reset_coda_cache_inv_stats();

#ifdef CONFIG_PROC_FS
	proc_fs_coda = proc_mkdir("coda", proc_root_fs);
	if (proc_fs_coda) {
		proc_fs_coda->owner = THIS_MODULE;
		coda_proc_create("vfs_stats", coda_vfs_stats_get_info);
		coda_proc_create("cache_inv_stats", coda_cache_inv_stats_get_info);
	}
#endif

#ifdef CONFIG_SYSCTL
	if ( !fs_table_header )
		fs_table_header = register_sysctl_table(fs_table, 0);
#endif 
}
Beispiel #3
0
void coda_sysctl_init()
{
	memset(&coda_callstats, 0, sizeof(coda_callstats));
	reset_coda_vfs_stats();
	reset_coda_upcall_stats();
	reset_coda_permission_stats();
	reset_coda_cache_inv_stats();

#ifdef CONFIG_PROC_FS
	proc_register(&proc_root_fs,&proc_fs_coda);
	proc_register(&proc_fs_coda,&proc_coda_vfs);
	proc_register(&proc_fs_coda,&proc_coda_upcall);
	proc_register(&proc_fs_coda,&proc_coda_permission);
	proc_register(&proc_fs_coda,&proc_coda_cache_inv);
#endif

#ifdef CONFIG_SYSCTL
	if ( !fs_table_header )
		fs_table_header = register_sysctl_table(fs_table, 0);
#endif 
}
Beispiel #4
0
static int
cmm_init (void)
{
	int rc = -ENOMEM;

#ifdef CONFIG_CMM_PROC
	cmm_sysctl_header = register_sysctl_table(cmm_dir_table);
	if (!cmm_sysctl_header)
		goto out;
#endif
#ifdef CONFIG_CMM_IUCV
	rc = smsg_register_callback(SMSG_PREFIX, cmm_smsg_target);
	if (rc < 0)
		goto out_smsg;
#endif
	rc = register_oom_notifier(&cmm_oom_nb);
	if (rc < 0)
		goto out_oom_notify;
	init_waitqueue_head(&cmm_thread_wait);
	init_timer(&cmm_timer);
	cmm_thread_ptr = kthread_run(cmm_thread, NULL, "cmmthread");
	rc = IS_ERR(cmm_thread_ptr) ? PTR_ERR(cmm_thread_ptr) : 0;
	if (!rc)
		goto out;
	/*
	 * kthread_create failed. undo all the stuff from above again.
	 */
	unregister_oom_notifier(&cmm_oom_nb);

out_oom_notify:
#ifdef CONFIG_CMM_IUCV
	smsg_unregister_callback(SMSG_PREFIX, cmm_smsg_target);
out_smsg:
#endif
#ifdef CONFIG_CMM_PROC
	unregister_sysctl_table(cmm_sysctl_header);
#endif
out:
	return rc;
}
Beispiel #5
0
static int __init init_nlm(void)
{
	int err;

#ifdef CONFIG_SYSCTL
	err = -ENOMEM;
	nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
	if (nlm_sysctl_table == NULL)
		goto err_sysctl;
#endif
	err = register_pernet_subsys(&lockd_net_ops);
	if (err)
		goto err_pernet;
	return 0;

err_pernet:
#ifdef CONFIG_SYSCTL
	unregister_sysctl_table(nlm_sysctl_table);
#endif
err_sysctl:
	return err;
}
Beispiel #6
0
static int
cmm_init (void)
{
	int rc;

	/* Prevent logical cpu 0 from being set offline. */
	rc = smp_get_cpu(cpumask_of_cpu(0));
	if (rc) {
		printk(KERN_ERR "CMM: unable to reserve cpu 0\n");
		return rc;
	}
#ifdef CONFIG_CMM_PROC
	cmm_sysctl_header = register_sysctl_table(cmm_dir_table, 1);
#endif
#ifdef CONFIG_CMM_IUCV
	smsg_register_callback(SMSG_PREFIX, cmm_smsg_target);
#endif
	INIT_WORK(&cmm_thread_starter, (void *) cmm_start_thread, 0);
	init_waitqueue_head(&cmm_thread_wait);
	init_timer(&cmm_timer);
	return 0;
}
Beispiel #7
0
static int
cmm_init (void)
{
	int rc = -ENOMEM;

#ifdef CONFIG_CMM_PROC
	cmm_sysctl_header = register_sysctl_table(cmm_dir_table, 1);
	if (!cmm_sysctl_header)
		goto out;
#endif
#ifdef CONFIG_CMM_IUCV
	rc = smsg_register_callback(SMSG_PREFIX, cmm_smsg_target);
	if (rc < 0)
		goto out_smsg;
#endif
	rc = register_oom_notifier(&cmm_oom_nb);
	if (rc < 0)
		goto out_oom_notify;
	cmm_thread_ptr = kthread_run(cmm_thread, NULL, "cmmthread");
	rc = IS_ERR(cmm_thread_ptr) ? PTR_ERR(cmm_thread_ptr) : 0;
	if (rc)
		goto out_kthread;
	return 0;

out_kthread:
	unregister_oom_notifier(&cmm_oom_nb);
out_oom_notify:
#ifdef CONFIG_CMM_IUCV
	smsg_unregister_callback(SMSG_PREFIX, cmm_smsg_target);
out_smsg:
#endif
#ifdef CONFIG_CMM_PROC
	unregister_sysctl_table(cmm_sysctl_header);
out:
#endif
	del_timer_sync(&cmm_timer);
	return rc;
}
int __init h3600_stowaway_init_module( void )
{
        /* register our character device */
        SFDEBUG(0,"registering char device\n");

        g_stowaway_major = devfs_register_chrdev(0, H3600_STOWAWAY_MODULE_NAME, &stowaway_fops);
        if (g_stowaway_major < 0) {
                printk(KERN_ALERT __FUNCTION__ ": can't get major number\n");
                return g_stowaway_major;
        }

        devfs_stowaway = devfs_register( NULL, H3600_STOWAWAY_DEVICE_NAME, 
					 DEVFS_FL_DEFAULT, g_stowaway_major, 
					 0, S_IFCHR | S_IRUSR | S_IWUSR, &stowaway_fops, NULL );

	/* Register in /proc filesystem */
	create_proc_read_entry(H3600_STOWAWAY_PROC_STATS, 0, proc_dir, 
			       h3600_stowaway_proc_stats_read, NULL );

	h3600_stowaway_sysctl_header = register_sysctl_table(h3600_stowaway_dir_table, 0);

	return 0;
}
Beispiel #9
0
int parport_proc_register(struct parport *port)
{
	struct parport_sysctl_table *t;
	int i;

	t = kmalloc(sizeof(*t), GFP_KERNEL);
	if (t == NULL)
		return -ENOMEM;
	memcpy(t, &parport_sysctl_template, sizeof(*t));

	t->device_dir[0].extra1 = port;

	for (i = 0; i < 8; i++)
		t->vars[i].extra1 = port;

	t->vars[0].data = &port->spintime;
	t->vars[5].child = t->device_dir;
	
	for (i = 0; i < 5; i++)
		t->vars[6 + i].extra2 = &port->probe_info[i];

	t->port_dir[0].procname = port->name;
	t->port_dir[0].ctl_name = port->number + 1; /* nb 0 isn't legal here */

	t->port_dir[0].child = t->vars;
	t->parport_dir[0].child = t->port_dir;
	t->dev_dir[0].child = t->parport_dir;

	t->sysctl_header = register_sysctl_table(t->dev_dir, 0);
	if (t->sysctl_header == NULL) {
		kfree(t);
		t = NULL;
	}
	port->sysctl_table = t;
	return 0;
}
Beispiel #10
0
int xprt_rdma_init(void)
{
	int rc;

	rc = rpcrdma_alloc_wq();
	if (rc)
		return rc;

	rc = xprt_register_transport(&xprt_rdma);
	if (rc) {
		rpcrdma_destroy_wq();
		return rc;
	}

	rc = xprt_register_transport(&xprt_rdma_bc);
	if (rc) {
		xprt_unregister_transport(&xprt_rdma);
		rpcrdma_destroy_wq();
		return rc;
	}

	dprintk("RPCRDMA Module Init, register RPC RDMA transport\n");

	dprintk("Defaults:\n");
	dprintk("\tSlots %d\n"
		"\tMaxInlineRead %d\n\tMaxInlineWrite %d\n",
		xprt_rdma_slot_table_entries,
		xprt_rdma_max_inline_read, xprt_rdma_max_inline_write);
	dprintk("\tPadding 0\n\tMemreg %d\n", xprt_rdma_memreg_strategy);

#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
	if (!sunrpc_table_header)
		sunrpc_table_header = register_sysctl_table(sunrpc_table);
#endif
	return 0;
}
Beispiel #11
0
int ethinit_module(void)
{
	int res;
        printk(KERN_INFO "init module called \n");
        init_module2_2();

        spin_lock_init(&eth_lock);

	  schar_name = "schar2";
		
	
	/* register device with kernel */
	res = register_chrdev(SCHAR_MAJOR_2, schar_name, &schar_fops);
       
	if (res) {
	      printk(KERN_INFO "can't register device with kernel\n");
		return res;
	}
	
	/* register proc entry */
	schar_root_header_2 = register_sysctl_table(schar_root_dir_2, 0);

	return 0;
}
Beispiel #12
0
/* allocate the tables for the presto devices. We need
 * sizeof(proto_channel_table)/sizeof(proto_channel_table[0])
 * entries for each dev
 */
int /* __init */ init_intermezzo_sysctl(void)
{
	int i;
	int total_dev = MAX_CHANNEL;
	int entries_per_dev = sizeof(proto_psdev_table) /
		sizeof(proto_psdev_table[0]);
	int total_entries = entries_per_dev * total_dev;
	ctl_table *dev_ctl_table;

	PRESTO_ALLOC(dev_ctl_table, sizeof(ctl_table) * total_entries);

	if (! dev_ctl_table) {
		CERROR("WARNING: presto couldn't allocate dev_ctl_table\n");
		EXIT;
		return -ENOMEM;
	}

	/* now fill in the entries ... we put the individual presto<x>
	 * entries at the end of the table, and the per-presto stuff
	 * starting at the front.  We assume that the compiler makes
	 * this code more efficient, but really, who cares ... it
	 * happens once per reboot.
	 */
	for(i = 0; i < total_dev; i++) {
		void *p;

		/* entry for this /proc/sys/intermezzo/intermezzo"i" */
		ctl_table *psdev = &presto_table[i + PRESTO_PRIMARY_CTLCNT];
		/* entries for the individual "files" in this "directory" */
		ctl_table *psdev_entries = &dev_ctl_table[i * entries_per_dev];
		/* init the psdev and psdev_entries with the prototypes */
		*psdev = proto_channel_entry;
		memcpy(psdev_entries, proto_psdev_table,
		       sizeof(proto_psdev_table));
		/* now specialize them ... */
		/* the psdev has to point to psdev_entries, and fix the number */
		psdev->ctl_name = psdev->ctl_name + i + 1; /* sorry */

		PRESTO_ALLOC(p, PROCNAME_SIZE);
		psdev->procname = p;
		if (!psdev->procname) {
			PRESTO_FREE(dev_ctl_table,
				    sizeof(ctl_table) * total_entries);
			return -ENOMEM;
		}
		sprintf((char *) psdev->procname, "intermezzo%d", i);
		/* hook presto into */
		psdev->child = psdev_entries;

		/* now for each psdev entry ... */
		psdev_entries[0].data = &(izo_channels[i].uc_hard);
		psdev_entries[1].data = &(izo_channels[i].uc_no_filter);
		psdev_entries[2].data = &(izo_channels[i].uc_no_journal);
		psdev_entries[3].data = &(izo_channels[i].uc_no_upcall);
		psdev_entries[4].data = &(izo_channels[i].uc_timeout);
#ifdef PRESTO_DEBUG
		psdev_entries[5].data = &(izo_channels[i].uc_errorval);
#endif
	}


#ifdef CONFIG_SYSCTL
	if ( !intermezzo_table_header )
		intermezzo_table_header =
			register_sysctl_table(intermezzo_table, 0);
#endif
#ifdef CONFIG_PROC_FS
	proc_fs_intermezzo = proc_mkdir("intermezzo", proc_root_fs);
	proc_fs_intermezzo->owner = THIS_MODULE;
	create_proc_info_entry("mounts", 0, proc_fs_intermezzo, 
			       intermezzo_mount_get_info);
#endif
	return 0;
}
static int __init ipc_sysctl_init(void)
{
	register_sysctl_table(ipc_root_table);
	return 0;
}
Beispiel #14
0
void ipx_register_sysctl(void)
{
	ipx_table_header = register_sysctl_table(ipx_root_table);
}
Beispiel #15
0
static int __init
abi_register_sysctl(void)
{
   register_sysctl_table(abi_root_table, 1);
   return 0;
}
Beispiel #16
0
void coda_sysctl_init(void)
{
	if ( !fs_table_header )
		fs_table_header = register_sysctl_table(fs_table);
}
Beispiel #17
0
static int __init init_sysctl(void)
{
    sysctl_header = register_sysctl_table(dev_root);
    return 0;
}
Beispiel #18
0
Datei: main.c Projekt: 7799/linux
/*
 * initialise the fs caching module
 */
static int __init fscache_init(void)
{
	unsigned int nr_cpus = num_possible_cpus();
	unsigned int cpu;
	int ret;

	fscache_object_max_active =
		clamp_val(nr_cpus,
			  fscache_object_max_active, WQ_UNBOUND_MAX_ACTIVE);

	ret = -ENOMEM;
	fscache_object_wq = alloc_workqueue("fscache_object", WQ_UNBOUND,
					    fscache_object_max_active);
	if (!fscache_object_wq)
		goto error_object_wq;

	fscache_op_max_active =
		clamp_val(fscache_object_max_active / 2,
			  fscache_op_max_active, WQ_UNBOUND_MAX_ACTIVE);

	ret = -ENOMEM;
	fscache_op_wq = alloc_workqueue("fscache_operation", WQ_UNBOUND,
					fscache_op_max_active);
	if (!fscache_op_wq)
		goto error_op_wq;

	for_each_possible_cpu(cpu)
		init_waitqueue_head(&per_cpu(fscache_object_cong_wait, cpu));

	ret = fscache_proc_init();
	if (ret < 0)
		goto error_proc;

#ifdef CONFIG_SYSCTL
	ret = -ENOMEM;
	fscache_sysctl_header = register_sysctl_table(fscache_sysctls_root);
	if (!fscache_sysctl_header)
		goto error_sysctl;
#endif

	fscache_cookie_jar = kmem_cache_create("fscache_cookie_jar",
					       sizeof(struct fscache_cookie),
					       0,
					       0,
					       fscache_cookie_init_once);
	if (!fscache_cookie_jar) {
		printk(KERN_NOTICE
		       "FS-Cache: Failed to allocate a cookie jar\n");
		ret = -ENOMEM;
		goto error_cookie_jar;
	}

	fscache_root = kobject_create_and_add("fscache", kernel_kobj);
	if (!fscache_root)
		goto error_kobj;

	printk(KERN_NOTICE "FS-Cache: Loaded\n");
	return 0;

error_kobj:
	kmem_cache_destroy(fscache_cookie_jar);
error_cookie_jar:
#ifdef CONFIG_SYSCTL
	unregister_sysctl_table(fscache_sysctl_header);
error_sysctl:
#endif
	fscache_proc_cleanup();
error_proc:
	destroy_workqueue(fscache_op_wq);
error_op_wq:
	destroy_workqueue(fscache_object_wq);
error_object_wq:
	return ret;
}
Beispiel #19
0
void unix_sysctl_register(void)
{
	unix_sysctl_header = register_sysctl_table(unix_root_table, 0);
}
/*
 * Initialize power interface
 */
static int __init pm_init(void)
{
	register_sysctl_table(pm_dir_table);
	return 0;
}
Beispiel #21
0
int __init
xpc_init(void)
{
	int ret;
	struct task_struct *kthread;

	dev_set_name(xpc_part, "part");
	dev_set_name(xpc_chan, "chan");

	if (is_shub()) {
		/*
		 * The ia64-sn2 architecture supports at most 64 partitions.
		 * And the inability to unregister remote amos restricts us
		 * further to only support exactly 64 partitions on this
		 * architecture, no less.
		 */
		if (xp_max_npartitions != 64) {
			dev_err(xpc_part, "max #of partitions not set to 64\n");
			ret = -EINVAL;
		} else {
			ret = xpc_init_sn2();
		}

	} else if (is_uv()) {
		ret = xpc_init_uv();

	} else {
		ret = -ENODEV;
	}

	if (ret != 0)
		return ret;

	ret = xpc_setup_partitions();
	if (ret != 0) {
		dev_err(xpc_part, "can't get memory for partition structure\n");
		goto out_1;
	}

	xpc_sysctl = register_sysctl_table(xpc_sys_dir);

	/*
	 * Fill the partition reserved page with the information needed by
	 * other partitions to discover we are alive and establish initial
	 * communications.
	 */
	ret = xpc_setup_rsvd_page();
	if (ret != 0) {
		dev_err(xpc_part, "can't setup our reserved page\n");
		goto out_2;
	}

	/* add ourselves to the reboot_notifier_list */
	ret = register_reboot_notifier(&xpc_reboot_notifier);
	if (ret != 0)
		dev_warn(xpc_part, "can't register reboot notifier\n");

	/* add ourselves to the die_notifier list */
	ret = register_die_notifier(&xpc_die_notifier);
	if (ret != 0)
		dev_warn(xpc_part, "can't register die notifier\n");

	/*
	 * The real work-horse behind xpc.  This processes incoming
	 * interrupts and monitors remote heartbeats.
	 */
	kthread = kthread_run(xpc_hb_checker, NULL, XPC_HB_CHECK_THREAD_NAME);
	if (IS_ERR(kthread)) {
		dev_err(xpc_part, "failed while forking hb check thread\n");
		ret = -EBUSY;
		goto out_3;
	}

	/*
	 * Startup a thread that will attempt to discover other partitions to
	 * activate based on info provided by SAL. This new thread is short
	 * lived and will exit once discovery is complete.
	 */
	kthread = kthread_run(xpc_initiate_discovery, NULL,
			      XPC_DISCOVERY_THREAD_NAME);
	if (IS_ERR(kthread)) {
		dev_err(xpc_part, "failed while forking discovery thread\n");

		/* mark this new thread as a non-starter */
		complete(&xpc_discovery_exited);

		xpc_do_exit(xpUnloading);
		return -EBUSY;
	}

	/* set the interface to point at XPC's functions */
	xpc_set_interface(xpc_initiate_connect, xpc_initiate_disconnect,
			  xpc_initiate_send, xpc_initiate_send_notify,
			  xpc_initiate_received, xpc_initiate_partid_to_nasids);

	return 0;

	/* initialization was not successful */
out_3:
	xpc_teardown_rsvd_page();

	(void)unregister_die_notifier(&xpc_die_notifier);
	(void)unregister_reboot_notifier(&xpc_reboot_notifier);
out_2:
	if (xpc_sysctl)
		unregister_sysctl_table(xpc_sysctl);

	xpc_teardown_partitions();
out_1:
	if (is_shub())
		xpc_exit_sn2();
	else if (is_uv())
		xpc_exit_uv();
	return ret;
}
void
rpc_register_sysctl(void)
{
	if (!sunrpc_table_header)
		sunrpc_table_header = register_sysctl_table(sunrpc_table);
}
int __init
xpc_init(void)
{
	int ret;
	struct task_struct *kthread;

	dev_set_name(xpc_part, "part");
	dev_set_name(xpc_chan, "chan");

	if (is_shub()) {
		/*
                                                              
                                                             
                                                          
                           
   */
		if (xp_max_npartitions != 64) {
			dev_err(xpc_part, "max #of partitions not set to 64\n");
			ret = -EINVAL;
		} else {
			ret = xpc_init_sn2();
		}

	} else if (is_uv()) {
		ret = xpc_init_uv();

	} else {
		ret = -ENODEV;
	}

	if (ret != 0)
		return ret;

	ret = xpc_setup_partitions();
	if (ret != 0) {
		dev_err(xpc_part, "can't get memory for partition structure\n");
		goto out_1;
	}

	xpc_sysctl = register_sysctl_table(xpc_sys_dir);

	/*
                                                                   
                                                                   
                   
  */
	ret = xpc_setup_rsvd_page();
	if (ret != 0) {
		dev_err(xpc_part, "can't setup our reserved page\n");
		goto out_2;
	}

	/*                                           */
	ret = register_reboot_notifier(&xpc_reboot_notifier);
	if (ret != 0)
		dev_warn(xpc_part, "can't register reboot notifier\n");

	/*                                        */
	ret = register_die_notifier(&xpc_die_notifier);
	if (ret != 0)
		dev_warn(xpc_part, "can't register die notifier\n");

	/*
                                                            
                                              
  */
	kthread = kthread_run(xpc_hb_checker, NULL, XPC_HB_CHECK_THREAD_NAME);
	if (IS_ERR(kthread)) {
		dev_err(xpc_part, "failed while forking hb check thread\n");
		ret = -EBUSY;
		goto out_3;
	}

	/*
                                                                      
                                                                    
                                                   
  */
	kthread = kthread_run(xpc_initiate_discovery, NULL,
			      XPC_DISCOVERY_THREAD_NAME);
	if (IS_ERR(kthread)) {
		dev_err(xpc_part, "failed while forking discovery thread\n");

		/*                                       */
		complete(&xpc_discovery_exited);

		xpc_do_exit(xpUnloading);
		return -EBUSY;
	}

	/*                                               */
	xpc_set_interface(xpc_initiate_connect, xpc_initiate_disconnect,
			  xpc_initiate_send, xpc_initiate_send_notify,
			  xpc_initiate_received, xpc_initiate_partid_to_nasids);

	return 0;

	/*                                   */
out_3:
	xpc_teardown_rsvd_page();

	(void)unregister_die_notifier(&xpc_die_notifier);
	(void)unregister_reboot_notifier(&xpc_reboot_notifier);
out_2:
	if (xpc_sysctl)
		unregister_sysctl_table(xpc_sysctl);

	xpc_teardown_partitions();
out_1:
	if (is_shub())
		xpc_exit_sn2();
	else if (is_uv())
		xpc_exit_uv();
	return ret;
}
Beispiel #24
0
struct ctl_table_header *mq_register_sysctl_table(void)
{
    return register_sysctl_table(mq_sysctl_root);
}
Beispiel #25
0
static void crypto_proc_fips_init(void)
{
	crypto_sysctls = register_sysctl_table(crypto_dir_table);
}
Beispiel #26
0
static void __init init_sysctl(void)
{
	sysctl_header = register_sysctl_table(root_table);
}
Beispiel #27
0
static __init int ia32_binfmt_init(void)
{
    register_sysctl_table(abi_root_table2);
    return 0;
}
Beispiel #28
0
static int __init init_nlm(void)
{
	nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
	return nlm_sysctl_table ? 0 : -ENOMEM;
}
Beispiel #29
0
/* This rather complex function must be called when you want to add an entry
   to /proc/sys/dev/sensors/chips. It also creates a new directory within 
   /proc/sys/dev/sensors/.
   ctl_template should be a template of the newly created directory. It is
   copied in memory. The extra2 field of each file is set to point to client.
   If any driver wants subdirectories within the newly created directory,
   this function must be updated! 
   controlling_mod is the controlling module. It should usually be
   THIS_MODULE when calling. Note that this symbol is not defined in
   kernels before 2.3.13; define it to NULL in that case. We will not use it
   for anything older than 2.3.27 anyway. */
int i2c_register_entry(struct i2c_client *client, const char *prefix,
			   ctl_table * ctl_template,
			   struct module *controlling_mod)
{
	int i, res, len, id;
	ctl_table *new_table;
	char *name;
	struct ctl_table_header *new_header;

	if ((res = i2c_create_name(&name, prefix, client->adapter,
				       client->addr))) return res;

	for (id = 0; id < SENSORS_ENTRY_MAX; id++)
		if (!i2c_entries[id]) {
			break;
		}
	if (id == SENSORS_ENTRY_MAX) {
		kfree(name);
		return -ENOMEM;
	}
	id += 256;

	len = 0;
	while (ctl_template[len].procname)
		len++;
	len += 7;
	if (!(new_table = kmalloc(sizeof(ctl_table) * len, GFP_KERNEL))) {
		kfree(name);
		return -ENOMEM;
	}

	memcpy(new_table, sysctl_table, 6 * sizeof(ctl_table));
	new_table[0].child = &new_table[2];
	new_table[2].child = &new_table[4];
	new_table[4].child = &new_table[6];
	new_table[4].procname = name;
	new_table[4].ctl_name = id;
	memcpy(new_table + 6, ctl_template, (len - 6) * sizeof(ctl_table));
	for (i = 6; i < len; i++)
		new_table[i].extra2 = client;

	if (!(new_header = register_sysctl_table(new_table, 0))) {
		kfree(new_table);
		kfree(name);
		return -ENOMEM;
	}

	i2c_entries[id - 256] = new_header;

	i2c_clients[id - 256] = client;
#ifdef DEBUG
	if (!new_header || !new_header->ctl_table ||
	    !new_header->ctl_table->child ||
	    !new_header->ctl_table->child->child ||
	    !new_header->ctl_table->child->child->de) {
		printk
		    ("i2c-proc.o: NULL pointer when trying to install fill_inode fix!\n");
		return id;
	}
#endif				/* DEBUG */
	i2c_inodes[id - 256] =
	    new_header->ctl_table->child->child->de->low_ino;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27))
	new_header->ctl_table->child->child->de->owner = controlling_mod;
#else
	new_header->ctl_table->child->child->de->fill_inode =
	    &i2c_dir_fill_inode;
#endif	/* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) */

	return id;
}
Beispiel #30
0
int __init iodump_init(void)
{
    int rc;

    printk(gBanner);

    // Register our device with Linux

    if ((rc = register_chrdev(BCM_IODUMP_MAJOR, "iodump", &iodump_fops)) < 0)
    {
        printk(KERN_WARNING "iodump: register_chrdev failed for major %d\n", BCM_IODUMP_MAJOR);
        return rc;
    }

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
    gSysCtlHeader = register_sysctl_table(gSysCtl, 0);
    if (gSysCtlHeader != NULL)
    {
        gSysCtlHeader->ctl_table->child->de->owner = THIS_MODULE;
    }
#else
    gSysCtlHeader = register_sysctl_table(gSysCtl);
#endif

    memset(&IoDump, 0, sizeof(IoDump));
    IoDump.bufsize = IODUMP_DEFAULT_BUFSIZE;
    IoDump.bufp = vmalloc(IoDump.bufsize);
    if (!IoDump.bufp)
    {
        return -ENOMEM;
    }
    memset(IoDump.bufp, 0, IoDump.bufsize);
    IoDump.bufwritep = IoDump.bufp;
    IoDump.bufreadp = IoDump.bufp;
    IoDump.bufendp = IoDump.bufp + IoDump.bufsize;

    strcpy(IoDump.filename, "/tmp/iodump.bin"); // default local file name
    IoDump.logfile = 0;         // log to socket by default
    strcpy(IoDump.ipaddr, "192.168.1.99");      // currently USB over ethernet host IP
    IoDump.port = 4000;         // default logging ip:port
    IoDump.enable = 0;          // dumping enabled flag
    IoDump.stream[0].ingress = 1;       // Main audio stream
    IoDump.stream[0].egress = 1;
    IoDump.stream[1].ingress = 0;
    IoDump.stream[1].egress = 0;
    IoDump.stream[2].ingress = 0;
    IoDump.stream[2].egress = 0;
    IoDump.stream[3].ingress = 0;       // Video stream (doesn't hurt to enable on audio device)
    IoDump.stream[3].egress = 0;
    IoDump.tdm.ingress = 1;     // TDM directions to log
    IoDump.tdm.egress = 1;
    IoDump.read_timeout = msecs_to_jiffies(50);
    IoDump.netDumpLock = SPIN_LOCK_UNLOCKED;

    // Create dumping to file or socket thread
    init_completion(&IoDumpExited);
    IoDumpThreadPid = kernel_thread(iodump_thread, 0, 0);

    // Create timer to tickle thread at regular intervals
    init_timer(&IoDumpTimer);
    IoDumpTimer.function = iodump_timer;

    return 0;
}