Пример #1
0
static int vibe_resume (struct platform_device *pdev)
{
	DPRINTK("*** in %s.\n", __func__);

	plat_vibrator_init();

	return 0;
}
Пример #2
0
static int __init vibe_probe(struct platform_device *pdev)
{
	int rc;
	struct vibe_state *state;

	DPRINTK("In %s...\n", __func__);

	state = kzalloc(sizeof(struct vibe_state), GFP_KERNEL);
	if (!state)
		return (-ENOMEM);

	plat_vibrator_register((struct vibrator_platform_data*)(pdev->dev.platform_data));

	/* init phys. vibe device */
	plat_vibrator_init();

	/* 
	 * Set default values: 0 = disabled, 50% duty cycle
	 */
	state->direction  = 0;
	state->duty_cycle = 50;

	/* 
	 * Configure hardware.
	 */
	rc = plat_vibrator_set_direction(state->direction);
	if (rc)
		goto err0;

	rc = plat_vibrator_set_duty_cycle(state->duty_cycle);
	if (rc)
		goto err0;

	dev_set_drvdata(&pdev->dev, state);

	mutex_init(&state->mutex);

	/* create sysfs attribute */
	if ((rc = device_create_file(&pdev->dev, &dev_attr_direction)))
		goto err0;

	if ((rc = device_create_file(&pdev->dev, &dev_attr_duty_cycle)))
		goto err1;

	register_vibetonz(state);
	printk(KERN_INFO "Vibrator driver initialized...\n");
	return 0;

err1:
	device_remove_file(&pdev->dev, &dev_attr_direction);
err0:
	kfree(state);
	printk(KERN_ERR "ERROR: Vibrator driver intitialization failed.\n");
	return rc;
}