/**
 * registers client associated with the node
 *
 * @param inode Inode concerned.
 * @param file File concerned.
 *
 * @return 0 on success, <0 on error.
 */
static int smschar_open(struct inode *inode, struct file *file)
{
	struct smschar_device_t *dev = container_of(inode->i_cdev,
						    struct smschar_device_t,
						    cdev);
	int rc = -ENODEV;

	sms_info("entering, device index = %d", dev->device_index);
	if (dev->coredev) {
		struct smsclient_params_t params;

      if(g_open_first==0 && dev->device_index==0)
      {
        smsspi_poweron();
        g_open_first = 1;
        sms_info("Opened first time");
      }
      else if(dev->device_index!=0)
        g_open_first=0;

		params.initial_id = dev->device_index ?
		    dev->device_index : SMS_HOST_LIB;
		params.data_type = dev->device_index ? MSG_SMS_DAB_CHANNEL : 0;
		params.onresponse_handler = smschar_onresponse;
		params.onremove_handler = smschar_onremove;
		params.context = dev;

		rc = smscore_register_client(dev->coredev, &params,
					     &dev->smsclient);
		if (!rc)
			file->private_data = dev;
		dev->cancel_waitq = 0;
		g_pnp_status_changed = 1;
		g_open_count++;
	}

	if (rc)
		sms_err("exiting, rc = %d", rc);

	return rc;
}
예제 #2
0
void sms_redownload_firmware_reset(void) // add by jiabf
{
    smsspibus_ssp_suspend(spi_dev->phy_dev);
    smsspi_poweron();
}