コード例 #1
0
ファイル: cx23888-ir.c プロジェクト: OpenStbV4l-dvb/v4l-dvb
int cx23888_ir_probe(struct cx23885_dev *dev)
{
	struct cx23888_ir_state *state;
	struct v4l2_subdev *sd;
	struct v4l2_subdev_ir_parameters default_params;
	int ret;

	state = kzalloc(sizeof(struct cx23888_ir_state), GFP_KERNEL);
	if (state == NULL)
		return -ENOMEM;

	spin_lock_init(&state->rx_kfifo_lock);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
	state->rx_kfifo = kfifo_alloc(CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL,
				      &state->rx_kfifo_lock);
	if (state->rx_kfifo == NULL)
		return -ENOMEM;
#else
	if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
		return -ENOMEM;
#endif

	state->dev = dev;
	state->id = V4L2_IDENT_CX23888_IR;
	state->rev = 0;
	sd = &state->sd;

	v4l2_subdev_init(sd, &cx23888_ir_controller_ops);
	v4l2_set_subdevdata(sd, state);
	/* FIXME - fix the formatting of dev->v4l2_dev.name and use it */
	snprintf(sd->name, sizeof(sd->name), "%s/888-ir", dev->name);
	sd->grp_id = CX23885_HW_888_IR;

	ret = v4l2_device_register_subdev(&dev->v4l2_dev, sd);
	if (ret == 0) {
		/*
		 * Ensure no interrupts arrive from '888 specific conditions,
		 * since we ignore them in this driver to have commonality with
		 * similar IR controller cores.
		 */
		cx23888_ir_write4(dev, CX23888_IR_IRQEN_REG, 0);

		mutex_init(&state->rx_params_lock);
		memcpy(&default_params, &default_rx_params,
		       sizeof(struct v4l2_subdev_ir_parameters));
		v4l2_subdev_call(sd, ir, rx_s_parameters, &default_params);

		mutex_init(&state->tx_params_lock);
		memcpy(&default_params, &default_tx_params,
		       sizeof(struct v4l2_subdev_ir_parameters));
		v4l2_subdev_call(sd, ir, tx_s_parameters, &default_params);
	} else {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
		kfifo_free(state->rx_kfifo);
#else
		kfifo_free(&state->rx_kfifo);
#endif
	}
	return ret;
}
コード例 #2
0
static int __init example_init(void)
{
#ifdef DYNAMIC
	int ret;

	ret = kfifo_alloc(&test, FIFO_SIZE, GFP_KERNEL);
	if (ret) {
		printk(KERN_ERR "error kfifo_alloc\n");
		return ret;
	}
#else
	INIT_KFIFO(test);
#endif
	if (testfunc() < 0) {
#ifdef DYNAMIC
		kfifo_free(&test);
#endif
		return -EIO;
	}

	if (proc_create(PROC_FIFO, 0, NULL, &fifo_fops) == NULL) {
#ifdef DYNAMIC
		kfifo_free(&test);
#endif
		return -ENOMEM;
	}
	return 0;
}
コード例 #3
0
ファイル: uart16550.c プロジェクト: ThibaultUrien/OS
static int uart16550_release (struct inode * node, struct file *file){
    struct  device_data *devicedata =  file->private_data;
    kfifo_free(&(devicedata->data_from_user));
    kfifo_free(&(devicedata->data_from_device));
    kfree(devicedata->task_user_push_data);
    kfree(devicedata->task_user_get_data);
    kfree(file->private_data);
    return 0;
}
コード例 #4
0
void dvb_hdhomerun_control_exit() {
	DEBUG_FUNC(1);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
	kfifo_free(&control_fifo_user);
	kfifo_free(&control_fifo_kernel);
#endif

	misc_deregister(&hdhomerun_control_device);
}
コード例 #5
0
ファイル: uart16550.c プロジェクト: evelinad/school
/*
 * unreg_dev() - unregisters a device & frees resources
 */
