static ssize_t prox_cal_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct gp2a_data *gp2a = dev_get_drvdata(dev); u8 value; int err; if (sysfs_streq(buf, "1")) { gp2a->cal_mode = 1; nondetect = PROX_NONDETECT_MODE1; detect = PROX_DETECT_MODE1; } else if (sysfs_streq(buf, "2")) { gp2a->cal_mode = 2; nondetect = PROX_NONDETECT_MODE2; detect = PROX_DETECT_MODE2; } else if (sysfs_streq(buf, "0")) { gp2a->cal_mode = 0; nondetect = PROX_NONDETECT; detect = PROX_DETECT; } else { pr_err("%s: invalid value %d\n", __func__, *buf); return -EINVAL; } #if defined(CONFIG_MACH_KYLE) value = 0x00; #else value = 0x08; #endif gp2a_i2c_write(gp2a, REGS_GAIN, &value); value = nondetect; gp2a_i2c_write(gp2a, REGS_HYS, &value); value = 0x04; gp2a_i2c_write(gp2a, REGS_CYCLE, &value); value = 0x03; gp2a_i2c_write(gp2a, REGS_OPMOD, &value); value = 0x00; gp2a_i2c_write(gp2a, REGS_CON, &value); err = gp2a_cal_mode_save_file(gp2a->cal_mode); if (err < 0) { pr_err("%s: prox_cal_write() failed\n", __func__); return err; } return size; }
static ssize_t proximity_cal_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { if (sysfs_streq(buf, "1")) gp2a_data->cal_mode = 1; else if (sysfs_streq(buf, "2")) gp2a_data->cal_mode = 2; else if (sysfs_streq(buf, "0")) gp2a_data->cal_mode = 0; else { pr_err("[GP2A] %s: invalid value %d\n", __func__, *buf); return -EINVAL; } printk(KERN_INFO "[GP2A] prox_cal_write =%d\n", gp2a_data->cal_mode); gp2a_cal_mode_save_file(gp2a_data->cal_mode); return size; }
static ssize_t prox_cal_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct gp2a_data *gp2a = dev_get_drvdata(dev); int err; if (sysfs_streq(buf, "1")) { gp2a->cal_mode = 1; gp2a->nondetect = PROX_NONDETECT_MODE1; gp2a->detect = PROX_DETECT_MODE1; } else if (sysfs_streq(buf, "2")) { gp2a->cal_mode = 2; gp2a->nondetect = PROX_NONDETECT_MODE2; gp2a->detect = PROX_DETECT_MODE2; } else if (sysfs_streq(buf, "0")) { gp2a->cal_mode = 0; gp2a->nondetect = PROX_NONDETECT; gp2a->detect = PROX_DETECT; } else { pr_err("%s,invalid value %d\n", __func__, *buf); return -EINVAL; } if (gp2a->power_state == 1) { gp2a_power_onoff(gp2a, 0); msleep(20); gp2a_power_onoff(gp2a, 1); } err = gp2a_cal_mode_save_file(gp2a->cal_mode); if (err < 0) { pr_err("%s,prox_cal_write() failed\n", __func__); return err; } return size; }