/* * Write a dryice register and wait until it completes. * * This function uses interrupts to determine when the * write has completed. */ static int di_write_wait(struct rtc_drv_data *pdata, u32 val, int reg) { int ret; int rc = 0; /* serialize register writes */ mutex_lock(&pdata->write_mutex); /* enable the write-complete interrupt */ di_int_enable(pdata, DIER_WCIE); pdata->dsr = 0; /* do the register write */ di_write(pdata, val, reg); /* wait for the write to finish */ ret = wait_event_interruptible_timeout(pdata->write_wait, pdata->dsr & (DSR_WCF | DSR_WEF), 1 * HZ); if (ret == 0) dev_warn(&pdata->pdev->dev, "Write-wait timeout\n"); /* check for write error */ if (pdata->dsr & DSR_WEF) { clear_write_error(pdata); rc = -EIO; } mutex_unlock(&pdata->write_mutex); return rc; }
static int di_write_wait(u32 val, const char *reg) { int cnt; int ret = 0; int rc = 0; /* wait for the write to finish */ for (cnt = 0; cnt < 100; cnt++) { if ((__raw_readl(&data.regs->dsr) & (DSR_WCF | DSR_WEF)) != 0) { ret = 1; break; } udelay(10); } if (ret == 0) printf("### Warning: RTC - Write-wait timeout " "val = 0x%.8x reg = %s\n", val, reg); /* check for write error */ if (__raw_readl(&data.regs->dsr) & DSR_WEF) { clear_write_error(); rc = -1; } return rc; }
/* * Write a dryice register and wait until it completes. * * This function uses interrupts to determine when the * write has completed. */ static int di_write_wait(struct imxdi_dev *imxdi, u32 val, int reg) { int ret; int rc = 0; /* serialize register writes */ mutex_lock(&imxdi->write_mutex); /* enable the write-complete interrupt */ di_int_enable(imxdi, DIER_WCIE); imxdi->dsr = 0; /* do the register write */ __raw_writel(val, imxdi->ioaddr + reg); /* wait for the write to finish */ ret = wait_event_interruptible_timeout(imxdi->write_wait, imxdi->dsr & (DSR_WCF | DSR_WEF), msecs_to_jiffies(1)); if (ret < 0) { rc = ret; goto out; } else if (ret == 0) { dev_warn(&imxdi->pdev->dev, "Write-wait timeout " "val = 0x%08x reg = 0x%08x\n", val, reg); } /* check for write error */ if (imxdi->dsr & DSR_WEF) { clear_write_error(imxdi); rc = -EIO; } out: mutex_unlock(&imxdi->write_mutex); return rc; }
static int di_write_wait(struct imxdi_dev *imxdi, u32 val, int reg) { int ret; int rc = 0; mutex_lock(&imxdi->write_mutex); di_int_enable(imxdi, DIER_WCIE); imxdi->dsr = 0; __raw_writel(val, imxdi->ioaddr + reg); ret = wait_event_interruptible_timeout(imxdi->write_wait, imxdi->dsr & (DSR_WCF | DSR_WEF), msecs_to_jiffies(1)); if (ret < 0) { rc = ret; goto out; } else if (ret == 0) { dev_warn(&imxdi->pdev->dev, "Write-wait timeout " "val = 0x%08x reg = 0x%08x\n", val, reg); } if (imxdi->dsr & DSR_WEF) { clear_write_error(imxdi); rc = -EIO; } out: mutex_unlock(&imxdi->write_mutex); return rc; }