Skip to content

Commit 4f799e7

Browse files
committed
ALSA: hda: Make snd_hdac_display_power() void function
After the recent refactoring, snd_hdac_display_power() doesn't return any error, hence it can be defined to return void. This makes many error checks redundant and allows us to reduce them gracefully. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 457f3c8 commit 4f799e7

5 files changed

Lines changed: 23 additions & 66 deletions

File tree

‎include/sound/hda_component.h‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
#ifdef CONFIG_SND_HDA_COMPONENT
1414
int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable);
15-
int snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx,
16-
bool enable);
15+
void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx,
16+
bool enable);
1717
int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid,
1818
int dev_id, int rate);
1919
int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid, int dev_id,
@@ -30,10 +30,9 @@ static inline int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable)
3030
{
3131
return 0;
3232
}
33-
static inline int snd_hdac_display_power(struct hdac_bus *bus,
34-
unsigned int idx, bool enable)
33+
static inline void snd_hdac_display_power(struct hdac_bus *bus,
34+
unsigned int idx, bool enable)
3535
{
36-
return 0;
3736
}
3837
static inline int snd_hdac_sync_audio_rate(struct hdac_device *codec,
3938
hda_nid_t nid, int dev_id, int rate)

‎sound/hda/hdac_component.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_set_codec_wakeup);
6262
*
6363
* This function updates the power status, and calls the get_power() and
6464
* put_power() ops accordingly, toggling the codec wakeup, too.
65-
*
66-
* Returns zero for success or a negative error code.
6765
*/
68-
int snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
66+
void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
6967
{
7068
struct drm_audio_component *acomp = bus->audio_component;
7169

@@ -77,7 +75,7 @@ int snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
7775
clear_bit(idx, &bus->display_power_status);
7876

7977
if (!acomp || !acomp->ops)
80-
return 0;
78+
return;
8179

8280
if (bus->display_power_status) {
8381
if (!bus->display_power_active) {
@@ -94,8 +92,6 @@ int snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
9492
bus->display_power_active = false;
9593
}
9694
}
97-
98-
return 0;
9995
}
10096
EXPORT_SYMBOL_GPL(snd_hdac_display_power);
10197

‎sound/pci/hda/hda_intel.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,12 +2216,7 @@ static int azx_probe_continue(struct azx *chip)
22162216
* this power. For other platforms, like Baytrail/Braswell, only the
22172217
* display codec needs the power and it can be released after probe.
22182218
*/
2219-
err = display_power(chip, true);
2220-
if (err < 0) {
2221-
dev_err(chip->card->dev,
2222-
"Cannot turn on display power on i915\n");
2223-
goto i915_power_fail;
2224-
}
2219+
display_power(chip, true);
22252220

22262221
err = azx_first_init(chip);
22272222
if (err < 0)
@@ -2271,8 +2266,6 @@ static int azx_probe_continue(struct azx *chip)
22712266
out_free:
22722267
if (err < 0 || !hda->need_i915_power)
22732268
display_power(chip, false);
2274-
2275-
i915_power_fail:
22762269
if (err < 0)
22772270
hda->init_failed = 1;
22782271
complete_all(&hda->probe_wait);

