From b244d335609f9bbf4c0204a365bf03b7ac53c3c8 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 20 Aug 2012 10:22:25 +0200
Subject: [PATCH] ALSA: hda - Add tracepoints at snd_hda_power_up/down entrances.
Git-commit: b244d335609f9bbf4c0204a365bf03b7ac53c3c8
Patch-mainline: 3.7-rc1
References: FATE#313695

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/hda_codec.c |    2 ++
 sound/pci/hda/hda_trace.h |   24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4423,6 +4423,7 @@ static void __snd_hda_power_up(struct hd
 
 	spin_lock(&codec->power_lock);
 	codec->power_count++;
+	trace_hda_power_count(codec);
 	/* Return if power_on or transitioning to power_on, unless currently
 	 * powering down. */
 	if ((codec->power_on || codec->power_transition > 0) &&
@@ -4502,6 +4503,7 @@ void snd_hda_power_down(struct hda_codec
 {
 	spin_lock(&codec->power_lock);
 	--codec->power_count;
+	trace_hda_power_count(codec);
 	if (!codec->power_on || codec->power_count || codec->power_transition) {
 		spin_unlock(&codec->power_lock);
 		return;
--- a/sound/pci/hda/hda_trace.h
+++ b/sound/pci/hda/hda_trace.h
@@ -87,6 +87,30 @@ DEFINE_EVENT(hda_power, hda_power_up,
 	TP_ARGS(codec)
 );
 
+TRACE_EVENT(hda_power_count,
+	TP_PROTO(struct hda_codec *codec),
+	TP_ARGS(codec),
+	TP_STRUCT__entry(
+		__field( unsigned int, card )
+		__field( unsigned int, addr )
+		__field( int, power_count )
+		__field( int, power_on )
+		__field( int, power_transition )
+	),
+
+	TP_fast_assign(
+		__entry->card = (codec)->bus->card->number;
+		__entry->addr = (codec)->addr;
+		__entry->power_count = (codec)->power_count;
+		__entry->power_on = (codec)->power_on;
+		__entry->power_transition = (codec)->power_transition;
+	),
+
+	TP_printk("[%d:%d] power_count=%d, power_on=%d, power_transition=%d",
+		  __entry->card, __entry->addr, __entry->power_count,
+		  __entry->power_on, __entry->power_transition)
+);
+
 TRACE_EVENT(hda_unsol_event,
 
 	TP_PROTO(struct hda_bus *bus, u32 res, u32 res_ex),
