Skip to content

Commit 9e993b3

Browse files
committed
ALSA: hda: codec: Reduce CONFIG_PM dependencies
CONFIG_PM is almost mandatory nowadays for real systems, but we have lots of CONFIG_PM dependent code in snd-hda-codec helper code. Let's reduce the dependencies of CONFIG_PM now. The only visible drawback would be a couple of superfluous trace entries for runtime PM, but we can live with that. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20240506161359.6960-3-tiwai@suse.de
1 parent 32d7c6c commit 9e993b3

4 files changed

Lines changed: 10 additions & 44 deletions

File tree

include/sound/hda_codec.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,9 @@ struct hda_codec_ops {
109109
void (*unsol_event)(struct hda_codec *codec, unsigned int res);
110110
void (*set_power_state)(struct hda_codec *codec, hda_nid_t fg,
111111
unsigned int power_state);
112-
#ifdef CONFIG_PM
113112
int (*suspend)(struct hda_codec *codec);
114113
int (*resume)(struct hda_codec *codec);
115114
int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid);
116-
#endif
117115
void (*stream_pm)(struct hda_codec *codec, hda_nid_t nid, bool on);
118116
};
119117

@@ -259,11 +257,9 @@ struct hda_codec {
259257
unsigned int no_stream_clean_at_suspend:1; /* do not clean streams at suspend */
260258
unsigned int ctl_dev_id:1; /* old control element id build behaviour */
261259

262-
#ifdef CONFIG_PM
263260
unsigned long power_on_acct;
264261
unsigned long power_off_acct;
265262
unsigned long power_jiffies;
266-
#endif
267263

268264
/* filter the requested power state per nid */
269265
unsigned int (*power_filter)(struct hda_codec *codec, hda_nid_t nid,
@@ -481,10 +477,8 @@ extern const struct dev_pm_ops hda_codec_driver_pm;
481477
static inline
482478
int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
483479
{
484-
#ifdef CONFIG_PM
485480
if (codec->patch_ops.check_power_status)
486481
return codec->patch_ops.check_power_status(codec, nid);
487-
#endif
488482
return 0;
489483
}
490484

@@ -495,14 +489,9 @@ int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
495489
#define snd_hda_power_up_pm(codec) snd_hdac_power_up_pm(&(codec)->core)
496490
#define snd_hda_power_down(codec) snd_hdac_power_down(&(codec)->core)
497491
#define snd_hda_power_down_pm(codec) snd_hdac_power_down_pm(&(codec)->core)
498-
#ifdef CONFIG_PM
499492
void snd_hda_codec_set_power_save(struct hda_codec *codec, int delay);
500493
void snd_hda_set_power_save(struct hda_bus *bus, int delay);
501494
void snd_hda_update_power_acct(struct hda_codec *codec);
502-
#else
503-
static inline void snd_hda_codec_set_power_save(struct hda_codec *codec, int delay) {}
504-
static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
505-
#endif
506495

507496
static inline bool hda_codec_need_resume(struct hda_codec *codec)
508497
{

sound/pci/hda/hda_codec.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ void snd_hda_shutup_pins(struct hda_codec *codec)
616616
}
617617
EXPORT_SYMBOL_GPL(snd_hda_shutup_pins);
618618

619-
#ifdef CONFIG_PM
620619
/* Restore the pin controls cleared previously via snd_hda_shutup_pins() */
621620
static void restore_shutup_pins(struct hda_codec *codec)
622621
{
@@ -634,7 +633,6 @@ static void restore_shutup_pins(struct hda_codec *codec)
634633
}
635634
codec->pins_shutup = 0;
636635
}
637-
#endif
638636

639637
static void hda_jackpoll_work(struct work_struct *work)
640638
{
@@ -1001,9 +999,7 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,
1001999
codec->card = card;
10021000
codec->addr = codec_addr;
10031001

1004-
#ifdef CONFIG_PM
10051002
codec->power_jiffies = jiffies;
1006-
#endif
10071003

10081004
snd_hda_sysfs_init(codec);
10091005

@@ -1238,7 +1234,6 @@ static void purify_inactive_streams(struct hda_codec *codec)
12381234
}
12391235
}
12401236

1241-
#ifdef CONFIG_PM
12421237
/* clean up all streams; called from suspend */
12431238
static void hda_cleanup_all_streams(struct hda_codec *codec)
12441239
{
@@ -1250,7 +1245,6 @@ static void hda_cleanup_all_streams(struct hda_codec *codec)
12501245
really_cleanup_stream(codec, p);
12511246
}
12521247
}
1253-
#endif
12541248

12551249
/*
12561250
* amp access functions
@@ -2858,7 +2852,6 @@ static void hda_exec_init_verbs(struct hda_codec *codec)
28582852
static inline void hda_exec_init_verbs(struct hda_codec *codec) {}
28592853
#endif
28602854

2861-
#ifdef CONFIG_PM
28622855
/* update the power on/off account with the current jiffies */
28632856
static void update_power_acct(struct hda_codec *codec, bool on)
28642857
{
@@ -2966,9 +2959,6 @@ static int hda_codec_runtime_resume(struct device *dev)
29662959
return 0;
29672960
}
29682961

