aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/most
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2018-05-08 11:45:02 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-08 13:41:49 +0200
commit7e6e228873945ccb46895f1f5e29187814ea1d8d (patch)
tree15dabc31e98cc168c21125614dd0dfc6061b1e21 /drivers/staging/most
parentstaging: most: i2c: remove redundant list_mutex (diff)
downloadlinux-dev-7e6e228873945ccb46895f1f5e29187814ea1d8d.tar.xz
linux-dev-7e6e228873945ccb46895f1f5e29187814ea1d8d.zip
staging: most: i2c: reduce parameters inconsistency
Currently, there are two module parameters for the i2c driver: - polling_req: boolean irq/polling mode; - scan_rate: polling rate, that is used in the case where the polling mode is active This model is misconfiguration-prone. For example, it is possible to select polling mode with the zero polling rate or configure non-zero polling rate in a combination with the IRQ mode. This patch replaces the 'polling_req' and 'scan_rate' by the 'polling_rate', where the value zero means the interrupt driven mode and other values are used as the polling rate in the polling mode. Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de> 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.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/staging/most/i2c/i2c.c b/drivers/staging/most/i2c/i2c.c
index f0d5b222f40a..4a4fc1005932 100644
--- a/drivers/staging/most/i2c/i2c.c
+++ b/drivers/staging/most/i2c/i2c.c
@@ -28,18 +28,11 @@ enum { CH_RX, CH_TX, NUM_CHANNELS };
#define list_first_mbo(ptr) \
list_first_entry(ptr, struct mbo, list)
-/* IRQ / Polling option */
-static bool polling_req;
-module_param(polling_req, bool, 0444);
-MODULE_PARM_DESC(polling_req, "Request Polling. Default = 0 (use irq)");
-
-/* Polling Rate */
-static int scan_rate = 100;
-module_param(scan_rate, int, 0644);
-MODULE_PARM_DESC(scan_rate, "Polling rate in times/sec. Default = 100");
+static unsigned int polling_rate;
+module_param(polling_rate, uint, 0644);
+MODULE_PARM_DESC(polling_rate, "Polling rate [Hz]. Default = 0 (use IRQ)");
struct hdm_i2c {
- bool polling_mode;
struct most_interface most_iface;
struct most_channel_capability capabilities[NUM_CHANNELS];
struct i2c_client *client;
@@ -89,8 +82,7 @@ static int configure_channel(struct most_interface *most_iface,
}
if (channel_config->direction == MOST_CH_RX) {
- dev->polling_mode = polling_req;
- if (!dev->polling_mode) {
+ if (!polling_rate) {
if (dev->client->irq <= 0) {
pr_err("bad irq: %d\n", dev->client->irq);
return -ENOENT;
@@ -103,8 +95,8 @@ static int configure_channel(struct most_interface *most_iface,
dev->client->irq, ret);
return ret;
}
- } else if (scan_rate) {
- delay = msecs_to_jiffies(MSEC_PER_SEC / scan_rate);
+ } else {
+ delay = msecs_to_jiffies(MSEC_PER_SEC / polling_rate);
dev->rx.delay = delay ? delay : 1;
pr = MSEC_PER_SEC / jiffies_to_msecs(dev->rx.delay);
pr_info("polling rate is %u Hz\n", pr);
@@ -135,13 +127,13 @@ static int enqueue(struct most_interface *most_iface,
if (ch_idx == CH_RX) {
/* RX */
- if (!dev->polling_mode)
+ if (!polling_rate)
disable_irq(dev->client->irq);
cancel_delayed_work_sync(&dev->rx.dwork);
list_add_tail(&mbo->list, &dev->rx.list);
- if (dev->rx.int_disabled || dev->polling_mode)
+ if (dev->rx.int_disabled || polling_rate)
pending_rx_work(&dev->rx.dwork.work);
- if (!dev->polling_mode)
+ if (!polling_rate)
enable_irq(dev->client->irq);
} else {
/* TX */
@@ -179,7 +171,7 @@ static int poison_channel(struct most_interface *most_iface,
BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
if (ch_idx == CH_RX) {
- if (!dev->polling_mode)
+ if (!polling_rate)
free_irq(dev->client->irq, dev);
cancel_delayed_work_sync(&dev->rx.dwork);
@@ -247,9 +239,8 @@ static void pending_rx_work(struct work_struct *work)
do_rx_work(dev);
- if (dev->polling_mode) {
- if (scan_rate)
- schedule_delayed_work(&dev->rx.dwork, dev->rx.delay);
+ if (polling_rate) {
+ schedule_delayed_work(&dev->rx.dwork, dev->rx.delay);
} else {
dev->rx.int_disabled = false;
enable_irq(dev->client->irq);