免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1890 | 回复: 0
打印 上一主题 下一主题

workstruct 死锁问题 . [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-10 08:55 |只看该作者 |倒序浏览
我用TI的tps65070 电源管理芯片的触摸屏接口,内核自带的驱动实现了触摸屏接口,使用的是workstruct,我现在添加了另外一个workstruct,在服务函数里面,调用了i2c read,但是出现死锁情况,在某些情况下.

我的work_struct
  1. static void tps6507x_battery_work(struct work_struct *work)
  2. {
  3.         int ret,result;
  4.         struct tps6507x_battery *tsc =  container_of(work,
  5.                                 struct tps6507x_battery, work.work);
  6.         ret = tps6507x_battery_read_u8(tsc,TPS6507X_REG_PPATH1, &result);
  7.         if (ret) {
  8.                 return ret;
  9.         }
  10.         if(result&(0x1<<6)){
  11.                 printk("\n---AC Connect---\n");
  12.                 Status_Ac=1;
  13.                 printk("Status_Ac_battery_work---%d\n",Status_Ac);
  14.         }else {
  15.                 Status_Ac=0;
  16.         }
  17.        
  18.         if(result&(0x1<<7)){
  19.                 printk("\n---USB Connect---\n");
  20.                 Status_Usb=1;
  21.         }else {
  22.                 Status_Usb=0;
  23.         }

  24.         ret = tps6507x_battery_read_u8(tsc,TPS6507X_REG_CHGCONFIG0, &result);
  25.         if (ret) {
  26.                 return ret;
  27.         }

  28.         if(result&(0x1<<2))
  29.         {
  30.                 Status_Charg_full=1;//full
  31.         }else{
  32.                 Status_Charg_full=0;//full
  33.         }

  34.         ret = tps6507x_battery_read_u8(tsc,TPS6507X_REG_CHGCONFIG3, &result);
  35.         if (ret) {
  36.                 return ret;
  37.         }

  38.         if(result&(0x1<<1)){
  39.                 Status_Charging=1;//Charging
  40.         }else{
  41.                 Status_Charging=1;
  42.         }

  43.         if (Status_Charg_full ==1){//full
  44.         schedule_delayed_work(&tsc->work, HZ);
  45.         return;
  46.         }
  47.         schedule_delayed_work(&tsc->work, 4 * HZ);
  48. }
复制代码
自带的触摸屏的work_struct:
  1. static void tps6507x_ts_handler(struct work_struct *work)
  2. {
  3.         struct tps6507x_ts *tsc =  container_of(work,
  4.                                 struct tps6507x_ts, work.work);
  5.         struct input_dev *input_dev = tsc->input_dev;
  6.         int pendown;
  7.         int schd;
  8.         int poll = 0;
  9.         s32 ret;

  10.         ret =  tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE,
  11.                                        &tsc->tc.pressure);
  12.         if (ret)
  13.                 goto done;

  14.         pendown = tsc->tc.pressure > tsc->min_pressure;

  15.         if (unlikely(!pendown && tsc->pendown)) {
  16.                 dev_dbg(tsc->dev, "UP\n");
  17.                 input_report_key(input_dev, BTN_TOUCH, 0);
  18.                 input_report_abs(input_dev, ABS_PRESSURE, 0);
  19.                 input_sync(input_dev);
  20.                 tsc->pendown = 0;
  21.         }

  22.         if (pendown) {

  23.                 if (!tsc->pendown) {
  24.                         dev_dbg(tsc->dev, "DOWN\n");
  25.                         input_report_key(input_dev, BTN_TOUCH, 1);
  26.                 } else
  27.                         dev_dbg(tsc->dev, "still down\n");

  28.                 ret =  tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_X_POSITION,
  29.                                                &tsc->tc.x);
  30.                 if (ret)
  31.                         goto done;

  32.                 ret =  tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_Y_POSITION,
  33.                                                &tsc->tc.y);
  34.                 if (ret)
  35.                         goto done;

  36.                 input_report_abs(input_dev, ABS_X, tsc->tc.x);
  37.                 input_report_abs(input_dev, ABS_Y, tsc->tc.y);
  38.                 input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure);
  39.                 input_sync(input_dev);
  40.                 tsc->pendown = 1;
  41.                 poll = 1;
  42.         }

  43. done:
  44.         /* always poll if not using interrupts */
  45.         poll = 1;

  46.         if (poll) {
  47.                 schd = queue_delayed_work(tsc->wq, &tsc->work,
  48.                                           msecs_to_jiffies(tsc->poll_period));
  49.                 if (schd)
  50.                         tsc->polling = 1;
  51.                 else {
  52.                         tsc->polling = 0;
  53.                         dev_err(tsc->dev, "re-schedule failed");
  54.                 }
  55.         } else
  56.                 tsc->polling = 0;

  57.         ret = tps6507x_adc_standby(tsc);
  58. }

复制代码
我的workstruct,由其是每次用power off关机,然后启动kernel 内核会出现死锁,

如果将电源直接拔掉,再开机,kernel 内核 不会出现死锁.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP