- 论坛徽章:
- 0
|
我用TI的tps65070 电源管理芯片的触摸屏接口,内核自带的驱动实现了触摸屏接口,使用的是workstruct,我现在添加了另外一个workstruct,在服务函数里面,调用了i2c read,但是出现死锁情况,在某些情况下.
我的work_struct- static void tps6507x_battery_work(struct work_struct *work)
- {
- int ret,result;
- struct tps6507x_battery *tsc = container_of(work,
- struct tps6507x_battery, work.work);
- ret = tps6507x_battery_read_u8(tsc,TPS6507X_REG_PPATH1, &result);
- if (ret) {
- return ret;
- }
- if(result&(0x1<<6)){
- printk("\n---AC Connect---\n");
- Status_Ac=1;
- printk("Status_Ac_battery_work---%d\n",Status_Ac);
- }else {
- Status_Ac=0;
- }
-
- if(result&(0x1<<7)){
- printk("\n---USB Connect---\n");
- Status_Usb=1;
- }else {
- Status_Usb=0;
- }
- ret = tps6507x_battery_read_u8(tsc,TPS6507X_REG_CHGCONFIG0, &result);
- if (ret) {
- return ret;
- }
- if(result&(0x1<<2))
- {
- Status_Charg_full=1;//full
- }else{
- Status_Charg_full=0;//full
- }
- ret = tps6507x_battery_read_u8(tsc,TPS6507X_REG_CHGCONFIG3, &result);
- if (ret) {
- return ret;
- }
- if(result&(0x1<<1)){
- Status_Charging=1;//Charging
- }else{
- Status_Charging=1;
- }
- if (Status_Charg_full ==1){//full
- schedule_delayed_work(&tsc->work, HZ);
- return;
- }
- schedule_delayed_work(&tsc->work, 4 * HZ);
- }
复制代码 自带的触摸屏的work_struct:- static void tps6507x_ts_handler(struct work_struct *work)
- {
- struct tps6507x_ts *tsc = container_of(work,
- struct tps6507x_ts, work.work);
- struct input_dev *input_dev = tsc->input_dev;
- int pendown;
- int schd;
- int poll = 0;
- s32 ret;
- ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE,
- &tsc->tc.pressure);
- if (ret)
- goto done;
- pendown = tsc->tc.pressure > tsc->min_pressure;
- if (unlikely(!pendown && tsc->pendown)) {
- dev_dbg(tsc->dev, "UP\n");
- input_report_key(input_dev, BTN_TOUCH, 0);
- input_report_abs(input_dev, ABS_PRESSURE, 0);
- input_sync(input_dev);
- tsc->pendown = 0;
- }
- if (pendown) {
- if (!tsc->pendown) {
- dev_dbg(tsc->dev, "DOWN\n");
- input_report_key(input_dev, BTN_TOUCH, 1);
- } else
- dev_dbg(tsc->dev, "still down\n");
- ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_X_POSITION,
- &tsc->tc.x);
- if (ret)
- goto done;
- ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_Y_POSITION,
- &tsc->tc.y);
- if (ret)
- goto done;
- input_report_abs(input_dev, ABS_X, tsc->tc.x);
- input_report_abs(input_dev, ABS_Y, tsc->tc.y);
- input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure);
- input_sync(input_dev);
- tsc->pendown = 1;
- poll = 1;
- }
- done:
- /* always poll if not using interrupts */
- poll = 1;
- if (poll) {
- schd = queue_delayed_work(tsc->wq, &tsc->work,
- msecs_to_jiffies(tsc->poll_period));
- if (schd)
- tsc->polling = 1;
- else {
- tsc->polling = 0;
- dev_err(tsc->dev, "re-schedule failed");
- }
- } else
- tsc->polling = 0;
- ret = tps6507x_adc_standby(tsc);
- }
复制代码 我的workstruct,由其是每次用power off关机,然后启动kernel 内核会出现死锁,
如果将电源直接拔掉,再开机,kernel 内核 不会出现死锁. |
|