| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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. |
|---|
| 13 | 4 | */ |
|---|
| 14 | 5 | |
|---|
| 15 | 6 | #include <linux/delay.h> |
|---|
| .. | .. |
|---|
| 169 | 160 | NULL, |
|---|
| 170 | 161 | }; |
|---|
| 171 | 162 | |
|---|
| 172 | | -static struct w1_family_ops w1_default_fops = { |
|---|
| 163 | +static const struct w1_family_ops w1_default_fops = { |
|---|
| 173 | 164 | .groups = w1_slave_default_groups, |
|---|
| 174 | 165 | }; |
|---|
| 175 | 166 | |
|---|
| .. | .. |
|---|
| 622 | 613 | |
|---|
| 623 | 614 | static int w1_family_notify(unsigned long action, struct w1_slave *sl) |
|---|
| 624 | 615 | { |
|---|
| 625 | | - struct w1_family_ops *fops; |
|---|
| 616 | + const struct w1_family_ops *fops; |
|---|
| 626 | 617 | int err; |
|---|
| 627 | 618 | |
|---|
| 628 | 619 | fops = sl->family->fops; |
|---|
| .. | .. |
|---|
| 1140 | 1131 | /* remainder if it woke up early */ |
|---|
| 1141 | 1132 | unsigned long jremain = 0; |
|---|
| 1142 | 1133 | |
|---|
| 1134 | + atomic_inc(&dev->refcnt); |
|---|
| 1135 | + |
|---|
| 1143 | 1136 | for (;;) { |
|---|
| 1144 | 1137 | |
|---|
| 1145 | 1138 | if (!jremain && dev->search_count) { |
|---|
| .. | .. |
|---|
| 1167 | 1160 | */ |
|---|
| 1168 | 1161 | mutex_unlock(&dev->list_mutex); |
|---|
| 1169 | 1162 | |
|---|
| 1170 | | - if (kthread_should_stop()) |
|---|
| 1163 | + if (kthread_should_stop()) { |
|---|
| 1164 | + __set_current_state(TASK_RUNNING); |
|---|
| 1171 | 1165 | break; |
|---|
| 1166 | + } |
|---|
| 1172 | 1167 | |
|---|
| 1173 | 1168 | /* Only sleep when the search is active. */ |
|---|
| 1174 | 1169 | if (dev->search_count) { |
|---|
| .. | .. |
|---|
| 1233 | 1228 | |
|---|
| 1234 | 1229 | static void __exit w1_fini(void) |
|---|
| 1235 | 1230 | { |
|---|
| 1236 | | - struct w1_master *dev; |
|---|
| 1231 | + struct w1_master *dev, *n; |
|---|
| 1237 | 1232 | |
|---|
| 1238 | 1233 | /* 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) |
|---|
| 1240 | 1235 | __w1_remove_master_device(dev); |
|---|
| 1241 | 1236 | |
|---|
| 1242 | 1237 | w1_fini_netlink(); |
|---|