/* This function writes buttons that can be disabled to @buf. If @only_disabled is true, then @buf contains only those buttons that are currently disabled. Returns 0 on success or negative errno on failure.  */
static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, char *buf, unsigned int type, bool only_disabled)
/* This function writes buttons that can be disabled to @buf. If @only_disabled is true, then @buf contains only those buttons that are currently disabled. Returns 0 on success or negative errno on failure.  */
static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, char *buf, unsigned int type, bool only_disabled)
{
	int n_events = get_n_events_by_type(type);
	unsigned long *bits;
	ssize_t ret;
	int i;
	bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL);
	if (!bits)
		return -ENOMEM;
	for (i = 0; i < ddata->n_buttons; i++) {
		struct gpio_button_data *bdata = &ddata->data[i];
		if (bdata->button->type != type)
			continue;
		if (only_disabled && !bdata->disabled)
			continue;
		__set_bit(bdata->button->code, bits);
	}
	ret = bitmap_scnlistprintf(buf, PAGE_SIZE - 2, bits, n_events);
	buf[ret++] = '\n';
	buf[ret] = '\0';
	kfree(bits);
	return ret;
}