void unreg_dev(int minor, int irq)
{
	int base_addr = devs[minor].base_addr;
	release_region(base_addr, COM_NR_PORTS);
	free_irq(irq, &devs[minor]);
	cdev_del(&devs[minor].cdev);
	kfifo_free(&devs[minor].read_buffer);
	kfifo_free(&devs[minor].write_buffer);
	unregister_chrdev_region(MKDEV(major, minor), 1);
}
コード例 #6
0
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//LaunchAudioHalThread
//	Clean up: free KFIFO
//----------------------------------------------------------------
int TerminateAudioHalThread(void)
{
	
	if(sgThreadData.pWorkqueue_AudioControl)
	{
		flush_workqueue(sgThreadData.pWorkqueue_AudioControl);
		destroy_workqueue(sgThreadData.pWorkqueue_AudioControl);
	}
	kfifo_free(&sgThreadData.m_pkfifo);
    kfifo_free(&sgThreadData.m_pkfifo_out);
	return 0;
}
コード例 #7
0
ファイル: thread_rw.c プロジェクト: gcsuri/linux-wetek-3.14.y
void threadrw_release(struct stream_buf_s *stbuf)
{
	struct threadrw_write_task *task = stbuf->write_thread;
	if (task) {
		wake_up_interruptible(&task->wq);
		cancel_delayed_work_sync(&task->write_work);
		free_task_buffers(task);
		kfifo_free(&task->freefifo);
		kfifo_free(&task->datafifo);
		vfree(task);
	}
	stbuf->write_thread = NULL;
	return;
}
コード例 #8
0
ファイル: kfifo.c プロジェクト: HackLinux/kbuf
int kfifo_ready(struct kfifo *kfifo)
{
	if (kfifo) {
		return kfifo_size(kfifo) - kfifo_free(kfifo);
	}
	return 0;
}
コード例 #9
0
ファイル: probe.c プロジェクト: b3rnik/dsl-n55u-bender
static __init int dccpprobe_init(void)
{
    int ret = -ENOMEM;

    init_waitqueue_head(&dccpw.wait);
    spin_lock_init(&dccpw.lock);
    dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock);
    if (IS_ERR(dccpw.fifo))
        return PTR_ERR(dccpw.fifo);

    if (!proc_net_fops_create(procname, S_IRUSR, &dccpprobe_fops))
        goto err0;

    ret = register_jprobe(&dccp_send_probe);
    if (ret)
        goto err1;

    pr_info("DCCP watch registered (port=%d)\n", port);
    return 0;
err1:
    proc_net_remove(procname);
err0:
    kfifo_free(dccpw.fifo);
    return ret;
}
コード例 #10
0
ファイル: IO_irq.c プロジェクト: cutecheng/rounder
int IO_irq_release(struct inode *inode, struct file *filp)
{
	
	free_irq(IO_irq_devices->IO_irq1, NULL);
	free_irq(IO_irq_devices->IO_irq2, NULL);
	free_irq(IO_irq_devices->IO_irq3, NULL);
	free_irq(IO_irq_devices->IO_irq4, NULL);
	s3c2410_gpio_cfgpin(S3C2410_GPG11, S3C2410_GPG11_INP);
	s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_INP);
	s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_INP);
	s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPF0_INP);
	IO_irq_devices->IO_status = 0 ;

	tasklet_kill(&keytask);

	if(!cancel_delayed_work(&irq_work_delay)) flush_workqueue(tekkamanwork);
	destroy_workqueue(tekkamanwork);
	
	kfifo_free(tekkamanfifo);
	kfree(tekkamantmp);
	kfree(tekkamanbuf);
	atomic_inc(&IO_irq_available); /* release the device */
	wake_up_interruptible_sync(&IO_irq_wait); /* awake other uid's */
	printk( "IO_irq: release !  \n");

	return 0;
}
コード例 #11
0
ファイル: gl_bow.c プロジェクト: Swapnil133609/Zeus_exp
/*----------------------------------------------------------------------------*/
BOOLEAN glUnregisterAmpc(IN P_GLUE_INFO_T prGlueInfo)
{
	ASSERT(prGlueInfo);

	if (prGlueInfo->rBowInfo.fgIsRegistered == FALSE) {
		return FALSE;
	} else {
		prGlueInfo->rBowInfo.fgIsRegistered = FALSE;

		/* 1. free netdev if necessary */
#if CFG_BOW_SEPARATE_DATA_PATH
		kalUninitBowDevice(prGlueInfo);
#endif

		/* 2. removal of character device */
		cdev_del(&(prGlueInfo->rBowInfo.cdev));

		/* 3. free kfifo */
/* kfifo_free(prGlueInfo->rBowInfo.prKfifo); */
		kfifo_free(&(prGlueInfo->rBowInfo.rKfifo));
/* prGlueInfo->rBowInfo.prKfifo = NULL; */
/* prGlueInfo->rBowInfo.rKfifo = NULL; */

		/* 4. free device number */
		unregister_chrdev_region(prGlueInfo->rBowInfo.u4DeviceNumber, 1);

		return TRUE;
	}
}				/* end of glUnregisterAmpc */
コード例 #12
0
ファイル: nfs.c プロジェクト: AshishNamdev/barebox
static void nfs_do_close(struct file_priv *priv)
{
	if (priv->fifo)
		kfifo_free(priv->fifo);

	free(priv);
}
コード例 #13
0
ファイル: tmsi.c プロジェクト: niklasrogers/openbci
static int tmsi_release_dev(struct tmsi_data* dev) {

    int i;
    if (!dev)
        return -ENODEV;
    // Unlink current receiving bulk URB
    for (i = 0; i < BULK_RECV_URBS; ++i)
        free_urb(dev->bulk_recv_urb[i]);
    // Unlink current receiving isochronous URB's
    for (i = ISOC_RECV_URBS-1; i>=0; --i)
        free_urb(dev->isoc_recv_urb[i]);

    if (dev->device_open > 0)
        dev->device_open = 0;


    // Remove buffer

    kfifo_reset(dev->packet_buffer);
    kfifo_free(dev->packet_buffer);
    up(dev->fifo_sem);
    kfree(dev->fifo_sem);
    kfree(dev->release_sem);

    /* decrement the count on our device */
    kref_put(&dev->kref, tmsi_delete);

    info("Tmsi device realese() success\n");
    dev->releasing = 0;
    return 0;
}
コード例 #14
0
static void logi_dj_remove(struct hid_device *hdev)
{
	struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
	struct dj_device *dj_dev;
	int i;

	dbg_hid("%s\n", __func__);

	cancel_work_sync(&djrcv_dev->work);

	hdev->ll_driver->close(hdev);
	hid_hw_stop(hdev);

	/* I suppose that at this point the only context that can access
	 * the djrecv_data is this thread as the work item is guaranteed to
	 * have finished and no more raw_event callbacks should arrive after
	 * the remove callback was triggered so no locks are put around the
	 * code below */
	for (i = 0; i < (DJ_MAX_PAIRED_DEVICES + DJ_DEVICE_INDEX_MIN); i++) {
		dj_dev = djrcv_dev->paired_dj_devices[i];
		if (dj_dev != NULL) {
			hid_destroy_device(dj_dev->hdev);
			kfree(dj_dev);
			djrcv_dev->paired_dj_devices[i] = NULL;
		}
	}

	kfifo_free(&djrcv_dev->notif_fifo);
	kfree(djrcv_dev);
	hid_set_drvdata(hdev, NULL);
}
コード例 #15
0
ファイル: ejemplo.c プロジェクト: tombe85/lin
int test(void)
{

	struct kfifo fifo;
	int ret, tam;
	char *buf;

	/* Inicializo la cola y compruebo errores */
        ret = kfifo_alloc(&fifo, FIFO_SIZE, GFP_KERNEL);
        if (ret) {
                printk(KERN_ERR "error kfifo_alloc\n");
                return ret;
        }

	/* Introduzco la cadena Hello en la cola */
	kfifo_in(&fifo, "Hello", 5);

	/* Introduzco la cadena LIN de la cola */
	kfifo_in(&fifo, "LIN", 3);

	/* Extraigo la cadena Hello de la cola */
	tam = kfifo_out(&fifo, buf, 5);
	printk(KERN_INFO "%s", buf);

	/* Devuelvo la cadena LIN sin extraerla de la cola */
	if (kfifo_peek(&test, buf))
		printk(KERN_INFO " %s\n", buf);
	
	/* Elimino la cola */
	kfifo_free(&test);

	return 0;
}
コード例 #16
0
static void __exit example_exit(void)
{
	remove_proc_entry(PROC_FIFO, NULL);
#ifdef DYNAMIC
	kfifo_free(&test);
#endif
}
コード例 #17
0
int canClose_driver(CAN_HANDLE fd0)
{
	((CANPipe*)fd0)->used = 0;
	kfifo_free (((CANPipe*)fd0)->pipe);
	
	return 0;
}
コード例 #18
0
static void logi_dj_remove(struct hid_device *hdev)
{
	struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
	struct dj_device *dj_dev;
	int i;

	dbg_hid("%s\n", __func__);

	cancel_work_sync(&djrcv_dev->work);

	hdev->ll_driver->close(hdev);
	hid_hw_stop(hdev);

	for (i = 0; i < (DJ_MAX_PAIRED_DEVICES + DJ_DEVICE_INDEX_MIN); i++) {
		dj_dev = djrcv_dev->paired_dj_devices[i];
		if (dj_dev != NULL) {
			hid_destroy_device(dj_dev->hdev);
			kfree(dj_dev);
			djrcv_dev->paired_dj_devices[i] = NULL;
		}
	}

	kfifo_free(&djrcv_dev->notif_fifo);
	kfree(djrcv_dev);
	hid_set_drvdata(hdev, NULL);
}
コード例 #19
0
static __exit void tcpprobe_exit(void)
{
	kfifo_free(tcpw.fifo);
	proc_net_remove(procname);
	unregister_jprobe(&tcp_send_probe);

}
コード例 #20
0
ファイル: u_serial.c プロジェクト: AlexShiLucky/linux
static int gs_console_setup(struct console *co, char *options)
{
	struct gscons_info *info = &gscons_info;
	int status;

	info->port = NULL;
	info->console_req = NULL;
	info->req_busy = 0;
	spin_lock_init(&info->con_lock);

	status = kfifo_alloc(&info->con_buf, GS_CONSOLE_BUF_SIZE, GFP_KERNEL);
	if (status) {
		pr_err("%s: allocate console buffer failed\n", __func__);
		return status;
	}

	info->console_thread = kthread_create(gs_console_thread,
					      co, "gs_console");
	if (IS_ERR(info->console_thread)) {
		pr_err("%s: cannot create console thread\n", __func__);
		kfifo_free(&info->con_buf);
		return PTR_ERR(info->console_thread);
	}
	wake_up_process(info->console_thread);

	return 0;
}
コード例 #21
0
void ccci_logic_ctlb_deinit(int md_id)
{
	ccif_t						*ccif;
	logic_channel_info_t		*ch_info;
	int							i;
	logic_dispatch_ctl_block_t	*ctl_b;

	ctl_b = logic_dispatch_ctlb[md_id];

	if(ctl_b != NULL){
		// Step 1, freeze ccci
		ctl_b->m_freezed = 1;
		// Step 2, de-init ccif
		ccif = logic_dispatch_ctlb[md_id]->m_ccif;
		ccif->ccif_de_init(ccif);
		// Step 3, kill ccci dispatch tasklet
		tasklet_kill(&ctl_b->m_dispatch_tasklet);
		// Step 4, free kfifo memory
		for(i=0; i<CCCI_MAX_CH_NUM; i++)
		{
			ch_info = &ctl_b->m_logic_ch_table[i];
			if(ch_info->m_kfifo_ready){
				kfifo_free(&ch_info->m_kfifo);
				ch_info->m_kfifo_ready = 0;
			}
		}
		// Step 5, destory wake lock
		wake_lock_destroy(&ctl_b->m_wakeup_wake_lock);
		// Step 6, free logic_dispatch_ctlb memory
		kfree(ctl_b);
		logic_dispatch_ctlb[md_id] = NULL;
	}
}
コード例 #22
0
ファイル: kfifo.c プロジェクト: uTank/HelloWorld
int main(void)
{
	struct kfifo fck;
	struct kfifo *fifo = &fck;
	int tmp, array[256];
	int out[256];
	int i;
	tmp = kfifo_alloc(fifo, 256, sizeof(int));
	printf("\nkfifo_alloc ret = %d\n", tmp);
	kfifo_disp_info(fifo);
	for(i = 0; i < ARRAY_SIZE(array); i++)
		array[i] = i;
//	for(i = 0; i < 100; i++)
	tmp = kfifo_in(fifo, array, 100);
	printf("\nkfifo_in ret = %d\n", tmp);
	kfifo_disp_info(fifo);
	
	tmp = kfifo_out(fifo, out, 10);
	printf("\nkfifo_out ret = %d\n", tmp);
	kfifo_disp_info(fifo);
	for(i = 0; i < 10; i++)
		printf("out[%d]= %d\n", i, out[i]);
	kfifo_free(fifo);

	return 0;
}
コード例 #23
0
ファイル: u_serial.c プロジェクト: AlexShiLucky/linux
static void gs_close(struct tty_struct *tty, struct file *file)
{
	struct gs_port *port = tty->driver_data;
	struct gserial	*gser;

	spin_lock_irq(&port->port_lock);

	if (port->port.count != 1) {
		if (port->port.count == 0)
			WARN_ON(1);
		else
			--port->port.count;
		goto exit;
	}

	pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file);

	/* mark port as closing but in use; we can drop port lock
	 * and sleep if necessary
	 */
	port->openclose = true;
	port->port.count = 0;

	gser = port->port_usb;
	if (gser && gser->disconnect)
		gser->disconnect(gser);

	/* wait for circular write buffer to drain, disconnect, or at
	 * most GS_CLOSE_TIMEOUT seconds; then discard the rest
	 */
	if (kfifo_len(&port->port_write_buf) > 0 && gser) {
		spin_unlock_irq(&port->port_lock);
		wait_event_interruptible_timeout(port->drain_wait,
					gs_writes_finished(port),
					GS_CLOSE_TIMEOUT * HZ);
		spin_lock_irq(&port->port_lock);
		gser = port->port_usb;
	}

	/* Iff we're disconnected, there can be no I/O in flight so it's
	 * ok to free the circular buffer; else just scrub it.  And don't
	 * let the push tasklet fire again until we're re-opened.
	 */
	if (gser == NULL)
		kfifo_free(&port->port_write_buf);
	else
		kfifo_reset(&port->port_write_buf);

	port->port.tty = NULL;

	port->openclose = false;

	pr_debug("gs_close: ttyGS%d (%p,%p) done!\n",
			port->port_num, tty, file);

	wake_up(&port->close_wait);
