Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: iTCO: Drop driver-internal locking

The locking code in the iTCO watchdog driver has been carried along from
before the watchdog core existed. The watchdog core protects calls into
drivers since commit f4e9c82f64b5 ("watchdog: Add Locking support"),
making driver-internal locking unnecessary. Drop it.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Link: https://lore.kernel.org/r/20250517160936.3231017-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Guenter Roeck and committed by
Wim Van Sebroeck
27a46a0f 45f1884d

-24
-24
drivers/watchdog/iTCO_wdt.c
··· 58 58 #include <linux/platform_device.h> /* For platform_driver framework */ 59 59 #include <linux/pci.h> /* For pci functions */ 60 60 #include <linux/ioport.h> /* For io-port access */ 61 - #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ 62 61 #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ 63 62 #include <linux/io.h> /* For inb/outb/... */ 64 63 #include <linux/platform_data/itco_wdt.h> ··· 101 102 * or memory-mapped PMC register bit 4 (TCO version 3). 102 103 */ 103 104 unsigned long __iomem *gcs_pmc; 104 - /* the lock for io operations */ 105 - spinlock_t io_lock; 106 105 /* the PCI-device */ 107 106 struct pci_dev *pci_dev; 108 107 /* whether or not the watchdog has been suspended */ ··· 283 286 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); 284 287 unsigned int val; 285 288 286 - spin_lock(&p->io_lock); 287 - 288 289 iTCO_vendor_pre_start(p->smi_res, wd_dev->timeout); 289 290 290 291 /* disable chipset's NO_REBOOT bit */ 291 292 if (p->update_no_reboot_bit(p->no_reboot_priv, false)) { 292 - spin_unlock(&p->io_lock); 293 293 dev_err(wd_dev->parent, "failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n"); 294 294 return -EIO; 295 295 } ··· 303 309 val &= 0xf7ff; 304 310 outw(val, TCO1_CNT(p)); 305 311 val = inw(TCO1_CNT(p)); 306 - spin_unlock(&p->io_lock); 307 312 308 313 if (val & 0x0800) 309 314 return -1; ··· 313 320 { 314 321 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); 315 322 unsigned int val; 316 - 317 - spin_lock(&p->io_lock); 318 323 319 324 iTCO_vendor_pre_stop(p->smi_res); 320 325 ··· 325 334 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ 326 335 p->update_no_reboot_bit(p->no_reboot_priv, true); 327 336 328 - spin_unlock(&p->io_lock); 329 - 330 337 if ((val & 0x0800) == 0) 331 338 return -1; 332 339 return 0; ··· 333 344 static int iTCO_wdt_ping(struct watchdog_device *wd_dev) 334 345 { 335 346 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); 336 - 337 - spin_lock(&p->io_lock); 338 347 339 348 /* Reload the timer by writing to the TCO Timer Counter register */ 340 349 if (p->iTCO_version >= 2) { ··· 345 358 outb(0x01, TCO_RLD(p)); 346 359 } 347 360 348 - spin_unlock(&p->io_lock); 349 361 return 0; 350 362 } 351 363 ··· 371 385 372 386 /* Write new heartbeat to watchdog */ 373 387 if (p->iTCO_version >= 2) { 374 - spin_lock(&p->io_lock); 375 388 val16 = inw(TCOv2_TMR(p)); 376 389 val16 &= 0xfc00; 377 390 val16 |= tmrval; 378 391 outw(val16, TCOv2_TMR(p)); 379 392 val16 = inw(TCOv2_TMR(p)); 380 - spin_unlock(&p->io_lock); 381 393 382 394 if ((val16 & 0x3ff) != tmrval) 383 395 return -EINVAL; 384 396 } else if (p->iTCO_version == 1) { 385 - spin_lock(&p->io_lock); 386 397 val8 = inb(TCOv1_TMR(p)); 387 398 val8 &= 0xc0; 388 399 val8 |= (tmrval & 0xff); 389 400 outb(val8, TCOv1_TMR(p)); 390 401 val8 = inb(TCOv1_TMR(p)); 391 - spin_unlock(&p->io_lock); 392 402 393 403 if ((val8 & 0x3f) != tmrval) 394 404 return -EINVAL; ··· 403 421 404 422 /* read the TCO Timer */ 405 423 if (p->iTCO_version >= 2) { 406 - spin_lock(&p->io_lock); 407 424 val16 = inw(TCO_RLD(p)); 408 425 val16 &= 0x3ff; 409 - spin_unlock(&p->io_lock); 410 426 411 427 time_left = ticks_to_seconds(p, val16); 412 428 } else if (p->iTCO_version == 1) { 413 - spin_lock(&p->io_lock); 414 429 val8 = inb(TCO_RLD(p)); 415 430 val8 &= 0x3f; 416 431 if (!(inw(TCO1_STS(p)) & 0x0008)) 417 432 val8 += (inb(TCOv1_TMR(p)) & 0x3f); 418 - spin_unlock(&p->io_lock); 419 433 420 434 time_left = ticks_to_seconds(p, val8); 421 435 } ··· 470 492 p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL); 471 493 if (!p) 472 494 return -ENOMEM; 473 - 474 - spin_lock_init(&p->io_lock); 475 495 476 496 p->tco_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_TCO); 477 497 if (!p->tco_res)