参照元

説明

引数

返り値

参考

実装

/**
 * gpiochip_add_pin_range() - add a range for GPIO <-> pin mapping
 * @chip: the gpiochip to add the range for
 * @pinctrl_name: the dev_name() of the pin controller to map to
 * @gpio_offset: the start offset in the current gpio_chip number space
 * @pin_offset: the start offset in the pin controller number space
 * @npins: the number of pins from the offset of each pin space (GPIO and
 *      pin controller) to accumulate in this range
 */
int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
                           unsigned int gpio_offset, unsigned int pin_offset,
                           unsigned int npins)
{
        struct gpio_pin_range *pin_range;
        int ret;
        pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL);
        if (!pin_range) {
                chip_err(chip, "failed to allocate pin ranges\n");
                return -ENOMEM;
        }
        /* Use local offset as range ID */
        pin_range->range.id = gpio_offset;
        pin_range->range.gc = chip;
        pin_range->range.name = chip->label;
        pin_range->range.base = chip->base + gpio_offset;
        pin_range->range.pin_base = pin_offset;
        pin_range->range.npins = npins;
        pin_range->pctldev = pinctrl_find_and_add_gpio_range(pinctl_name,
                        &pin_range->range);
        if (IS_ERR(pin_range->pctldev)) {
                ret = PTR_ERR(pin_range->pctldev);
                chip_err(chip, "could not create pin range\n");
                kfree(pin_range);
                return ret;
        }
        chip_dbg(chip, "created GPIO range %d->%d ==> %s PIN %d->%d\n",
                 gpio_offset, gpio_offset + npins - 1,
                 pinctl_name,
                 pin_offset, pin_offset + npins - 1);
        list_add_tail(&pin_range->node, &chip->pin_ranges);
        return 0;
}
EXPORT_SYMBOL_GPL(gpiochip_add_pin_range);

コメント


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS