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

[PATCH] better CONFIG_W1_SLAVE_DS2433_CRC handling

CONFIG_W1_SLAVE_DS2433_CRC can be used directly, there's no reason for the
indirection of defining a different variable in the Makefile.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Evgeniy Polyakov and committed by
Linus Torvalds
e9d55f9d ec0837f2

+15 -23
-4
drivers/w1/Makefile
··· 2 2 # Makefile for the Dallas's 1-wire bus. 3 3 # 4 4 5 - ifeq ($(CONFIG_W1_DS2433_CRC), y) 6 - EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC 7 - endif 8 - 9 5 obj-$(CONFIG_W1) += wire.o 10 6 wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o 11 7
-4
drivers/w1/slaves/Makefile
··· 2 2 # Makefile for the Dallas's 1-wire slaves. 3 3 # 4 4 5 - ifeq ($(CONFIG_W1_SLAVE_DS2433_CRC), y) 6 - EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC 7 - endif 8 - 9 5 obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o 10 6 obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o 11 7 obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o
+15 -15
drivers/w1/slaves/w1_ds2433.c
··· 13 13 #include <linux/device.h> 14 14 #include <linux/types.h> 15 15 #include <linux/delay.h> 16 - #ifdef CONFIG_W1_F23_CRC 16 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 17 17 #include <linux/crc16.h> 18 18 19 19 #define CRC16_INIT 0 ··· 62 62 return count; 63 63 } 64 64 65 - #ifdef CONFIG_W1_F23_CRC 65 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 66 66 static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, 67 67 int block) 68 68 { ··· 89 89 90 90 return 0; 91 91 } 92 - #endif /* CONFIG_W1_F23_CRC */ 92 + #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 93 93 94 94 static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, 95 95 size_t count) 96 96 { 97 97 struct w1_slave *sl = kobj_to_w1_slave(kobj); 98 - #ifdef CONFIG_W1_F23_CRC 98 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 99 99 struct w1_f23_data *data = sl->family_data; 100 100 int i, min_page, max_page; 101 101 #else ··· 107 107 108 108 mutex_lock(&sl->master->mutex); 109 109 110 - #ifdef CONFIG_W1_F23_CRC 110 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 111 111 112 112 min_page = (off >> W1_PAGE_BITS); 113 113 max_page = (off + count - 1) >> W1_PAGE_BITS; ··· 119 119 } 120 120 memcpy(buf, &data->memory[off], count); 121 121 122 - #else /* CONFIG_W1_F23_CRC */ 122 + #else /* CONFIG_W1_SLAVE_DS2433_CRC */ 123 123 124 124 /* read directly from the EEPROM */ 125 125 if (w1_reset_select_slave(sl)) { ··· 133 133 w1_write_block(sl->master, wrbuf, 3); 134 134 w1_read_block(sl->master, buf, count); 135 135 136 - #endif /* CONFIG_W1_F23_CRC */ 136 + #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 137 137 138 138 out_up: 139 139 mutex_unlock(&sl->master->mutex); ··· 208 208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) 209 209 return 0; 210 210 211 - #ifdef CONFIG_W1_F23_CRC 211 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 212 212 /* can only write full blocks in cached mode */ 213 213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) { 214 214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n", ··· 223 223 return -EINVAL; 224 224 } 225 225 } 226 - #endif /* CONFIG_W1_F23_CRC */ 226 + #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 227 227 228 228 mutex_lock(&sl->master->mutex); 229 229 ··· 262 262 static int w1_f23_add_slave(struct w1_slave *sl) 263 263 { 264 264 int err; 265 - #ifdef CONFIG_W1_F23_CRC 265 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 266 266 struct w1_f23_data *data; 267 267 268 268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL); ··· 271 271 memset(data, 0, sizeof(struct w1_f23_data)); 272 272 sl->family_data = data; 273 273 274 - #endif /* CONFIG_W1_F23_CRC */ 274 + #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 275 275 276 276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 277 277 278 - #ifdef CONFIG_W1_F23_CRC 278 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 279 279 if (err) 280 280 kfree(data); 281 - #endif /* CONFIG_W1_F23_CRC */ 281 + #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 282 282 283 283 return err; 284 284 } 285 285 286 286 static void w1_f23_remove_slave(struct w1_slave *sl) 287 287 { 288 - #ifdef CONFIG_W1_F23_CRC 288 + #ifdef CONFIG_W1_SLAVE_DS2433_CRC 289 289 kfree(sl->family_data); 290 290 sl->family_data = NULL; 291 - #endif /* CONFIG_W1_F23_CRC */ 291 + #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 292 292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 293 293 } 294 294