static int oxfw_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) { struct snd_oxfw *oxfw; if (entry->vendor_id == VENDOR_LOUD && !detect_loud_models(unit)) return -ENODEV; /* Allocate this independent of sound card instance. */ oxfw = kzalloc(sizeof(struct snd_oxfw), GFP_KERNEL); if (oxfw == NULL) return -ENOMEM; oxfw->entry = entry; oxfw->unit = fw_unit_get(unit); dev_set_drvdata(&unit->device, oxfw); mutex_init(&oxfw->mutex); spin_lock_init(&oxfw->lock); init_waitqueue_head(&oxfw->hwdep_wait); /* Allocate and register this sound card later. */ INIT_DEFERRABLE_WORK(&oxfw->dwork, do_registration); snd_fw_schedule_registration(unit, &oxfw->dwork); return 0; }
static int __init init_rq_avg(void) { rq_data = kzalloc(sizeof(struct runqueue_data), GFP_KERNEL); if (rq_data == NULL) { pr_err("%s cannot allocate memory\n", __func__); return -ENOMEM; } spin_lock_init(&rq_data->lock); rq_data->update_rate = RQ_AVG_TIMER_RATE; INIT_DEFERRABLE_WORK(&rq_data->work, rq_work_fn); return 0; }
static int abx500_temp_probe(struct platform_device *pdev) { struct abx500_temp *data; int err; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->pdev = pdev; mutex_init(&data->lock); /* Chip specific initialization */ err = abx500_hwmon_init(data); if (err < 0 || !data->ops.read_sensor || !data->ops.show_name || !data->ops.show_label) return err; INIT_DEFERRABLE_WORK(&data->work, gpadc_monitor); platform_set_drvdata(pdev, data); err = sysfs_create_group(&pdev->dev.kobj, &abx500_temp_group); if (err < 0) { dev_err(&pdev->dev, "Create sysfs group failed (%d)\n", err); return err; } data->hwmon_dev = hwmon_device_register(&pdev->dev); if (IS_ERR(data->hwmon_dev)) { err = PTR_ERR(data->hwmon_dev); dev_err(&pdev->dev, "Class registration failed (%d)\n", err); goto exit_sysfs_group; } if (data->ops.irq_handler) { err = setup_irqs(pdev); if (err < 0) goto exit_hwmon_reg; } return 0; exit_hwmon_reg: hwmon_device_unregister(data->hwmon_dev); exit_sysfs_group: sysfs_remove_group(&pdev->dev.kobj, &abx500_temp_group); return err; }
static int sec_therm_probe(struct platform_device *pdev) { struct sec_therm_platform_data *pdata = fill_therm_pdata(pdev); struct sec_therm_info *info; int ret = 0; dev_info(&pdev->dev, "%s: SEC Thermistor Driver Loading\n", __func__); info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; info->dev = &pdev->dev; info->pdata = pdata; info->vadc_dev = qpnp_get_vadc(info->dev, "therm"); therm_vadc_dev = info->vadc_dev; if (IS_ERR(info->vadc_dev)) { ret = PTR_ERR(info->vadc_dev); pr_err("%s:ret=%d\n",__func__,ret); if (ret != -EPROBE_DEFER) pr_err("vadc property missing\n"); else goto err_therm; } dev_set_drvdata(&pdev->dev, info); ret = sysfs_create_group(&info->dev->kobj, &sec_therm_group); if (ret) { dev_err(info->dev, "failed to create sysfs attribute group\n"); } if (!(pdata->no_polling)) { INIT_DEFERRABLE_WORK(&info->polling_work, sec_therm_polling_work); schedule_delayed_work(&info->polling_work, msecs_to_jiffies(info->pdata->polling_interval)); } return ret; err_therm: kfree(info); return ret; }
static int batmon_probe(struct platform_device *pdev) { int i; struct sysedp_batmon_rbat_lut *rbat; if (pdev->dev.of_node) of_batmon_calc_get_pdata(pdev, &pdata); else pdata = pdev->dev.platform_data; if (!pdata) return -EINVAL; /* validate pdata->rbat_lut table */ rbat = pdata->rbat_lut; if (!rbat) return -EINVAL; for (i = 1; i < rbat->temp_size; i++) if (rbat->temp_axis[i] >= rbat->temp_axis[i-1]) return -EINVAL; for (i = 1; i < rbat->capacity_size; i++) if (rbat->capacity_axis[i] >= rbat->capacity_axis[i-1]) return -EINVAL; if (rbat->capacity_size * rbat->temp_size != rbat->data_size) return -EINVAL; psy = power_supply_get_by_name(pdata->power_supply); if (!psy) return -EFAULT; if (init_ocv_reader()) return -EFAULT; init_sysfs(); INIT_DEFERRABLE_WORK(&work, batmon_update); schedule_delayed_work(&work, 0); init_debug(); return 0; }
static int __devinit bcl_probe(struct platform_device *pdev) { struct bcl_context *bcl; int ret = 0; bcl = kzalloc(sizeof(struct bcl_context), GFP_KERNEL); if (!bcl) { pr_err("Cannot allocate bcl_context\n"); return -ENOMEM; } gbcl = bcl; /* For BCL */ /* Init default BCL params */ bcl->dev = &pdev->dev; bcl->bcl_mode = BCL_DEVICE_DISABLED; bcl->bcl_threshold_mode[BCL_IAVAIL_LOW_THRESHOLD_TYPE] = BCL_IAVAIL_THRESHOLD_DISABLED; bcl->bcl_threshold_mode[BCL_IAVAIL_HIGH_THRESHOLD_TYPE] = BCL_IAVAIL_THRESHOLD_DISABLED; bcl->bcl_threshold_value_ma[BCL_IAVAIL_LOW_THRESHOLD_TYPE] = 0; bcl->bcl_threshold_value_ma[BCL_IAVAIL_HIGH_THRESHOLD_TYPE] = 0; bcl->bcl_vbat_min = BATTERY_VOLTAGE_MIN; snprintf(bcl->bcl_type, BCL_NAME_LENGTH, "%s", bcl_type); bcl->bcl_poll_interval_msec = BCL_POLL_INTERVAL; ret = create_bcl_sysfs(bcl); if (ret < 0) { pr_err("Cannot create bcl sysfs\n"); kfree(bcl); return ret; } platform_set_drvdata(pdev, bcl); INIT_DEFERRABLE_WORK(&bcl->bcl_iavail_work, bcl_iavail_work); return 0; }
static int snd_ff_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) { struct snd_ff *ff; ff = devm_kzalloc(&unit->device, sizeof(struct snd_ff), GFP_KERNEL); if (!ff) return -ENOMEM; ff->unit = fw_unit_get(unit); dev_set_drvdata(&unit->device, ff); mutex_init(&ff->mutex); spin_lock_init(&ff->lock); init_waitqueue_head(&ff->hwdep_wait); ff->spec = (const struct snd_ff_spec *)entry->driver_data; /* Register this sound card later. */ INIT_DEFERRABLE_WORK(&ff->dwork, do_registration); snd_fw_schedule_registration(unit, &ff->dwork); return 0; }
static int motu_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) { struct snd_motu *motu; /* Allocate this independently of sound card instance. */ motu = devm_kzalloc(&unit->device, sizeof(struct snd_motu), GFP_KERNEL); if (!motu) return -ENOMEM; motu->unit = fw_unit_get(unit); dev_set_drvdata(&unit->device, motu); motu->spec = (const struct snd_motu_spec *)entry->driver_data; mutex_init(&motu->mutex); spin_lock_init(&motu->lock); init_waitqueue_head(&motu->hwdep_wait); /* Allocate and register this sound card later. */ INIT_DEFERRABLE_WORK(&motu->dwork, do_registration); snd_fw_schedule_registration(unit, &motu->dwork); return 0; }
static int snd_dg00x_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) { struct snd_dg00x *dg00x; /* Allocate this independent of sound card instance. */ dg00x = kzalloc(sizeof(struct snd_dg00x), GFP_KERNEL); if (dg00x == NULL) return -ENOMEM; dg00x->unit = fw_unit_get(unit); dev_set_drvdata(&unit->device, dg00x); mutex_init(&dg00x->mutex); spin_lock_init(&dg00x->lock); init_waitqueue_head(&dg00x->hwdep_wait); /* Allocate and register this sound card later. */ INIT_DEFERRABLE_WORK(&dg00x->dwork, do_registration); snd_fw_schedule_registration(unit, &dg00x->dwork); return 0; }
static int max17040_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct power_supply_config psy_cfg = {}; struct max17040_chip *chip; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) return -EIO; chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; chip->client = client; chip->pdata = client->dev.platform_data; i2c_set_clientdata(client, chip); psy_cfg.drv_data = chip; chip->battery = power_supply_register(&client->dev, &max17040_battery_desc, &psy_cfg); if (IS_ERR(chip->battery)) { dev_err(&client->dev, "failed: power supply register\n"); return PTR_ERR(chip->battery); } max17040_reset(client); max17040_get_version(client); INIT_DEFERRABLE_WORK(&chip->work, max17040_work); queue_delayed_work(system_power_efficient_wq, &chip->work, MAX17040_DELAY); return 0; }
static int bebob_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) { struct snd_bebob *bebob; const struct snd_bebob_spec *spec; if (entry->vendor_id == VEN_FOCUSRITE && entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH) spec = get_saffire_spec(unit); else if (entry->vendor_id == VEN_MAUDIO1 && entry->model_id == MODEL_MAUDIO_AUDIOPHILE_BOTH && !check_audiophile_booted(unit)) spec = NULL; else spec = (const struct snd_bebob_spec *)entry->driver_data; if (spec == NULL) { if (entry->vendor_id == VEN_MAUDIO1 || entry->vendor_id == VEN_MAUDIO2) return snd_bebob_maudio_load_firmware(unit); else return -ENODEV; } /* Allocate this independent of sound card instance. */ bebob = kzalloc(sizeof(struct snd_bebob), GFP_KERNEL); if (bebob == NULL) return -ENOMEM; bebob->unit = fw_unit_get(unit); bebob->entry = entry; bebob->spec = spec; dev_set_drvdata(&unit->device, bebob); mutex_init(&bebob->mutex); spin_lock_init(&bebob->lock); init_waitqueue_head(&bebob->hwdep_wait); /* Allocate and register this sound card later. */ INIT_DEFERRABLE_WORK(&bebob->dwork, do_registration); if (entry->vendor_id != VEN_MAUDIO1 || (entry->model_id != MODEL_MAUDIO_FW1814 && entry->model_id != MODEL_MAUDIO_PROJECTMIX)) { snd_fw_schedule_registration(unit, &bebob->dwork); } else { /* * This is a workaround. This bus reset seems to have an effect * to make devices correctly handling transactions. Without * this, the devices have gap_count mismatch. This causes much * failure of transaction. * * Just after registration, user-land application receive * signals from dbus and starts I/Os. To avoid I/Os till the * future bus reset, registration is done in next update(). */ fw_schedule_bus_reset(fw_parent_device(bebob->unit)->card, false, true); } return 0; }
static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct pm2xxx_platform_data *pl_data = i2c_client->dev.platform_data; struct power_supply_config psy_cfg = {}; struct pm2xxx_charger *pm2; int ret = 0; u8 val; int i; if (!pl_data) { dev_err(&i2c_client->dev, "No platform data supplied\n"); return -EINVAL; } pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL); if (!pm2) { dev_err(&i2c_client->dev, "pm2xxx_charger allocation failed\n"); return -ENOMEM; } /* get parent data */ pm2->dev = &i2c_client->dev; pm2->pm2_int = &pm2xxx_int; /* get charger spcific platform data */ if (!pl_data->wall_charger) { dev_err(pm2->dev, "no charger platform data supplied\n"); ret = -EINVAL; goto free_device_info; } pm2->pdata = pl_data->wall_charger; /* get battery specific platform data */ if (!pl_data->battery) { dev_err(pm2->dev, "no battery platform data supplied\n"); ret = -EINVAL; goto free_device_info; } pm2->bat = pl_data->battery; if (!i2c_check_functionality(i2c_client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_READ_WORD_DATA)) { ret = -ENODEV; dev_info(pm2->dev, "pm2301 i2c_check_functionality failed\n"); goto free_device_info; } pm2->config.pm2xxx_i2c = i2c_client; pm2->config.pm2xxx_id = (struct i2c_device_id *) id; i2c_set_clientdata(i2c_client, pm2); /* AC supply */ /* power_supply base class */ pm2->ac_chg_desc.name = pm2->pdata->label; pm2->ac_chg_desc.type = POWER_SUPPLY_TYPE_MAINS; pm2->ac_chg_desc.properties = pm2xxx_charger_ac_props; pm2->ac_chg_desc.num_properties = ARRAY_SIZE(pm2xxx_charger_ac_props); pm2->ac_chg_desc.get_property = pm2xxx_charger_ac_get_property; psy_cfg.supplied_to = pm2->pdata->supplied_to; psy_cfg.num_supplicants = pm2->pdata->num_supplicants; /* pm2xxx_charger sub-class */ pm2->ac_chg.ops.enable = &pm2xxx_charger_ac_en; pm2->ac_chg.ops.kick_wd = &pm2xxx_charger_watchdog_kick; pm2->ac_chg.ops.update_curr = &pm2xxx_charger_update_charger_current; pm2->ac_chg.max_out_volt = pm2xxx_charger_voltage_map[ ARRAY_SIZE(pm2xxx_charger_voltage_map) - 1]; pm2->ac_chg.max_out_curr = pm2xxx_charger_current_map[ ARRAY_SIZE(pm2xxx_charger_current_map) - 1]; pm2->ac_chg.wdt_refresh = WD_KICK_INTERVAL; pm2->ac_chg.enabled = true; pm2->ac_chg.external = true; /* Create a work queue for the charger */ pm2->charger_wq = create_singlethread_workqueue("pm2xxx_charger_wq"); if (pm2->charger_wq == NULL) { ret = -ENOMEM; dev_err(pm2->dev, "failed to create work queue\n"); goto free_device_info; } /* Init work for charger detection */ INIT_WORK(&pm2->ac_work, pm2xxx_charger_ac_work); /* Init work for checking HW status */ INIT_WORK(&pm2->check_main_thermal_prot_work, pm2xxx_charger_check_main_thermal_prot_work); /* Init work for HW failure check */ INIT_DEFERRABLE_WORK(&pm2->check_hw_failure_work, pm2xxx_charger_check_hw_failure_work); /* * VDD ADC supply needs to be enabled from this driver when there * is a charger connected to avoid erroneous BTEMP_HIGH/LOW * interrupts during charging */ pm2->regu = regulator_get(pm2->dev, "vddadc"); if (IS_ERR(pm2->regu)) { ret = PTR_ERR(pm2->regu); dev_err(pm2->dev, "failed to get vddadc regulator\n"); goto free_charger_wq; } /* Register AC charger class */ pm2->ac_chg.psy = power_supply_register(pm2->dev, &pm2->ac_chg_desc, &psy_cfg); if (IS_ERR(pm2->ac_chg.psy)) { dev_err(pm2->dev, "failed to register AC charger\n"); ret = PTR_ERR(pm2->ac_chg.psy); goto free_regulator; } /* Register interrupts */ ret = request_threaded_irq(gpio_to_irq(pm2->pdata->gpio_irq_number), NULL, pm2xxx_charger_irq[0].isr, pm2->pdata->irq_type, pm2xxx_charger_irq[0].name, pm2); if (ret != 0) { dev_err(pm2->dev, "failed to request %s IRQ %d: %d\n", pm2xxx_charger_irq[0].name, gpio_to_irq(pm2->pdata->gpio_irq_number), ret); goto unregister_pm2xxx_charger; } ret = pm_runtime_set_active(pm2->dev); if (ret) dev_err(pm2->dev, "set active Error\n"); pm_runtime_enable(pm2->dev); pm_runtime_set_autosuspend_delay(pm2->dev, PM2XXX_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(pm2->dev); pm_runtime_resume(pm2->dev); /* pm interrupt can wake up system */ ret = enable_irq_wake(gpio_to_irq(pm2->pdata->gpio_irq_number)); if (ret) { dev_err(pm2->dev, "failed to set irq wake\n"); goto unregister_pm2xxx_interrupt; } mutex_init(&pm2->lock); if (gpio_is_valid(pm2->pdata->lpn_gpio)) { /* get lpn GPIO from platform data */ pm2->lpn_pin = pm2->pdata->lpn_gpio; /* * Charger detection mechanism requires pulling up the LPN pin * while i2c communication if Charger is not connected * LPN pin of PM2301 is GPIO60 of AB9540 */ ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio"); if (ret < 0) { dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n"); goto disable_pm2_irq_wake; } ret = gpio_direction_output(pm2->lpn_pin, 0); if (ret < 0) { dev_err(pm2->dev, "pm2301_lpm_gpio direction failed\n"); goto free_gpio; } set_lpn_pin(pm2); } /* read interrupt registers */ for (i = 0; i < PM2XXX_NUM_INT_REG; i++) pm2xxx_reg_read(pm2, pm2xxx_interrupt_registers[i], &val); ret = pm2xxx_charger_detection(pm2, &val); if ((ret == 0) && val) { pm2->ac.charger_connected = 1; ab8500_override_turn_on_stat(~AB8500_POW_KEY_1_ON, AB8500_MAIN_CH_DET); pm2->ac_conn = true; power_supply_changed(pm2->ac_chg.psy); sysfs_notify(&pm2->ac_chg.psy->dev.kobj, NULL, "present"); } return 0; free_gpio: if (gpio_is_valid(pm2->lpn_pin)) gpio_free(pm2->lpn_pin); disable_pm2_irq_wake: disable_irq_wake(gpio_to_irq(pm2->pdata->gpio_irq_number)); unregister_pm2xxx_interrupt: /* disable interrupt */ free_irq(gpio_to_irq(pm2->pdata->gpio_irq_number), pm2); unregister_pm2xxx_charger: /* unregister power supply */ power_supply_unregister(pm2->ac_chg.psy); free_regulator: /* disable the regulator */ regulator_put(pm2->regu); free_charger_wq: destroy_workqueue(pm2->charger_wq); free_device_info: kfree(pm2); return ret; }
static int bcl_probe(struct platform_device *pdev) { struct bcl_context *bcl = NULL; int ret = 0; enum bcl_device_mode bcl_mode = BCL_DEVICE_DISABLED; bcl = devm_kzalloc(&pdev->dev, sizeof(struct bcl_context), GFP_KERNEL); if (!bcl) { pr_err("Cannot allocate bcl_context\n"); return -ENOMEM; } /* For BCL */ /* Init default BCL params */ if (of_property_read_bool(pdev->dev.of_node, "qcom,bcl-enable")) bcl_mode = BCL_DEVICE_ENABLED; else bcl_mode = BCL_DEVICE_DISABLED; bcl->bcl_mode = BCL_DEVICE_DISABLED; bcl->dev = &pdev->dev; bcl->bcl_monitor_type = BCL_IAVAIL_MONITOR_TYPE; bcl->bcl_threshold_mode[BCL_LOW_THRESHOLD_TYPE] = BCL_IAVAIL_THRESHOLD_DISABLED; bcl->bcl_threshold_mode[BCL_HIGH_THRESHOLD_TYPE] = BCL_IAVAIL_THRESHOLD_DISABLED; bcl->bcl_threshold_value_ma[BCL_LOW_THRESHOLD_TYPE] = 0; bcl->bcl_threshold_value_ma[BCL_HIGH_THRESHOLD_TYPE] = 0; bcl->bcl_vbat_min = BATTERY_VOLTAGE_MIN; snprintf(bcl->bcl_type, BCL_NAME_LENGTH, "%s", bcl_type[BCL_IAVAIL_MONITOR_TYPE]); bcl->bcl_poll_interval_msec = BCL_POLL_INTERVAL; if (of_property_read_bool(pdev->dev.of_node, "qcom,bcl-no-bms")) bcl->bcl_no_bms = true; else bcl->bcl_no_bms = false; bcl_frequency_mask = get_mask_from_core_handle(pdev, "qcom,bcl-freq-control-list"); bcl_hotplug_mask = get_mask_from_core_handle(pdev, "qcom,bcl-hotplug-list"); bcl_soc_hotplug_mask = get_mask_from_core_handle(pdev, "qcom,bcl-soc-hotplug-list"); if (!bcl_hotplug_mask && !bcl_soc_hotplug_mask) bcl_hotplug_enabled = false; else bcl_hotplug_enabled = true; if (of_property_read_bool(pdev->dev.of_node, "qcom,bcl-framework-interface")) ret = probe_bcl_periph_prop(bcl); else ret = probe_btm_properties(bcl); if (ret == -EPROBE_DEFER) return ret; ret = create_bcl_sysfs(bcl); if (ret < 0) { pr_err("Cannot create bcl sysfs\n"); return ret; } cpumask_clear(bcl_cpu_online_mask); bcl_psy.name = bcl_psy_name; bcl_psy.type = POWER_SUPPLY_TYPE_BMS; bcl_psy.get_property = bcl_battery_get_property; bcl_psy.set_property = bcl_battery_set_property; bcl_psy.num_properties = 0; #ifndef CONFIG_LGE_PM bcl_psy.external_power_changed = power_supply_callback; #endif gbcl = bcl; platform_set_drvdata(pdev, bcl); INIT_DEFERRABLE_WORK(&bcl->bcl_iavail_work, bcl_iavail_work); INIT_WORK(&bcl_hotplug_work, bcl_handle_hotplug); if (bcl_hotplug_enabled) register_cpu_notifier(&bcl_cpu_notifier); if (bcl_mode == BCL_DEVICE_ENABLED) bcl_mode_set(bcl_mode); return 0; }
static inline void dbs_timer_init(struct greenmax_info_s *this_greenmax) { int delay = get_timer_delay(); INIT_DEFERRABLE_WORK(&this_greenmax->work, do_dbs_timer); schedule_delayed_work_on(this_greenmax->cpu, &this_greenmax->work, delay); }
static int lc709203f_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct lc709203f_chip *chip; int ret; /* Required PEC functionality */ client->flags = client->flags | I2C_CLIENT_PEC; /* Check if device exist or not */ ret = i2c_smbus_read_word_data(client, LC709203F_NUM_OF_THE_PARAM); if (ret < 0) { dev_err(&client->dev, "device is not responding, %d\n", ret); return ret; } dev_info(&client->dev, "Device Params 0x%04x\n", ret); chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; chip->client = client; if (client->dev.of_node) { chip->pdata = devm_kzalloc(&client->dev, sizeof(*chip->pdata), GFP_KERNEL); if (!chip->pdata) return -ENOMEM; of_lc709203f_parse_platform_data(client, chip->pdata); } else { chip->pdata = client->dev.platform_data; } if (!chip->pdata) return -ENODATA; mutex_init(&chip->mutex); chip->shutdown_complete = 0; i2c_set_clientdata(client, chip); if (chip->pdata->initial_rsoc) { ret = lc709203f_write_word(chip->client, LC709203F_INITIAL_RSOC, chip->pdata->initial_rsoc); if (ret < 0) { dev_err(&client->dev, "INITIAL_RSOC write failed: %d\n", ret); return ret; } dev_info(&client->dev, "initial-rsoc: 0x%04x\n", chip->pdata->initial_rsoc); } ret = lc709203f_write_word(chip->client, LC709203F_ALARM_LOW_CELL_RSOC, chip->pdata->alert_low_rsoc); if (ret < 0) { dev_err(&client->dev, "LOW_RSOC write failed: %d\n", ret); return ret; } ret = lc709203f_write_word(chip->client, LC709203F_ALARM_LOW_CELL_VOLT, chip->pdata->alert_low_voltage); if (ret < 0) { dev_err(&client->dev, "LOW_VOLT write failed: %d\n", ret); return ret; } if (chip->pdata->appli_adjustment) { ret = lc709203f_write_word(chip->client, LC709203F_ADJUSTMENT_PACK_APPLI, chip->pdata->appli_adjustment); if (ret < 0) { dev_err(&client->dev, "ADJUSTMENT_APPLI write failed: %d\n", ret); return ret; } } if (chip->pdata->tz_name || !chip->pdata->thermistor_beta) goto skip_thermistor_config; if (chip->pdata->therm_adjustment) { ret = lc709203f_write_word(chip->client, LC709203F_ADJUSTMENT_PACK_THERM, chip->pdata->therm_adjustment); if (ret < 0) { dev_err(&client->dev, "ADJUSTMENT_THERM write failed: %d\n", ret); return ret; } } ret = lc709203f_write_word(chip->client, LC709203F_THERMISTOR_B, chip->pdata->thermistor_beta); if (ret < 0) { dev_err(&client->dev, "THERMISTOR_B write failed: %d\n", ret); return ret; } ret = lc709203f_write_word(chip->client, LC709203F_STATUS_BIT, 0x1); if (ret < 0) { dev_err(&client->dev, "STATUS_BIT write failed: %d\n", ret); return ret; } skip_thermistor_config: lc709203f_update_soc_voltage(chip); chip->battery.name = "battery"; chip->battery.type = POWER_SUPPLY_TYPE_BATTERY; chip->battery.get_property = lc709203f_get_property; chip->battery.properties = lc709203f_battery_props; chip->battery.num_properties = ARRAY_SIZE(lc709203f_battery_props); chip->status = POWER_SUPPLY_STATUS_DISCHARGING; chip->lasttime_status = POWER_SUPPLY_STATUS_DISCHARGING; chip->charge_complete = 0; /* Remove current property if it is not supported */ if (!chip->pdata->support_battery_current) chip->battery.num_properties--; ret = power_supply_register(&client->dev, &chip->battery); if (ret) { dev_err(&client->dev, "failed: power supply register\n"); goto error; } lc709203f_bgi.tz_name = chip->pdata->tz_name; chip->bg_dev = battery_gauge_register(&client->dev, &lc709203f_bgi, chip); if (IS_ERR(chip->bg_dev)) { ret = PTR_ERR(chip->bg_dev); dev_err(&client->dev, "battery gauge register failed: %d\n", ret); goto bg_err; } INIT_DEFERRABLE_WORK(&chip->work, lc709203f_work); schedule_delayed_work(&chip->work, 0); lc709203f_debugfs_init(client); if (client->irq) { ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, lc709203f_irq, IRQF_ONESHOT | IRQF_TRIGGER_FALLING, dev_name(&client->dev), chip); if (ret < 0) { dev_err(&client->dev, "%s: request IRQ %d fail, err = %d\n", __func__, client->irq, ret); client->irq = 0; goto irq_reg_error; } } device_set_wakeup_capable(&client->dev, 1); dev_info(&client->dev, "Battery Voltage %dmV and SoC %d%%\n", chip->vcell, chip->soc); return 0; irq_reg_error: cancel_delayed_work_sync(&chip->work); bg_err: power_supply_unregister(&chip->battery); error: mutex_destroy(&chip->mutex); return ret; }
static irqreturn_t exynos4x12_tmu_irq_handler(int irq, void *id) { struct s5p_tmu_info *info = id; unsigned int status; disable_irq_nosync(irq); status = __raw_readl(info->tmu_base + EXYNOS4_TMU_INTSTAT) & 0x1FFFF; pr_info("EXYNOS4x12_tmu interrupt: INTSTAT = 0x%08x\n", status); /* To handle multiple interrupt pending, * interrupt by high temperature are serviced with priority. */ #if defined(CONFIG_TC_VOLTAGE) if (status & INTSTAT_FALL0) { info->tmu_state = TMU_STATUS_TC; __raw_writel(INTCLEARALL, info->tmu_base + EXYNOS4_TMU_INTCLEAR); exynos_interrupt_enable(info, 0); } else if (status & INTSTAT_RISE2) { info->tmu_state = TMU_STATUS_TRIPPED; __raw_writel(INTCLEAR_RISE2, info->tmu_base + EXYNOS4_TMU_INTCLEAR); #else if (status & INTSTAT_RISE2) { info->tmu_state = TMU_STATUS_TRIPPED; __raw_writel(INTCLEAR_RISE2, info->tmu_base + EXYNOS4_TMU_INTCLEAR); #endif } else if (status & INTSTAT_RISE1) { info->tmu_state = TMU_STATUS_WARNING; __raw_writel(INTCLEAR_RISE1, info->tmu_base + EXYNOS4_TMU_INTCLEAR); } else if (status & INTSTAT_RISE0) { info->tmu_state = TMU_STATUS_THROTTLED; __raw_writel(INTCLEAR_RISE0, info->tmu_base + EXYNOS4_TMU_INTCLEAR); } else { pr_err("%s: interrupt error\n", __func__); __raw_writel(INTCLEARALL, info->tmu_base + EXYNOS4_TMU_INTCLEAR); queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate / 2); return -ENODEV; } /* read current temperature & save */ info->last_temperature = get_curr_temp(info); queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate); return IRQ_HANDLED; } static irqreturn_t exynos4210_tmu_irq_handler(int irq, void *id) { struct s5p_tmu_info *info = id; unsigned int status; disable_irq_nosync(irq); status = __raw_readl(info->tmu_base + EXYNOS4_TMU_INTSTAT); /* pr_info("EXYNOS4212_tmu interrupt: INTSTAT = 0x%08x\n", status); */ /* To handle multiple interrupt pending, * interrupt by high temperature are serviced with priority. */ if (status & TMU_INTSTAT2) { info->tmu_state = TMU_STATUS_TRIPPED; __raw_writel(INTCLEAR2, info->tmu_base + EXYNOS4_TMU_INTCLEAR); } else if (status & TMU_INTSTAT1) { info->tmu_state = TMU_STATUS_WARNING; __raw_writel(INTCLEAR1, info->tmu_base + EXYNOS4_TMU_INTCLEAR); } else if (status & TMU_INTSTAT0) { info->tmu_state = TMU_STATUS_THROTTLED; __raw_writel(INTCLEAR0, info->tmu_base + EXYNOS4_TMU_INTCLEAR); } else { pr_err("%s: interrupt error\n", __func__); __raw_writel(INTCLEARALL, info->tmu_base + EXYNOS4_TMU_INTCLEAR); queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate / 2); return -ENODEV; } /* read current temperature & save */ info->last_temperature = get_curr_temp(info); queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate); return IRQ_HANDLED; } #ifdef CONFIG_TMU_SYSFS static ssize_t s5p_tmu_show_curr_temp(struct device *dev, struct device_attribute *attr, char *buf) { struct s5p_tmu_info *info = dev_get_drvdata(dev); unsigned int curr_temp; curr_temp = get_curr_temp(info); curr_temp *= 10; pr_info("curr temp = %d\n", curr_temp); return sprintf(buf, "%d\n", curr_temp); } static DEVICE_ATTR(curr_temp, S_IRUGO, s5p_tmu_show_curr_temp, NULL); #endif static int __devinit s5p_tmu_probe(struct platform_device *pdev) { struct s5p_tmu_info *info; struct s5p_platform_tmu *pdata; struct resource *res; unsigned int mask = (enable_mask & ENABLE_DBGMASK); int ret = 0; pr_debug("%s: probe=%p\n", __func__, pdev); info = kzalloc(sizeof(struct s5p_tmu_info), GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "failed to alloc memory!\n"); ret = -ENOMEM; goto err_nomem; } platform_set_drvdata(pdev, info); info->dev = &pdev->dev; info->tmu_state = TMU_STATUS_INIT; /* set cpufreq limit level at 1st_throttle & 2nd throttle */ pdata = info->dev->platform_data; if (pdata->cpufreq.limit_1st_throttle) exynos_cpufreq_get_level(pdata->cpufreq.limit_1st_throttle, &info->cpufreq_level_1st_throttle); if (pdata->cpufreq.limit_2nd_throttle) exynos_cpufreq_get_level(pdata->cpufreq.limit_2nd_throttle, &info->cpufreq_level_2nd_throttle); pr_info("@@@ %s: cpufreq_limit: 1st_throttle: %u, 2nd_throttle = %u\n", __func__, info->cpufreq_level_1st_throttle, info->cpufreq_level_2nd_throttle); #if defined(CONFIG_TC_VOLTAGE) /* Temperature compensated voltage */ if (exynos_find_cpufreq_level_by_volt(pdata->temp_compensate.arm_volt, &info->cpulevel_tc) < 0) { dev_err(&pdev->dev, "cpufreq_get_level error\n"); ret = -EINVAL; goto err_nores; } #ifdef CONFIG_BUSFREQ_OPP /* To lock bus frequency in OPP mode */ info->bus_dev = dev_get("exynos-busfreq"); if (info->bus_dev < 0) { dev_err(&pdev->dev, "Failed to get_dev\n"); ret = -EINVAL; goto err_nores; } if (exynos4x12_find_busfreq_by_volt(pdata->temp_compensate.bus_volt, &info->busfreq_tc)) { dev_err(&pdev->dev, "get_busfreq_value error\n"); ret = -EINVAL; goto err_nores; } #endif pr_info("%s: cpufreq_level[%u], busfreq_value[%u]\n", __func__, info->cpulevel_tc, info->busfreq_tc); #endif /* Map auto_refresh_rate of normal & tq0 mode */ info->auto_refresh_tq0 = get_refresh_interval(FREQ_IN_PLL, AUTO_REFRESH_PERIOD_TQ0); info->auto_refresh_normal = get_refresh_interval(FREQ_IN_PLL, AUTO_REFRESH_PERIOD_NORMAL); /* To poll current temp, set sampling rate to ONE second sampling */ info->sampling_rate = usecs_to_jiffies(1000 * 1000); /* 10sec monitroing */ info->monitor_period = usecs_to_jiffies(10000 * 1000); /* support test mode */ if (mask & ENABLE_TEST_MODE) set_temperature_params(info); else print_temperature_params(info); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get memory region resource\n"); ret = -ENODEV; goto err_nores; } info->ioarea = request_mem_region(res->start, res->end-res->start + 1, pdev->name); if (!(info->ioarea)) { dev_err(&pdev->dev, "failed to reserve memory region\n"); ret = -EBUSY; goto err_nores; } info->tmu_base = ioremap(res->start, (res->end - res->start) + 1); if (!(info->tmu_base)) { dev_err(&pdev->dev, "failed ioremap()\n"); ret = -ENOMEM; goto err_nomap; } tmu_monitor_wq = create_freezable_workqueue(dev_name(&pdev->dev)); if (!tmu_monitor_wq) { pr_info("Creation of tmu_monitor_wq failed\n"); ret = -ENOMEM; goto err_wq; } /* To support periodic temprature monitoring */ if (mask & ENABLE_TEMP_MON) { INIT_DEFERRABLE_WORK(&info->monitor, exynos4_poll_cur_temp); queue_delayed_work_on(0, tmu_monitor_wq, &info->monitor, info->monitor_period); } INIT_DEFERRABLE_WORK(&info->polling, exynos4_handler_tmu_state); info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) { dev_err(&pdev->dev, "no irq for thermal %d\n", info->irq); ret = -EINVAL; goto err_irq; } if (soc_is_exynos4210()) ret = request_irq(info->irq, exynos4210_tmu_irq_handler, IRQF_DISABLED, "s5p-tmu interrupt", info); else ret = request_irq(info->irq, exynos4x12_tmu_irq_handler, IRQF_DISABLED, "s5p-tmu interrupt", info); if (ret) { dev_err(&pdev->dev, "request_irq is failed. %d\n", ret); goto err_irq; } ret = device_create_file(&pdev->dev, &dev_attr_temperature); if (ret != 0) { pr_err("Failed to create temperatue file: %d\n", ret); goto err_sysfs_file1; } ret = device_create_file(&pdev->dev, &dev_attr_tmu_state); if (ret != 0) { pr_err("Failed to create tmu_state file: %d\n", ret); goto err_sysfs_file2; } ret = device_create_file(&pdev->dev, &dev_attr_lot_id); if (ret != 0) { pr_err("Failed to create lot id file: %d\n", ret); goto err_sysfs_file3; } ret = tmu_initialize(pdev); if (ret) goto err_init; #ifdef CONFIG_TMU_SYSFS ret = device_create_file(&pdev->dev, &dev_attr_curr_temp); if (ret < 0) { dev_err(&pdev->dev, "Failed to create sysfs group\n"); goto err_init; } #endif #ifdef CONFIG_TMU_DEBUG ret = device_create_file(&pdev->dev, &dev_attr_print_state); if (ret) { dev_err(&pdev->dev, "Failed to create tmu sysfs group\n\n"); return ret; } #endif #if defined(CONFIG_TC_VOLTAGE) /* s/w workaround for fast service when interrupt is not occured, * such as current temp is lower than tc interrupt temperature * or current temp is continuosly increased. */ if (get_curr_temp(info) <= pdata->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); } #if defined(CONFIG_VIDEO_MALI400MP) if (mali_voltage_lock_init()) pr_err("Failed to initialize mail voltage lock.\n"); #endif #endif /* initialize tmu_state */ queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate); return ret; err_init: device_remove_file(&pdev->dev, &dev_attr_lot_id); err_sysfs_file3: device_remove_file(&pdev->dev, &dev_attr_tmu_state); err_sysfs_file2: device_remove_file(&pdev->dev, &dev_attr_temperature); err_sysfs_file1: if (info->irq >= 0) free_irq(info->irq, info); err_irq: destroy_workqueue(tmu_monitor_wq); err_wq: iounmap(info->tmu_base); err_nomap: release_resource(info->ioarea); kfree(info->ioarea); err_nores: kfree(info); info = NULL; err_nomem: dev_err(&pdev->dev, "initialization failed.\n"); return ret; } static int __devinit s5p_tmu_remove(struct platform_device *pdev) { struct s5p_tmu_info *info = platform_get_drvdata(pdev); cancel_delayed_work(&info->polling); destroy_workqueue(tmu_monitor_wq); device_remove_file(&pdev->dev, &dev_attr_temperature); device_remove_file(&pdev->dev, &dev_attr_tmu_state); if (info->irq >= 0) free_irq(info->irq, info); iounmap(info->tmu_base); release_resource(info->ioarea); kfree(info->ioarea); kfree(info); info = NULL; pr_info("%s is removed\n", dev_name(&pdev->dev)); return 0; } #ifdef CONFIG_PM static int s5p_tmu_suspend(struct platform_device *pdev, pm_message_t state) { struct s5p_tmu_info *info = platform_get_drvdata(pdev); if (!info) return -EAGAIN; /* save register value */ info->reg_save[0] = __raw_readl(info->tmu_base + EXYNOS4_TMU_CONTROL); info->reg_save[1] = __raw_readl(info->tmu_base + EXYNOS4_TMU_SAMPLING_INTERNAL); info->reg_save[2] = __raw_readl(info->tmu_base + EXYNOS4_TMU_COUNTER_VALUE0); info->reg_save[3] = __raw_readl(info->tmu_base + EXYNOS4_TMU_COUNTER_VALUE1); info->reg_save[4] = __raw_readl(info->tmu_base + EXYNOS4_TMU_INTEN); if (soc_is_exynos4210()) { info->reg_save[5] = __raw_readl(info->tmu_base + EXYNOS4210_TMU_THRESHOLD_TEMP); info->reg_save[6] = __raw_readl(info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL0); info->reg_save[7] = __raw_readl(info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL1); info->reg_save[8] = __raw_readl(info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL2); info->reg_save[9] = __raw_readl(info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL3); } else { info->reg_save[5] = __raw_readl(info->tmu_base + EXYNOS4x12_TMU_TRESHOLD_TEMP_RISE); #if defined(CONFIG_TC_VOLTAGE) info->reg_save[6] = __raw_readl(info->tmu_base + EXYNOS4x12_TMU_TRESHOLD_TEMP_FALL); #endif } disable_irq(info->irq); return 0; } static int s5p_tmu_resume(struct platform_device *pdev) { struct s5p_tmu_info *info = platform_get_drvdata(pdev); struct s5p_platform_tmu *data; if (!info || !(info->dev)) return -EAGAIN; data = info->dev->platform_data; /* restore tmu register value */ __raw_writel(info->reg_save[0], info->tmu_base + EXYNOS4_TMU_CONTROL); __raw_writel(info->reg_save[1], info->tmu_base + EXYNOS4_TMU_SAMPLING_INTERNAL); __raw_writel(info->reg_save[2], info->tmu_base + EXYNOS4_TMU_COUNTER_VALUE0); __raw_writel(info->reg_save[3], info->tmu_base + EXYNOS4_TMU_COUNTER_VALUE1); if (soc_is_exynos4210()) { __raw_writel(info->reg_save[5], info->tmu_base + EXYNOS4210_TMU_THRESHOLD_TEMP); __raw_writel(info->reg_save[6], info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL0); __raw_writel(info->reg_save[7], info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL1); __raw_writel(info->reg_save[8], info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL2); __raw_writel(info->reg_save[9], info->tmu_base + EXYNOS4210_TMU_TRIG_LEVEL3); } else { __raw_writel(info->reg_save[5], info->tmu_base + EXYNOS4x12_TMU_TRESHOLD_TEMP_RISE); #if defined(CONFIG_TC_VOLTAGE) __raw_writel(info->reg_save[6], info->tmu_base + EXYNOS4x12_TMU_TRESHOLD_TEMP_FALL); #endif } __raw_writel(info->reg_save[4], info->tmu_base + EXYNOS4_TMU_INTEN); #if defined(CONFIG_TC_VOLTAGE) /* s/w workaround for fast service when interrupt is not occured, * such as current temp is lower than tc interrupt temperature * or current temp is continuosly increased.. */ mdelay(1); if (get_curr_temp(info) <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); } #endif /* Find out tmu_state after wakeup */ queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, 0); return 0; } #else #define s5p_tmu_suspend NULL #define s5p_tmu_resume NULL #endif static struct platform_driver s5p_tmu_driver = { .probe = s5p_tmu_probe, .remove = s5p_tmu_remove, .suspend = s5p_tmu_suspend, .resume = s5p_tmu_resume, .driver = { .name = "s5p-tmu", .owner = THIS_MODULE, }, }; static int __init s5p_tmu_driver_init(void) { return platform_driver_register(&s5p_tmu_driver); } static void __exit s5p_tmu_driver_exit(void) { platform_driver_unregister(&s5p_tmu_driver); }
static int __devinit sec_fuelgauge_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct sec_fuelgauge_info *fuelgauge; int ret = 0; union power_supply_propval raw_soc_val; dev_dbg(&client->dev, "%s: SEC Fuelgauge Driver Loading\n", __func__); if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) return -EIO; fuelgauge = kzalloc(sizeof(*fuelgauge), GFP_KERNEL); if (!fuelgauge) return -ENOMEM; mutex_init(&fuelgauge->fg_lock); fuelgauge->client = client; fuelgauge->pdata = client->dev.platform_data; i2c_set_clientdata(client, fuelgauge); fuelgauge->psy_fg.name = "sec-fuelgauge"; fuelgauge->psy_fg.type = POWER_SUPPLY_TYPE_UNKNOWN; fuelgauge->psy_fg.get_property = sec_fg_get_property; fuelgauge->psy_fg.set_property = sec_fg_set_property; fuelgauge->psy_fg.properties = sec_fuelgauge_props; fuelgauge->psy_fg.num_properties = ARRAY_SIZE(sec_fuelgauge_props); fuelgauge->capacity_max = fuelgauge->pdata->capacity_max; raw_soc_val.intval = SEC_FUELGAUGE_CAPACITY_TYPE_RAW; sec_hal_fg_get_property(fuelgauge->client, POWER_SUPPLY_PROP_CAPACITY, &raw_soc_val); raw_soc_val.intval /= 10; fuelgauge->is_reset = false; if(raw_soc_val.intval > fuelgauge->pdata->capacity_max) sec_fg_calculate_dynamic_scale(fuelgauge); if (!fuelgauge->pdata->fg_gpio_init()) { dev_err(&client->dev, "%s: Failed to Initialize GPIO\n", __func__); goto err_free; } if (!sec_hal_fg_init(fuelgauge->client)) { dev_err(&client->dev, "%s: Failed to Initialize Fuelgauge\n", __func__); goto err_free; } ret = power_supply_register(&client->dev, &fuelgauge->psy_fg); if (ret) { dev_err(&client->dev, "%s: Failed to Register psy_fg\n", __func__); goto err_free; } if (fuelgauge->pdata->fg_irq) { INIT_DEFERRABLE_WORK( &fuelgauge->isr_work, sec_fg_isr_work); ret = request_threaded_irq(fuelgauge->pdata->fg_irq, NULL, sec_fg_irq_thread, fuelgauge->pdata->fg_irq_attr | IRQF_ONESHOT, "fuelgauge-irq", fuelgauge); if (ret) { dev_err(&client->dev, "%s: Failed to Reqeust IRQ\n", __func__); goto err_supply_unreg; } ret = enable_irq_wake(fuelgauge->pdata->fg_irq); if (ret < 0) dev_err(&client->dev, "%s: Failed to Enable Wakeup Source(%d)\n", __func__, ret); } fuelgauge->is_fuel_alerted = false; if (fuelgauge->pdata->fuel_alert_soc >= 0) { if (sec_hal_fg_fuelalert_init(fuelgauge->client, fuelgauge->pdata->fuel_alert_soc)) wake_lock_init(&fuelgauge->fuel_alert_wake_lock, WAKE_LOCK_SUSPEND, "fuel_alerted"); else { dev_err(&client->dev, "%s: Failed to Initialize Fuel-alert\n", __func__); goto err_irq; } } fuelgauge->initial_update_of_soc = true; ret = sec_fg_create_attrs(fuelgauge->psy_fg.dev); if (ret) { dev_err(&client->dev, "%s : Failed to create_attrs\n", __func__); goto err_irq; } pr_info("%s: fg_irq: %d, capacity_max: %d, " "cpacity_max_margin: %d, capacity_min: %d," "calculation_type: 0x%x, fuel_alert_soc: %d,\n" "repeated_fuelalert: %d, RCOMP0: 0x%x," "RCOMP_charging: 0x%x, temp_cohot: %d," "temp_cocold: %d, is_using_model_data: %d," "type_str: %s,\n", __func__, fuelgauge->pdata->fg_irq, fuelgauge->pdata->capacity_max, fuelgauge->pdata->capacity_max_margin, fuelgauge->pdata->capacity_min, fuelgauge->pdata->capacity_calculation_type, fuelgauge->pdata->fuel_alert_soc, fuelgauge->pdata->repeated_fuelalert, get_battery_data(fuelgauge).RCOMP0, get_battery_data(fuelgauge).RCOMP_charging, get_battery_data(fuelgauge).temp_cohot, get_battery_data(fuelgauge).temp_cocold, get_battery_data(fuelgauge).is_using_model_data, get_battery_data(fuelgauge).type_str ); dev_dbg(&client->dev, "%s: SEC Fuelgauge Driver Loaded\n", __func__); return 0; err_irq: if (fuelgauge->pdata->fg_irq) free_irq(fuelgauge->pdata->fg_irq, fuelgauge); wake_lock_destroy(&fuelgauge->fuel_alert_wake_lock); err_supply_unreg: power_supply_unregister(&fuelgauge->psy_fg); err_free: mutex_destroy(&fuelgauge->fg_lock); kfree(fuelgauge); return ret; }