Loading drivers/hwmon/jc42.c +89 −97 Original line number Diff line number Diff line Loading @@ -176,65 +176,6 @@ struct jc42_data { u16 temp_max; }; static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id); static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info); static int jc42_remove(struct i2c_client *client); static struct jc42_data *jc42_update_device(struct device *dev); static const struct i2c_device_id jc42_id[] = { { "jc42", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, jc42_id); #ifdef CONFIG_PM static int jc42_suspend(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); data->config |= JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } static int jc42_resume(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); data->config &= ~JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } static const struct dev_pm_ops jc42_dev_pm_ops = { .suspend = jc42_suspend, .resume = jc42_resume, }; #define JC42_DEV_PM_OPS (&jc42_dev_pm_ops) #else #define JC42_DEV_PM_OPS NULL #endif /* CONFIG_PM */ /* This is the driver that will be inserted */ static struct i2c_driver jc42_driver = { .class = I2C_CLASS_SPD, .driver = { .name = "jc42", .pm = JC42_DEV_PM_OPS, }, .probe = jc42_probe, .remove = jc42_remove, .id_table = jc42_id, .detect = jc42_detect, .address_list = normal_i2c, }; #define JC42_TEMP_MIN_EXTENDED (-40000) #define JC42_TEMP_MIN 0 #define JC42_TEMP_MAX 125000 Loading @@ -261,6 +202,53 @@ static int jc42_temp_from_reg(s16 reg) return reg * 125 / 2; } static struct jc42_data *jc42_update_device(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; struct jc42_data *ret = data; int val; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_input = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_CRITICAL); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_crit = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_LOWER); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_min = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_UPPER); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_max = val; data->last_updated = jiffies; data->valid = true; } abort: mutex_unlock(&data->update_lock); return ret; } /* sysfs stuff */ /* read routines for temperature limits */ Loading Loading @@ -537,52 +525,56 @@ static int jc42_remove(struct i2c_client *client) return 0; } static struct jc42_data *jc42_update_device(struct device *dev) #ifdef CONFIG_PM static int jc42_suspend(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; struct jc42_data *ret = data; int val; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP); if (val < 0) { ret = ERR_PTR(val); goto abort; data->config |= JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } data->temp_input = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_CRITICAL); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_crit = val; static int jc42_resume(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_LOWER); if (val < 0) { ret = ERR_PTR(val); goto abort; data->config &= ~JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } data->temp_min = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_UPPER); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_max = val; static const struct dev_pm_ops jc42_dev_pm_ops = { .suspend = jc42_suspend, .resume = jc42_resume, }; data->last_updated = jiffies; data->valid = true; } abort: mutex_unlock(&data->update_lock); return ret; } #define JC42_DEV_PM_OPS (&jc42_dev_pm_ops) #else #define JC42_DEV_PM_OPS NULL #endif /* CONFIG_PM */ static const struct i2c_device_id jc42_id[] = { { "jc42", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, jc42_id); static struct i2c_driver jc42_driver = { .class = I2C_CLASS_SPD, .driver = { .name = "jc42", .pm = JC42_DEV_PM_OPS, }, .probe = jc42_probe, .remove = jc42_remove, .id_table = jc42_id, .detect = jc42_detect, .address_list = normal_i2c, }; module_i2c_driver(jc42_driver); Loading Loading
drivers/hwmon/jc42.c +89 −97 Original line number Diff line number Diff line Loading @@ -176,65 +176,6 @@ struct jc42_data { u16 temp_max; }; static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id); static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info); static int jc42_remove(struct i2c_client *client); static struct jc42_data *jc42_update_device(struct device *dev); static const struct i2c_device_id jc42_id[] = { { "jc42", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, jc42_id); #ifdef CONFIG_PM static int jc42_suspend(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); data->config |= JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } static int jc42_resume(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); data->config &= ~JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } static const struct dev_pm_ops jc42_dev_pm_ops = { .suspend = jc42_suspend, .resume = jc42_resume, }; #define JC42_DEV_PM_OPS (&jc42_dev_pm_ops) #else #define JC42_DEV_PM_OPS NULL #endif /* CONFIG_PM */ /* This is the driver that will be inserted */ static struct i2c_driver jc42_driver = { .class = I2C_CLASS_SPD, .driver = { .name = "jc42", .pm = JC42_DEV_PM_OPS, }, .probe = jc42_probe, .remove = jc42_remove, .id_table = jc42_id, .detect = jc42_detect, .address_list = normal_i2c, }; #define JC42_TEMP_MIN_EXTENDED (-40000) #define JC42_TEMP_MIN 0 #define JC42_TEMP_MAX 125000 Loading @@ -261,6 +202,53 @@ static int jc42_temp_from_reg(s16 reg) return reg * 125 / 2; } static struct jc42_data *jc42_update_device(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; struct jc42_data *ret = data; int val; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_input = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_CRITICAL); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_crit = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_LOWER); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_min = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_UPPER); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_max = val; data->last_updated = jiffies; data->valid = true; } abort: mutex_unlock(&data->update_lock); return ret; } /* sysfs stuff */ /* read routines for temperature limits */ Loading Loading @@ -537,52 +525,56 @@ static int jc42_remove(struct i2c_client *client) return 0; } static struct jc42_data *jc42_update_device(struct device *dev) #ifdef CONFIG_PM static int jc42_suspend(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; struct jc42_data *ret = data; int val; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP); if (val < 0) { ret = ERR_PTR(val); goto abort; data->config |= JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } data->temp_input = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_CRITICAL); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_crit = val; static int jc42_resume(struct device *dev) { struct jc42_data *data = dev_get_drvdata(dev); val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_LOWER); if (val < 0) { ret = ERR_PTR(val); goto abort; data->config &= ~JC42_CFG_SHUTDOWN; i2c_smbus_write_word_swapped(data->client, JC42_REG_CONFIG, data->config); return 0; } data->temp_min = val; val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_UPPER); if (val < 0) { ret = ERR_PTR(val); goto abort; } data->temp_max = val; static const struct dev_pm_ops jc42_dev_pm_ops = { .suspend = jc42_suspend, .resume = jc42_resume, }; data->last_updated = jiffies; data->valid = true; } abort: mutex_unlock(&data->update_lock); return ret; } #define JC42_DEV_PM_OPS (&jc42_dev_pm_ops) #else #define JC42_DEV_PM_OPS NULL #endif /* CONFIG_PM */ static const struct i2c_device_id jc42_id[] = { { "jc42", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, jc42_id); static struct i2c_driver jc42_driver = { .class = I2C_CLASS_SPD, .driver = { .name = "jc42", .pm = JC42_DEV_PM_OPS, }, .probe = jc42_probe, .remove = jc42_remove, .id_table = jc42_id, .detect = jc42_detect, .address_list = normal_i2c, }; module_i2c_driver(jc42_driver); Loading