From ca322a3f77e20f3988dbaec53f2d209929c8ab74 Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Tue, 27 Aug 2013 05:50:13 -0400 Subject: smdk4412: max77693_haptic: move sysfs node Change-Id: If25044f5eb36ea0374c691c8fee3965b785b8cbf --- drivers/motor/max77693_haptic.c | 65 +++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 39 deletions(-) (limited to 'drivers') diff --git a/drivers/motor/max77693_haptic.c b/drivers/motor/max77693_haptic.c index 1836e33..beb7f2a 100644 --- a/drivers/motor/max77693_haptic.c +++ b/drivers/motor/max77693_haptic.c @@ -3,7 +3,7 @@ * * Copyright (C) 2011 ByungChang Cha * Copyright (C) 2012 The CyanogenMod Project - * Daniel Hillenbrand + * Daniel Hillenbrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -260,64 +260,46 @@ void vibtonz_pwm(int nForce) EXPORT_SYMBOL(vibtonz_pwm); #endif -static ssize_t pwm_val_show(struct device *dev, +static ssize_t pwm_value_show(struct device *dev, struct device_attribute *attr, char *buf) { int count; - pwm_val = ((pwm_duty - 18525) * 100) / 18525; + pwm_val = ((pwm_duty - 18525) * 100) / 18525; count = sprintf(buf, "%lu\n", pwm_val); - pr_debug("[VIB] pwm_val: %lu\n", pwm_val); + pr_debug("[VIB] pwm_value: %lu\n", pwm_val); return count; } -ssize_t pwm_val_store(struct device *dev, +ssize_t pwm_value_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { if (kstrtoul(buf, 0, &pwm_val)) pr_err("[VIB] %s: error on storing pwm_val\n", __func__); - pr_info("[VIB] %s: pwm_val=%lu\n", __func__, pwm_val); + pr_info("[VIB] %s: pwm_value=%lu\n", __func__, pwm_val); - pwm_duty = (pwm_val * 18525) / 100 + 18525; + pwm_duty = (pwm_val * 18525) / 100 + 18525; - /* make sure new pwm duty is in range */ - if(pwm_duty > 37050) - { - pwm_duty = 37050; - } - else if (pwm_duty < 18525) - { - pwm_duty = 18525; - } + /* make sure new pwm duty is in range */ + if(pwm_duty > 37050) + { + pwm_duty = 37050; + } + else if (pwm_duty < 18525) + { + pwm_duty = 18525; + } pr_info("[VIB] %s: pwm_duty=%d\n", __func__, pwm_duty); return size; } -static DEVICE_ATTR(pwm_val, S_IRUGO | S_IWUSR, - pwm_val_show, pwm_val_store); - -static int create_vibrator_sysfs(void) -{ - int ret; - struct kobject *vibrator_kobj; - vibrator_kobj = kobject_create_and_add("vibrator", NULL); - if (unlikely(!vibrator_kobj)) - return -ENOMEM; - - ret = sysfs_create_file(vibrator_kobj, - &dev_attr_pwm_val.attr); - if (unlikely(ret < 0)) { - pr_err("[VIB] sysfs_create_file failed: %d\n", ret); - return ret; - } - - return 0; -} +static DEVICE_ATTR(pwm_value, S_IRUGO | S_IWUSR, + pwm_value_show, pwm_value_store); static int max77693_haptic_probe(struct platform_device *pdev) { @@ -381,8 +363,6 @@ static int max77693_haptic_probe(struct platform_device *pdev) hap_data->tout_dev.get_time = haptic_get_time; hap_data->tout_dev.enable = haptic_enable; - create_vibrator_sysfs(); - #ifdef CONFIG_ANDROID_TIMED_OUTPUT error = timed_output_dev_register(&hap_data->tout_dev); if (error < 0) { @@ -390,8 +370,15 @@ static int max77693_haptic_probe(struct platform_device *pdev) error = -EFAULT; goto err_timed_output_register; } -#endif + pr_err("[VIB] timed_output device is registrated\n"); + + /* User controllable pwm level */ + error = device_create_file(hap_data->tout_dev.dev, &dev_attr_pwm_value); + if (error < 0) { + pr_err("[VIB] create sysfs fail: pwm_value\n"); + } +#endif pr_debug("[VIB] -- %s\n", __func__); return error; -- cgit v1.1