From patchwork Tue Jun 14 13:21:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1643300 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-weidmueller-onmicrosoft-com header.b=XibsgL+K; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LMpyB05q5z9sGJ for ; Tue, 14 Jun 2022 23:22:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 86E4484300; Tue, 14 Jun 2022 15:22:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.b="XibsgL+K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A0B2B84300; Tue, 14 Jun 2022 15:22:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0615.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::615]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DEEFC83F63 for ; Tue, 14 Jun 2022 15:22:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan.herbrechtsmeier-oss@weidmueller.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxTLHTOznggvVwyXz4UY30jQ1cA5ERPQOrkeNwJjm4oDiIy4Oi7UVL57LO4CC073oT1opZL162/zL2JfcnFgm0/UsV9eAGEXhIrUUQWssSyUjR77k9eI5gftD/HFWPAxWqCJNkXxVGIfbDd0FWJqVPbX5CzhRoV9zfarvSimEzpJy0VFfZYdVOs7xnau5wF/lcZYVQpSW7oAqZxQhb7+eGMjuswwlyu9qRW4OZyoG17FXpjn6TDPiDCHxXm0L9d5Q9ODApIn76dezLJVhGpE7uNXGx2q9Q56yhJnyqHoeGiyDDkj6veDuQ045kSiL7KCfAF1yEFxsaZK+Seh0vvjbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XzEA2KJuewfW/GSw4vSZp48Ej6FrOnPihCVxi6WNOro=; b=ZoInJEB3NUBIfxRoHot5ehMu74DAkzqeVlGfopSHoUbcd8ub4zloBpWFPze3xDwHyMXtvBOd5w+Y2IYlV+u4rvS/+kew6utg/tOsWar9jSI63+afOek41Zu9whldnTjwcXxkItSaiO1319vimAkPqQCrW1AHb/gvO/rMfOPK6/RtWSwVqzfawnLSNmrMUK7nF91KMcztVoPsGAjTSDcOIypMZ7VBqOkOlrnBe8CCKThs98PyTY0N/IkTCOsZcaLQ19LkBn4xaLREGqL6ie6VSAw1Y/au8n2zc7s00dOdpNi0n1Wi63FmqQ7gQMBWJ05n0hnqpzdVghhG+SoHbcsw4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XzEA2KJuewfW/GSw4vSZp48Ej6FrOnPihCVxi6WNOro=; b=XibsgL+KcQWNfSCpGHserafe/JYgaEVhRVLCqBbRJrjDy2H1/wqXc9Pq+2wYIMasZKaPXu2voQwjl2GimOnmG732748/3vEOuVG1ea2gf4TZn0oyxBSl5j0AKkT7587joKsUK+c0blFuPoYlNQyBpebX3xx4qdrK+LuxhFZp28o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by DBAPR08MB5846.eurprd08.prod.outlook.com (2603:10a6:10:1b0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Tue, 14 Jun 2022 13:22:11 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5332.020; Tue, 14 Jun 2022 13:22:11 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de, Marek Vasut Cc: Stefan Herbrechtsmeier , Etienne Carriere , Heinrich Schuchardt , =?utf-8?q?Marek_Beh=C3=BAn?= , Michael Walle , Nandor Han , Patrick Delaunay , Rasmus Villemoes , Simon Glass Subject: [PATCH 1/2] dm: core: Add functions to read 8/16-bit integers Date: Tue, 14 Jun 2022 15:21:30 +0200 Message-Id: <20220614132132.22329-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: AS9PR07CA0046.eurprd07.prod.outlook.com (2603:10a6:20b:46b::9) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df55f51d-7d5e-41cb-6263-08da4e08e3bd X-MS-TrafficTypeDiagnostic: DBAPR08MB5846:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: naaFXEP6bSmtm3qJuI9loGjvYjA1c+pcYcr0J50k6BOFuoPSSnMKKJSeV4K1HNPU8NfcQfEnIgGXnG3mrhD23HB4A0VAe1sXqHU4Z/lDNKieGd9K2HmfDmLoCNiqckHwkCJv7PcEuX2IIxSYJm+SgR6sUHNpsOfSaAELeeB0hdREOWuIrOofLr6EPjc/od87q/p6Eq1W6J7B1duYLo8hcXM+eJMZqiWGifKoBrRkNF32qQeSrxOI7ieXumRksChiAwP4Dy8X2PqSsKrNtqEtpzkmNOyCn4DGEceAMidvDNbnDEonzk0wsk7HRqhrWsqS6H8jF84H2IgAMmOm1rcwyvvH8PkXC4ZjSFgoFbJjSoCnT4aEgo3iAWhRl0QPrLQ73LqlxxrCg93ir3FP1FHeNVUvKcB4J1bjTB2SB01nvfhMvANZlvoVQhJR9JRlkFB9jxpXC5994QY4SAWGPk9TuQ4MolLi+w6jYUcX9TGDvBlmPkJlu6nEvsLhGl+jg/5TqRkuWO01Ag5tdT1YXOldIDajRlYjMudQWSq2ryzvCUZc0e79Q7m/J6M32K1ZbbN1fezoh5VkpuluCE/DnCwJLM/zG+31OhUkBYEJs2j67tAi7cd/O1NJpY0azOlVdVFKNo8snu1BXqX4uSZk20OE9hiYMFFSErOUA9o51DmkF9YbCh9tzeop0sN3sIXFjp3wGTkUvbqYHoiAU0LSQyNZVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB6969.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(36756003)(38350700002)(38100700002)(86362001)(83380400001)(26005)(6512007)(2616005)(1076003)(6506007)(52116002)(316002)(2906002)(7416002)(6666004)(6486002)(54906003)(30864003)(508600001)(6916009)(8936002)(186003)(66556008)(66476007)(8676002)(4326008)(5660300002)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: riohJ1vateaECLc9aU5kZ6laAjtDDqbqQ9mKmZrbA4C819O/FTIY0hAZXFyB/0oq3Ie2iNPXJFaTLVxwpX1wCqDFTM+ppaYiHPCLg/K0lHSPwzvhBsVVjyBU1gGji5x+1M9cNFpg9oojHFVE+YOhkPOiWmpxTkSMKf1cd8Z8OGttERcbecXrxHQ84SQU42i7gb/CDqrdlhHakYIi+CMGSgDQFS0lFWVjknhRDzb+zSCJK541ISKmJ/38rXM3C6X+rvyF3O+2lRhHUKEQblPV58XjkfbPt5FBH1mcKX43P1IWS28fosIfwraaXkMu/R9y8G3Yw9QuqsSI5bjivrf4zPM2yezjzQCRaL0ThkY5Pb3NnKHKAeuT637pFuqhuuGv1JPHLsvKkCO0115ZwJNxHoYsi0hdKaPb2U5ZNziJ5U7ic1n9g4c+gingugRkLeebW/exnVnNCxTWP7qy4U9ItTzNXz4ILieVXfsRQfj593jPr82hTjgh5xlewUlt/0aufn57ktqtqwSHqoSZbEP73TnNgBkrFZuFQ46XRraYw0zwuctCBVcRWF9C76SHy2pQdSGGjDrK35aFLSfHg0kx3S1eln99jDmoKb4gqV4y+nAD3avHLnqblbK8mKz83g7/Z+HS3H9AYHfl1OkoDs9jyZjZnl+xJVGxiXlc4Yv+6aXfXNgxQEicEtxIeWUXEpIcqd+5LlpdsnlvN69GdmEg2+UucIsUUufe5E6apFyy0V/yvA1rpFVXr8WLd9UOFn776tEyd9cIUrcvPfjU5VRrVEysrU1mFjZgI2ngJ11Oi2XqRv+8XgrE7GTC0cJpUIYEfCSA3s+0sTr4d4QJ9auIiofoo77GWU8LOhv+wvFzRL5Gk9+LdluG18perb0oGd+7g9r8ValdlQbB6QwSJaZJHDJ/rjD5YKprLNLFxKz99cAL50vU+KjveaBZ4aroabKMejj78U3Cj1WubhYmfubfFX4DwUot7ymBJD7Zfu1/fyjlbjqAPzegApelpyUeR2BLdvDnXr29v271bW+/Y5OLUV21732lYbbrQB3+GxqJ0hkufOoszZfPPJIraIssm+FzyzcLoDJqWHQjV2mnRXfyhAvLlXBTEA8KB2ldHvalDwolXKW9hljL94msYV6DFAyS8rMzptIGm8DRiX6PswXYFW2DsOjnxjpWBI4xqa355Gg0mUdu3TPf9A+RN0v1IcjM9KRW2r7cYeO3k1q4Wi1Skn6lNJ+JbeofWp9zTz3yyBv3cFzF6Y0Sv3fdgd5pIXIrNKpHoxHiMjcoEMVLQ6r4Uyu50cfkirnAebudMm9nawrZwuaryWkdt1B/oNGtqaqj1gcyARnignwZZ3HxRi1QemeW5EJ1SzY8S8jd44DrLRGkGYlCGXFVxBFUFYcSBuzpAC8CFYYv3LI5+zCncErHVpB5VlsTIE0dgTcZBGQdAjjdFnIQrMlkWzdEInbtSgswNkv7mrLKrrNnE7PbHqDZwb6VqPgP1P+QIUVWVImtCQGFTUNd84lhD8qsK66eVslijL+hvMU4H4jhECO6CYlZ6TmuA7uZnJKTQVhvoVfyOJonT22IQNM/8mID8xWxIctCve8UD8xHWyRILImdDDDcCLvF4MRIYGuVVE4Yh4Z4OjKs7ob0Bd0209mLNL1qWze7ehRvDnl5gx+MmNRckRO+fo8lMKkc72tvnhwop8x6ZyMMfbTQ7e/oNNm98CIjvOvKGGCf3hoEjZAG9HEed1mrRJGAPvB+e0/lWO4IztOC328= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: df55f51d-7d5e-41cb-6263-08da4e08e3bd X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2022 13:22:11.5765 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u+I+AJVXYU9i5oYThhaVXhipLrFenkNJ2CAp9Fqvfk761txGc1gu0oeLmbRPVw702jkffNY+9ZphzIQo9DTV5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5846 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Stefan Herbrechtsmeier Add functions to read 8/16-bit integers like the existing functions for 32/64-bit to simplify read of 8/16-bit integers from device tree properties. Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Marek Vasut Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 2 ++ drivers/core/of_access.c | 38 +++++++++++++++++++++++ drivers/core/ofnode.c | 62 +++++++++++++++++++++++++++++++++++++ drivers/core/read.c | 21 +++++++++++++ include/dm/of_access.h | 32 +++++++++++++++++++ include/dm/ofnode.h | 40 ++++++++++++++++++++++++ include/dm/read.h | 65 +++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 19 ++++++++++++ 8 files changed, 279 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 8f93775ff4..035f5edfa2 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -226,6 +226,8 @@ test5-gpios = <&gpio_a 19>; bool-value; + int8-value = /bits/ 8 <0x12>; + int16-value = /bits/ 16 <0x1234>; int-value = <1234>; uint-value = <(-1234)>; int64-value = /bits/ 64 <0x1111222233334444>; diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index c20b19cb50..0efcde3ba5 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -482,6 +482,44 @@ static void *of_find_property_value_of_size(const struct device_node *np, return prop->value; } +int of_read_u8(const struct device_node *np, const char *propname, u8 *outp) +{ + const u8 *val; + + debug("%s: %s: ", __func__, propname); + if (!np) + return -EINVAL; + val = of_find_property_value_of_size(np, propname, sizeof(*outp)); + if (IS_ERR(val)) { + debug("(not found)\n"); + return PTR_ERR(val); + } + + *outp = *val; + debug("%#x (%d)\n", *outp, *outp); + + return 0; +} + +int of_read_u16(const struct device_node *np, const char *propname, u16 *outp) +{ + const __be16 *val; + + debug("%s: %s: ", __func__, propname); + if (!np) + return -EINVAL; + val = of_find_property_value_of_size(np, propname, sizeof(*outp)); + if (IS_ERR(val)) { + debug("(not found)\n"); + return PTR_ERR(val); + } + + *outp = be16_to_cpup(val); + debug("%#x (%d)\n", *outp, *outp); + + return 0; +} + int of_read_u32(const struct device_node *np, const char *propname, u32 *outp) { return of_read_u32_index(np, propname, 0, outp); diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index a59832ebbf..ce411b7c35 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -31,6 +31,68 @@ bool ofnode_name_eq(ofnode node, const char *name) return (strlen(name) == len) && !strncmp(node_name, name, len); } +int ofnode_read_u8(ofnode node, const char *propname, u8 *outp) +{ + const u8 *cell; + int len; + + assert(ofnode_valid(node)); + debug("%s: %s: ", __func__, propname); + + if (ofnode_is_np(node)) + return of_read_u8(ofnode_to_np(node), propname, outp); + + cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname, + &len); + if (!cell || len < sizeof(*cell)) { + debug("(not found)\n"); + return -EINVAL; + } + *outp = *cell; + debug("%#x (%d)\n", *outp, *outp); + + return 0; +} + +u8 ofnode_read_u8_default(ofnode node, const char *propname, u8 def) +{ + assert(ofnode_valid(node)); + ofnode_read_u8(node, propname, &def); + + return def; +} + +int ofnode_read_u16(ofnode node, const char *propname, u16 *outp) +{ + const fdt16_t *cell; + int len; + + assert(ofnode_valid(node)); + debug("%s: %s: ", __func__, propname); + + if (ofnode_is_np(node)) + return of_read_u16(ofnode_to_np(node), propname, outp); + + cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname, + &len); + if (!cell || len < sizeof(*cell)) { + debug("(not found)\n"); + return -EINVAL; + } + *outp = be16_to_cpup(cell); + debug("%#x (%d)\n", *outp, *outp); + + return 0; +} + +u16 ofnode_read_u16_default(ofnode node, const char *propname, u16 def) +{ + assert(ofnode_valid(node)); + ofnode_read_u16(node, propname, &def); + + return def; +} + int ofnode_read_u32(ofnode node, const char *propname, u32 *outp) { return ofnode_read_u32_index(node, propname, 0, outp); diff --git a/drivers/core/read.c b/drivers/core/read.c index c73508d276..07ab8ab41c 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -13,6 +13,27 @@ #include #include +int dev_read_u8(const struct udevice *dev, const char *propname, u8 *outp) +{ + return ofnode_read_u8(dev_ofnode(dev), propname, outp); +} + +u8 dev_read_u8_default(const struct udevice *dev, const char *propname, u8 def) +{ + return ofnode_read_u8_default(dev_ofnode(dev), propname, def); +} + +int dev_read_u16(const struct udevice *dev, const char *propname, u16 *outp) +{ + return ofnode_read_u16(dev_ofnode(dev), propname, outp); +} + +u16 dev_read_u16_default(const struct udevice *dev, const char *propname, + u16 def) +{ + return ofnode_read_u16_default(dev_ofnode(dev), propname, def); +} + int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp) { return ofnode_read_u32(dev_ofnode(dev), propname, outp); diff --git a/include/dm/of_access.h b/include/dm/of_access.h index ec6e6e2c7c..ec9603bc58 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -258,6 +258,38 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from, */ struct device_node *of_find_node_by_phandle(phandle handle); +/** + * of_read_u8() - Find and read a 8-bit integer from a property + * + * Search for a property in a device node and read a 8-bit value from + * it. + * + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @outp: pointer to return value, modified only if return value is 0. + * + * Return: 0 on success, -EINVAL if the property does not exist, + * -ENODATA if property does not have a value, and -EOVERFLOW if the + * property data isn't large enough. + */ +int of_read_u8(const struct device_node *np, const char *propname, u8 *outp); + +/** + * of_read_u16() - Find and read a 16-bit integer from a property + * + * Search for a property in a device node and read a 16-bit value from + * it. + * + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @outp: pointer to return value, modified only if return value is 0. + * + * Return: 0 on success, -EINVAL if the property does not exist, + * -ENODATA if property does not have a value, and -EOVERFLOW if the + * property data isn't large enough. + */ +int of_read_u16(const struct device_node *np, const char *propname, u16 *outp); + /** * of_read_u32() - Find and read a 32-bit integer from a property * diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 2c4d72d77f..5a41affba1 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -245,6 +245,46 @@ static inline ofnode ofnode_root(void) */ bool ofnode_name_eq(ofnode node, const char *name); +/** + * ofnode_read_u8() - Read a 8-bit integer from a property + * + * @node: valid node reference to read property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * Return: 0 if OK, -ve on error + */ +int ofnode_read_u8(ofnode node, const char *propname, u8 *outp); + +/** + * ofnode_read_u8_default() - Read a 8-bit integer from a property + * + * @node: valid node reference to read property from + * @propname: name of the property to read from + * @def: default value to return if the property has no value + * Return: property value, or @def if not found + */ +u8 ofnode_read_u8_default(ofnode node, const char *propname, u8 def); + +/** + * ofnode_read_u16() - Read a 16-bit integer from a property + * + * @node: valid node reference to read property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * Return: 0 if OK, -ve on error + */ +int ofnode_read_u16(ofnode node, const char *propname, u16 *outp); + +/** + * ofnode_read_u16_default() - Read a 16-bit integer from a property + * + * @node: valid node reference to read property from + * @propname: name of the property to read from + * @def: default value to return if the property has no value + * Return: property value, or @def if not found + */ +u16 ofnode_read_u16_default(ofnode node, const char *propname, u16 def); + /** * ofnode_read_u32() - Read a 32-bit integer from a property * diff --git a/include/dm/read.h b/include/dm/read.h index 1b54b69acf..122b9cd15b 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -31,6 +31,47 @@ static inline const struct device_node *dev_np(const struct udevice *dev) #endif #if !defined(CONFIG_DM_DEV_READ_INLINE) || CONFIG_IS_ENABLED(OF_PLATDATA) +/** + * dev_read_u8() - read a 8-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * Return: 0 if OK, -ve on error + */ +int dev_read_u8(const struct udevice *dev, const char *propname, u8 *outp); + +/** + * dev_read_u8_default() - read a 8-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @def: default value to return if the property has no value + * Return: property value, or @def if not found + */ +u8 dev_read_u8_default(const struct udevice *dev, const char *propname, u8 def); + +/** + * dev_read_u16() - read a 16-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * Return: 0 if OK, -ve on error + */ +int dev_read_u16(const struct udevice *dev, const char *propname, u16 *outp); + +/** + * dev_read_u16_default() - read a 16-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @def: default value to return if the property has no value + * Return: property value, or @def if not found + */ +u16 dev_read_u16_default(const struct udevice *dev, const char *propname, + u16 def); + /** * dev_read_u32() - read a 32-bit integer from a device's DT property * @@ -772,6 +813,30 @@ phy_interface_t dev_read_phy_mode(const struct udevice *dev); #else /* CONFIG_DM_DEV_READ_INLINE is enabled */ #include +static inline int dev_read_u8(const struct udevice *dev, + const char *propname, u8 *outp) +{ + return ofnode_read_u8(dev_ofnode(dev), propname, outp); +} + +static inline int dev_read_u8_default(const struct udevice *dev, + const char *propname, u8 def) +{ + return ofnode_read_u8_default(dev_ofnode(dev), propname, def); +} + +static inline int dev_read_u16(const struct udevice *dev, + const char *propname, u16 *outp) +{ + return ofnode_read_u16(dev_ofnode(dev), propname, outp); +} + +static inline int dev_read_u16_default(const struct udevice *dev, + const char *propname, u16 def) +{ + return ofnode_read_u16_default(dev_ofnode(dev), propname, def); +} + static inline int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp) { diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index e1de066226..41385293df 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -868,6 +868,8 @@ DM_TEST(dm_test_first_child, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); static int dm_test_read_int(struct unit_test_state *uts) { struct udevice *dev; + u8 val8; + u16 val16; u32 val32; s32 sval; uint val; @@ -875,6 +877,23 @@ static int dm_test_read_int(struct unit_test_state *uts) ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev)); ut_asserteq_str("a-test", dev->name); + + ut_assertok(dev_read_u8(dev, "int8-value", &val8)); + ut_asserteq(0x12, val8); + + ut_asserteq(-EINVAL, dev_read_u8(dev, "missing", &val8)); + ut_asserteq(6, dev_read_u8_default(dev, "missing", 6)); + + ut_asserteq(0x12, dev_read_u8_default(dev, "int8-value", 6)); + + ut_assertok(dev_read_u16(dev, "int16-value", &val16)); + ut_asserteq(0x1234, val16); + + ut_asserteq(-EINVAL, dev_read_u16(dev, "missing", &val16)); + ut_asserteq(6, dev_read_u16_default(dev, "missing", 6)); + + ut_asserteq(0x1234, dev_read_u16_default(dev, "int16-value", 6)); + ut_assertok(dev_read_u32(dev, "int-value", &val32)); ut_asserteq(1234, val32); From patchwork Tue Jun 14 13:21:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1643301 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-weidmueller-onmicrosoft-com header.b=ERGBSY4k; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LMpyK1MVGz9sGJ for ; Tue, 14 Jun 2022 23:22:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E3B984328; Tue, 14 Jun 2022 15:22:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.b="ERGBSY4k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC00484328; Tue, 14 Jun 2022 15:22:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0615.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::615]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3536584314 for ; Tue, 14 Jun 2022 15:22:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan.herbrechtsmeier-oss@weidmueller.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXupuAhQd7y5xolC8ATypAH1HUX5pIQI50jsKI7FriYP5BnuY3q18qEKXGyWChO70fyydJMY4rdzaoruC0UaOyDphp/umwS2IuDYMaPeLezrcMUys3+HrCdUeCvKIxPrX3c6fZ4N8hCv4SgpqbNo6DLYAjZ3ZJKzffZ/4vxcP4Lcuq76zU4ZmR6IEeKy+8GufzfqUYsqFnbx9OErjcaleuGhoH391MZ8JBIbPaUYJRtdqkGuh90vuqxuUiv+d8UBwvvw9LXVWnBpFPK2iddH3MuFEx1jlNMGVQ0f9SfRttzYMLKWpZmaWr+8WsErfRATVseL0TLEpfSYXCjVTx6pXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3Yv9lNyAviI/DQDI2yMRjLGzlA6AaV0KREosval4s+s=; b=hGYYq85R7P7D1dbKnSEpa3LJ13HS14MPPKCDd3wYOEZsDMm3PDO8Cxzf1cdH7t2HIedDQZ553k7LGYBxp+AvNHWv3PHP85njz2Yk5v22nwYEQxvVa2yxUzN03g20WGfhiyAPSwdKpZN2mpVwVTiJkqxkgvN44dm/09n7E9XZHvv2aHrEwBA1X+HrH6qLkLhXnVYyxReKhYB/BddLHBla/YLBsStc32uTtkhbr5YdWpmHW39q6eBp1aLQHdNh8qNjirb93H5lBaWKGCRulzCjQdXzbtSCWppo6/kx9m68mnEIQONxqu4LUN3V5oYEIEHe+tqriGs4aTjxn3KAV4Jaww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3Yv9lNyAviI/DQDI2yMRjLGzlA6AaV0KREosval4s+s=; b=ERGBSY4krWvH7ajX7xFmaMyXWyiezx8efGPtNx4xcV/drnv73z+LHLE3xOnzBt+FHyAHfHP4MqM52b2MHAzowo78q2RFqraBfvOxczYl2bwkIwE1lIGbqNQtOKjABWZ6gJOP8o6qDo/Zby/duxOcnM7W1l3AWbXjIfQbTR+lWkA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by DBAPR08MB5846.eurprd08.prod.outlook.com (2603:10a6:10:1b0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Tue, 14 Jun 2022 13:22:12 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5332.020; Tue, 14 Jun 2022 13:22:12 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de, Marek Vasut Cc: Stefan Herbrechtsmeier Subject: [PATCH 2/2] misc: usb251xb: Support 8/16 bit device tree values Date: Tue, 14 Jun 2022 15:21:31 +0200 Message-Id: <20220614132132.22329-2-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614132132.22329-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220614132132.22329-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS9PR07CA0046.eurprd07.prod.outlook.com (2603:10a6:20b:46b::9) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ae89098-1e65-4cfd-ce60-08da4e08e42f X-MS-TrafficTypeDiagnostic: DBAPR08MB5846:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ucSa3h3AVuwZILbwOnq5lD0lFJ/+Gkn6yIGJnqtqonIj8ys3G93DjJQGPjdUNsYcYyRbhAaLRJow7YaOIFV82wR48g5dzY+SMkGNJL5o3K3okRbuclUr97R5SgMburR7CgysAQwodDLJG948Dyn1snyEiG9VjelfFUo8npH/fYlgirTogV5/fKAq2UZrpmd0zOt796s9qAMP9Y2SUY+c21Kg2yy3jgtQON1ns4M6QljAVmFV8qGZcS2J6Iyf3Xp9SoyhNAIHyr50CsJDAkKBhFFWSDxErskQ6byq196Q+N/s4qlCTwx6O58ic3Rxn27F2EX+UwZneeOdVKNGvJ4EfqRvUupzypiQfz7R3GKc/vvjTmQli95mk8uDIJrlOmamQFwpTZ6C+X06bgwM0TGYDrYkrPyjtwtTCe+2jFxC6j3sMTq8ARHNAm0knRNyvzdIAFq9Dkk/Dk+lvGLtJjHtoSr9IZUNTcbz7iq97g8ohBnq3Rf7FoJhEAgiIcykGwX/V5Uze/MzUYqAVflsAq81MK1WfgTCKyLWRI+XgSml5abHLG96o5I7rJY4PwC/DWmboI5rnegowHts8Hg96tJxjBCoiw0wWCCDqwESN3dZi2HGIz5dJR2RdQkiwpBd1NIpB5S5rHlCXecnUQBoT1fVSxv4hr6JfEO+tMHZhbs4z+21kRS2oR72K1fPXyq22zdJRu7gnhfdeTT0Am2P6ID6lsyTmKvLokEwNAfee46BcyINZucR9ZF0Jr+1c2RQX208LUcgMXD9pmjI5VffA0lSk4aOSwvGLfVigwjzQnokQns= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB6969.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(36756003)(38350700002)(38100700002)(86362001)(83380400001)(26005)(6512007)(2616005)(107886003)(1076003)(6506007)(52116002)(316002)(2906002)(6666004)(6486002)(966005)(508600001)(6916009)(8936002)(186003)(66556008)(66476007)(8676002)(4326008)(5660300002)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j3c2kvktXAn88MIajgIFTT9v6b+iS5cpYwlffE/gRCXfvo7llrtVWlYKH3NC3xM5Xs4UvnMsnp5Z3grSk3fmd5AJVndnk/hoDcnTJdNVShc4HwJnZg+YnakQpa+6WoQ7jsBqrL43/W1qpJmFbvMbKPdUFiePSXNkjYZb1U5yfz7vq11B9QQpAfBTTmb2VZaWcsBjPjOfhJMFNMl+TGdL2GQOshygcPF/amv/0K0UCUoz7hzYogk3kGscdbngYXEbRJdlsPqmXu5HAGK6UTPt5UP3Yq5tJ5c7TrqWNjjFMhV/fgD8H56lzsRNekP/4IcZvoBkmEz195fDpo+WVMUHS+yszZllwgXdeveilzkrfcBl6r4++D/Nsdc+b1luOwPRvt9aFM0Fs3F8erEfofXhE9batNKdIAYUEAN8jNSzq5EJr9SMzY9PVAo9+siEGLMY173UtJDIiSvV8pcg2SQa1i2X+jTMUnnTJr+ti0QButHx2aoCd3bfRB7fv0GvfIU+CxBklE1bObaqVNL1a2FlLxeLDHOwqu7airR3mPKq3WwTo8qwCLogdLnPDdI//0CPoW8gUsyVOUquK4Wz15+2qB6iyl2Em+6HbF3JoXel+xG9cLkxNvuvfo0atuWcAd5FYeh0QF5c76wwOK4iHLXPQDBypGr9fF0MVNPNO5G10I86/zFrC/2AEjwYsztniGjHtcLyqoAo+bc/GUP2MCAefBSTTKopJfrholSWkdaCwMQ7tjr2iB4Kb81WkQbUYizVCa6wKqRQMfdBgeye+Oo0HZopndjlAmEJlLfoBnIMD8YHIQzUUZjfA+PPBRT9IDjqC2yawD344GGJUDv4rn+nmaRRCteurq0sbchiGtQkLUOw9EBg0ohXct7I57IP1wOm+hrKXX1IJYTv6Toy/zOte0ow9a/V/beno8eeRglWUMxFtXpJsdyC/h+IX5il8hF9Q7zaCSWUCa68+xGrSeEZG6RtyDuazJRBSZ3CbncQIYw8TJTpxfxdLNpcV+m3xtR5rMoRMcolFc4JIuoRNcYILZG+wOEhB804M1KUVXC85TYoQPmH8p/wxF7M5u7Zrbu+Id/zvyHBncCtWw2oqBj90lZ84tB9W33kG5SFu+bHDDKXFfzEebCjnbE/UDhjr4+jOeGxqDp9cL6S4fq9VMLWWsupNHfpkqZ98krXdg5DuWZKIHyWRWTlx9ECO1+rTVASiznV+HMeGYKw55Bj0AfA5xAhX0/V2aS6AczMpAwMJHmY/mWoJUR0SmXQ9dvnIDX5Nqm5Pq/5FhsYGiI4Ayye+JNOXy0IaFqsftnU+jkTDY1ydU+Sj8WMey9V/lpa1KCNKgfceSjDBRYU5NLkKGwa4DQ4hobKZLXbduoDT7tNNbTh74rfZOTJzOVvAZUNYWN+HD8APix5f40Hj34aQQpidSoQqnbAcyyYmmFWaRqV0mn+xRga7U2TR95Lxd0VAnGNlpKEvSAx9w6FkNyu1MrzqvVS+ej0fUahnwBQzjB4KFwuK5wCpMXcvgLF8Upe71iN3Aua2hkrvJrNmVCxrhGrsnOE3wlKs9fU6BV4Le+Fyvgpt58X8C0VucQvKQRhXNdZBl5mcexlJuFl9ZRgK2+OFFGbzbj9yBMTFQfG1z9gFJnpktHDJTK43VVrKIlSqm5T4vok6cXA1K6cgRA0Cs7k8glF4a1qMnb3sSThfeoop5Wi8TmmWXQ1x8xoSgYhRcx6kxp2Rqy96z7mMJbblBo7QvcH4liysQrN6K0WBuvmjHU= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ae89098-1e65-4cfd-ce60-08da4e08e42f X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2022 13:22:12.3420 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fhShH4jTCk9fkW5von09kpGhnC8Hm5IxOVa6Xu/0QgMDuTG+Xy9hE5DkiyqHYrZ4zxzprLDSkDDGujikQvfRxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5846 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Stefan Herbrechtsmeier The device tree binding [1] specify the vendor-id, product-id, device-id and language-id as 16 bit values and the linux driver reads the boost-up value as 8 bit value. [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/usb/usb251xb.txt Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Marek Vasut --- drivers/misc/usb251xb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/misc/usb251xb.c b/drivers/misc/usb251xb.c index 077edc2504..a78ad1843a 100644 --- a/drivers/misc/usb251xb.c +++ b/drivers/misc/usb251xb.c @@ -400,14 +400,14 @@ static int usb251xb_of_to_plat(struct udevice *dev) } } - if (dev_read_u32(dev, "vendor-id", &hub->vendor_id)) - hub->vendor_id = USB251XB_DEF_VENDOR_ID; + hub->vendor_id = dev_read_u16_default(dev, "vendor-id", + USB251XB_DEF_VENDOR_ID); - if (dev_read_u32(dev, "product-id", &hub->product_id)) - hub->product_id = data->product_id; + hub->product_id = dev_read_u16_default(dev, "product-id", + data->product_id); - if (dev_read_u32(dev, "device-id", &hub->device_id)) - hub->device_id = USB251XB_DEF_DEVICE_ID; + hub->device_id = dev_read_u16_default(dev, "device-id", + USB251XB_DEF_DEVICE_ID); hub->conf_data1 = USB251XB_DEF_CONFIG_DATA_1; if (dev_read_bool(dev, "self-powered")) { @@ -513,11 +513,11 @@ static int usb251xb_of_to_plat(struct udevice *dev) if (!dev_read_u32(dev, "power-on-time-ms", &property_u32)) hub->power_on_time = min_t(u8, property_u32 / 2, 255); - if (dev_read_u32(dev, "language-id", &hub->lang_id)) - hub->lang_id = USB251XB_DEF_LANGUAGE_ID; + hub->lang_id = dev_read_u16_default(dev, "language-id", + USB251XB_DEF_LANGUAGE_ID); - if (!dev_read_u32(dev, "boost-up", &hub->boost_up)) - hub->boost_up = USB251XB_DEF_BOOST_UP; + hub->boost_up = dev_read_u8_default(dev, "boost-up", + USB251XB_DEF_BOOST_UP); cproperty_char = dev_read_string(dev, "manufacturer"); strlcpy(str, cproperty_char ? : USB251XB_DEF_MANUFACTURER_STRING,