ASoC: Use of_property_read_bool() for boolean properties
authorRob Herring <robh@kernel.org>
Fri, 10 Mar 2023 14:47:32 +0000 (08:47 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Oct 2023 21:08:51 +0000 (23:08 +0200)
[ Upstream commit 2d2998b84330899bf88a0414f3356869be4a69eb ]

It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties.
Convert reading boolean properties to to of_property_read_bool().

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230310144733.1546413-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Stable-dep-of: 197c53c8ecb3 ("ASoC: fsl_sai: Don't disable bitclock for i.MX8MP")
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/codecs/sta32x.c
sound/soc/codecs/sta350.c
sound/soc/codecs/tas5086.c
sound/soc/fsl/fsl_sai.c
sound/soc/fsl/fsl_ssi.c
sound/soc/fsl/imx-card.c
sound/soc/sh/rcar/ssi.c

index 8c86b57..29af959 100644 (file)
@@ -1054,35 +1054,32 @@ static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x)
        of_property_read_u8(np, "st,ch3-output-mapping",
                            &pdata->ch3_output_mapping);
 
-       if (of_get_property(np, "st,fault-detect-recovery", NULL))
-               pdata->fault_detect_recovery = 1;
-       if (of_get_property(np, "st,thermal-warning-recovery", NULL))
-               pdata->thermal_warning_recovery = 1;
-       if (of_get_property(np, "st,thermal-warning-adjustment", NULL))
-               pdata->thermal_warning_adjustment = 1;
-       if (of_get_property(np, "st,needs_esd_watchdog", NULL))
-               pdata->needs_esd_watchdog = 1;
+       pdata->fault_detect_recovery =
+               of_property_read_bool(np, "st,fault-detect-recovery");
+       pdata->thermal_warning_recovery =
+               of_property_read_bool(np, "st,thermal-warning-recovery");
+       pdata->thermal_warning_adjustment =
+               of_property_read_bool(np, "st,thermal-warning-adjustment");
+       pdata->needs_esd_watchdog =
+               of_property_read_bool(np, "st,needs_esd_watchdog");
 
        tmp = 140;
        of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
        pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20;
 
        /* CONFE */
-       if (of_get_property(np, "st,max-power-use-mpcc", NULL))
-               pdata->max_power_use_mpcc = 1;
-
-       if (of_get_property(np, "st,max-power-correction", NULL))
-               pdata->max_power_correction = 1;
-
-       if (of_get_property(np, "st,am-reduction-mode", NULL))
-               pdata->am_reduction_mode = 1;
-
-       if (of_get_property(np, "st,odd-pwm-speed-mode", NULL))
-               pdata->odd_pwm_speed_mode = 1;
+       pdata->max_power_use_mpcc =
+               of_property_read_bool(np, "st,max-power-use-mpcc");
+       pdata->max_power_correction =
+               of_property_read_bool(np, "st,max-power-correction");
+       pdata->am_reduction_mode =
+               of_property_read_bool(np, "st,am-reduction-mode");
+       pdata->odd_pwm_speed_mode =
+               of_property_read_bool(np, "st,odd-pwm-speed-mode");
 
        /* CONFF */
-       if (of_get_property(np, "st,invalid-input-detect-mute", NULL))
-               pdata->invalid_input_detect_mute = 1;
+       pdata->invalid_input_detect_mute =
+               of_property_read_bool(np, "st,invalid-input-detect-mute");
 
        sta32x->pdata = pdata;
 
index 9ed13ae..b033a5f 100644 (file)
@@ -1106,12 +1106,12 @@ static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
        of_property_read_u8(np, "st,ch3-output-mapping",
                            &pdata->ch3_output_mapping);
 
