/* * Description: * Input: * Output: */ static int __snfc_avail_poll_get_cen_status(void) { int rc = 0; unsigned char read_buf = 0x00; int cen_status; rc = snfc_i2c_read(0x02, &read_buf, 1); if(rc) { SNFC_DEBUG_MSG("[__snfc_avail_poll_get_cen_status] snfc_i2c_read : %d \n",rc); return -1; } // check bit 7(locken) if(read_buf&0x01) { SNFC_DEBUG_MSG_LOW("[__snfc_avail_poll_get_cen_status] CEN = High (UNLOCK) \n"); cen_status = GPIO_HIGH_VALUE; } else { SNFC_DEBUG_MSG_LOW("[__snfc_avail_poll_get_cen_status] CEN = Low (LOCK) \n"); cen_status = GPIO_LOW_VALUE; } return cen_status; }
/* * Description: * Input: * Output: */ static ssize_t snfc_cen_read(struct file *fp, char *buf, size_t count, loff_t *pos) { //struct snfc_i2c_dev *snfc_i2c_dev = fp->private_data; unsigned char read_buf = 0x00; char snfc_cen = -1, rc = -1; SNFC_DEBUG_MSG_LOW("[snfc_cen] snfc_cen_read - start \n"); /* Check error */ if(NULL == fp || NULL == buf || 1 != count || NULL == pos) { SNFC_DEBUG_MSG("[snfc_cen][read] parameter ERROR \n"); return -1; } mutex_lock(&nfc_cen_mutex); rc = snfc_i2c_read(0x02, &read_buf, 1, snfc_i2c_dev.client); mutex_unlock(&nfc_cen_mutex); if(rc) { SNFC_DEBUG_MSG("[snfc_cen][read] snfc_i2c_read : %d \n",rc); return -1; } // check bit 7(locken) if(read_buf&0x01) // unlock { SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][read] CEN = High (UNLOCK) \n"); snfc_cen = (char)GPIO_HIGH_VALUE; } else // lock { SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][read] CEN = Low (LOCK) \n"); snfc_cen = (char)GPIO_LOW_VALUE; } rc = copy_to_user(buf, &snfc_cen, count); if(rc) { SNFC_DEBUG_MSG("[snfc_cen][read] ERROR - copy_from_user \n"); return -1; } SNFC_DEBUG_MSG_LOW("[snfc_cen][read] snfc_cen_read - end \n"); return 1; }
/* * Description: * Input: * Output: */ static ssize_t snfc_cen_read(struct file *fp, char *buf, size_t count, loff_t *pos) { unsigned char read_buf = 0x00; char snfc_cen = -1, rc = -1; #ifdef FEATURE_DEBUG_LOW SNFC_DEBUG_MSG("[snfc_cen] snfc_cen_read - start \n"); #endif /* Check error */ if(NULL == fp) { SNFC_DEBUG_MSG("[snfc_cen][read] ERROR fp \n"); return -1; } if(NULL == buf) { SNFC_DEBUG_MSG("[snfc_cen][read] ERROR buf \n"); return -1; } if(1 != count) { SNFC_DEBUG_MSG("[snfc_cen][read] ERROR count, count = %d \n", count); //return -1; } if(NULL == pos) { SNFC_DEBUG_MSG("[snfc_cen][read] ERROR file \n"); //return -1; } mutex_lock(&nfc_cen_mutex); rc = snfc_i2c_read(0x02, &read_buf, 1); mutex_unlock(&nfc_cen_mutex); if(rc) { SNFC_DEBUG_MSG("[snfc_cen][read] snfc_i2c_read : %d \n",rc); return -1; } // check bit 7(locken) if(read_buf&0x01) // unlock { #ifdef FEATURE_DEBUG_LOW SNFC_DEBUG_MSG("[snfc_cen][read] CEN = High (UNLOCK) \n"); #endif snfc_cen = (char)GPIO_HIGH_VALUE; } else // lock { #ifdef FEATURE_DEBUG_LOW SNFC_DEBUG_MSG("[snfc_cen][read] CEN = Low (LOCK) \n"); #endif snfc_cen = (char)GPIO_LOW_VALUE; } rc = copy_to_user(buf, &snfc_cen, count); if(rc) { SNFC_DEBUG_MSG("[snfc_cen][read] ERROR - copy_from_user \n"); return -1; } #ifdef FEATURE_DEBUG_LOW SNFC_DEBUG_MSG("[snfc_cen][read] snfc_cen_read - end \n"); #endif return 1; }