Harden Super X EC driver helpers
This commit is contained in:
parent
62154c4d00
commit
15b2c131b2
2 changed files with 29 additions and 13 deletions
2
Makefile
2
Makefile
|
|
@ -29,7 +29,7 @@ endif
|
|||
|
||||
DRIVER := oxp-sensors
|
||||
ifneq ("","$(wildcard .git/*)")
|
||||
DRIVER_VERSION := $(shell git describe --long --tags | sed s/\-/\./g )
|
||||
DRIVER_VERSION := $(shell git describe --long --tags --always --dirty | sed s/\-/\./g )
|
||||
else
|
||||
ifneq ("", "$(wildcard VERSION)")
|
||||
DRIVER_VERSION := $(shell cat VERSION)
|
||||
|
|
|
|||
|
|
@ -99,15 +99,18 @@ static int read_from_ec(u8 reg, int size, long *val)
|
|||
for (i = 0; i < size; i++) {
|
||||
ret = ec_read(reg + i, &buffer);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out_unlock;
|
||||
*val <<= i * 8;
|
||||
*val += buffer;
|
||||
}
|
||||
|
||||
if (!unlock_global_acpi_lock())
|
||||
return -EBUSY;
|
||||
ret = 0;
|
||||
|
||||
return 0;
|
||||
out_unlock:
|
||||
if (!unlock_global_acpi_lock() && !ret)
|
||||
ret = -EBUSY;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int write_to_ec(u8 reg, u8 value)
|
||||
|
|
@ -119,8 +122,8 @@ static int write_to_ec(u8 reg, u8 value)
|
|||
|
||||
ret = ec_write(reg, value);
|
||||
|
||||
if (!unlock_global_acpi_lock())
|
||||
return -EBUSY;
|
||||
if (!unlock_global_acpi_lock() && !ret)
|
||||
ret = -EBUSY;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -481,7 +484,22 @@ static struct attribute *oxp_ec_attrs[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
ATTRIBUTE_GROUPS(oxp_ec);
|
||||
static umode_t oxp_ec_attr_is_visible(struct kobject *kobj,
|
||||
struct attribute *attr, int n)
|
||||
{
|
||||
if (attr == &dev_attr_tt_toggle.attr)
|
||||
return attr->mode;
|
||||
|
||||
if (led_regs_valid)
|
||||
return attr->mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct attribute_group oxp_ec_group = {
|
||||
.attrs = oxp_ec_attrs,
|
||||
.is_visible = oxp_ec_attr_is_visible,
|
||||
};
|
||||
|
||||
static const struct hwmon_ops oxp_ec_hwmon_ops = {
|
||||
.is_visible = oxp_ec_hwmon_is_visible,
|
||||
|
|
@ -506,11 +524,9 @@ static int oxp_platform_probe(struct platform_device *pdev)
|
|||
|
||||
led_regs_valid = led_map_complete();
|
||||
|
||||
if (led_regs_valid) {
|
||||
ret = devm_device_add_group(dev, &oxp_ec_group);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
ret = devm_device_add_group(dev, &oxp_ec_group);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL,
|
||||
&oxp_ec_chip_info, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue