Beispiel #1
0
static int
msmrtc_probe(struct platform_device *pdev)
{
	printk("RTC probe\n");
	rtc = rtc_device_register("msm_rtc",
				  &pdev->dev,
				  &msm_rtc_ops,
				  THIS_MODULE);
	if (IS_ERR(rtc)) {
		printk(KERN_ERR "%s: Can't register RTC device (%ld)\n",
		       pdev->name, PTR_ERR(rtc));
		return PTR_ERR(rtc);
	}

#ifdef CONFIG_QUICK_WAKEUP
	if(quickwakeup_register(&quick_ops))
	{
		printk(KERN_ERR "%s: Can't register quickwakeup events\n",
			pdev->name);
		return 1;
	}
#endif
 
	printk("MSM RTC started\n");
	return 0;
}
Beispiel #2
0
int scbs_init_devices(void)
{
	int rc;
	int major;

	printk("Super cool battery software km driver\n");

	/* Create a device node */
	scbs_class = class_create(THIS_MODULE, "scbs");
	if (IS_ERR(scbs_class)) {
		rc = -ENOMEM;
		printk(KERN_ERR
		       "scbs: failed to create scbs class\n");
		goto fail;
	}

	rc = alloc_chrdev_region(&scbs_devno, 0, 1, "scbs");
	if (rc < 0) {
		printk(KERN_ERR
		       "scbs: Failed to alloc chardev region (%d)\n", rc);
		goto fail_destroy_class;
	}

	major = MAJOR(scbs_devno);
	scbs_device = device_create(scbs_class, NULL,
					 scbs_devno, NULL, "%d",
					 0);
	if (IS_ERR(scbs_device)) {
		rc = -ENOMEM;
		goto fail_unregister_cdev_region;
	}

	cdev_init(&scbs_cdev, &scbs_fops);
	scbs_cdev.owner = THIS_MODULE;

	rc = cdev_add(&scbs_cdev, scbs_devno, 1);
	if (rc < 0)
		goto fail_destroy_device;

	spin_lock_init(&consumer_lock);
	spin_lock_init(&producer_lock);

	buffer.size = RING_BUF_SIZE;
	buffer.buf = kmalloc(RING_BUF_SIZE*sizeof(struct scbs_data_point),GFP_KERNEL );

	return quickwakeup_register(&quick_ops);

fail_destroy_device:
	device_destroy(scbs_class, scbs_devno);
fail_unregister_cdev_region:
	unregister_chrdev_region(scbs_devno,1);
fail_destroy_class:
	class_destroy(scbs_class);
fail:
	return rc;
}