aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/most
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2018-05-08 11:44:55 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-08 13:41:48 +0200
commit0ecbf7fc366a5c4e6cfef49572739f1e2544faf5 (patch)
tree832f570b658a8e34b488779fff8b18744600d62a /drivers/staging/most
parentstaging: most: aim-sound: add flexible format support (diff)
downloadlinux-dev-0ecbf7fc366a5c4e6cfef49572739f1e2544faf5.tar.xz
linux-dev-0ecbf7fc366a5c4e6cfef49572739f1e2544faf5.zip
staging: most: i2c: shorten lifetime of IRQ handler
Currently the IRQ handler used for the rx channel lives between the functions i2c_probe and i2c_remove. This patch shortens the lifetime and keeps the handler alive only between the functions configure_channel and poison_channel. 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.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/drivers/staging/most/i2c/i2c.c b/drivers/staging/most/i2c/i2c.c
index 8ec660bd2990..b382f094a901 100644
--- a/drivers/staging/most/i2c/i2c.c
+++ b/drivers/staging/most/i2c/i2c.c
@@ -56,6 +56,8 @@ struct hdm_i2c {
#define to_hdm(iface) container_of(iface, struct hdm_i2c, most_iface)
+static irqreturn_t most_irq_handler(int, void *);
+
/**
* configure_channel - called from MOST core to configure a channel
* @iface: interface the channel belongs to
@@ -71,6 +73,7 @@ static int configure_channel(struct most_interface *most_iface,
int ch_idx,
struct most_channel_config *channel_config)
{
+ int ret;
struct hdm_i2c *dev = to_hdm(most_iface);
BUG_ON(ch_idx < 0 || ch_idx >= NUM_CHANNELS);
@@ -86,7 +89,21 @@ static int configure_channel(struct most_interface *most_iface,
return -EPERM;
}
+ if (channel_config->direction == MOST_CH_RX) {
+ dev->polling_mode = polling_req || dev->client->irq <= 0;
+ if (!dev->polling_mode) {
+ pr_info("Requesting IRQ: %d\n", dev->client->irq);
+ ret = request_irq(dev->client->irq, most_irq_handler, 0,
+ dev->client->name, dev);
+ if (ret) {
+ pr_info("IRQ request failed: %d, falling back to polling\n",
+ ret);
+ dev->polling_mode = true;
+ }
+ }
+ }
if ((channel_config->direction == MOST_CH_RX) && (dev->polling_mode)) {
+ pr_info("Using polling at rate: %d times/sec\n", scan_rate);
schedule_delayed_work(&dev->rx.dwork,
msecs_to_jiffies(MSEC_PER_SEC / 4));
}
@@ -160,6 +177,10 @@ static int poison_channel(struct most_interface *most_iface,
dev->is_open[ch_idx] = false;
if (ch_idx == CH_RX) {
+ if (!dev->polling_mode)
+ free_irq(dev->client->irq, dev);
+ cancel_delayed_work_sync(&dev->rx.dwork);
+
mutex_lock(&dev->rx.list_mutex);
while (!list_empty(&dev->rx.list)) {
mbo = list_first_mbo(&dev->rx.list);
@@ -347,21 +368,6 @@ static int i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
return ret;
}
- dev->polling_mode = polling_req || client->irq <= 0;
- if (!dev->polling_mode) {
- pr_info("Requesting IRQ: %d\n", client->irq);
- ret = request_irq(client->irq, most_irq_handler, 0,
- client->name, dev);
- if (ret) {
- pr_info("IRQ request failed: %d, falling back to polling\n",
- ret);
- dev->polling_mode = true;
- }
- }
-
- if (dev->polling_mode)
- pr_info("Using polling at rate: %d times/sec\n", scan_rate);
-
return 0;
}
@@ -377,11 +383,7 @@ static int i2c_remove(struct i2c_client *client)
{
struct hdm_i2c *dev = i2c_get_clientdata(client);
- if (!dev->polling_mode)
- free_irq(client->irq, dev);
-
most_deregister_interface(&dev->most_iface);
- cancel_delayed_work_sync(&dev->rx.dwork);
kfree(dev);
return 0;