diff --git a/drivers/nfc/qti/nfc_common.c b/drivers/nfc/qti/nfc_common.c index 9b593f8bd51d..38a8578a3b6b 100644 --- a/drivers/nfc/qti/nfc_common.c +++ b/drivers/nfc/qti/nfc_common.c @@ -651,6 +651,40 @@ unsigned int nfc_ioctl_nfcc_info(struct file *filp, unsigned long arg) * * @return 0 on success, error code for failures. */ + +#ifdef CONFIG_COMPAT +long nfc_compat_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg) +{ + int ret = 0; + struct nfc_dev *nfc_dev = pfile->private_data; + + arg = (compat_u64)arg; + pr_debug("%s cmd = %x arg = %zx\n", __func__, cmd, arg); + + switch (cmd) { + case NFC_SET_PWR: + ret = nfc_ioctl_power_states(nfc_dev, arg); + break; + case ESE_SET_PWR: + ret = nfc_ese_pwr(nfc_dev, arg); + break; + case ESE_GET_PWR: + ret = nfc_ese_pwr(nfc_dev, ESE_POWER_STATE); + break; + case NFCC_GET_INFO: + ret = nfc_ioctl_nfcc_info(pfile, arg); + break; + case NFC_GET_PLATFORM_TYPE: + ret = nfc_dev->interface; + break; + default: + pr_err("%s bad cmd %lu\n", __func__, arg); + ret = -ENOIOCTLCMD; + } + return ret; +} +#endif + long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg) { int ret = 0; diff --git a/drivers/nfc/qti/nfc_common.h b/drivers/nfc/qti/nfc_common.h index 2dc31036c1e7..a4ed5348ab0d 100644 --- a/drivers/nfc/qti/nfc_common.h +++ b/drivers/nfc/qti/nfc_common.h @@ -254,6 +254,9 @@ struct nfc_dev { int nfc_dev_open(struct inode *inode, struct file *filp); int nfc_dev_close(struct inode *inode, struct file *filp); long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg); +#ifdef CONFIG_COMPAT +long nfc_compat_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg); +#endif int nfc_parse_dt(struct device *dev, struct platform_gpio *nfc_gpio, struct platform_ldo *ldo, uint8_t interface); int nfc_misc_probe(struct nfc_dev *nfc_dev, diff --git a/drivers/nfc/qti/nfc_i2c_drv.c b/drivers/nfc/qti/nfc_i2c_drv.c index fee83a9f9a2e..e5480a1afd58 100644 --- a/drivers/nfc/qti/nfc_i2c_drv.c +++ b/drivers/nfc/qti/nfc_i2c_drv.c @@ -266,6 +266,9 @@ static const struct file_operations nfc_i2c_dev_fops = { .open = nfc_dev_open, .release = nfc_dev_close, .unlocked_ioctl = nfc_dev_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = nfc_compat_dev_ioctl, +#endif }; int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id)