mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
power: pmic: Use trailing_strtol() instead of a local function
Use the common function to obtain the number from the end of the string, instead of a local function. Also tweak the position of a debug() statement. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Przemyslaw Marczak <p.marczak@samsung.com> Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
This commit is contained in:
parent
f26c8a8e77
commit
e15bb3e63c
1 changed files with 5 additions and 18 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <fdtdec.h>
|
#include <fdtdec.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
#include <vsprintf.h>
|
||||||
#include <dm/lists.h>
|
#include <dm/lists.h>
|
||||||
#include <dm/device-internal.h>
|
#include <dm/device-internal.h>
|
||||||
#include <dm/uclass-internal.h>
|
#include <dm/uclass-internal.h>
|
||||||
|
@ -17,16 +18,6 @@
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
static ulong str_get_num(const char *ptr, const char *maxptr)
|
|
||||||
{
|
|
||||||
if (!ptr || !maxptr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
while (!isdigit(*ptr) && ptr++ < maxptr);
|
|
||||||
|
|
||||||
return simple_strtoul(ptr, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pmic_bind_children(struct udevice *pmic, int offset,
|
int pmic_bind_children(struct udevice *pmic, int offset,
|
||||||
const struct pmic_child_info *child_info)
|
const struct pmic_child_info *child_info)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +26,6 @@ int pmic_bind_children(struct udevice *pmic, int offset,
|
||||||
struct driver *drv;
|
struct driver *drv;
|
||||||
struct udevice *child;
|
struct udevice *child;
|
||||||
const char *node_name;
|
const char *node_name;
|
||||||
int node_name_len;
|
|
||||||
int bind_count = 0;
|
int bind_count = 0;
|
||||||
int node;
|
int node;
|
||||||
int prefix_len;
|
int prefix_len;
|
||||||
|
@ -47,19 +37,19 @@ int pmic_bind_children(struct udevice *pmic, int offset,
|
||||||
for (node = fdt_first_subnode(blob, offset);
|
for (node = fdt_first_subnode(blob, offset);
|
||||||
node > 0;
|
node > 0;
|
||||||
node = fdt_next_subnode(blob, node)) {
|
node = fdt_next_subnode(blob, node)) {
|
||||||
node_name = fdt_get_name(blob, node, &node_name_len);
|
node_name = fdt_get_name(blob, node, NULL);
|
||||||
|
|
||||||
debug("* Found child node: '%s' at offset:%d\n", node_name,
|
debug("* Found child node: '%s' at offset:%d\n", node_name,
|
||||||
node);
|
node);
|
||||||
|
|
||||||
child = NULL;
|
child = NULL;
|
||||||
for (info = child_info; info->prefix && info->driver; info++) {
|
for (info = child_info; info->prefix && info->driver; info++) {
|
||||||
|
debug(" - compatible prefix: '%s'\n", info->prefix);
|
||||||
|
|
||||||
prefix_len = strlen(info->prefix);
|
prefix_len = strlen(info->prefix);
|
||||||
if (strncmp(info->prefix, node_name, prefix_len))
|
if (strncmp(info->prefix, node_name, prefix_len))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
debug(" - compatible prefix: '%s'\n", info->prefix);
|
|
||||||
|
|
||||||
drv = lists_driver_lookup_name(info->driver);
|
drv = lists_driver_lookup_name(info->driver);
|
||||||
if (!drv) {
|
if (!drv) {
|
||||||
debug(" - driver: '%s' not found!\n",
|
debug(" - driver: '%s' not found!\n",
|
||||||
|
@ -78,10 +68,7 @@ int pmic_bind_children(struct udevice *pmic, int offset,
|
||||||
|
|
||||||
debug(" - bound child device: '%s'\n", child->name);
|
debug(" - bound child device: '%s'\n", child->name);
|
||||||
|
|
||||||
child->driver_data = str_get_num(node_name +
|
child->driver_data = trailing_strtol(node_name);
|
||||||
prefix_len,
|
|
||||||
node_name +
|
|
||||||
node_name_len);
|
|
||||||
|
|
||||||
debug(" - set 'child->driver_data': %lu\n",
|
debug(" - set 'child->driver_data': %lu\n",
|
||||||
child->driver_data);
|
child->driver_data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue