Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 731e082f authored by Gagan Malvi's avatar Gagan Malvi
Browse files

drivers/misc/mediatek: mtk-nfc: Fix printing APIs



Signed-off-by: default avatarGagan Malvi <malvi@aospa.co>
parent e2dd1b71
Loading
Loading
Loading
Loading
+19 −19
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ static char *I2CDMAReadBuf; /*= NULL;*/ /* unnecessary initialise */
static unsigned int I2CDMAReadBuf_pa;    /* = NULL; */
#endif                                   /* KRNMTKLEGACY_I2C */

static bool enable_debug_log;
static bool enable_debug_log = false;
int is_nfc_exist=0;

/*The enum is used to index a pw_states array, the values matter here*/
@@ -284,7 +284,7 @@ static int st21nfc_loc_set_polaritymode(struct st21nfc_device *st21nfc_dev,
  unsigned int irq_type;
  int ret;

  if (enable_debug_log) pr_info("%s:%d mode %d", __FILE__, __LINE__, mode);
  if (enable_debug_log) pr_debug("%s:%d mode %d", __FILE__, __LINE__, mode);

  st21nfc_dev->polarity_mode = mode;
  /* setup irq_flags */
@@ -324,7 +324,7 @@ static int st21nfc_loc_set_polaritymode(struct st21nfc_device *st21nfc_dev,
  st21nfc_dev->irq_is_attached = true;
  st21nfc_disable_irq(st21nfc_dev);

  if (enable_debug_log) pr_info("%s:%d ret %d", __FILE__, __LINE__, ret);
  if (enable_debug_log) pr_debug("%s:%d ret %d", __FILE__, __LINE__, ret);
  return ret;
}

@@ -466,7 +466,7 @@ static ssize_t st21nfc_dev_read(struct file *filp, char __user *buf,
  if (enable_debug_log) pr_debug("%s : reading %zu bytes.\n", __func__, count);

  if (0 == gpiod_get_value(st21nfc_dev->gpiod_irq)) {
    pr_info("%s : read called but no IRQ.\n", __func__);
    pr_debug("%s : read called but no IRQ.\n", __func__);
    memset(st21nfc_dev->buffer, 0x7E, count);
    if (copy_to_user(buf, st21nfc_dev->buffer, count)) {
      pr_warn("%s : failed to copy to user space\n", __func__);
@@ -611,7 +611,7 @@ static int st21nfc_dev_open(struct inode *inode, struct file *filp) {
  struct st21nfc_device *st21nfc_dev =
      container_of(filp->private_data, struct st21nfc_device, st21nfc_device);

  if (enable_debug_log) pr_info("%s:%d dev_open", __FILE__, __LINE__);
  if (enable_debug_log) pr_debug("%s:%d dev_open", __FILE__, __LINE__);

  if (st21nfc_dev->device_open) {
    ret = -EBUSY;
@@ -634,12 +634,12 @@ static int st21nfc_release(struct inode *inode, struct file *file) {
static void (*st21nfc_st54spi_cb)(int, void *);
static void *st21nfc_st54spi_data;
void st21nfc_register_st54spi_cb(void (*cb)(int, void *), void *data) {
  if (enable_debug_log) pr_info("%s\n", __func__);
  if (enable_debug_log) pr_debug("%s\n", __func__);
  st21nfc_st54spi_cb = cb;
  st21nfc_st54spi_data = data;
}
void st21nfc_unregister_st54spi_cb(void) {
  if (enable_debug_log) pr_info("%s\n", __func__);
  if (enable_debug_log) pr_debug("%s\n", __func__);
  st21nfc_st54spi_cb = NULL;
  st21nfc_st54spi_data = NULL;
}
@@ -669,19 +669,19 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd,
  switch (cmd) {
    case ST21NFC_SET_POLARITY_RISING:
    case ST21NFC_LEGACY_SET_POLARITY_RISING:
      pr_info(" ### ST21NFC_SET_POLARITY_RISING ###\n");
      pr_debug(" ### ST21NFC_SET_POLARITY_RISING ###\n");
      st21nfc_loc_set_polaritymode(st21nfc_dev, IRQF_TRIGGER_RISING);
      break;

    case ST21NFC_SET_POLARITY_HIGH:
    case ST21NFC_LEGACY_SET_POLARITY_HIGH:
      pr_info(" ### ST21NFC_SET_POLARITY_HIGH ###\n");
      pr_debug(" ### ST21NFC_SET_POLARITY_HIGH ###\n");
      st21nfc_loc_set_polaritymode(st21nfc_dev, IRQF_TRIGGER_HIGH);
      break;

    case ST21NFC_PULSE_RESET:
    case ST21NFC_LEGACY_PULSE_RESET:
      pr_info("%s Double Pulse Request\n", __func__);
      pr_debug("%s Double Pulse Request\n", __func__);
      if (!IS_ERR(st21nfc_dev->gpiod_reset)) {
        if (st21nfc_st54spi_cb != 0)
          (*st21nfc_st54spi_cb)(ST54SPI_CB_RESET_START, st21nfc_st54spi_data);
@@ -694,7 +694,7 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd,
        gpiod_set_value(st21nfc_dev->gpiod_reset, 0);
        msleep(20);
        gpiod_set_value(st21nfc_dev->gpiod_reset, 1);
        pr_info("%s done Double Pulse Request\n", __func__);
        pr_debug("%s done Double Pulse Request\n", __func__);
        if (st21nfc_st54spi_cb != 0)
          (*st21nfc_st54spi_cb)(ST54SPI_CB_RESET_END, st21nfc_st54spi_data);
      }
@@ -721,7 +721,7 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd,
    case ST21NFC_RECOVERY:
    case ST21NFC_LEGACY_RECOVERY:
      /* For ST21NFCD usage only */
      pr_info("%s Recovery Request\n", __func__);
      pr_debug("%s Recovery Request\n", __func__);
      if (!IS_ERR(st21nfc_dev->gpiod_reset)) {
        if (st21nfc_dev->irq_is_attached) {
          devm_free_irq(&st21nfc_dev->client->dev, st21nfc_dev->client->irq,
@@ -744,7 +744,7 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd,
        usleep_range(10000, 11000);
        gpiod_set_value(st21nfc_dev->gpiod_reset, 1);

        pr_info("%s done Pulse Request\n", __func__);
        pr_debug("%s done Pulse Request\n", __func__);
      }
      msleep(20);
      gpiod_set_value(st21nfc_dev->gpiod_irq, 0);
@@ -753,7 +753,7 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd,
      msleep(20);
      gpiod_set_value(st21nfc_dev->gpiod_irq, 0);
      msleep(20);
      pr_info("%s Recovery procedure finished\n", __func__);
      pr_debug("%s Recovery procedure finished\n", __func__);
      ret = gpiod_direction_input(st21nfc_dev->gpiod_irq);
      if (ret) {
        pr_err("%s : gpiod_direction_input failed\n", __func__);
@@ -1057,7 +1057,7 @@ static int st21nfc_probe(struct i2c_client *client,
    pr_err("%s : gpio_request failed\n", __FILE__);
    return -ENODEV;
  }
  pr_info("%s : IRQ GPIO = %d\n", __func__, r);
  pr_debug("%s : IRQ GPIO = %d\n", __func__, r);
  ret = gpio_direction_input(r);
  if (ret) {
    pr_err("%s : gpio_direction_input failed\n", __FILE__);
@@ -1089,7 +1089,7 @@ static int st21nfc_probe(struct i2c_client *client,
    pr_err("%s : gpio_request failed\n", __FILE__);
    return -ENODEV;
  }
  pr_info("%s : RST GPIO = %d\n", __func__, r);
  pr_debug("%s : RST GPIO = %d\n", __func__, r);
  ret = gpio_direction_output(r, 1);
  if (ret) {
    pr_err("%s : gpio_direction_output failed\n", __FILE__);
@@ -1182,7 +1182,7 @@ static int st21nfc_probe(struct i2c_client *client,
  np = of_find_compatible_node(NULL, NULL, "mediatek,irq_nfc-eint");
  if (np) {
    client->irq = irq_of_parse_and_map(np, 0);
    pr_info("%s : MT IRQ GPIO = %d\n", __func__, client->irq);
    pr_debug("%s : MT IRQ GPIO = %d\n", __func__, client->irq);
  }
#endif  // ST21NFCD_MTK

@@ -1375,7 +1375,7 @@ static struct platform_driver st21nfc_platform_driver = {

/* module load/unload record keeping */
static int __init st21nfc_dev_init(void) {
  pr_info("Loading st21nfc driver\n");
  pr_debug("Loading st21nfc driver\n");
#ifndef KRNMTKLEGACY_GPIO
  platform_driver_register(&st21nfc_platform_driver);
  if (enable_debug_log) pr_debug("Loading st21nfc i2c driver\n");
@@ -1386,7 +1386,7 @@ static int __init st21nfc_dev_init(void) {
module_init(st21nfc_dev_init);

static void __exit st21nfc_dev_exit(void) {
  pr_info("Unloading st21nfc driver\n");
  pr_debug("Unloading st21nfc driver\n");
  i2c_del_driver(&st21nfc_driver);
}

+28 −28
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ st54spi_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
	st54spi = filp->private_data;

	if (debug_enabled)
		pr_info("st54spi Read: %d bytes\n", count);
		pr_debug("st54spi Read: %d bytes\n", count);

	mutex_lock(&st54spi->buf_lock);
	status = st54spi_sync_read(st54spi, count);
@@ -215,7 +215,7 @@ st54spi_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
	mutex_unlock(&st54spi->buf_lock);

	if (debug_enabled)
		pr_info("st54spi Read: status: %d\n", status);
		pr_debug("st54spi Read: status: %d\n", status);

	return status;
}
@@ -236,7 +236,7 @@ st54spi_write(struct file *filp, const char __user *buf,
	st54spi = filp->private_data;

	if (debug_enabled)
		pr_info("st54spi Write: %d bytes\n", count);
		pr_debug("st54spi Write: %d bytes\n", count);

	mutex_lock(&st54spi->buf_lock);
	missing = copy_from_user(st54spi->tx_buffer, buf, count);
@@ -247,7 +247,7 @@ st54spi_write(struct file *filp, const char __user *buf,
	mutex_unlock(&st54spi->buf_lock);

	if (debug_enabled)
		pr_info("st54spi Write: status: %d\n", status);
		pr_debug("st54spi Write: status: %d\n", status);

	return status;
}
@@ -423,7 +423,7 @@ st54spi_power_off(struct st54spi_data *st54spi)
		spi_message_init(&m);
		spi_message_add_tail(&t, &m);

		pr_info("%s : change NSS polarity to %d\n", __func__,
		pr_debug("%s : change NSS polarity to %d\n", __func__,
			st54spi_chip_info.cs_pol);
		st54spi->spi->controller_data = &st54spi_chip_info;
		st54spi_sync(st54spi, &m);
@@ -477,7 +477,7 @@ st54spi_power_on(struct st54spi_data *st54spi)
		spi_message_init(&m);
		spi_message_add_tail(&t, &m);

		pr_info("%s : restored polarity and force 1 xfer\n",
		pr_debug("%s : restored polarity and force 1 xfer\n",
			__func__);
		st54spi_sync(st54spi, &m);
	}
@@ -491,13 +491,13 @@ st54spi_power_set(struct st54spi_data *st54spi, int val)
{
#ifndef WITH_SE_PWR_CONTROL
	if (debug_enabled)
		pr_info("st54spi se_pwr_req DISABLED: %d\n", val);
		pr_debug("st54spi se_pwr_req DISABLED: %d\n", val);
#else // WITH_SE_PWR_CONTROL
	if (!st54spi)
		return;

	if (debug_enabled)
		pr_info("st54spi sehal pwr_req: %d\n", val);
		pr_debug("st54spi sehal pwr_req: %d\n", val);

	if (val) {
		st54spi->sehal_needs_poweron = 1;
@@ -558,7 +558,7 @@ st54spi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
	spin_unlock_irq(&st54spi->spi_lock);

	if (debug_enabled)
		pr_info("st54spi ioctl cmd %d\n", cmd);
		pr_debug("st54spi ioctl cmd %d\n", cmd);

	if (spi == NULL)
		return -ESHUTDOWN;
@@ -694,7 +694,7 @@ st54spi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
	spi_dev_put(spi);

	if (debug_enabled)
		pr_info("st54spi ioctl retval %d\n", retval);
		pr_debug("st54spi ioctl retval %d\n", retval);

	return retval;
}
@@ -724,7 +724,7 @@ st54spi_compat_ioc_message(struct file *filp, unsigned int cmd,
	spin_unlock_irq(&st54spi->spi_lock);

	if (debug_enabled)
		pr_info("st54spi compat_ioctl cmd %d\n", cmd);
		pr_debug("st54spi compat_ioctl cmd %d\n", cmd);
	if (spi == NULL)
		return -ESHUTDOWN;

@@ -754,7 +754,7 @@ st54spi_compat_ioc_message(struct file *filp, unsigned int cmd,
	mutex_unlock(&st54spi->buf_lock);
	spi_dev_put(spi);
	if (debug_enabled)
		pr_info("st54spi compat_ioctl retval %d\n", retval);
		pr_debug("st54spi compat_ioctl retval %d\n", retval);
	return retval;
}

@@ -792,7 +792,7 @@ static int st54spi_open(struct inode *inode, struct file *filp)
	}

	if (debug_enabled)
		pr_info("st54spi: open\n");
		pr_debug("st54spi: open\n");

	if (!st54spi->tx_buffer) {
		st54spi->tx_buffer = kmalloc(bufsiz, GFP_KERNEL);
@@ -819,7 +819,7 @@ static int st54spi_open(struct inode *inode, struct file *filp)
	mutex_unlock(&device_list_lock);

	if (debug_enabled)
		pr_info("st54spi: open - force power on\n");
		pr_debug("st54spi: open - force power on\n");
	st54spi_power_set(st54spi, 1);
	return 0;

@@ -840,7 +840,7 @@ static int st54spi_release(struct inode *inode, struct file *filp)
	filp->private_data = NULL;

	if (debug_enabled)
		pr_info("st54spi: release\n");
		pr_debug("st54spi: release\n");

	/* last close? */
	st54spi->users--;
@@ -848,7 +848,7 @@ static int st54spi_release(struct inode *inode, struct file *filp)
		int		dofree;

		if (debug_enabled)
			pr_info("st54spi: release - may allow power off\n");
			pr_debug("st54spi: release - may allow power off\n");
		st54spi_power_set(st54spi, 0);

		kfree(st54spi->tx_buffer);
@@ -955,7 +955,7 @@ static int st54spi_parse_dt(struct device *dev, struct st54spi_data *pdata)
#if (!defined(CONFIG_MTK_GPIO) || defined(CONFIG_MTK_GPIOLIB_STAND))
		r = of_get_named_gpio(np, "gpio-power-std", 0);
		if (r < 0)
			pr_info("%s: get ST54 failed (%d)", __FILE__, r);
			pr_debug("%s: get ST54 failed (%d)", __FILE__, r);
		else
			pdata->power_gpio = r;
		r = 0;
@@ -964,11 +964,11 @@ static int st54spi_parse_dt(struct device *dev, struct st54spi_data *pdata)
			&(pdata->power_gpio), 1);
#endif
	} else {
		pr_info("%s : get num err.\n", __func__);
		pr_debug("%s : get num err.\n", __func__);
		return -1;
	}

	pr_info("[dsc]%s : get power_gpio[%d]\n", __func__, pdata->power_gpio);
	pr_debug("[dsc]%s : get power_gpio[%d]\n", __func__, pdata->power_gpio);
	return r;
}
#else
@@ -984,7 +984,7 @@ static void st54spi_st21nfc_cb(int dir, void *data)
{
	struct st54spi_data	*st54spi = (struct st54spi_data	*)data;

	pr_info("%s : dir %d data %p\n", __func__, dir, st54spi);
	pr_debug("%s : dir %d data %p\n", __func__, dir, st54spi);
	if (!st54spi)
		return;

@@ -1111,14 +1111,14 @@ static int st54spi_probe(struct spi_device *spi)
#endif
				);
		if (ret)
			pr_info("%s : power request failed (%d)\n", __FILE__,
			pr_debug("%s : power request failed (%d)\n", __FILE__,
				ret);

		pr_info("%s : power GPIO = %d\n", __func__,
		pr_debug("%s : power GPIO = %d\n", __func__,
			st54spi->power_gpio);
		ret = gpio_direction_output(st54spi->power_gpio, 1);
		if (ret)
			pr_info("%s : reset direction_output failed\n",
			pr_debug("%s : reset direction_output failed\n",
				__FILE__);

		/* active high */
@@ -1126,7 +1126,7 @@ static int st54spi_probe(struct spi_device *spi)
	}

	#ifdef WITH_SE_PWR_CONTROL
	pr_info("%s : Register with st21nfc driver, %p\n", __func__, st54spi);
	pr_debug("%s : Register with st21nfc driver, %p\n", __func__, st54spi);
	st21nfc_register_st54spi_cb(st54spi_st21nfc_cb, st54spi);
	#endif // WITH_SE_PWR_CONTROL

@@ -1138,7 +1138,7 @@ static int st54spi_remove(struct spi_device *spi)
	struct st54spi_data	*st54spi = spi_get_drvdata(spi);

	#ifdef WITH_SE_PWR_CONTROL
	pr_info("%s : Unregister from st21nfc driver\n", __func__);
	pr_debug("%s : Unregister from st21nfc driver\n", __func__);
	st21nfc_unregister_st54spi_cb();
	#endif // WITH_SE_PWR_CONTROL

@@ -1182,7 +1182,7 @@ static int __init st54spi_init(void)
{
	int status;

	pr_info("Loading st54spi driver\n");
	pr_debug("Loading st54spi driver\n");

	/* Claim our 256 reserved device numbers.  Then register a class
	 * that will key udev/mdev to add/remove /dev nodes.  Last, register
@@ -1191,7 +1191,7 @@ static int __init st54spi_init(void)
	BUILD_BUG_ON(N_SPI_MINORS > 256);
	spidev_major = __register_chrdev(0, 0, N_SPI_MINORS, "spi",
		&st54spi_fops);
	pr_info("Loading st54spi driver, major: %d\n", spidev_major);
	pr_debug("Loading st54spi driver, major: %d\n", spidev_major);

	st54spi_class = class_create(THIS_MODULE, "spidev");
	if (IS_ERR(st54spi_class)) {
@@ -1204,7 +1204,7 @@ static int __init st54spi_init(void)
		class_destroy(st54spi_class);
		unregister_chrdev(spidev_major, st54spi_spi_driver.driver.name);
	}
	pr_info("Loading st54spi driver: %d\n", status);
	pr_debug("Loading st54spi driver: %d\n", status);
	return status;
}
module_init(st54spi_init);