Skip to content

Commit

Permalink
Revert "tacho-motor: workqueue per device"
Browse files Browse the repository at this point in the history
This reverts commit 0a6dc8e.

This is possibly causing deadlocks on boot.

Issue ev3dev/ev3dev#623
  • Loading branch information
dlech committed May 8, 2016
1 parent 886af5f commit 4b123b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
1 change: 0 additions & 1 deletion include/tacho_motor_class.h
Expand Up @@ -124,7 +124,6 @@ struct tacho_motor_device {
struct device dev;
struct delayed_work run_timed_work;
struct delayed_work ramp_work;
struct workqueue_struct *wq;
};

/**
Expand Down
21 changes: 8 additions & 13 deletions motors/tacho_motor_class.c
Expand Up @@ -381,8 +381,10 @@ static int tm_do_one_ramp_step(struct tacho_motor_device *tm,
*/
last_ramp_time = jiffies - tm->last_ramp_work_time;
tm->last_ramp_work_time = jiffies;
queue_delayed_work(tm->wq, &tm->ramp_work, last_ramp_time >= RAMP_PERIOD
? 0 : RAMP_PERIOD - last_ramp_time);
schedule_delayed_work(&tm->ramp_work,
last_ramp_time >= RAMP_PERIOD
? 0
: RAMP_PERIOD - last_ramp_time);

return 0;
}
Expand Down Expand Up @@ -685,8 +687,8 @@ static int tm_send_command(struct tacho_motor_device *tm,
tm->command = cmd;

if (cmd == TM_COMMAND_RUN_TIMED)
queue_delayed_work(tm->wq, &tm->run_timed_work,
msecs_to_jiffies(new_params.time_sp));
schedule_delayed_work(&tm->run_timed_work,
msecs_to_jiffies(new_params.time_sp));

return 0;
}
Expand Down Expand Up @@ -1200,10 +1202,6 @@ int register_tacho_motor(struct tacho_motor_device *tm, struct device *parent)
if (!tm || !tm->address || !tm->info || !parent)
return -EINVAL;

tm->wq = create_singlethread_workqueue("tacho-motor");
if (!tm->wq)
return -ENOMEM;

tm->dev.release = tacho_motor_release;
tm->dev.parent = parent;

Expand All @@ -1218,7 +1216,6 @@ int register_tacho_motor(struct tacho_motor_device *tm, struct device *parent)
break;
default:
dev_err(&tm->dev, "unhandled motion type\n");
destroy_workqueue(tm->wq);
return -EINVAL;
}

Expand All @@ -1230,10 +1227,9 @@ int register_tacho_motor(struct tacho_motor_device *tm, struct device *parent)
INIT_DELAYED_WORK(&tm->run_timed_work, tacho_motor_class_run_timed_work);

err = device_register(&tm->dev);
if (err) {
destroy_workqueue(tm->wq);

if (err)
return err;
}

dev_info(&tm->dev, "Registered '%s' on '%s'.\n", tm->driver_name,
tm->address);
Expand All @@ -1248,7 +1244,6 @@ void unregister_tacho_motor(struct tacho_motor_device *tm)
tm->address);
cancel_delayed_work_sync(&tm->run_timed_work);
cancel_delayed_work_sync(&tm->ramp_work);
destroy_workqueue(tm->wq);
device_unregister(&tm->dev);
}
EXPORT_SYMBOL_GPL(unregister_tacho_motor);
Expand Down

0 comments on commit 4b123b3

Please sign in to comment.