diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-09 19:59:54 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-09 19:59:54 -0700 |
commit | 71219b3494a32b5e1f22c4b1a5be2eb0d5524057 (patch) | |
tree | 682f2079dd82f5b929aa550e96a2fd417e135419 /drivers/hwmon/g762.c | |
parent | c18bb396d3d261ebbb4efbc05129c5d354c541e4 (diff) | |
parent | e3a2d2be510ec8a35ecd2a17a42467d417962bb7 (diff) |
Merge tag 'hwmon-for-linus-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck:
- added chip support: new Centaur CPUs, ADM1272, NCT6796D
- ucd9000: added debugfs attributes, gpio support
- cleanup and minor bug fixes
* tag 'hwmon-for-linus-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (via-cputemp) support new centaur CPUs
hwmon: (nct6775) Fix writing pwmX_mode
hwmon: (lm92) Add max6635 to lm92_id[]
hwmon: (pmbus/adm1275) Add support for ADM1272
hwmon: (lm92) Do not try to detect MAX6635
hwmon: (ucd9000) Add debugfs attributes to provide mfr_status
hwmon: (ucd9000) Add gpio chip interface
hwmon: (nct6775) Add support for NCT6796D
hwmon: (nct6775) Initialize boolean variables with declaration
hwmon: (nct6775) Improve fan6/pwm6 support
hwmon: (nct6775) Use NUM_FAN consistently
hwmon: (g762) handle cleanup with devm_add_action
hwmon: (sht3x) Update data sheet URL
hwmon: (sht21) Update data sheet URLs
hwmon: (pmbus/adm1275) Accept negative page register values
hwmon: (pmbus/max8688) Accept negative page register values
Diffstat (limited to 'drivers/hwmon/g762.c')
-rw-r--r-- | drivers/hwmon/g762.c | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c index 6d1208b2b6d2..6c83c385a7ca 100644 --- a/drivers/hwmon/g762.c +++ b/drivers/hwmon/g762.c @@ -128,7 +128,6 @@ enum g762_regs { G762_REG_FAN_CMD2_GEAR_MODE_1)) >> 2)) struct g762_data { - struct device *hwmon_dev; struct i2c_client *client; struct clk *clk; @@ -594,6 +593,14 @@ MODULE_DEVICE_TABLE(of, g762_dt_match); * call to g762_of_clock_disable(). Note that a reference to clock is kept * in our private data structure to be used in this function. */ +static void g762_of_clock_disable(void *data) +{ + struct g762_data *g762 = data; + + clk_disable_unprepare(g762->clk); + clk_put(g762->clk); +} + static int g762_of_clock_enable(struct i2c_client *client) { struct g762_data *data; @@ -626,6 +633,7 @@ static int g762_of_clock_enable(struct i2c_client *client) data = i2c_get_clientdata(client); data->clk = clk; + devm_add_action(&client->dev, g762_of_clock_disable, data); return 0; clk_unprep: @@ -637,17 +645,6 @@ static int g762_of_clock_enable(struct i2c_client *client) return ret; } -static void g762_of_clock_disable(struct i2c_client *client) -{ - struct g762_data *data = i2c_get_clientdata(client); - - if (!data->clk) - return; - - clk_disable_unprepare(data->clk); - clk_put(data->clk); -} - static int g762_of_prop_import_one(struct i2c_client *client, const char *pname, int (*psetter)(struct device *dev, @@ -698,8 +695,6 @@ static int g762_of_clock_enable(struct i2c_client *client) { return 0; } - -static void g762_of_clock_disable(struct i2c_client *client) { } #endif /* @@ -1054,6 +1049,7 @@ static inline int g762_fan_init(struct device *dev) static int g762_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct device *dev = &client->dev; + struct device *hwmon_dev; struct g762_data *data; int ret; @@ -1080,35 +1076,15 @@ static int g762_probe(struct i2c_client *client, const struct i2c_device_id *id) return ret; ret = g762_of_prop_import(client); if (ret) - goto clock_dis; + return ret; /* ... or platform_data */ ret = g762_pdata_prop_import(client); if (ret) - goto clock_dis; + return ret; - data->hwmon_dev = hwmon_device_register_with_groups(dev, client->name, + hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, data, g762_groups); - if (IS_ERR(data->hwmon_dev)) { - ret = PTR_ERR(data->hwmon_dev); - goto clock_dis; - } - - return 0; - - clock_dis: - g762_of_clock_disable(client); - - return ret; -} - -static int g762_remove(struct i2c_client *client) -{ - struct g762_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - g762_of_clock_disable(client); - - return 0; + return PTR_ERR_OR_ZERO(hwmon_dev); } static struct i2c_driver g762_driver = { @@ -1117,7 +1093,6 @@ static struct i2c_driver g762_driver = { .of_match_table = of_match_ptr(g762_dt_match), }, .probe = g762_probe, - .remove = g762_remove, .id_table = g762_id, }; |