Lines Matching refs:chip
196 static inline int bh1770_lux_interrupt_control(struct bh1770_chip *chip, in bh1770_lux_interrupt_control() argument
199 chip->int_mode_lux = lux; in bh1770_lux_interrupt_control()
201 return i2c_smbus_write_byte_data(chip->client, in bh1770_lux_interrupt_control()
203 (lux << 1) | chip->int_mode_prox); in bh1770_lux_interrupt_control()
206 static inline int bh1770_prox_interrupt_control(struct bh1770_chip *chip, in bh1770_prox_interrupt_control() argument
209 chip->int_mode_prox = ps; in bh1770_prox_interrupt_control()
210 return i2c_smbus_write_byte_data(chip->client, in bh1770_prox_interrupt_control()
212 (chip->int_mode_lux << 1) | (ps << 0)); in bh1770_prox_interrupt_control()
216 static int bh1770_lux_rate(struct bh1770_chip *chip, int rate_index) in bh1770_lux_rate() argument
219 if (pm_runtime_suspended(&chip->client->dev)) in bh1770_lux_rate()
223 if (chip->prox_enable_count) in bh1770_lux_rate()
226 return i2c_smbus_write_byte_data(chip->client, in bh1770_lux_rate()
231 static int bh1770_prox_rate(struct bh1770_chip *chip, int mode) in bh1770_prox_rate() argument
236 chip->prox_rate_threshold : chip->prox_rate; in bh1770_prox_rate()
238 return i2c_smbus_write_byte_data(chip->client, in bh1770_prox_rate()
244 static inline int bh1770_led_cfg(struct bh1770_chip *chip) in bh1770_led_cfg() argument
247 return i2c_smbus_write_byte_data(chip->client, in bh1770_led_cfg()
251 chip->prox_led); in bh1770_led_cfg()
260 static inline u8 bh1770_psraw_to_adjusted(struct bh1770_chip *chip, u8 psraw) in bh1770_psraw_to_adjusted() argument
263 adjusted = (u16)(((u32)(psraw + chip->prox_const) * chip->prox_coef) / in bh1770_psraw_to_adjusted()
270 static inline u8 bh1770_psadjusted_to_raw(struct bh1770_chip *chip, u8 ps) in bh1770_psadjusted_to_raw() argument
274 raw = (((u32)ps * BH1770_COEF_SCALER) / chip->prox_coef); in bh1770_psadjusted_to_raw()
275 if (raw > chip->prox_const) in bh1770_psadjusted_to_raw()
276 raw = raw - chip->prox_const; in bh1770_psadjusted_to_raw()
288 static int bh1770_prox_set_threshold(struct bh1770_chip *chip) in bh1770_prox_set_threshold() argument
293 if (pm_runtime_suspended(&chip->client->dev)) in bh1770_prox_set_threshold()
296 tmp = bh1770_psadjusted_to_raw(chip, chip->prox_threshold); in bh1770_prox_set_threshold()
297 chip->prox_threshold_hw = tmp; in bh1770_prox_set_threshold()
299 return i2c_smbus_write_byte_data(chip->client, BH1770_PS_TH_LED1, in bh1770_prox_set_threshold()
303 static inline u16 bh1770_lux_raw_to_adjusted(struct bh1770_chip *chip, u16 raw) in bh1770_lux_raw_to_adjusted() argument
306 lux = ((u32)raw * chip->lux_corr) / BH1770_LUX_CORR_SCALE; in bh1770_lux_raw_to_adjusted()
310 static inline u16 bh1770_lux_adjusted_to_raw(struct bh1770_chip *chip, in bh1770_lux_adjusted_to_raw() argument
313 return (u32)adjusted * BH1770_LUX_CORR_SCALE / chip->lux_corr; in bh1770_lux_adjusted_to_raw()
317 static int bh1770_lux_update_thresholds(struct bh1770_chip *chip, in bh1770_lux_update_thresholds() argument
324 if (pm_runtime_suspended(&chip->client->dev)) in bh1770_lux_update_thresholds()
333 threshold_hi = bh1770_lux_adjusted_to_raw(chip, threshold_hi); in bh1770_lux_update_thresholds()
336 threshold_lo = bh1770_lux_adjusted_to_raw(chip, threshold_lo); in bh1770_lux_update_thresholds()
338 if (chip->lux_thres_hi_onchip == threshold_hi && in bh1770_lux_update_thresholds()
339 chip->lux_thres_lo_onchip == threshold_lo) in bh1770_lux_update_thresholds()
342 chip->lux_thres_hi_onchip = threshold_hi; in bh1770_lux_update_thresholds()
343 chip->lux_thres_lo_onchip = threshold_lo; in bh1770_lux_update_thresholds()
350 ret = i2c_smbus_write_i2c_block_data(chip->client, in bh1770_lux_update_thresholds()
357 static int bh1770_lux_get_result(struct bh1770_chip *chip) in bh1770_lux_get_result() argument
362 ret = i2c_smbus_read_byte_data(chip->client, BH1770_ALS_DATA_0); in bh1770_lux_get_result()
367 ret = i2c_smbus_read_byte_data(chip->client, BH1770_ALS_DATA_1); in bh1770_lux_get_result()
371 chip->lux_data_raw = data | ((ret & 0xff) << 8); in bh1770_lux_get_result()
377 static u32 bh1770_get_corr_value(struct bh1770_chip *chip) in bh1770_get_corr_value() argument
381 tmp = (BH1770_LUX_CORR_SCALE * chip->lux_ga) / BH1770_LUX_GA_SCALE; in bh1770_get_corr_value()
383 tmp = (tmp * chip->lux_cf) / BH1770_LUX_CF_SCALE; in bh1770_get_corr_value()
385 tmp = (tmp * chip->lux_calib) / BH1770_CALIB_SCALER; in bh1770_get_corr_value()
389 static int bh1770_lux_read_result(struct bh1770_chip *chip) in bh1770_lux_read_result() argument
391 bh1770_lux_get_result(chip); in bh1770_lux_read_result()
392 return bh1770_lux_raw_to_adjusted(chip, chip->lux_data_raw); in bh1770_lux_read_result()
399 static int bh1770_chip_on(struct bh1770_chip *chip) in bh1770_chip_on() argument
401 int ret = regulator_bulk_enable(ARRAY_SIZE(chip->regs), in bh1770_chip_on()
402 chip->regs); in bh1770_chip_on()
409 i2c_smbus_write_byte_data(chip->client, BH1770_ALS_CONTROL, in bh1770_chip_on()
418 chip->lux_data_raw = 0; in bh1770_chip_on()
419 chip->prox_data = 0; in bh1770_chip_on()
420 ret = i2c_smbus_write_byte_data(chip->client, in bh1770_chip_on()
424 chip->lux_thres_hi_onchip = BH1770_LUX_RANGE; in bh1770_chip_on()
425 chip->lux_thres_lo_onchip = 0; in bh1770_chip_on()
430 static void bh1770_chip_off(struct bh1770_chip *chip) in bh1770_chip_off() argument
432 i2c_smbus_write_byte_data(chip->client, in bh1770_chip_off()
434 i2c_smbus_write_byte_data(chip->client, in bh1770_chip_off()
436 i2c_smbus_write_byte_data(chip->client, in bh1770_chip_off()
438 regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); in bh1770_chip_off()
442 static int bh1770_prox_mode_control(struct bh1770_chip *chip) in bh1770_prox_mode_control() argument
444 if (chip->prox_enable_count) { in bh1770_prox_mode_control()
445 chip->prox_force_update = true; /* Force immediate update */ in bh1770_prox_mode_control()
447 bh1770_lux_rate(chip, chip->lux_rate_index); in bh1770_prox_mode_control()
448 bh1770_prox_set_threshold(chip); in bh1770_prox_mode_control()
449 bh1770_led_cfg(chip); in bh1770_prox_mode_control()
450 bh1770_prox_rate(chip, PROX_BELOW_THRESHOLD); in bh1770_prox_mode_control()
451 bh1770_prox_interrupt_control(chip, BH1770_ENABLE); in bh1770_prox_mode_control()
452 i2c_smbus_write_byte_data(chip->client, in bh1770_prox_mode_control()
455 chip->prox_data = 0; in bh1770_prox_mode_control()
456 bh1770_lux_rate(chip, chip->lux_rate_index); in bh1770_prox_mode_control()
457 bh1770_prox_interrupt_control(chip, BH1770_DISABLE); in bh1770_prox_mode_control()
458 i2c_smbus_write_byte_data(chip->client, in bh1770_prox_mode_control()
465 static int bh1770_prox_read_result(struct bh1770_chip *chip) in bh1770_prox_read_result() argument
471 ret = i2c_smbus_read_byte_data(chip->client, BH1770_PS_DATA_LED1); in bh1770_prox_read_result()
475 if (ret > chip->prox_threshold_hw) in bh1770_prox_read_result()
485 if (chip->lux_data_raw > PROX_IGNORE_LUX_LIMIT) in bh1770_prox_read_result()
488 chip->prox_data = bh1770_psraw_to_adjusted(chip, ret); in bh1770_prox_read_result()
491 if (chip->prox_data >= chip->prox_abs_thres || in bh1770_prox_read_result()
492 chip->prox_force_update) in bh1770_prox_read_result()
493 chip->prox_persistence_counter = chip->prox_persistence; in bh1770_prox_read_result()
495 chip->prox_force_update = false; in bh1770_prox_read_result()
499 if (chip->prox_persistence_counter < chip->prox_persistence) { in bh1770_prox_read_result()
500 chip->prox_persistence_counter++; in bh1770_prox_read_result()
507 chip->prox_persistence_counter = 0; in bh1770_prox_read_result()
509 chip->prox_data = 0; in bh1770_prox_read_result()
515 bh1770_prox_rate(chip, mode); in bh1770_prox_read_result()
516 sysfs_notify(&chip->client->dev.kobj, NULL, "prox0_raw"); in bh1770_prox_read_result()
522 static int bh1770_detect(struct bh1770_chip *chip) in bh1770_detect() argument
524 struct i2c_client *client = chip->client; in bh1770_detect()
538 chip->revision = (part & BH1770_REV_MASK) >> BH1770_REV_SHIFT; in bh1770_detect()
539 chip->prox_coef = BH1770_COEF_SCALER; in bh1770_detect()
540 chip->prox_const = 0; in bh1770_detect()
541 chip->lux_cf = BH1770_NEUTRAL_CF; in bh1770_detect()
545 snprintf(chip->chipname, sizeof(chip->chipname), "BH1770GLC"); in bh1770_detect()
551 snprintf(chip->chipname, sizeof(chip->chipname), "SFH7770"); in bh1770_detect()
553 chip->prox_coef = 819; /* 0.8 * BH1770_COEF_SCALER */ in bh1770_detect()
554 chip->prox_const = 40; in bh1770_detect()
576 struct bh1770_chip *chip = in bh1770_prox_work() local
579 mutex_lock(&chip->mutex); in bh1770_prox_work()
580 bh1770_prox_read_result(chip); in bh1770_prox_work()
581 mutex_unlock(&chip->mutex); in bh1770_prox_work()
587 struct bh1770_chip *chip = data; in bh1770_irq() local
591 mutex_lock(&chip->mutex); in bh1770_irq()
592 status = i2c_smbus_read_byte_data(chip->client, BH1770_ALS_PS_STATUS); in bh1770_irq()
595 i2c_smbus_read_byte_data(chip->client, BH1770_INTERRUPT); in bh1770_irq()
602 bh1770_lux_get_result(chip); in bh1770_irq()
603 if (unlikely(chip->lux_wait_result)) { in bh1770_irq()
604 chip->lux_wait_result = false; in bh1770_irq()
605 wake_up(&chip->wait); in bh1770_irq()
606 bh1770_lux_update_thresholds(chip, in bh1770_irq()
607 chip->lux_threshold_hi, in bh1770_irq()
608 chip->lux_threshold_lo); in bh1770_irq()
613 i2c_smbus_write_byte_data(chip->client, BH1770_INTERRUPT, in bh1770_irq()
617 sysfs_notify(&chip->client->dev.kobj, NULL, "lux0_input"); in bh1770_irq()
619 if (chip->int_mode_prox && (status & BH1770_INT_LEDS_INT)) { in bh1770_irq()
620 rate = prox_rates_ms[chip->prox_rate_threshold]; in bh1770_irq()
621 bh1770_prox_read_result(chip); in bh1770_irq()
625 i2c_smbus_write_byte_data(chip->client, BH1770_INTERRUPT, in bh1770_irq()
626 (chip->int_mode_lux << 1) | in bh1770_irq()
627 (chip->int_mode_prox << 0)); in bh1770_irq()
628 mutex_unlock(&chip->mutex); in bh1770_irq()
639 cancel_delayed_work_sync(&chip->prox_work); in bh1770_irq()
640 schedule_delayed_work(&chip->prox_work, in bh1770_irq()
650 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_power_state_store() local
658 mutex_lock(&chip->mutex); in bh1770_power_state_store()
662 ret = bh1770_lux_rate(chip, chip->lux_rate_index); in bh1770_power_state_store()
668 ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE); in bh1770_power_state_store()
675 bh1770_lux_update_thresholds(chip, BH1770_LUX_DEF_THRES, in bh1770_power_state_store()
678 chip->lux_wait_result = true; in bh1770_power_state_store()
679 bh1770_prox_mode_control(chip); in bh1770_power_state_store()
685 mutex_unlock(&chip->mutex); in bh1770_power_state_store()
698 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_lux_result_show() local
705 timeout = wait_event_interruptible_timeout(chip->wait, in bh1770_lux_result_show()
706 !chip->lux_wait_result, in bh1770_lux_result_show()
711 mutex_lock(&chip->mutex); in bh1770_lux_result_show()
712 ret = sprintf(buf, "%d\n", bh1770_lux_read_result(chip)); in bh1770_lux_result_show()
713 mutex_unlock(&chip->mutex); in bh1770_lux_result_show()
728 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_enable_store() local
736 mutex_lock(&chip->mutex); in bh1770_prox_enable_store()
738 if (!chip->prox_enable_count) in bh1770_prox_enable_store()
739 chip->prox_data = 0; in bh1770_prox_enable_store()
742 chip->prox_enable_count++; in bh1770_prox_enable_store()
743 else if (chip->prox_enable_count > 0) in bh1770_prox_enable_store()
744 chip->prox_enable_count--; in bh1770_prox_enable_store()
750 bh1770_prox_mode_control(chip); in bh1770_prox_enable_store()
752 mutex_unlock(&chip->mutex); in bh1770_prox_enable_store()
759 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_enable_show() local
762 mutex_lock(&chip->mutex); in bh1770_prox_enable_show()
763 len = sprintf(buf, "%d\n", chip->prox_enable_count); in bh1770_prox_enable_show()
764 mutex_unlock(&chip->mutex); in bh1770_prox_enable_show()
771 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_result_show() local
774 mutex_lock(&chip->mutex); in bh1770_prox_result_show()
775 if (chip->prox_enable_count && !pm_runtime_suspended(dev)) in bh1770_prox_result_show()
776 ret = sprintf(buf, "%d\n", chip->prox_data); in bh1770_prox_result_show()
779 mutex_unlock(&chip->mutex); in bh1770_prox_result_show()
803 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_get_prox_rate_above() local
804 return sprintf(buf, "%d\n", prox_rates_hz[chip->prox_rate_threshold]); in bh1770_get_prox_rate_above()
810 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_get_prox_rate_below() local
811 return sprintf(buf, "%d\n", prox_rates_hz[chip->prox_rate]); in bh1770_get_prox_rate_below()
828 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_set_prox_rate_above() local
836 mutex_lock(&chip->mutex); in bh1770_set_prox_rate_above()
837 chip->prox_rate_threshold = bh1770_prox_rate_validate(value); in bh1770_set_prox_rate_above()
838 mutex_unlock(&chip->mutex); in bh1770_set_prox_rate_above()
846 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_set_prox_rate_below() local
854 mutex_lock(&chip->mutex); in bh1770_set_prox_rate_below()
855 chip->prox_rate = bh1770_prox_rate_validate(value); in bh1770_set_prox_rate_below()
856 mutex_unlock(&chip->mutex); in bh1770_set_prox_rate_below()
863 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_get_prox_thres() local
864 return sprintf(buf, "%d\n", chip->prox_threshold); in bh1770_get_prox_thres()
871 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_set_prox_thres() local
882 mutex_lock(&chip->mutex); in bh1770_set_prox_thres()
883 chip->prox_threshold = value; in bh1770_set_prox_thres()
884 ret = bh1770_prox_set_threshold(chip); in bh1770_set_prox_thres()
885 mutex_unlock(&chip->mutex); in bh1770_set_prox_thres()
894 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_persistence_show() local
896 return sprintf(buf, "%u\n", chip->prox_persistence); in bh1770_prox_persistence_show()
903 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_persistence_store() local
914 chip->prox_persistence = value; in bh1770_prox_persistence_store()
922 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_abs_thres_show() local
923 return sprintf(buf, "%u\n", chip->prox_abs_thres); in bh1770_prox_abs_thres_show()
930 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_prox_abs_thres_store() local
941 chip->prox_abs_thres = value; in bh1770_prox_abs_thres_store()
949 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_chip_id_show() local
950 return sprintf(buf, "%s rev %d\n", chip->chipname, chip->revision); in bh1770_chip_id_show()
962 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_lux_calib_show() local
965 mutex_lock(&chip->mutex); in bh1770_lux_calib_show()
966 len = sprintf(buf, "%u\n", chip->lux_calib); in bh1770_lux_calib_show()
967 mutex_unlock(&chip->mutex); in bh1770_lux_calib_show()
975 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_lux_calib_store() local
985 mutex_lock(&chip->mutex); in bh1770_lux_calib_store()
986 old_calib = chip->lux_calib; in bh1770_lux_calib_store()
987 chip->lux_calib = value; in bh1770_lux_calib_store()
988 new_corr = bh1770_get_corr_value(chip); in bh1770_lux_calib_store()
990 chip->lux_calib = old_calib; in bh1770_lux_calib_store()
991 mutex_unlock(&chip->mutex); in bh1770_lux_calib_store()
994 chip->lux_corr = new_corr; in bh1770_lux_calib_store()
996 bh1770_lux_update_thresholds(chip, chip->lux_threshold_hi, in bh1770_lux_calib_store()
997 chip->lux_threshold_lo); in bh1770_lux_calib_store()
999 mutex_unlock(&chip->mutex); in bh1770_lux_calib_store()
1018 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_get_lux_rate() local
1019 return sprintf(buf, "%d\n", lux_rates_hz[chip->lux_rate_index]); in bh1770_get_lux_rate()
1026 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_set_lux_rate() local
1038 mutex_lock(&chip->mutex); in bh1770_set_lux_rate()
1039 chip->lux_rate_index = i; in bh1770_set_lux_rate()
1040 ret = bh1770_lux_rate(chip, i); in bh1770_set_lux_rate()
1041 mutex_unlock(&chip->mutex); in bh1770_set_lux_rate()
1052 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_get_lux_thresh_above() local
1053 return sprintf(buf, "%d\n", chip->lux_threshold_hi); in bh1770_get_lux_thresh_above()
1059 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_get_lux_thresh_below() local
1060 return sprintf(buf, "%d\n", chip->lux_threshold_lo); in bh1770_get_lux_thresh_below()
1063 static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target, in bh1770_set_lux_thresh() argument
1076 mutex_lock(&chip->mutex); in bh1770_set_lux_thresh()
1082 if (!chip->lux_wait_result) in bh1770_set_lux_thresh()
1083 ret = bh1770_lux_update_thresholds(chip, in bh1770_set_lux_thresh()
1084 chip->lux_threshold_hi, in bh1770_set_lux_thresh()
1085 chip->lux_threshold_lo); in bh1770_set_lux_thresh()
1086 mutex_unlock(&chip->mutex); in bh1770_set_lux_thresh()
1095 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_set_lux_thresh_above() local
1096 int ret = bh1770_set_lux_thresh(chip, &chip->lux_threshold_hi, buf); in bh1770_set_lux_thresh_above()
1106 struct bh1770_chip *chip = dev_get_drvdata(dev); in bh1770_set_lux_thresh_below() local
1107 int ret = bh1770_set_lux_thresh(chip, &chip->lux_threshold_lo, buf); in bh1770_set_lux_thresh_below()
1185 struct bh1770_chip *chip; in bh1770_probe() local
1188 chip = devm_kzalloc(&client->dev, sizeof *chip, GFP_KERNEL); in bh1770_probe()
1189 if (!chip) in bh1770_probe()
1192 i2c_set_clientdata(client, chip); in bh1770_probe()
1193 chip->client = client; in bh1770_probe()
1195 mutex_init(&chip->mutex); in bh1770_probe()
1196 init_waitqueue_head(&chip->wait); in bh1770_probe()
1197 INIT_DELAYED_WORK(&chip->prox_work, bh1770_prox_work); in bh1770_probe()
1204 chip->pdata = client->dev.platform_data; in bh1770_probe()
1205 chip->lux_calib = BH1770_LUX_NEUTRAL_CALIB_VALUE; in bh1770_probe()
1206 chip->lux_rate_index = BH1770_LUX_DEFAULT_RATE; in bh1770_probe()
1207 chip->lux_threshold_lo = BH1770_LUX_DEF_THRES; in bh1770_probe()
1208 chip->lux_threshold_hi = BH1770_LUX_DEF_THRES; in bh1770_probe()
1210 if (chip->pdata->glass_attenuation == 0) in bh1770_probe()
1211 chip->lux_ga = BH1770_NEUTRAL_GA; in bh1770_probe()
1213 chip->lux_ga = chip->pdata->glass_attenuation; in bh1770_probe()
1215 chip->prox_threshold = BH1770_PROX_DEF_THRES; in bh1770_probe()
1216 chip->prox_led = chip->pdata->led_def_curr; in bh1770_probe()
1217 chip->prox_abs_thres = BH1770_PROX_DEF_ABS_THRES; in bh1770_probe()
1218 chip->prox_persistence = BH1770_DEFAULT_PERSISTENCE; in bh1770_probe()
1219 chip->prox_rate_threshold = BH1770_PROX_DEF_RATE_THRESH; in bh1770_probe()
1220 chip->prox_rate = BH1770_PROX_DEFAULT_RATE; in bh1770_probe()
1221 chip->prox_data = 0; in bh1770_probe()
1223 chip->regs[0].supply = reg_vcc; in bh1770_probe()
1224 chip->regs[1].supply = reg_vleds; in bh1770_probe()
1227 ARRAY_SIZE(chip->regs), chip->regs); in bh1770_probe()
1233 err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), in bh1770_probe()
1234 chip->regs); in bh1770_probe()
1241 err = bh1770_detect(chip); in bh1770_probe()
1246 bh1770_chip_on(chip); in bh1770_probe()
1250 chip->lux_corr = bh1770_get_corr_value(chip); in bh1770_probe()
1251 if (chip->lux_corr == 0) { in bh1770_probe()
1257 if (chip->pdata->setup_resources) { in bh1770_probe()
1258 err = chip->pdata->setup_resources(); in bh1770_probe()
1265 err = sysfs_create_group(&chip->client->dev.kobj, in bh1770_probe()
1268 dev_err(&chip->client->dev, "Sysfs registration failed\n"); in bh1770_probe()
1281 "bh1770", chip); in bh1770_probe()
1287 regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); in bh1770_probe()
1290 sysfs_remove_group(&chip->client->dev.kobj, in bh1770_probe()
1293 if (chip->pdata->release_resources) in bh1770_probe()
1294 chip->pdata->release_resources(); in bh1770_probe()
1296 regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); in bh1770_probe()
1302 struct bh1770_chip *chip = i2c_get_clientdata(client); in bh1770_remove() local
1304 free_irq(client->irq, chip); in bh1770_remove()
1306 sysfs_remove_group(&chip->client->dev.kobj, in bh1770_remove()
1309 if (chip->pdata->release_resources) in bh1770_remove()
1310 chip->pdata->release_resources(); in bh1770_remove()
1312 cancel_delayed_work_sync(&chip->prox_work); in bh1770_remove()
1315 bh1770_chip_off(chip); in bh1770_remove()
1327 struct bh1770_chip *chip = i2c_get_clientdata(client); in bh1770_suspend() local
1329 bh1770_chip_off(chip); in bh1770_suspend()
1337 struct bh1770_chip *chip = i2c_get_clientdata(client); in bh1770_resume() local
1340 bh1770_chip_on(chip); in bh1770_resume()
1347 ret = bh1770_lux_rate(chip, chip->lux_rate_index); in bh1770_resume()
1348 ret |= bh1770_lux_interrupt_control(chip, BH1770_ENABLE); in bh1770_resume()
1351 bh1770_lux_update_thresholds(chip, BH1770_LUX_DEF_THRES, in bh1770_resume()
1354 chip->lux_wait_result = true; in bh1770_resume()
1355 bh1770_prox_mode_control(chip); in bh1770_resume()
1365 struct bh1770_chip *chip = i2c_get_clientdata(client); in bh1770_runtime_suspend() local
1367 bh1770_chip_off(chip); in bh1770_runtime_suspend()
1375 struct bh1770_chip *chip = i2c_get_clientdata(client); in bh1770_runtime_resume() local
1377 bh1770_chip_on(chip); in bh1770_runtime_resume()