参照元

説明

引数

返り値

参考

実装

/**
 * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank)
 * @np:         device node of the GPIO chip
 * @mm_gc:      pointer to the of_mm_gpio_chip allocated structure
 *
 * To use this function you should allocate and fill mm_gc with:
 *
 * 1) In the gpio_chip structure:
 *    - all the callbacks
 *    - of_gpio_n_cells
 *    - of_xlate callback (optional)
 *
 * 3) In the of_mm_gpio_chip structure:
 *    - save_regs callback (optional)
 *
 * If succeeded, this function will map bank's memory and will
 * do all necessary work for you. Then you'll able to use .regs
 * to manage GPIOs from the callbacks.
 */
int of_mm_gpiochip_add(struct device_node *np,
                       struct of_mm_gpio_chip *mm_gc)
{
        int ret = -ENOMEM;
        struct gpio_chip *gc = &mm_gc->gc;
        gc->label = kstrdup(np->full_name, GFP_KERNEL);
        if (!gc->label)
                goto err0;
        mm_gc->regs = of_iomap(np, 0);
        if (!mm_gc->regs)
                goto err1;
        gc->base = -1;

        if (mm_gc->save_regs)
                mm_gc->save_regs(mm_gc);

        mm_gc->gc.of_node = np;

        ret = gpiochip_add(gc);
        if (ret)
                goto err2;
        return 0;
err2:
        iounmap(mm_gc->regs);
err1:
        kfree(gc->label);
err0:
        pr_err("%s: GPIO chip registration failed with status %d\n",
               np->full_name, ret);
        return ret;
}
EXPORT_SYMBOL(of_mm_gpiochip_add);

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-05-19 (木) 11:06:11