提交 4248bd7d 编写于 作者: A Andrzej Pietrasiewicz 提交者: Felipe Balbi

usb: gadget: f_printer: actually limit the number of instances

There is a predefined maximum number of printer instances, currently 4.
A chrdev region is allocated accordingly, but with configfs the user
can create as many printer function directories as they like. To make the
number of printer  instances consistent with the number of allocated
minors, the limit is enforced at directory creation time.
Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 774cf72f
......@@ -1248,7 +1248,15 @@ static struct config_item_type printer_func_type = {
static inline int gprinter_get_minor(void)
{
return ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL);
int ret;
ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL);
if (ret >= PRINTER_MINORS) {
ida_simple_remove(&printer_ida, ret);
ret = -ENODEV;
}
return ret;
}
static inline void gprinter_put_minor(int minor)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册