diff --git a/drivers/sensors/hts221.c b/drivers/sensors/hts221.c index 4dc9c0d2dd1..7ce201ecacd 100644 --- a/drivers/sensors/hts221.c +++ b/drivers/sensors/hts221.c @@ -174,8 +174,6 @@ static const struct file_operations g_humidityops = #endif }; -static struct hts221_dev_s *g_humid_data; - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -1069,13 +1067,14 @@ out: static int hts221_int_handler(int irq, FAR void *context, FAR void *arg) { - if (!g_humid_data) - return OK; + FAR struct hts221_dev_s *priv = (FAR struct hts221_dev_s *)arg; - g_humid_data->int_pending = true; + DEBUGASSERT(priv != NULL); + + priv->int_pending = true; hts221_dbg("Hts221 interrupt\n"); #ifndef CONFIG_DISABLE_POLL - hts221_notify(g_humid_data); + hts221_notify(priv); #endif return OK; @@ -1095,7 +1094,6 @@ int hts221_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, return -ENOMEM; } - g_humid_data = priv; priv->addr = addr; priv->i2c = i2c; 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_attach(priv->config, hts221_int_handler); + priv->config->irq_attach(priv->config, hts221_int_handler, priv); priv->config->irq_enable(priv->config, false); return OK; } diff --git a/include/nuttx/sensors/hts221.h b/include/nuttx/sensors/hts221.h index 47142c3f82d..1b9ddc56251 100644 --- a/include/nuttx/sensors/hts221.h +++ b/include/nuttx/sensors/hts221.h @@ -117,10 +117,11 @@ typedef struct hts221_settings_s typedef struct hts221_config_s { int irq; - CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr); - CODE void (*irq_enable)(FAR const struct hts221_config_s * state, + CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr, + FAR void *arg); + CODE void (*irq_enable)(FAR const struct hts221_config_s *state, 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); } hts221_config_t;