-       if (of_get_property(np, "st,thermal-warning-recovery", NULL))
-               pdata->thermal_warning_recovery = 1;
-       if (of_get_property(np, "st,thermal-warning-adjustment", NULL))
-               pdata->thermal_warning_adjustment = 1;
-       if (of_get_property(np, "st,fault-detect-recovery", NULL))
-               pdata->fault_detect_recovery = 1;
+       pdata->thermal_warning_recovery =
+               of_property_read_bool(np, "st,thermal-warning-recovery");
+       pdata->thermal_warning_adjustment =
+               of_property_read_bool(np, "st,thermal-warning-adjustment");
+       pdata->fault_detect_recovery =
+               of_property_read_bool(np, "st,fault-detect-recovery");
 
        pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP;
        if (!of_property_read_string(np, "st,ffx-power-output-mode",
@@ -1133,41 +1133,34 @@ static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
        of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
        pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20;
 
-       if (of_get_property(np, "st,overcurrent-warning-adjustment", NULL))
-               pdata->oc_warning_adjustment = 1;
+       pdata->oc_warning_adjustment =
+               of_property_read_bool(np, "st,overcurrent-warning-adjustment");
 
        /* CONFE */
-       if (of_get_property(np, "st,max-power-use-mpcc", NULL))
-               pdata->max_power_use_mpcc = 1;
-
-       if (of_get_property(np, "st,max-power-correction", NULL))
-               pdata->max_power_correction = 1;
-
-       if (of_get_property(np, "st,am-reduction-mode", NULL))
-               pdata->am_reduction_mode = 1;
-
-       if (of_get_property(np, "st,odd-pwm-speed-mode", NULL))
-               pdata->odd_pwm_speed_mode = 1;
-
-       if (of_get_property(np, "st,distortion-compensation", NULL))
-               pdata->distortion_compensation = 1;
+       pdata->max_power_use_mpcc =
+               of_property_read_bool(np, "st,max-power-use-mpcc");
+       pdata->max_power_correction =
+               of_property_read_bool(np, "st,max-power-correction");
+       pdata->am_reduction_mode =
+               of_property_read_bool(np, "st,am-reduction-mode");
+       pdata->odd_pwm_speed_mode =
+               of_property_read_bool(np, "st,odd-pwm-speed-mode");
+       pdata->distortion_compensation =
+               of_property_read_bool(np, "st,distortion-compensation");
 
        /* CONFF */
-       if (of_get_property(np, "st,invalid-input-detect-mute", NULL))
-               pdata->invalid_input_detect_mute = 1;
+       pdata->invalid_input_detect_mute =
+               of_property_read_bool(np, "st,invalid-input-detect-mute");
 
        /* MISC */
-       if (of_get_property(np, "st,activate-mute-output", NULL))
-               pdata->activate_mute_output = 1;
-
-       if (of_get_property(np, "st,bridge-immediate-off", NULL))
-               pdata->bridge_immediate_off = 1;
-
-       if (of_get_property(np, "st,noise-shape-dc-cut", NULL))
-               pdata->noise_shape_dc_cut = 1;
-
-       if (of_get_property(np, "st,powerdown-master-volume", NULL))
-               pdata->powerdown_master_vol = 1;
+       pdata->activate_mute_output =
+               of_property_read_bool(np, "st,activate-mute-output");
+       pdata->bridge_immediate_off =
+               of_property_read_bool(np, "st,bridge-immediate-off");
+       pdata->noise_shape_dc_cut =
+               of_property_read_bool(np, "st,noise-shape-dc-cut");
+       pdata->powerdown_master_vol =
+               of_property_read_bool(np, "st,powerdown-master-volume");
 
        if (!of_property_read_u8(np, "st,powerdown-delay-divider", &tmp8)) {
                if (is_power_of_2(tmp8) && tmp8 >= 1 && tmp8 <= 128)
index 22143cc..f9e7122 100644 (file)
@@ -840,7 +840,7 @@ static int tas5086_probe(struct snd_soc_component *component)
                        snprintf(name, sizeof(name),
                                 "ti,mid-z-channel-%d", i + 1);
 
-                       if (of_get_property(of_node, name, NULL) != NULL)
+                       if (of_property_read_bool(of_node, name))
                                priv->pwm_start_mid_z |= 1 << i;
                }
        }
index b7552b0..2c17d16 100644 (file)
@@ -1381,18 +1381,18 @@ static int fsl_sai_probe(struct platform_device *pdev)
        sai->cpu_dai_drv.symmetric_channels = 1;
        sai->cpu_dai_drv.symmetric_sample_bits = 1;
 
-       if (of_find_property(np, "fsl,sai-synchronous-rx", NULL) &&
-           of_find_property(np, "fsl,sai-asynchronous", NULL)) {
+       if (of_property_read_bool(np, "fsl,sai-synchronous-rx") &&
+           of_property_read_bool(np, "fsl,sai-asynchronous")) {
                /* error out if both synchronous and asynchronous are present */
                dev_err(dev, "invalid binding for synchronous mode\n");
                return -EINVAL;
        }
 
-       if (of_find_property(np, "fsl,sai-synchronous-rx", NULL)) {
+       if (of_property_read_bool(np, "fsl,sai-synchronous-rx")) {
                /* Sync Rx with Tx */
                sai->synchronous[RX] = false;
                sai->synchronous[TX] = true;
-       } else if (of_find_property(np, "fsl,sai-asynchronous", NULL)) {
+       } else if (of_property_read_bool(np, "fsl,sai-asynchronous")) {
                /* Discard all settings for asynchronous mode */
                sai->synchronous[RX] = false;
                sai->synchronous[TX] = false;
@@ -1401,7 +1401,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
                sai->cpu_dai_drv.symmetric_sample_bits = 0;
        }
 
-       if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) &&
+       if (of_property_read_bool(np, "fsl,sai-mclk-direction-output") &&
            of_device_is_compatible(np, "fsl,imx6ul-sai")) {
                gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
                if (IS_ERR(gpr)) {
@@ -1442,7 +1442,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
                dev_warn(dev, "Error reading SAI version: %d\n", ret);
 
        /* Select MCLK direction */
-       if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) &&
+       if (of_property_read_bool(np, "fsl,sai-mclk-direction-output") &&
            sai->soc_data->max_register >= FSL_SAI_MCTL) {
                regmap_update_bits(sai->regmap, FSL_SAI_MCTL,
                                   FSL_SAI_MCTL_MCLK_EN, FSL_SAI_MCTL_MCLK_EN);
index 46a5355..6af00b6 100644 (file)
@@ -1447,7 +1447,7 @@ static int fsl_ssi_probe_from_dt(struct fsl_ssi *ssi)
                        return -EINVAL;
                }
                strcpy(ssi->card_name, "ac97-codec");
-       } else if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) {
+       } else if (!of_property_read_bool(np, "fsl,ssi-asynchronous")) {
                /*
                 * In synchronous mode, STCK and STFS ports are used by RX
                 * as well. So the software should limit the sample rates,
index 3f128ce..64a4d7e 100644 (file)
@@ -563,7 +563,7 @@ static int imx_card_parse_of(struct imx_card_data *data)
                        link_data->cpu_sysclk_id = FSL_SAI_CLK_MAST1;
 
                        /* sai may support mclk/bclk = 1 */
-                       if (of_find_property(np, "fsl,mclk-equal-bclk", NULL)) {
+                       if (of_property_read_bool(np, "fsl,mclk-equal-bclk")) {
                                link_data->one2one_ratio = true;
                        } else {
                                int i;
index 7ade6c5..cb7fff4 100644 (file)
@@ -1208,10 +1208,10 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
                        goto rsnd_ssi_probe_done;
                }
 
-               if (of_get_property(np, "shared-pin", NULL))
+               if (of_property_read_bool(np, "shared-pin"))
                        rsnd_flags_set(ssi, RSND_SSI_CLK_PIN_SHARE);
 
-               if (of_get_property(np, "no-busif", NULL))
+               if (of_property_read_bool(np, "no-busif"))
                        rsnd_flags_set(ssi, RSND_SSI_NO_BUSIF);
 
                ssi->irq = irq_of_parse_and_map(np, 0);