int irq;
struct rtc_device *rtc;
- /* The mutex protects alarm operations, and prevents a race
- * between the enable_irq() in the workqueue and the free_irq()
- * in the remove function.
- */
- struct mutex mutex;
bool suspended;
};
int ret;
u8 buf[4];
- mutex_lock(&ds3232->mutex);
-
ret = regmap_read(ds3232->regmap, DS3232_REG_SR, &stat);
if (ret)
goto out;
ret = 0;
out:
- mutex_unlock(&ds3232->mutex);
return ret;
}
if (ds3232->irq <= 0)
return -EINVAL;
- mutex_lock(&ds3232->mutex);
-
buf[0] = bin2bcd(alarm->time.tm_sec);
buf[1] = bin2bcd(alarm->time.tm_min);
buf[2] = bin2bcd(alarm->time.tm_hour);
ret = regmap_write(ds3232->regmap, DS3232_REG_CR, control);
}
out:
- mutex_unlock(&ds3232->mutex);
return ret;
}
int control;
int ret;
- mutex_lock(&ds3232->mutex);
-
ret = regmap_read(ds3232->regmap, DS3232_REG_CR, &control);
if (ret)
- goto unlock;
+ return ret;
if (enabled)
/* enable alarm1 interrupt */
control &= ~(DS3232_REG_CR_A1IE);
ret = regmap_write(ds3232->regmap, DS3232_REG_CR, control);
-unlock:
- mutex_unlock(&ds3232->mutex);
-
return ret;
}
{
struct device *dev = dev_id;
struct ds3232 *ds3232 = dev_get_drvdata(dev);
+ struct mutex *lock = &ds3232->rtc->ops_lock;
int ret;
int stat, control;
- mutex_lock(&ds3232->mutex);
+ mutex_lock(lock);
ret = regmap_read(ds3232->regmap, DS3232_REG_SR, &stat);
if (ret)
}
unlock:
- mutex_unlock(&ds3232->mutex);
+ mutex_unlock(lock);
return IRQ_HANDLED;
}
ds3232->dev = dev;
dev_set_drvdata(dev, ds3232);
- mutex_init(&ds3232->mutex);
-
ret = ds3232_check_rtc_status(dev);
if (ret)
return ret;