2969-
#endif /* CONFIG_PM */
2970-
2971-
#ifdef CONFIG_PM_SLEEP
29722962
static int hda_codec_pm_prepare(struct device *dev)
29732963
{
29742964
struct hda_codec *codec = dev_to_hda_codec(dev);
@@ -3023,22 +3013,19 @@ static int hda_codec_pm_restore(struct device *dev)
30233013
dev->power.power_state = PMSG_RESTORE;
30243014
return pm_runtime_force_resume(dev);
30253015
}
3026-
#endif /* CONFIG_PM_SLEEP */
30273016

30283017
/* referred in hda_bind.c */
30293018
const struct dev_pm_ops hda_codec_driver_pm = {
3030-
#ifdef CONFIG_PM_SLEEP
3031-
.prepare = hda_codec_pm_prepare,
3032-
.complete = hda_codec_pm_complete,
3033-
.suspend = hda_codec_pm_suspend,
3034-
.resume = hda_codec_pm_resume,
3035-
.freeze = hda_codec_pm_freeze,
3036-
.thaw = hda_codec_pm_thaw,
3037-
.poweroff = hda_codec_pm_suspend,
3038-
.restore = hda_codec_pm_restore,
3039-
#endif /* CONFIG_PM_SLEEP */
3040-
SET_RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume,
3041-
NULL)
3019+
.prepare = pm_sleep_ptr(hda_codec_pm_prepare),
3020+
.complete = pm_sleep_ptr(hda_codec_pm_complete),
3021+
.suspend = pm_sleep_ptr(hda_codec_pm_suspend),
3022+
.resume = pm_sleep_ptr(hda_codec_pm_resume),
3023+
.freeze = pm_sleep_ptr(hda_codec_pm_freeze),
3024+
.thaw = pm_sleep_ptr(hda_codec_pm_thaw),
3025+
.poweroff = pm_sleep_ptr(hda_codec_pm_suspend),
3026+
.restore = pm_sleep_ptr(hda_codec_pm_restore),
3027+
.runtime_suspend = pm_ptr(hda_codec_runtime_suspend),
3028+
.runtime_resume = pm_ptr(hda_codec_runtime_resume),
30423029
};
30433030

30443031
/* suspend the codec at shutdown; called from driver's shutdown callback */
@@ -3425,7 +3412,6 @@ int snd_hda_add_new_ctls(struct hda_codec *codec,
34253412
}
34263413
EXPORT_SYMBOL_GPL(snd_hda_add_new_ctls);
34273414

3428-
#ifdef CONFIG_PM
34293415
/**
34303416
* snd_hda_codec_set_power_save - Configure codec's runtime PM
34313417
* @codec: codec device to configure
@@ -3516,7 +3502,6 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
35163502
return 0;
35173503
}
35183504
EXPORT_SYMBOL_GPL(snd_hda_check_amp_list_power);
3519-
#endif
35203505

35213506
/*
35223507
* input MUX helper
@@ -4060,12 +4045,10 @@ void snd_hda_bus_reset_codecs(struct hda_bus *bus)
40604045
/* FIXME: maybe a better way needed for forced reset */
40614046
if (current_work() != &codec->jackpoll_work.work)
40624047
cancel_delayed_work_sync(&codec->jackpoll_work);
4063-
#ifdef CONFIG_PM
40644048
if (hda_codec_is_power_on(codec)) {
40654049
hda_call_codec_suspend(codec);
40664050
hda_call_codec_resume(codec);
40674051
}
4068-
#endif
40694052
}
40704053
}
40714054

sound/pci/hda/hda_controller.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,11 +1075,9 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)
10751075
bool active, handled = false;
10761076
int repeat = 0; /* count for avoiding endless loop */
10771077

1078-
#ifdef CONFIG_PM
10791078
if (azx_has_pm_runtime(chip))
10801079
if (!pm_runtime_active(chip->card->dev))
10811080
return IRQ_NONE;
1082-
#endif
10831081

10841082
spin_lock(&bus->reg_lock);
10851083

sound/pci/hda/hda_sysfs.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct hda_hint {
2626
const char *val; /* contained in the same alloc as key */
2727
};
2828

29-
#ifdef CONFIG_PM
3029
static ssize_t power_on_acct_show(struct device *dev,
3130
struct device_attribute *attr,
3231
char *buf)
@@ -47,7 +46,6 @@ static ssize_t power_off_acct_show(struct device *dev,
4746

4847
static DEVICE_ATTR_RO(power_on_acct);
4948
static DEVICE_ATTR_RO(power_off_acct);
50-
#endif /* CONFIG_PM */
5149

5250
#define CODEC_INFO_SHOW(type, field) \
5351
static ssize_t type##_show(struct device *dev, \
@@ -745,10 +743,8 @@ static struct attribute *hda_dev_attrs[] = {
745743
&dev_attr_modelname.attr,
746744
&dev_attr_init_pin_configs.attr,
747745
&dev_attr_driver_pin_configs.attr,
748-
#ifdef CONFIG_PM
749746
&dev_attr_power_on_acct.attr,
750747
&dev_attr_power_off_acct.attr,
751-
#endif
752748
#ifdef CONFIG_SND_HDA_RECONFIG
753749
&dev_attr_init_verbs.attr,
754750
&dev_attr_hints.attr,

0 commit comments

Comments
 (0)