‎sound/soc/codecs/hdac_hdmi.c‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,13 +2031,8 @@ static int hdac_hdmi_dev_probe(struct hdac_device *hdev)
20312031
* Turned off in the runtime_suspend during the first explicit
20322032
* pm_runtime_suspend call.
20332033
*/
2034-
ret = snd_hdac_display_power(hdev->bus, hdev->addr, true);
2035-
if (ret < 0) {
2036-
dev_err(&hdev->dev,
2037-
"Cannot turn on display power on i915 err: %d\n",
2038-
ret);
2039-
return ret;
2040-
}
2034+
snd_hdac_display_power(hdev->bus, hdev->addr, true);
2035+
20412036
ret = hdac_hdmi_parse_and_map_nid(hdev, &hdmi_dais, &num_dais);
20422037
if (ret < 0) {
20432038
dev_err(&hdev->dev,
@@ -2169,7 +2164,6 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
21692164
struct hdac_device *hdev = dev_to_hdac_dev(dev);
21702165
struct hdac_bus *bus = hdev->bus;
21712166
struct hdac_ext_link *hlink = NULL;
2172-
int err;
21732167

21742168
dev_dbg(dev, "Enter: %s\n", __func__);
21752169

@@ -2195,19 +2189,16 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
21952189

21962190
snd_hdac_ext_bus_link_put(bus, hlink);
21972191

2198-
err = snd_hdac_display_power(bus, hdev->addr, false);
2199-
if (err < 0)
2200-
dev_err(dev, "Cannot turn off display power on i915\n");
2192+
snd_hdac_display_power(bus, hdev->addr, false);
22012193

2202-
return err;
2194+
return 0;
22032195
}
22042196

22052197
static int hdac_hdmi_runtime_resume(struct device *dev)
22062198
{
22072199
struct hdac_device *hdev = dev_to_hdac_dev(dev);
22082200
struct hdac_bus *bus = hdev->bus;
22092201
struct hdac_ext_link *hlink = NULL;
2210-
int err;
22112202

22122203
dev_dbg(dev, "Enter: %s\n", __func__);
22132204

@@ -2223,11 +2214,7 @@ static int hdac_hdmi_runtime_resume(struct device *dev)
22232214

22242215
snd_hdac_ext_bus_link_get(bus, hlink);
22252216

2226-
err = snd_hdac_display_power(bus, hdev->addr, true);
2227-
if (err < 0) {
2228-
dev_err(dev, "Cannot turn on display power on i915\n");
2229-
return err;
2230-
}
2217+
snd_hdac_display_power(bus, hdev->addr, true);
22312218

22322219
hdac_hdmi_skl_enable_all_pins(hdev);
22332220
hdac_hdmi_skl_enable_dp12(hdev);

‎sound/soc/intel/skylake/skl.c‎

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static int skl_suspend(struct device *dev)
311311
struct pci_dev *pci = to_pci_dev(dev);
312312
struct hdac_bus *bus = pci_get_drvdata(pci);
313313
struct skl *skl = bus_to_skl(bus);
314-
int ret = 0;
314+
int ret;
315315

316316
/*
317317
* Do not suspend if streams which are marked ignore suspend are
@@ -333,14 +333,10 @@ static int skl_suspend(struct device *dev)
333333
skl->skl_sst->fw_loaded = false;
334334
}
335335

336-
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
337-
ret = snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
338-
if (ret < 0)
339-
dev_err(bus->dev,
340-
"Cannot turn OFF display power on i915\n");
341-
}
336+
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
337+
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
342338

343-
return ret;
339+
return 0;
344340
}
345341

346342
static int skl_resume(struct device *dev)
@@ -352,14 +348,8 @@ static int skl_resume(struct device *dev)
352348
int ret;
353349

354350
/* Turned OFF in HDMI codec driver after codec reconfiguration */
355-
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
356-
ret = snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
357-
if (ret < 0) {
358-
dev_err(bus->dev,
359-
"Cannot turn on display power on i915\n");
360-
return ret;
361-
}
362-
}
351+
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
352+
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
363353

364354
/*
365355
* resume only when we are not in suspend active, otherwise need to
@@ -783,11 +773,9 @@ static int skl_i915_init(struct hdac_bus *bus)
783773
if (err < 0)
784774
return err;
785775

786-
err = snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
787-
if (err < 0)
788-
dev_err(bus->dev, "Cannot turn on display power on i915\n");
776+
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
789777

790-
return err;
778+
return 0;
791779
}
792780

793781
static void skl_probe_work(struct work_struct *work)
@@ -837,14 +825,8 @@ static void skl_probe_work(struct work_struct *work)
837825
list_for_each_entry(hlink, &bus->hlink_list, list)
838826
snd_hdac_ext_bus_link_put(bus, hlink);
839827

840-
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
841-
err = snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
842-
if (err < 0) {
843-
dev_err(bus->dev, "Cannot turn off display power on i915\n");
844-
skl_machine_device_unregister(skl);
845-
return;
846-
}
847-
}
828+
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
829+
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
848830

849831
/* configure PM */
850832
pm_runtime_put_noidle(bus->dev);
@@ -855,7 +837,7 @@ static void skl_probe_work(struct work_struct *work)
855837

856838
out_err:
857839
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
858-
err = snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
840+
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
859841
}
860842

861843
/*

0 commit comments

Comments
 (0)