hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/w1/w1.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
134 */
145
156 #include <linux/delay.h>
....@@ -169,7 +160,7 @@
169160 NULL,
170161 };
171162
172
-static struct w1_family_ops w1_default_fops = {
163
+static const struct w1_family_ops w1_default_fops = {
173164 .groups = w1_slave_default_groups,
174165 };
175166
....@@ -622,7 +613,7 @@
622613
623614 static int w1_family_notify(unsigned long action, struct w1_slave *sl)
624615 {
625
- struct w1_family_ops *fops;
616
+ const struct w1_family_ops *fops;
626617 int err;
627618
628619 fops = sl->family->fops;
....@@ -1140,6 +1131,8 @@
11401131 /* remainder if it woke up early */
11411132 unsigned long jremain = 0;
11421133
1134
+ atomic_inc(&dev->refcnt);
1135
+
11431136 for (;;) {
11441137
11451138 if (!jremain && dev->search_count) {
....@@ -1167,8 +1160,10 @@
11671160 */
11681161 mutex_unlock(&dev->list_mutex);
11691162
1170
- if (kthread_should_stop())
1163
+ if (kthread_should_stop()) {
1164
+ __set_current_state(TASK_RUNNING);
11711165 break;
1166
+ }
11721167
11731168 /* Only sleep when the search is active. */
11741169 if (dev->search_count) {
....@@ -1233,10 +1228,10 @@
12331228
12341229 static void __exit w1_fini(void)
12351230 {
1236
- struct w1_master *dev;
1231
+ struct w1_master *dev, *n;
12371232
12381233 /* Set netlink removal messages and some cleanup */
1239
- list_for_each_entry(dev, &w1_masters, w1_master_entry)
1234
+ list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry)
12401235 __w1_remove_master_device(dev);
12411236
12421237 w1_fini_netlink();