exit:
	spin_unlock_irq(&port->port_lock);
}
コード例 #24
0
void rfbi_exit(void)
{
	DSSDBG("rfbi_exit\n");

	kfifo_free(rfbi.cmd_fifo);

	iounmap(rfbi.base);
}
コード例 #25
0
//-------------------------------------------------exit_fun--------------------------------------------------------
static void __exit pseudo_exit(void)
{
	printk("device unloaded\n");
        kfifo_free(&my_dev->kfifo);    
     //   kfree(my_dev->buff); 
        kfree(my_dev);
	unregister_chrdev_region(pdevice,1);
}
コード例 #26
0
ファイル: main.c プロジェクト: Lyude/linux
static void lbs_free_adapter(struct lbs_private *priv)
{
	lbs_free_cmd_buffer(priv);
	kfifo_free(&priv->event_fifo);
	del_timer(&priv->command_timer);
	del_timer(&priv->tx_lockup_timer);
	del_timer(&priv->auto_deepsleep_timer);
}
コード例 #27
0
ファイル: kfifo_buf.c プロジェクト: Sangil-Lee/ZynqFPGA
static void iio_kfifo_buffer_release(struct iio_buffer *buffer)
{
	struct iio_kfifo *kf = iio_to_kfifo(buffer);

	mutex_destroy(&kf->user_lock);
	kfifo_free(&kf->kf);
	kfree(kf);
}
コード例 #28
0
static inline void
dhd_kfifo_free(struct kfifo *fifo)
{
	kfifo_free(fifo);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
	/* FC11 releases the fifo memory */
	kfree(fifo);
#endif
}
コード例 #29
0
void hidpp_remove(struct hidpp_device *hidpp_dev)
{
	dbg_hid("%s\n", __func__);
	cancel_work_sync(&hidpp_dev->work);
	mutex_destroy(&hidpp_dev->send_mutex);
	kfifo_free(&hidpp_dev->delayed_work_fifo);
	hidpp_dev->initialized = false;
	hidpp_dev->hid_dev = NULL;
}
コード例 #30
0
ファイル: u_serial.c プロジェクト: AlexShiLucky/linux
static void gserial_console_exit(void)
{
	struct gscons_info *info = &gscons_info;

	unregister_console(&gserial_cons);
	if (!IS_ERR_OR_NULL(info->console_thread))
		kthread_stop(info->console_thread);
	kfifo_free(&info->con_buf);
}