static int set_report_rate(struct rmi_function_info *function_info, bool nonstandard) { if (nonstandard) { return rmi_set_bits(function_info->sensor, function_info->funcDescriptor.controlBaseAddr, NONSTANDARD_REPORT_RATE); } else { return rmi_set_bits(function_info->sensor, function_info->funcDescriptor.controlBaseAddr, NONSTANDARD_REPORT_RATE); } }
static ssize_t rmi_fn_01_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct rmi_function_device *fn = dev_get_drvdata(dev); unsigned int reset; int retval; printk(KERN_INFO "%s: Reset written with %s", __func__, buf); if (sscanf(buf, "%u", &reset) != 1) return -EINVAL; if (reset < 0 || reset > 1) return -EINVAL; /* Per spec, 0 has no effect, so we skip it entirely. */ if (reset) { retval = rmi_set_bits(fn->sensor, fn->rfi->funcDescriptor.commandBaseAddr, F01_RESET); if (retval < 0) { printk(KERN_ERR "%s: failed to issue reset command, error = %d.", __func__, retval); return retval; } } return count; }
int FN_01_config(struct rmi_function_info *rmifninfo) { int retval = 0; struct f01_instance_data *instance_data = rmifninfo->fndata; printk(KERN_DEBUG "%s: RMI4 function $01 config\n", __func__); /* First thing to do is set the configuration bit. We'll check this at * the end to determine if the device has reset during the config process. */ retval = rmi_set_bits(rmifninfo->sensor, rmifninfo->funcDescriptor.controlBaseAddr, F01_CONFIGURED); if (retval) printk(KERN_WARNING "%s: failed to set configured bit, errno = %d.", __func__, retval); /* At config time, the device is presumably in its default state, so we * only need to write non-default configuration settings. */ if (instance_data->nonstandard_report_rate) { retval = set_report_rate(rmifninfo, true); if (!retval) printk(KERN_WARNING "%s: failed to configure report rate, errno = %d.", __func__, retval); } /* TODO: Check for reset! */ return retval; }