Lines Matching refs:data

211 		.data = &ntc_thermistor_id[0] },
213 .data = &ntc_thermistor_id[1] },
215 .data = &ntc_thermistor_id[2] },
217 .data = &ntc_thermistor_id[3] },
219 .data = &ntc_thermistor_id[4] },
221 .data = &ntc_thermistor_id[5]},
225 .data = &ntc_thermistor_id[0] },
227 .data = &ntc_thermistor_id[1] },
229 .data = &ntc_thermistor_id[2] },
231 .data = &ntc_thermistor_id[3] },
233 .data = &ntc_thermistor_id[4] },
309 static int get_ohm_of_thermistor(struct ntc_data *data, unsigned int uv) in get_ohm_of_thermistor() argument
311 struct ntc_thermistor_platform_data *pdata = data->pdata; in get_ohm_of_thermistor()
342 static void lookup_comp(struct ntc_data *data, unsigned int ohm, in lookup_comp() argument
354 if (ohm >= data->comp[0].ohm) { in lookup_comp()
359 if (ohm <= data->comp[data->n_comp - 1].ohm) { in lookup_comp()
360 *i_low = data->n_comp - 1; in lookup_comp()
361 *i_high = data->n_comp - 1; in lookup_comp()
367 end = data->n_comp; in lookup_comp()
379 if (ohm >= data->comp[mid].ohm) { in lookup_comp()
389 if (ohm >= data->comp[start].ohm) in lookup_comp()
402 if (ohm == data->comp[end].ohm) in lookup_comp()
408 static int get_temp_mc(struct ntc_data *data, unsigned int ohm) in get_temp_mc() argument
413 lookup_comp(data, ohm, &low, &high); in get_temp_mc()
416 temp = data->comp[low].temp_c * 1000; in get_temp_mc()
418 temp = data->comp[low].temp_c * 1000 + in get_temp_mc()
419 ((data->comp[high].temp_c - data->comp[low].temp_c) * in get_temp_mc()
420 1000 * ((int)ohm - (int)data->comp[low].ohm)) / in get_temp_mc()
421 ((int)data->comp[high].ohm - (int)data->comp[low].ohm); in get_temp_mc()
426 static int ntc_thermistor_get_ohm(struct ntc_data *data) in ntc_thermistor_get_ohm() argument
430 if (data->pdata->read_ohm) in ntc_thermistor_get_ohm()
431 return data->pdata->read_ohm(); in ntc_thermistor_get_ohm()
433 if (data->pdata->read_uv) { in ntc_thermistor_get_ohm()
434 read_uv = data->pdata->read_uv(data->pdata); in ntc_thermistor_get_ohm()
437 return get_ohm_of_thermistor(data, read_uv); in ntc_thermistor_get_ohm()
444 struct ntc_data *data = dev_get_drvdata(dev); in ntc_read_temp() local
447 ohm = ntc_thermistor_get_ohm(data); in ntc_read_temp()
451 *temp = get_temp_mc(data, ohm); in ntc_read_temp()
459 struct ntc_data *data = dev_get_drvdata(dev); in ntc_show_name() local
461 return sprintf(buf, "%s\n", data->name); in ntc_show_name()
473 struct ntc_data *data = dev_get_drvdata(dev); in ntc_show_temp() local
476 ohm = ntc_thermistor_get_ohm(data); in ntc_show_temp()
480 return sprintf(buf, "%d\n", get_temp_mc(data, ohm)); in ntc_show_temp()
508 struct ntc_data *data; in ntc_thermistor_probe() local
547 data = devm_kzalloc(&pdev->dev, sizeof(struct ntc_data), GFP_KERNEL); in ntc_thermistor_probe()
548 if (!data) in ntc_thermistor_probe()
551 pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); in ntc_thermistor_probe()
553 data->dev = &pdev->dev; in ntc_thermistor_probe()
554 data->pdata = pdata; in ntc_thermistor_probe()
555 strlcpy(data->name, pdev_id->name, sizeof(data->name)); in ntc_thermistor_probe()
559 data->comp = ncpXXwb473; in ntc_thermistor_probe()
560 data->n_comp = ARRAY_SIZE(ncpXXwb473); in ntc_thermistor_probe()
563 data->comp = ncpXXwl333; in ntc_thermistor_probe()
564 data->n_comp = ARRAY_SIZE(ncpXXwl333); in ntc_thermistor_probe()
567 data->comp = b57330v2103; in ntc_thermistor_probe()
568 data->n_comp = ARRAY_SIZE(b57330v2103); in ntc_thermistor_probe()
576 platform_set_drvdata(pdev, data); in ntc_thermistor_probe()
578 ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group); in ntc_thermistor_probe()
580 dev_err(data->dev, "unable to create sysfs files\n"); in ntc_thermistor_probe()
584 data->hwmon_dev = hwmon_device_register(data->dev); in ntc_thermistor_probe()
585 if (IS_ERR(data->hwmon_dev)) { in ntc_thermistor_probe()
586 dev_err(data->dev, "unable to register as hwmon device.\n"); in ntc_thermistor_probe()
587 ret = PTR_ERR(data->hwmon_dev); in ntc_thermistor_probe()
594 data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev, in ntc_thermistor_probe()
596 if (IS_ERR(data->tz)) { in ntc_thermistor_probe()
598 data->tz = NULL; in ntc_thermistor_probe()
603 sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); in ntc_thermistor_probe()
610 struct ntc_data *data = platform_get_drvdata(pdev); in ntc_thermistor_remove() local
611 struct ntc_thermistor_platform_data *pdata = data->pdata; in ntc_thermistor_remove()
613 hwmon_device_unregister(data->hwmon_dev); in ntc_thermistor_remove()
614 sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); in ntc_thermistor_remove()
617 thermal_zone_of_sensor_unregister(data->dev, data->tz); in ntc_thermistor_remove()