HTS221 driver: Modify to use new interrupt parameter passing hooks.

This commit is contained in:
Gregory Nutt 2017-03-31 05:31:35 -06:00
parent c5d55c62f4
commit 916bd8a48f
2 changed files with 10 additions and 11 deletions

View File

@ -174,8 +174,6 @@ static const struct file_operations g_humidityops =
#endif #endif
}; };
static struct hts221_dev_s *g_humid_data;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -1069,13 +1067,14 @@ out:
static int hts221_int_handler(int irq, FAR void *context, FAR void *arg) static int hts221_int_handler(int irq, FAR void *context, FAR void *arg)
{ {
if (!g_humid_data) FAR struct hts221_dev_s *priv = (FAR struct hts221_dev_s *)arg;
return OK;
g_humid_data->int_pending = true; DEBUGASSERT(priv != NULL);
priv->int_pending = true;
hts221_dbg("Hts221 interrupt\n"); hts221_dbg("Hts221 interrupt\n");
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
hts221_notify(g_humid_data); hts221_notify(priv);
#endif #endif
return OK; return OK;
@ -1095,7 +1094,6 @@ int hts221_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
return -ENOMEM; return -ENOMEM;
} }
g_humid_data = priv;
priv->addr = addr; priv->addr = addr;
priv->i2c = i2c; priv->i2c = i2c;
priv->config = config; priv->config = config;
@ -1125,7 +1123,7 @@ int hts221_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
priv->config->irq_clear(priv->config); priv->config->irq_clear(priv->config);
} }
priv->config->irq_attach(priv->config, hts221_int_handler); priv->config->irq_attach(priv->config, hts221_int_handler, priv);
priv->config->irq_enable(priv->config, false); priv->config->irq_enable(priv->config, false);
return OK; return OK;
} }

View File

@ -117,10 +117,11 @@ typedef struct hts221_settings_s
typedef struct hts221_config_s typedef struct hts221_config_s
{ {
int irq; int irq;
CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr); CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr,
CODE void (*irq_enable)(FAR const struct hts221_config_s * state, FAR void *arg);
CODE void (*irq_enable)(FAR const struct hts221_config_s *state,
bool enable); bool enable);
CODE void (*irq_clear)(FAR const struct hts221_config_s * state); CODE void (*irq_clear)(FAR const struct hts221_config_s *state);
CODE int (*set_power)(FAR const struct hts221_config_s *state, bool on); CODE int (*set_power)(FAR const struct hts221_config_s *state, bool on);
} hts221_config_t; } hts221_config_t;