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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'w1-drv-6.5' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1 into char-misc-next

Krzysztof writes:

1-Wire bus drivers for v6.5

1. Several older cleanups and minor improvements like dropping redundant
match function, fixing indentation and typos, simplifying sysfs
attribute show, removing redundant variable initializations, using max()
instead of open-coding it and constifying pointer to
struct hwmon_channel_info.

2. w1_therm: fix inverted lock handling causing spurious temperature
reads.

3. sgi: Use strscpy() over strlcpy().

4. w1 bus fixes:
- Correct missing OF node reference put in error path.
- Correct iterating over master device list while removing items from
it.
- Don't use loop iterator past the loop.

* tag 'w1-drv-6.5' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1:
w1: Replace usage of found with dedicated list iterator variable
w1: therm: constify pointers to hwmon_channel_info
w1: Add missing of_node_put() in w1.c
w1: no need to initialise statics to 0
w1: ds2438: remove redundant initialization of variable crc
w1: w1_therm: fix typo in comment
w1: w1_therm: Use max() instead of doing it manually
w1: fix loop in w1_fini()
w1: remove redundant initialization to variable result
w1: Simplify the atribute show
w1: Fix Kconfig indentation
w1: sgi: move from strlcpy with unused retval to strscpy
w1: Remove driver match function
w1: w1_therm: fix locking behavior in convert_t

