in slaves/w1_therm.c [915:980]
static int w1_therm_add_slave(struct w1_slave *sl)
{
struct w1_therm_family_converter *sl_family_conv;
/* Allocate memory */
sl->family_data = kzalloc(sizeof(struct w1_therm_family_data),
GFP_KERNEL);
if (!sl->family_data)
return -ENOMEM;
atomic_set(THERM_REFCNT(sl->family_data), 1);
/* Get a pointer to the device specific function struct */
sl_family_conv = device_family(sl);
if (!sl_family_conv) {
kfree(sl->family_data);
return -ENODEV;
}
/* save this pointer to the device structure */
SLAVE_SPECIFIC_FUNC(sl) = sl_family_conv;
if (bulk_read_support(sl)) {
/*
* add the sys entry to trigger bulk_read
* at master level only the 1st time
*/
if (!bulk_read_device_counter) {
int err = device_create_file(&sl->master->dev,
&dev_attr_therm_bulk_read);
if (err)
dev_warn(&sl->dev,
"%s: Device has been added, but bulk read is unavailable. err=%d\n",
__func__, err);
}
/* Increment the counter */
bulk_read_device_counter++;
}
/* Getting the power mode of the device {external, parasite} */
SLAVE_POWERMODE(sl) = read_powermode(sl);
if (SLAVE_POWERMODE(sl) < 0) {
/* no error returned as device has been added */
dev_warn(&sl->dev,
"%s: Device has been added, but power_mode may be corrupted. err=%d\n",
__func__, SLAVE_POWERMODE(sl));
}
/* Getting the resolution of the device */
if (SLAVE_SPECIFIC_FUNC(sl)->get_resolution) {
SLAVE_RESOLUTION(sl) =
SLAVE_SPECIFIC_FUNC(sl)->get_resolution(sl);
if (SLAVE_RESOLUTION(sl) < 0) {
/* no error returned as device has been added */
dev_warn(&sl->dev,
"%s:Device has been added, but resolution may be corrupted. err=%d\n",
__func__, SLAVE_RESOLUTION(sl));
}
}
/* Finally initialize convert_triggered flag */
SLAVE_CONVERT_TRIGGERED(sl) = 0;
return 0;
}