Re: gpiolib: add names file in gpio chip sysfs.
From: David Brownell
Date: Tue Aug 04 2009 - 20:29:45 EST
On Monday 03 August 2009, ben@xxxxxxxxx wrote:
> +static ssize_t chip_names_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + const struct gpio_chip*chip = dev_get_drvdata(dev);
> + char **names = chip->names;
> + int ptr = 0;
> + int name;
> +
> + if (!names)
> + return -EINVAL;
> +
> + for (name = 0; name < chip->ngpio && ptr < PAGE_SIZE; name++)
> + ptr += snprintf(buf + ptr, PAGE_SIZE - ptr,
> + "%s\n", names[name] ? names[name] : "");
Surely the actual GPIO number should be there too?
This whole chip->names thing still seems odd to me,
since it's creating a redundant namespace.
> +
> + return ptr;
> +}
> +DEVICE_ATTR(names, 0444, chip_names_show, NULL);
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/