aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/hwmon.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-01-02hwmon: Fix parameter documentationGuenter Roeck1-6/+6
sparse reports: drivers/hwmon/hwmon.c:681: warning: No description found for parameter 'chip' drivers/hwmon/hwmon.c:681: warning: Excess function parameter 'info' description in 'hwmon_device_register_with_info' drivers/hwmon/hwmon.c:789: warning: No description found for parameter 'chip' drivers/hwmon/hwmon.c:789: warning: No description found for parameter 'groups' drivers/hwmon/hwmon.c:789: warning: Excess function parameter 'info' description in 'devm_hwmon_device_register_with_info' Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-12-26hwmon: Deal with errors from the thermal subsystemLinus Walleij1-4/+17
If the thermal subsystem returne -EPROBE_DEFER or any other error when hwmon calls devm_thermal_zone_of_sensor_register(), this is silently ignored. I ran into this with an incorrectly defined thermal zone, making it non-existing and thus this call failed with -EPROBE_DEFER assuming it would appear later. The sensor was still added which is incorrect: sensors must strictly be added after the thermal zones, so deferred probe must be respected. Fixes: d560168b5d0f ("hwmon: (core) New hwmon registration API") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13hwmon: (core) constify thermal_zone_of_device_ops structuresJulia Lawall1-1/+1
The thermal_zone_of_device_ops structure is only passed as the fourth argument to devm_thermal_zone_of_sensor_register, which is declared as const. Thus the thermal_zone_of_device_ops structure itself can be const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13hwmon: constify attribute_group structures.Arvind Yadav1-1/+1
attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 6655 304 0 6959 1b2f drivers/hwmon/hwmon.o File size After adding 'const': text data bss dec hex filename 6703 240 0 6943 1b1f drivers/hwmon/hwmon.o Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-04-02hwmon: Constify str parameter of hwmon_ops->read_stringJean Delvare1-1/+1
The read_string callback is supposed to retrieve a pointer to a constant string. Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-31hwmon: Register thermal zone only if 'dev' parameter was providedGuenter Roeck1-1/+1
Rgistering a thermal zone uses devm_kzalloc(), which requires a pointer to the parent device. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-31hwmon: Relax name attribute validation for new APIsGuenter Roeck1-2/+4
While invalid name attributes are really not desirable and do mess up libsensors, enforcing valid names has the detrimental effect of driving users away from using the new hardware monitoring API, especially those registering name attributes violating the ABI restrictions. Another undesirable side effect is that this violation and the resulting error may only be discovered some time after a conversion to the new API, which in turn may trigger a revert of that conversion. To solve the problem, relax validation and only issue a warning instead of returning an error if a name attribute violating the ABI is provided. This lets callers continue to provide invalid name attributes while notifying them about it. Many thanks are due to Dmitry Torokhov for the idea. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-25hwmon: Make name attribute mandatory for new APIsGuenter Roeck1-1/+7
It does not make sense to use one of the the new APIs when not even providing a name attribute. Make it mandatory. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-02hwmon: (core) use permission-specific DEVICE_ATTR variantsJulia Lawall1-2/+2
Use DEVICE_ATTR_RO for read-only attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Simplify sysfs attribute name allocationGuenter Roeck1-8/+9
Allocating the sysfs attribute name only if needed and only with the required minimum length looks optimal, but does not take the additional overhead for both devm_ data structures and the allocation header itself into account. This also results in unnecessary memory fragmentation. Move the sysfs name string into struct hwmon_device_attribute and give it a sufficient length to reduce this overhead. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Rename groups parameter in API to extra_groupsGuenter Roeck1-4/+4
The 'groups' parameter of hwmon_device_register_with_info() and devm_hwmon_device_register_with_info() is only necessary if extra non-standard attributes need to be provided. Rename the parameter to extra_groups and clarify the documentation. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Explain why at least two attribute groups are allocatedGuenter Roeck1-1/+1
A list of sysfs attribute groups is NULL-terminated, so we always need to allocate data for at least two groups (the dynamically generated group plus the NULL pointer). Add a comment to explain the situation. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Make is_visible callback truly mandatoryGuenter Roeck1-3/+3
The is_visible callback provides the sysfs attribute mode and is thus truly mandatory as documented. Check it once at registration and remove other checks for its existence. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Deprecate hwmon_device_register()Guenter Roeck1-0/+3
Inform the user that hwmon_device_register() is deprecated, and suggest conversion to the newest API. Also remove hwmon_device_register() from the kernel API documentation. Note that hwmon_device_register() is not marked as __deprecated() since doing so might result in build errors. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Clarify use of chip attributesGuenter Roeck1-3/+7
Describing chip attributes as "attributes which apply to the entire chip" is confusing. Rephrase to "attributes which are not bound to a specific input or output". Also rename hwmon_chip_attr_templates[] to hwmon_chip_attrs[] to indicate that the respective strings strings are not templates but actual attribute names. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-09hwmon: (core) Add support for string attributes to new APIGuenter Roeck1-2/+31
The new API is so far only suited for data attributes and does not work well for string attributes, specifically for the 'label' attributes. Provide a separate callback function for those. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-10-24hwmon: (core) fix resource leak on devm_kcalloc failureColin Ian King1-2/+4
If dev_kcalloc fails to allocate hw_dev->groups then the current exit path is a direct return, causing a leak of resources such as hwdev and ida is not removed. Fix this by exiting via the free_hwmon exit path that performs the necessary resource cleanup. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sysGuenter Roeck1-2/+8
If both hwmon and thermal_sys are built as modules, and CONFIG_THERMAL_HWMON is enabled, the following cyclic module dependency is reported. depmod: ERROR: Found 2 modules in dependency cycles! depmod: ERROR: Cycle detected: hwmon -> thermal_sys -> hwmon Fixes: e4bce763adb2 ("hwmon: (core) New hwmon registration API") Reported-by: Vignesh R <vigneshr@ti.com> Cc: Keerthy J <j-keerthy@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Add basic pwm attribute support to new APIGuenter Roeck1-0/+9
Add basic pwm attribute support (no auto attributes) to new API. Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Add fan attribute support to new APIGuenter Roeck1-0/+16
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Add energy and humidity attribute support to new APIGuenter Roeck1-0/+20
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Add power attribute support to new APIGuenter Roeck1-0/+30
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Add current attribute support to new APIGuenter Roeck1-0/+21
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Add voltage attribute support to new APIGuenter Roeck1-0/+21
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) New hwmon registration APIGuenter Roeck1-27/+458
Up to now, each hwmon driver has to implement its own sysfs attributes. This requires a lot of template code, and distracts from the driver's core function to read and write chip registers. To be able to reduce driver complexity, move sensor attribute handling and thermal zone registration into hwmon core. By using the new API, driver code and data size is typically reduced by 20-70%, depending on driver complexity and the number of sysfs attributes supported. With this patch, the new API only supports thermal sensors. Support for other sensor types will be added with subsequent patches. Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Order include files alphabeticallyGuenter Roeck1-6/+4
Ordering include files alphabetically makes it easier to add new ones. Stop including linux/spinlock.h and linux/kdev_t.h since both are not needed. Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-03-03hwmon: Do not accept invalid name attributesGuenter Roeck1-0/+5
hwmon name attributes must not include '-', as specified in Documentation/hwmon/sysfs-interface. Also filter out spaces, tabs, wildcards, and newline characters. Tested-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2013-10-13hwmon: Provide managed hwmon registrationGuenter Roeck1-0/+63
Drivers using the new hwmon_device_register_with_groups API often have a remove function which consists solely of a call hwmon_device_unregister(). Provide support for devm_hwmon_device_register_with_groups and devm_hwmon_device_unregister to allow this repeated code to be removed and help eliminate error handling code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2013-10-13hwmon: Introduce hwmon_device_register_with_groupsGuenter Roeck1-16/+106
hwmon_device_register_with_groups() lets callers register a hwmon device together with all sysfs attributes in a single call. When using hwmon_device_register_with_groups(), hwmon attributes are attached to the hwmon device directly and no longer with its parent device. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-12-19hwmon: Fix PCI device reference leak in quirkJean Delvare1-12/+14
Thankfully this only affects systems with one specific south bridge and is most probably harmless unless the hwmon module is heavily cycled. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: (hwmon) Fix multi-line commentsGuenter Roeck1-10/+10
Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: fix checkpatch issuesFrans Meulenbroeks1-3/+2
fixed: WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable +EXPORT_SYMBOL_GPL(hwmon_device_register); WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable +EXPORT_SYMBOL_GPL(hwmon_device_unregister); Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
2011-10-31hwmon: convert idr to ida and use ida_simple interfaceJonathan Cameron1-24/+8
hwmon was using an idr with a NULL pointer, so convert to an ida which then allows use of Rusty's ida_simple_get. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Tejun Heo <tj@kernel.org> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: David Airlie <airlied@linux.ie> Cc: Thomas Hellstrom <thellstrom@vmware.com> Cc: Evgeniy Polyakov <zbr@ioremap.net> Cc: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-01-08hwmon: (core) Use pr_fmt and pr_<level>Joe Perches1-1/+3
Added #define pr_fmt KBUILD_MODNAME ": " fmt Converted printks to pr_<level> Coalesced any long formats Removed prefixes from formats Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
2009-06-15hwmon: PCI quirk for hwmon access on MSI MS-7031 boardJean Delvare1-0/+29
The MSI MS-7031 is based on an ATI IXP300 south bridge. On this south bridge, accessible I/O ports must be enabled explicitly. Unfortunately the BIOS forgets to enable access to the hardware monitoring chip I/O ports, so hardware monitoring fails. Add a quirk enabling access to the required ports (0x295-0x296). This is exactly what MSI's own hardware monitoring application is doing, so it has to be the right way. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-01-06hwmon: struct device - replace bus_id with dev_name(), dev_set_name()Kay Sievers1-1/+1
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-16device create: misc: convert device_create_drvdata to device_createGreg Kroah-Hartman1-2/+2
Now that device_create() has been audited, rename things back to the original call to be sane. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21device create: hwmon: convert device_create to device_create_drvdataGreg Kroah-Hartman1-1/+2
device_create() is race-prone, so use the race-free device_create_drvdata() instead as device_create() is going away. Cc: Mark M. Hoffman <mhoffman@lightlink.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-10-09hwmon: Convert from class_device to deviceTony Jones1-14/+13
Convert from class_device to device for hwmon_device_register/unregister Signed-off-by: Tony Jones <tonyj@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2007-02-14hwmon: Use subsys_initcallDavid Brownell1-1/+1
Subsystem infrastructure should normally register with "subsys_initcall", so that it's available to drivers that may need to initialize early. This patch updates "hwmon" to do so. It's common for embedded systems to have multifunction chips with hardware monitoring interfaces, and to have those chips be used during system bringup ... before a normal "module_init" would kick, or maybe just linked so they'd init before hwmon. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2006-03-23[PATCH] hwmon: add required idr lockingMark M. Hoffman1-6/+20
Add required locking around idr_ routines, retry the idr_pre_get/idr_get_new pair properly, and sprinkle in some likely/unlikely for good measure. (Lack of idr locking didn't hurt when all callers were I2C clients, as the i2c-core serialized for us anyway. Now that we have non I2C hwmon drivers, this is truly necessary.) Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-11-07[PATCH] fix remaining missing includesTim Schmielau1-0/+1
Fix more include file problems that surfaced since I submitted the previous fix-missing-includes.patch. This should now allow not to include sched.h from module.h, which is done by a followup patch. Signed-off-by: Tim Schmielau <tim@physik3.uni-rostock.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-10-28[PATCH] Driver Core: fix up all callers of class_device_create()Greg Kroah-Hartman1-1/+1
The previous patch adding the ability to nest struct class_device changed the paramaters to the call class_device_create(). This patch fixes up all in-kernel users of the function. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-05[PATCH] I2C hwmon: hwmon sysfs classMark M. Hoffman1-0/+98
This patch adds the sysfs class "hwmon" for use by hardware monitoring (sensors) chip drivers. It also fixes up the related Kconfig/Makefile bits. Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>