+42 -58
+1 -1
drivers/w1/masters/sgi_w1.c
··· 93 93 94 94 pdata = dev_get_platdata(&pdev->dev); 95 95 if (pdata) { 96 - strlcpy(sdev->dev_id, pdata->dev_id, sizeof(sdev->dev_id)); 96 + strscpy(sdev->dev_id, pdata->dev_id, sizeof(sdev->dev_id)); 97 97 sdev->bus_master.dev_id = sdev->dev_id; 98 98 } 99 99
+2 -2
drivers/w1/slaves/Kconfig
··· 71 71 help 72 72 Say Y here if you want to use a 1-wire 73 73 is a 112-byte user-programmable EEPROM is 74 - organized as 7 pages of 16 bytes each with 64bit 75 - unique number. Requires OverDrive Speed to talk to. 74 + organized as 7 pages of 16 bytes each with 64bit 75 + unique number. Requires OverDrive Speed to talk to. 76 76 77 77 config W1_SLAVE_DS2430 78 78 tristate "256b EEPROM family support (DS2430)"
-2
drivers/w1/slaves/w1_ds2438.c
··· 66 66 size_t count; 67 67 68 68 while (retries--) { 69 - crc = 0; 70 - 71 69 if (w1_reset_select_slave(sl)) 72 70 continue; 73 71 w1_buf[0] = W1_DS2438_RECALL_MEMORY;
+17 -20
drivers/w1/slaves/w1_therm.c
··· 284 284 * trigger_bulk_read() - function to trigger a bulk read on the bus 285 285 * @dev_master: the device master of the bus 286 286 * 287 - * Send a SKIP ROM follow by a CONVERT T commmand on the bus. 287 + * Send a SKIP ROM follow by a CONVERT T command on the bus. 288 288 * It also set the status flag in each slave &struct w1_therm_family_data 289 289 * to signal that a conversion is in progress. 290 290 * ··· 454 454 .config = w1_temp_config, 455 455 }; 456 456 457 - static const struct hwmon_channel_info *w1_info[] = { 457 + static const struct hwmon_channel_info * const w1_info[] = { 458 458 &w1_temp, 459 459 NULL 460 460 }; ··· 1159 1159 1160 1160 w1_write_8(dev_master, W1_CONVERT_TEMP); 1161 1161 1162 - if (strong_pullup) { /*some device need pullup */ 1162 + if (SLAVE_FEATURES(sl) & W1_THERM_POLL_COMPLETION) { 1163 + ret = w1_poll_completion(dev_master, W1_POLL_CONVERT_TEMP); 1164 + if (ret) { 1165 + dev_dbg(&sl->dev, "%s: Timeout\n", __func__); 1166 + goto mt_unlock; 1167 + } 1168 + mutex_unlock(&dev_master->bus_mutex); 1169 + } else if (!strong_pullup) { /*no device need pullup */ 1163 1170 sleep_rem = msleep_interruptible(t_conv); 1164 1171 if (sleep_rem != 0) { 1165 1172 ret = -EINTR; 1166 1173 goto mt_unlock; 1167 1174 } 1168 1175 mutex_unlock(&dev_master->bus_mutex); 1169 - } else { /*no device need pullup */ 1170 - if (SLAVE_FEATURES(sl) & W1_THERM_POLL_COMPLETION) { 1171 - ret = w1_poll_completion(dev_master, W1_POLL_CONVERT_TEMP); 1172 - if (ret) { 1173 - dev_dbg(&sl->dev, "%s: Timeout\n", __func__); 1174 - goto mt_unlock; 1175 - } 1176 - mutex_unlock(&dev_master->bus_mutex); 1177 - } else { 1178 - /* Fixed delay */ 1179 - mutex_unlock(&dev_master->bus_mutex); 1180 - sleep_rem = msleep_interruptible(t_conv); 1181 - if (sleep_rem != 0) { 1182 - ret = -EINTR; 1183 - goto dec_refcnt; 1184 - } 1176 + } else { /*some device need pullup */ 1177 + mutex_unlock(&dev_master->bus_mutex); 1178 + sleep_rem = msleep_interruptible(t_conv); 1179 + if (sleep_rem != 0) { 1180 + ret = -EINTR; 1181 + goto dec_refcnt; 1185 1182 } 1186 1183 } 1187 1184 ret = read_scratchpad(sl, info); ··· 1512 1515 if (bulk_read_support(sl)) { 1513 1516 int t_cur = conversion_time(sl); 1514 1517 1515 - t_conv = t_cur > t_conv ? t_cur : t_conv; 1518 + t_conv = max(t_cur, t_conv); 1516 1519 strong_pullup = strong_pullup || 1517 1520 (w1_strong_pullup == 2 || 1518 1521 (!SLAVE_POWERMODE(sl) &&
+22 -33
drivers/w1/w1.c
··· 32 32 module_param_named(timeout, w1_timeout, int, 0); 33 33 MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); 34 34 35 - static int w1_timeout_us = 0; 35 + static int w1_timeout_us; 36 36 module_param_named(timeout_us, w1_timeout_us, int, 0); 37 37 MODULE_PARM_DESC(timeout_us, 38 38 "time in microseconds between automatic slave searches"); ··· 57 57 58 58 DEFINE_MUTEX(w1_mlock); 59 59 LIST_HEAD(w1_masters); 60 - 61 - static int w1_master_match(struct device *dev, struct device_driver *drv) 62 - { 63 - return 1; 64 - } 65 60 66 61 static int w1_master_probe(struct device *dev) 67 62 { ··· 169 174 170 175 static struct bus_type w1_bus_type = { 171 176 .name = "w1", 172 - .match = w1_master_match, 173 177 .uevent = w1_uevent, 174 178 }; 175 179 ··· 295 301 296 302 static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct device_attribute *attr, char *buf) 297 303 { 298 - ssize_t count; 299 - count = sprintf(buf, "%d\n", w1_timeout); 300 - return count; 304 + return sprintf(buf, "%d\n", w1_timeout); 301 305 } 302 306 303 307 static ssize_t w1_master_attribute_show_timeout_us(struct device *dev, 304 308 struct device_attribute *attr, char *buf) 305 309 { 306 - ssize_t count; 307 - count = sprintf(buf, "%d\n", w1_timeout_us); 308 - return count; 310 + return sprintf(buf, "%d\n", w1_timeout_us); 309 311 } 310 312 311 313 static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, ··· 491 501 struct w1_master *md = dev_to_w1_master(dev); 492 502 struct w1_reg_num rn; 493 503 struct w1_slave *sl; 494 - ssize_t result = count; 504 + ssize_t result; 495 505 496 506 if (w1_atoreg_num(dev, buf, count, &rn)) 497 507 return -EINVAL; ··· 692 702 dev_err(&sl->dev, 693 703 "Device registration [%s] failed. err=%d\n", 694 704 dev_name(&sl->dev), err); 705 + of_node_put(sl->dev.of_node); 695 706 put_device(&sl->dev); 696 707 return err; 697 708 } ··· 821 830 822 831 struct w1_master *w1_search_master_id(u32 id) 823 832 { 824 - struct w1_master *dev; 825 - int found = 0; 833 + struct w1_master *dev = NULL, *iter; 826 834 827 835 mutex_lock(&w1_mlock); 828 - list_for_each_entry(dev, &w1_masters, w1_master_entry) { 829 - if (dev->id == id) { 830 - found = 1; 831 - atomic_inc(&dev->refcnt); 836 + list_for_each_entry(iter, &w1_masters, w1_master_entry) { 837 + if (iter->id == id) { 838 + dev = iter; 839 + atomic_inc(&iter->refcnt); 832 840 break; 833 841 } 834 842 } 835 843 mutex_unlock(&w1_mlock); 836 844 837 - return (found)?dev:NULL; 845 + return dev; 838 846 } 839 847 840 848 struct w1_slave *w1_search_slave(struct w1_reg_num *id) 841 849 { 842 850 struct w1_master *dev; 843 - struct w1_slave *sl = NULL; 844 - int found = 0; 851 + struct w1_slave *sl = NULL, *iter; 845 852 846 853 mutex_lock(&w1_mlock); 847 854 list_for_each_entry(dev, &w1_masters, w1_master_entry) { 848 855 mutex_lock(&dev->list_mutex); 849 - list_for_each_entry(sl, &dev->slist, w1_slave_entry) { 850 - if (sl->reg_num.family == id->family && 851 - sl->reg_num.id == id->id && 852 - sl->reg_num.crc == id->crc) { 853 - found = 1; 856 + list_for_each_entry(iter, &dev->slist, w1_slave_entry) { 857 + if (iter->reg_num.family == id->family && 858 + iter->reg_num.id == id->id && 859 + iter->reg_num.crc == id->crc) { 860 + sl = iter; 854 861 atomic_inc(&dev->refcnt); 855 - atomic_inc(&sl->refcnt); 862 + atomic_inc(&iter->refcnt); 856 863 break; 857 864 } 858 865 } 859 866 mutex_unlock(&dev->list_mutex); 860 867 861 - if (found) 868 + if (sl) 862 869 break; 863 870 } 864 871 mutex_unlock(&w1_mlock); 865 872 866 - return (found)?sl:NULL; 873 + return sl; 867 874 } 868 875 869 876 void w1_reconnect_slaves(struct w1_family *f, int attach) ··· 1252 1263 1253 1264 static void __exit w1_fini(void) 1254 1265 { 1255 - struct w1_master *dev; 1266 + struct w1_master *dev, *n; 1256 1267 1257 1268 /* Set netlink removal messages and some cleanup */ 1258 - list_for_each_entry(dev, &w1_masters, w1_master_entry) 1269 + list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) 1259 1270 __w1_remove_master_device(dev); 1260 1271 1261 1272 w1_fini_netlink();