static ssize_t anx7816_write_reg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int ret = 0; char op, i; char r[3]; char v[3]; unchar tmp; int id, reg, val = 0 ; if (sp_tx_cur_states() != STATE_PLAY_BACK) { pr_err("%s: error!, Not STATE_PLAY_BACK\n", LOG_TAG); return -EINVAL; } if (count != 7 && count != 5) { pr_err("%s: cnt:%d, invalid input!\n", LOG_TAG, count-1); pr_err("%s: ex) 05df -> op:0(read) id:5 reg:0xdf \n", LOG_TAG); pr_err("%s: ex) 15df5f -> op:1(wirte) id:5 reg:0xdf val:0x5f\n", LOG_TAG); return -EINVAL; } ret = snprintf(&op, 2, buf); ret = snprintf(&i, 2, buf+1); ret = snprintf(r, 3, buf+2); id = simple_strtoul(&i, NULL, 10); reg = simple_strtoul(r, NULL, 16); if ((id != 0 && id != 1 && id != 5 && id != 6 && id != 7)) { pr_err("%s: invalid addr id! (id:0,1,5,6,7)\n", LOG_TAG); return -EINVAL; } id = anx7816_id_change(id); /* ex) 5 -> 0x72 */ switch (op) { case 0x30: /* "0" -> read */ sp_read_reg(id, reg, &tmp); pr_info("%s: anx7816 read(0x%x,0x%x)= 0x%x \n", LOG_TAG, id, reg, tmp); break; case 0x31: /* "1" -> write */ ret = snprintf(v, 3, buf+4); val = simple_strtoul(v, NULL, 16); sp_write_reg(id, reg, val); sp_read_reg(id, reg, &tmp); pr_info("%s: anx7816 write(0x%x,0x%x,0x%x)\n", LOG_TAG, id, reg, tmp); break; default: pr_err("%s: invalid operation code! (0:read, 1:write)\n", LOG_TAG); return -EINVAL; } return count; }
static void anx7816_work_func(struct work_struct *work) { struct anx7816_data *td = container_of(work, struct anx7816_data, work.work); int workqueu_timer = 0; if (sp_tx_cur_states() >= STATE_PLAY_BACK) workqueu_timer = 500; else workqueu_timer = 100; mutex_lock(&td->lock); slimport_main_process(); mutex_unlock(&td->lock); queue_delayed_work(td->workqueue, &td->work, msecs_to_jiffies(workqueu_timer)); }