Skip to content

Commit d50497c

Browse files
Prashant MalaniEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_proto: Fix check_features ret val
The kerneldoc for cros_ec_check_features() states that it returns 1 or 0 depedending on whether a feature is supported or not, but it instead returns a negative error number in one case, and a non-1 bitmask in other cases. Since all call-sites only check for a 1 or 0 return value, update the function to return boolean values. Signed-off-by: Prashant Malani <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5135b21 commit d50497c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,18 +808,20 @@ EXPORT_SYMBOL(cros_ec_get_host_event);
808808
*
809809
* Call this function to test whether the ChromeOS EC supports a feature.
810810
*
811-
* Return: 1 if supported, 0 if not
811+
* Return: true if supported, false if not (or if an error was encountered).
812812
*/
813-
int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
813+
bool cros_ec_check_features(struct cros_ec_dev *ec, int feature)
814814
{
815815
struct cros_ec_command *msg;
816816
int ret;
817817

818818
if (ec->features[0] == -1U && ec->features[1] == -1U) {
819819
/* features bitmap not read yet */
820820
msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
821-
if (!msg)
822-
return -ENOMEM;
821+
if (!msg) {
822+
dev_err(ec->dev, "failed to allocate memory to get EC features\n");
823+
return false;
824+
}
823825

824826
msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
825827
msg->insize = sizeof(ec->features);
@@ -839,7 +841,7 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
839841
kfree(msg);
840842
}
841843

842-
return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
844+
return !!(ec->features[feature / 32] & EC_FEATURE_MASK_0(feature));
843845
}
844846
EXPORT_SYMBOL_GPL(cros_ec_check_features);
845847

include/linux/platform_data/cros_ec_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev,
227227

228228
u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
229229

230-
int cros_ec_check_features(struct cros_ec_dev *ec, int feature);
230+
bool cros_ec_check_features(struct cros_ec_dev *ec, int feature);
231231

232232
int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
233233

0 commit comments

Comments
 (0)