Skip to content

Commit 8dc244f

Browse files
Alan CoxWim Van Sebroeck
authored andcommitted
[WATCHDOG 48/57] txx9: Fix locking, switch to unlocked_ioctl
Review and switch to unlocked_ioctl Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
1 parent f92d374 commit 8dc244f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

drivers/watchdog/txx9wdt.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,34 @@ static unsigned long txx9wdt_alive;
4545
static int expect_close;
4646
static struct txx9_tmr_reg __iomem *txx9wdt_reg;
4747
static struct clk *txx9_imclk;
48+
static DECLARE_LOCK(txx9_lock);
4849

4950
static void txx9wdt_ping(void)
5051
{
52+
spin_lock(&txx9_lock);
5153
__raw_writel(TXx9_TMWTMR_TWIE | TXx9_TMWTMR_TWC, &txx9wdt_reg->wtmr);
54+
spin_unlock(&txx9_lock);
5255
}
5356

5457
static void txx9wdt_start(void)
5558
{
59+
spin_lock(&txx9_lock);
5660
__raw_writel(WD_TIMER_CLK * timeout, &txx9wdt_reg->cpra);
5761
__raw_writel(WD_TIMER_CCD, &txx9wdt_reg->ccdr);
5862
__raw_writel(0, &txx9wdt_reg->tisr); /* clear pending interrupt */
5963
__raw_writel(TXx9_TMTCR_TCE | TXx9_TMTCR_CCDE | TXx9_TMTCR_TMODE_WDOG,
6064
&txx9wdt_reg->tcr);
6165
__raw_writel(TXx9_TMWTMR_TWIE | TXx9_TMWTMR_TWC, &txx9wdt_reg->wtmr);
66+
spin_unlock(&txx9_lock);
6267
}
6368

6469
static void txx9wdt_stop(void)
6570
{
71+
spin_lock(&txx9_lock);
6672
__raw_writel(TXx9_TMWTMR_WDIS, &txx9wdt_reg->wtmr);
6773
__raw_writel(__raw_readl(&txx9wdt_reg->tcr) & ~TXx9_TMTCR_TCE,
6874
&txx9wdt_reg->tcr);
75+
spin_unlock(&txx9_lock);
6976
}
7077

7178
static int txx9wdt_open(struct inode *inode, struct file *file)
@@ -120,13 +127,13 @@ static ssize_t txx9wdt_write(struct file *file, const char __user *data,
120127
return len;
121128
}
122129

123-
static int txx9wdt_ioctl(struct inode *inode, struct file *file,
124-
unsigned int cmd, unsigned long arg)
130+
static long txx9wdt_ioctl(struct file *file, unsigned int cmd,
131+
unsigned long arg)
125132
{
126133
void __user *argp = (void __user *)arg;
127134
int __user *p = argp;
128135
int new_timeout;
129-
static struct watchdog_info ident = {
136+
static const struct watchdog_info ident = {
130137
.options = WDIOF_SETTIMEOUT |
131138
WDIOF_KEEPALIVEPING |
132139
WDIOF_MAGICCLOSE,
@@ -168,18 +175,18 @@ static int txx9wdt_notify_sys(struct notifier_block *this, unsigned long code,
168175
}
169176

170177
static const struct file_operations txx9wdt_fops = {
171-
.owner = THIS_MODULE,
172-
.llseek = no_llseek,
173-
.write = txx9wdt_write,
174-
.ioctl = txx9wdt_ioctl,
175-
.open = txx9wdt_open,
176-
.release = txx9wdt_release,
178+
.owner = THIS_MODULE,
179+
.llseek = no_llseek,
180+
.write = txx9wdt_write,
181+
.unlocked_ioctl = txx9wdt_ioctl,
182+
.open = txx9wdt_open,
183+
.release = txx9wdt_release,
177184
};
178185

179186
static struct miscdevice txx9wdt_miscdev = {
180-
.minor = WATCHDOG_MINOR,
181-
.name = "watchdog",
182-
.fops = &txx9wdt_fops,
187+
.minor = WATCHDOG_MINOR,
188+
.name = "watchdog",
189+
.fops = &txx9wdt_fops,
183190
};
184191

185192
static struct notifier_block txx9wdt_notifier = {

0 commit comments

Comments
 (0)