diff options
| author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2026-05-14 00:01:29 +0200 |
|---|---|---|
| committer | Vinod Koul <vkoul@kernel.org> | 2026-05-14 21:02:21 +0530 |
| commit | 79a5274fb39904f8a60bdd7bf7753ee1ba700210 (patch) | |
| tree | ce285f36568a2e717f2fc580be24b0c5334e8865 | |
| parent | 62455f6be1256084cfff8690df416f418b6f0dd2 (diff) | |
| download | linux-79a5274fb39904f8a60bdd7bf7753ee1ba700210.tar.gz linux-79a5274fb39904f8a60bdd7bf7753ee1ba700210.zip | |
phy: phy-can-transceiver: Don't check for specific errors when parsing properties
Instead of checking for the specific error codes (that can be considered
a layering violation to some extent) check for the property existence first
and then either parse it, or apply a default value.
With that, return an error when parsing of the existing property fails.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260513220336.369628-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
| -rw-r--r-- | drivers/phy/phy-can-transceiver.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c index 5c9698f77c7d..3cebaa54f7db 100644 --- a/drivers/phy/phy-can-transceiver.c +++ b/drivers/phy/phy-can-transceiver.c @@ -128,8 +128,9 @@ static int can_transceiver_phy_probe(struct platform_device *pdev) struct gpio_desc *standby_gpio; struct gpio_desc *enable_gpio; struct mux_state *mux_state; - u32 max_bitrate = 0; int err, i, num_ch = 1; + const char *propname; + u32 max_bitrate; drvdata = device_get_match_data(dev); if (!drvdata) @@ -151,9 +152,17 @@ static int can_transceiver_phy_probe(struct platform_device *pdev) priv->mux_state = mux_state; - err = device_property_read_u32(dev, "max-bitrate", &max_bitrate); - if ((err != -EINVAL) && !max_bitrate) - dev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n"); + propname = "max-bitrate"; + if (device_property_present(dev, propname)) { + err = device_property_read_u32(dev, propname, &max_bitrate); + if (err) + return dev_err_probe(dev, err, "failed to parse %s\n", propname); + + if (max_bitrate == 0) + dev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n"); + } else { + max_bitrate = 0; + } for (i = 0; i < num_ch; i++) { can_transceiver_phy = &priv->can_transceiver_phy[i]; |
