diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-12-11 13:31:14 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-12-11 13:31:14 +0100 |
commit | b33e3e0f99946260200a43e783488416eeed112a (patch) | |
tree | 9f48d7f56344d98b0e6abc7b34c0fda0e19cb5be /drivers | |
parent | 2d525e7ee0a8059881e725db7d3f1d8ebb5e63f5 (diff) | |
parent | 8bc9efc85b8af8a23a0c86b04e2265730a220ade (diff) | |
download | barebox-b33e3e0f99946260200a43e783488416eeed112a.tar.gz barebox-b33e3e0f99946260200a43e783488416eeed112a.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 77 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 48 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 2 | ||||
-rw-r--r-- | drivers/video/fb.c | 21 | ||||
-rw-r--r-- | drivers/watchdog/wd_core.c | 19 |
5 files changed, 129 insertions, 38 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index c39da558d1..dcb5ccd018 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -149,6 +149,31 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np, ap->alias, ap->stem, ap->id, np->full_name); } +static struct device_node *of_alias_resolve(struct device_node *root, struct property *pp) +{ + /* Skip those we do not want to proceed */ + if (!of_prop_cmp(pp->name, "name") || + !of_prop_cmp(pp->name, "phandle") || + !of_prop_cmp(pp->name, "linux,phandle")) + return NULL; + + return of_find_node_by_path_from(root, of_property_get_value(pp)); +} + +static int of_alias_id_parse(const char *start, int *len) +{ + const char *end = start + strlen(start); + + /* walk the alias backwards to extract the id and work out + * the 'stem' string */ + while (isdigit(*(end-1)) && end > start) + end--; + + *len = end - start; + + return simple_strtol(end, NULL, 10); +} + /** * of_alias_scan - Scan all properties of 'aliases' node * @@ -175,28 +200,15 @@ void of_alias_scan(void) list_for_each_entry(pp, &of_aliases->properties, list) { const char *start = pp->name; - const char *end = start + strlen(start); struct device_node *np; struct alias_prop *ap; int id, len; - /* Skip those we do not want to proceed */ - if (!of_prop_cmp(pp->name, "name") || - !of_prop_cmp(pp->name, "phandle") || - !of_prop_cmp(pp->name, "linux,phandle")) - continue; - - np = of_find_node_by_path(of_property_get_value(pp)); + np = of_alias_resolve(root_node, pp); if (!np) continue; - /* walk the alias backwards to extract the id and work out - * the 'stem' string */ - while (isdigit(*(end-1)) && end > start) - end--; - len = end - start; - - id = simple_strtol(end, NULL, 10); + id = of_alias_id_parse(start, &len); if (id < 0) continue; @@ -235,6 +247,41 @@ int of_alias_get_id(struct device_node *np, const char *stem) } EXPORT_SYMBOL_GPL(of_alias_get_id); +int of_alias_get_id_from(struct device_node *root, struct device_node *np, + const char *stem) +{ + struct device_node *aliasnp, *entrynp; + struct property *pp; + + if (!root) + return of_alias_get_id(np, stem); + + aliasnp = of_find_node_by_path_from(root, "/aliases"); + if (!aliasnp) + return -ENODEV; + + for_each_property_of_node(aliasnp, pp) { + const char *start = pp->name; + int id, len; + + entrynp = of_alias_resolve(root_node, pp); + if (entrynp != np) + continue; + + id = of_alias_id_parse(start, &len); + if (id < 0) + continue; + + if (strncasecmp(start, stem, len)) + continue; + + return id; + } + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(of_alias_get_id_from); + const char *of_alias_get(struct device_node *np) { struct alias_prop *app; diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index da3e0c7a8f..96924c4cb9 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -207,34 +207,43 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) ret = fastboot_generic_init(&f_fb->fastboot, opts->common.export_bbu); if (ret) - return ret; + goto err_wq_unregister; /* DYNAMIC interface numbers assignments */ id = usb_interface_id(c, f); - if (id < 0) - return id; + if (id < 0) { + ret = id; + goto fb_generic_free; + } + interface_desc.bInterfaceNumber = id; id = usb_string_id(c->cdev); - if (id < 0) - return id; + if (id < 0) { + ret = id; + goto fb_generic_free; + } fastboot_string_defs[0].id = id; interface_desc.iInterface = id; us = usb_gstrings_attach(cdev, fastboot_strings, 1); if (IS_ERR(us)) { ret = PTR_ERR(us); - return ret; + goto fb_generic_free; } f_fb->in_ep = usb_ep_autoconfig(gadget, &fs_ep_in); - if (!f_fb->in_ep) - return -ENODEV; + if (!f_fb->in_ep) { + ret = -ENODEV; + goto fb_generic_free; + } f_fb->in_ep->driver_data = c->cdev; f_fb->out_ep = usb_ep_autoconfig(gadget, &fs_ep_out); - if (!f_fb->out_ep) - return -ENODEV; + if (!f_fb->out_ep) { + ret = -ENODEV; + goto fb_generic_free; + } f_fb->out_ep->driver_data = c->cdev; hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress; @@ -244,7 +253,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) if (!f_fb->out_req) { puts("failed to alloc out req\n"); ret = -EINVAL; - return ret; + goto fb_generic_free; } f_fb->out_req->complete = rx_handler_command; @@ -254,15 +263,28 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) if (!f_fb->in_req) { puts("failed alloc req in\n"); ret = -EINVAL; - return ret; + goto err_free_out_req; } f_fb->in_req->complete = fastboot_complete; ret = usb_assign_descriptors(f, fb_fs_descs, fb_hs_descs, NULL); if (ret) - return ret; + goto err_free_in_req; return 0; + +err_free_in_req: + free(f_fb->in_req->buf); + usb_ep_free_request(f_fb->in_ep, f_fb->in_req); +err_free_out_req: + free(f_fb->out_req->buf); + usb_ep_free_request(f_fb->out_ep, f_fb->out_req); +fb_generic_free: + fastboot_generic_free(&f_fb->fastboot); +err_wq_unregister: + wq_unregister(&f_fb->wq); + + return ret; } static void fastboot_unbind(struct usb_configuration *c, struct usb_function *f) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 38999927c5..287849102d 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -240,7 +240,7 @@ static int ehci_td_buffer(struct qTD *td, dma_addr_t addr, size_t sz) } if (idx == buffer_count) { - pr_debug("out of buffer pointers (%u bytes left)\n", sz); + pr_debug("out of buffer pointers (%zu bytes left)\n", sz); return -ENOMEM; } diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 2d82bc01fa..113c1419a1 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -119,22 +119,25 @@ int fb_disable(struct fb_info *info) return 0; } +static int fb_enable_get(struct param_d *param, void *priv) +{ + struct fb_info *info = priv; + + info->p_enable = info->enabled; + return 0; +} + static int fb_enable_set(struct param_d *param, void *priv) { struct fb_info *info = priv; - int enable; if (!info->mode) return -EINVAL; - enable = info->p_enable; - - if (enable) - fb_enable(info); + if (info->p_enable) + return fb_enable(info); else - fb_disable(info); - - return 0; + return fb_disable(info); } static struct fb_videomode *fb_num_to_mode(struct fb_info *info, int num) @@ -314,7 +317,7 @@ int register_framebuffer(struct fb_info *info) if (ret) goto err_free; - dev_add_param_bool(dev, "enable", fb_enable_set, NULL, + dev_add_param_bool(dev, "enable", fb_enable_set, fb_enable_get, &info->p_enable, info); if (IS_ENABLED(CONFIG_DRIVER_VIDEO_EDID)) diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index 665338af61..643c53268f 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -261,6 +261,25 @@ struct watchdog *watchdog_get_default(void) } EXPORT_SYMBOL(watchdog_get_default); +int watchdog_get_alias_id_from(struct watchdog *wd, struct device_node *root) +{ + struct device_node *dstnp, *srcnp = wd->hwdev ? wd->hwdev->device_node : NULL; + char *name; + + if (!srcnp) + return -ENODEV; + + name = of_get_reproducible_name(srcnp); + dstnp = of_find_node_by_reproducible_name(root, name); + free(name); + + if (!dstnp) + return -ENODEV; + + return of_alias_get_id_from(root, wd->hwdev->device_node, "watchdog"); +} +EXPORT_SYMBOL(watchdog_get_alias_id_from); + struct watchdog *watchdog_get_by_name(const char *name) { struct watchdog *tmp; |