X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fw1%2Fw1_int.c;h=6840dfebe4d4c82a5abc242a8ee1d66570f100ab;hb=0f79b72e45da68bf542a63a08f9c924b91b507e7;hp=475996cd1b7d4661766c4f79f82e316d672a909c;hpb=2c5bfdac33607a618d8cf1532ef235ca9eccd49e;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index 475996c..6840dfe 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c @@ -27,6 +27,7 @@ #include "w1.h" #include "w1_log.h" #include "w1_netlink.h" +#include "w1_int.h" static u32 w1_ids = 1; @@ -40,7 +41,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, /* * We are in process context(kernel thread), so can sleep. */ - dev = kmalloc(sizeof(struct w1_master) + sizeof(struct w1_bus_master), GFP_KERNEL); + dev = kzalloc(sizeof(struct w1_master) + sizeof(struct w1_bus_master), GFP_KERNEL); if (!dev) { printk(KERN_ERR "Failed to allocate %zd bytes for new w1 device.\n", @@ -48,7 +49,6 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, return NULL; } - memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); dev->bus_master = (struct w1_bus_master *)(dev + 1); @@ -99,7 +99,8 @@ int w1_add_master_device(struct w1_bus_master *master) /* validate minimum functionality */ if (!(master->touch_bit && master->reset_bus) && - !(master->write_bit && master->read_bit)) { + !(master->write_bit && master->read_bit) && + !(master->write_byte && master->read_byte && master->reset_bus)) { printk(KERN_ERR "w1_add_master_device: invalid function set\n"); return(-EINVAL); } @@ -169,22 +170,24 @@ void __w1_remove_master_device(struct w1_master *dev) void w1_remove_master_device(struct w1_bus_master *bm) { - struct w1_master *dev = NULL; + struct w1_master *dev, *found = NULL; list_for_each_entry(dev, &w1_masters, w1_master_entry) { if (!dev->initialized) continue; - if (dev->bus_master->data == bm->data) + if (dev->bus_master->data == bm->data) { + found = dev; break; + } } - if (!dev) { + if (!found) { printk(KERN_ERR "Device doesn't exist.\n"); return; } - __w1_remove_master_device(dev); + __w1_remove_master_device(found); } EXPORT_SYMBOL(w1_add_master_device);