Esempio n. 1
0
static void pantech_debug_work_init(struct work_struct *work)
{
	int	rc;	
	
	printk(KERN_ERR "%s is called\n", __func__);
	rc = msm_nv_rpc_connect();
	if (rc == 0) {
		init_pantech_debug_option();
	}
	else {
		printk(KERN_ERR "%s : msm_nv_rpc_connect error(%d)\n", 
			__func__, rc);
	}
}
//lee.eunsuk 20110516 static size_t panmac_read(struct file *filp, char* buf, size_t count, loff_t *f_pos)
static ssize_t panmac_read(struct file *filp, char* buf, size_t count, loff_t *f_pos)
{
  nv_cmd_item_type item;
  int rc, result;
  int copy_len;
  char temp[PANMAC_MAC_MAX_LEN + 1];

  rc = msm_nv_rpc_connect();
  if (rc != 0) {
    printk(KERN_ERR "%s : msm_nv_rpc_connect error(%d)\n", __func__, rc);
    return 0;
  }
  result = msm_nv_read(NV_WLAN_MAC_ADDRESS_I, &item);
  if (result != 0)
  {
    printk(KERN_INFO "msm_nv_read failed (%d)\n", result);
    return 0;
  }
  
  printk(KERN_INFO "msm_nv_read: %08X %08X\n", item.wlan_mac_address[0], item.wlan_mac_address[1]);
    
  sprintf(temp, "%02x:%02x:%02x:%02x:%02x:%02x",
    (item.wlan_mac_address[0] >> 8)  & 0xFF,
    (item.wlan_mac_address[0] >> 16) & 0xFF,
    (item.wlan_mac_address[0] >> 24) & 0xFF,
    (item.wlan_mac_address[1] >> 16) & 0xFF,
    (item.wlan_mac_address[1] >> 24) & 0xFF,
    (item.wlan_mac_address[0])       & 0xFF);
    
  copy_len = PANMAC_MAC_MAX_LEN > count ? count: PANMAC_MAC_MAX_LEN;

  if(copy_to_user(buf, temp, copy_len))
  	return -EFAULT;
  
  if (*f_pos == 0)
  {
    *f_pos += copy_len;
    return copy_len;
  }

  return 0;
}
static int __init pantech_debug_opt_init(void)
{
	int	rc;

	printk(KERN_INFO "%s is called\n", __func__);

	rc = platform_driver_register(&pantech_debug_opt_driver);
	if (rc < 0) {
		printk(KERN_ERR "%s: platform_driver_register rc = %d\n",
			__func__, rc);
	}

	rc = msm_nv_rpc_connect();
	if (rc == 0) {
		init_pantech_debug_option();
	}
	else {
		printk(KERN_ERR "%s : msm_nv_rpc_connect error(%d)\n", 
			__func__, rc);
	}

	return	rc;
}