From 4f6189525bff0eeacee39893cde5b09cdf63d217 Mon Sep 17 00:00:00 2001 From: Chun XU Date: Tue, 7 Feb 2017 19:19:12 +0800 Subject: [PATCH] misc: tegra_cec: add recover IOCTL Provide error recovery from IOCTL to user space. Bug 1866338 Change-Id: I705ada6c8d4cb13f1c882993468f467da2908fdf Signed-off-by: Chun XU Reviewed-on: http://git-master/r/1300499 (cherry picked from commit a646f4903c8794641432fa838a27ee5584944eb5) --- drivers/misc/tegra-cec/tegra_cec.c | 27 +++++++++++++++++++++++++++ drivers/misc/tegra-cec/tegra_cec.h | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/misc/tegra-cec/tegra_cec.c b/drivers/misc/tegra-cec/tegra_cec.c index 2b8949b9..98eca5aa 100644 --- a/drivers/misc/tegra-cec/tegra_cec.c +++ b/drivers/misc/tegra-cec/tegra_cec.c @@ -304,12 +304,38 @@ out: return IRQ_HANDLED; } +static long tegra_cec_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct tegra_cec *cec = file->private_data; + + if (_IOC_TYPE(cmd) != TEGRA_CEC_IOC_MAGIC) + return -EINVAL; + + switch (cmd) { + case TEGRA_CEC_IOCTL_ERROR_RECOVERY: + mutex_lock(&cec->recovery_lock); + tegra_cec_error_recovery(cec); + mutex_unlock(&cec->recovery_lock); + break; + default: + dev_err(cec->dev, "unsupported ioctl\n"); + return -EINVAL; + } + + return 0; +} + static const struct file_operations tegra_cec_fops = { .owner = THIS_MODULE, .open = tegra_cec_open, .release = tegra_cec_release, .read = tegra_cec_read, .write = tegra_cec_write, + .unlocked_ioctl = tegra_cec_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = tegra_cec_ioctl, +#endif }; static int tegra_cec_send_one_touch_play(struct tegra_cec *cec) @@ -534,6 +560,7 @@ static int tegra_cec_probe(struct platform_device *pdev) atomic_set(&cec->init_done, 0); mutex_init(&cec->tx_lock); + mutex_init(&cec->recovery_lock); #if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE) ret = tegra_nvdisp_unpowergate_partition(cec->soc->powergate_id); diff --git a/drivers/misc/tegra-cec/tegra_cec.h b/drivers/misc/tegra-cec/tegra_cec.h index 3f06a81f..34300d0f 100644 --- a/drivers/misc/tegra-cec/tegra_cec.h +++ b/drivers/misc/tegra-cec/tegra_cec.h @@ -1,7 +1,7 @@ /* * drivers/misc/tegra-cec/tegra_cec.h * - * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2012-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -31,6 +31,7 @@ struct tegra_cec { struct miscdevice misc_dev; struct clk *clk; struct mutex tx_lock; + struct mutex recovery_lock; void __iomem *cec_base; int tegra_cec_irq; wait_queue_head_t rx_waitq; @@ -163,4 +164,8 @@ static int tegra_cec_remove(struct platform_device *pdev); #define TEGRA_CEC_NAME "tegra_cec" +#define TEGRA_CEC_IOC_MAGIC 'C' + +#define TEGRA_CEC_IOCTL_ERROR_RECOVERY _IO(TEGRA_CEC_IOC_MAGIC, 1) + #endif /* TEGRA_CEC_H */