aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/motor/isa1200_vibrator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/motor/isa1200_vibrator.c')
-rw-r--r--drivers/motor/isa1200_vibrator.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/drivers/motor/isa1200_vibrator.c b/drivers/motor/isa1200_vibrator.c
index 4b26dc3..0f2da51 100644
--- a/drivers/motor/isa1200_vibrator.c
+++ b/drivers/motor/isa1200_vibrator.c
@@ -269,7 +269,7 @@ static void isa1200_vibrator_enable(struct timed_output_dev *_dev, int value)
spin_unlock_irqrestore(&data->lock, flags);
}
-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;
@@ -277,19 +277,19 @@ static ssize_t pwm_val_show(struct device *dev,
pwm_val = ((isapwm_duty - 500) * 100) / 500;
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_err("[VIB] %s: error on storing pwm_value\n", __func__);
- pr_info("[VIB] %s: pwm_val=%lu\n", __func__, pwm_val);
+ pr_info("[VIB] %s: pwm_value=%lu\n", __func__, pwm_val);
isapwm_duty = (pwm_val * 500) / 100 + 500;
@@ -307,26 +307,8 @@ ssize_t pwm_val_store(struct device *dev,
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 __devinit isa1200_vibrator_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@@ -373,12 +355,16 @@ static int __devinit isa1200_vibrator_i2c_probe(struct i2c_client *client,
ddata->duty = pdata->duty;
ddata->period = pdata->period;
+ /* User controllable pwm level */
+ ret = device_create_file(ddata->dev.dev, &dev_attr_pwm_value);
+ if (ret < 0) {
+ pr_err("[VIB] create sysfs fail: pwm_value\n");
+ }
+
ddata->dev.name = "vibrator";
ddata->dev.get_time = isa1200_vibrator_get_time;
ddata->dev.enable = isa1200_vibrator_enable;
- create_vibrator_sysfs();
-
hrtimer_init(&ddata->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ddata->timer.function = isa1200_vibrator_timer_func;
INIT_WORK(&ddata->work, isa1200_vibrator_work);