video: tegra: dc: limit access to win_h sysfs
Jon Mayo [Tue, 26 Nov 2013 19:15:49 +0000 (11:15 -0800)]
Return error when display is powered down for reads or writes to win_h.

Bug 1412225

Change-Id: I6df22cede222ff2f0ff381c0941dab2e7d08eabb
Signed-off-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-on: http://git-master/r/335744
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit

drivers/video/tegra/dc/dc_sysfs.c

index 1c574af..c9343d1 100644 (file)
@@ -135,7 +135,7 @@ static ssize_t enable_store(struct device *dev,
        return count;
 }
 
-static DEVICE_ATTR(enable, S_IRUGO|S_IWUSR, enable_show, enable_store);
+static DEVICE_ATTR(enable, S_IRUSR | S_IWUSR, enable_show, enable_store);
 
 #ifdef CONFIG_TEGRA_DC_WIN_H
 static ssize_t win_h_show(struct device *device,
@@ -145,6 +145,9 @@ static ssize_t win_h_show(struct device *device,
        struct tegra_dc *dc = platform_get_drvdata(ndev);
        unsigned long val = 0;
 
+       if (!dc->enabled)
+               return -EIO; /* not powered */
+
        mutex_lock(&dc->lock);
        tegra_dc_io_start(dc);
 
@@ -169,7 +172,7 @@ static ssize_t win_h_store(struct device *dev,
 
        if (!dc->enabled) {
                dev_err(&dc->ndev->dev, "%s: DC not enabled.\n", __func__);
-               return -EFAULT;
+               return -EIO; /* not powered */
        }
 
        if (kstrtouint(buf, 10, &val) < 0)