aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/most
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2018-05-08 11:44:58 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-08 13:41:49 +0200
commitea8bcd5282d9dc683d7a544c42bcc057c168d315 (patch)
treef0d34154167f0f3d21ec2283c4b2813b897a1d54 /drivers/staging/most
parentstaging: most: i2c: avoid polling in case of misconfig (diff)
downloadlinux-dev-ea8bcd5282d9dc683d7a544c42bcc057c168d315.tar.xz
linux-dev-ea8bcd5282d9dc683d7a544c42bcc057c168d315.zip
staging: most: i2c: prevent zero delay polling
This patch avoids that a configured scan_rate of more than MSEC_PER_SEC might result in a polling delay of zero. Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/most')
-rw-r--r--drivers/staging/most/i2c/i2c.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/staging/most/i2c/i2c.c b/drivers/staging/most/i2c/i2c.c
index e03cb6c65c88..30d18cc5f072 100644
--- a/drivers/staging/most/i2c/i2c.c
+++ b/drivers/staging/most/i2c/i2c.c
@@ -49,6 +49,7 @@ struct hdm_i2c {
struct list_head list;
struct mutex list_mutex;
bool int_disabled;
+ unsigned int delay;
} rx;
char name[64];
};
@@ -75,6 +76,7 @@ static int configure_channel(struct most_interface *most_iface,
{
int ret;
struct hdm_i2c *dev = to_hdm(most_iface);
+ unsigned int delay;
BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
BUG_ON(dev->is_open[ch_idx]);
@@ -105,6 +107,8 @@ static int configure_channel(struct most_interface *most_iface,
return ret;
}
} else if (scan_rate) {
+ delay = msecs_to_jiffies(MSEC_PER_SEC / scan_rate);
+ dev->rx.delay = delay ? delay : 1;
pr_info("polling rate is %d Hz\n", scan_rate);
}
}
@@ -265,9 +269,7 @@ static void pending_rx_work(struct work_struct *work)
if (dev->polling_mode) {
if (dev->is_open[CH_RX] && scan_rate)
- schedule_delayed_work(&dev->rx.dwork,
- msecs_to_jiffies(MSEC_PER_SEC
- / scan_rate));
+ schedule_delayed_work(&dev->rx.dwork, dev->rx.delay);
} else {
dev->rx.int_disabled = false;
enable_irq(dev->client->irq);