Skip to content

Commit 66df9fa

Browse files
mjruhlij-intel
authored andcommitted
platform/x86/intel/pmt: refactor base parameter
To support an upcoming crashlog change, use the parent of struct intel_pmt_entry, struct crashlog_entry, as a main parameter. Using struct crashlog_entry will allow for a more flexible interface to control the crashlog feature. - Refactor to use struct crashlog_entry in place of struct intel_pmt_entry - Rename variables from "entry" to "crashlog" Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Michael J. Ruhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent f57b32c commit 66df9fa

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

drivers/platform/x86/intel/pmt/crashlog.c

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ struct pmt_crashlog_priv {
6666
*/
6767

6868
/* Read, modify, write the control register, setting or clearing @bit based on @set */
69-
static void pmt_crashlog_rmw(struct intel_pmt_entry *entry, u32 bit, bool set)
69+
static void pmt_crashlog_rmw(struct crashlog_entry *crashlog, u32 bit, bool set)
7070
{
71+
struct intel_pmt_entry *entry = &crashlog->entry;
7172
u32 reg = readl(entry->disc_table + CONTROL_OFFSET);
7273

7374
reg &= ~CRASHLOG_FLAG_TRIGGER_MASK;
@@ -81,23 +82,24 @@ static void pmt_crashlog_rmw(struct intel_pmt_entry *entry, u32 bit, bool set)
8182
}
8283

8384
/* Read the status register and see if the specified @bit is set */
84-
static bool pmt_crashlog_rc(struct intel_pmt_entry *entry, u32 bit)
85+
static bool pmt_crashlog_rc(struct crashlog_entry *crashlog, u32 bit)
8586
{
87+
struct intel_pmt_entry *entry = &crashlog->entry;
8688
u32 reg = readl(entry->disc_table + CONTROL_OFFSET);
8789

8890
return !!(reg & bit);
8991
}
9092

91-
static bool pmt_crashlog_complete(struct intel_pmt_entry *entry)
93+
static bool pmt_crashlog_complete(struct crashlog_entry *crashlog)
9294
{
9395
/* return current value of the crashlog complete flag */
94-
return pmt_crashlog_rc(entry, CRASHLOG_FLAG_TRIGGER_COMPLETE);
96+
return pmt_crashlog_rc(crashlog, CRASHLOG_FLAG_TRIGGER_COMPLETE);
9597
}
9698

97-
static bool pmt_crashlog_disabled(struct intel_pmt_entry *entry)
99+
static bool pmt_crashlog_disabled(struct crashlog_entry *crashlog)
98100
{
99101
/* return current value of the crashlog disabled flag */
100-
return pmt_crashlog_rc(entry, CRASHLOG_FLAG_DISABLE);
102+
return pmt_crashlog_rc(crashlog, CRASHLOG_FLAG_DISABLE);
101103
}
102104

103105
static bool pmt_crashlog_supported(struct intel_pmt_entry *entry)
@@ -115,20 +117,20 @@ static bool pmt_crashlog_supported(struct intel_pmt_entry *entry)
115117
return crash_type == CRASH_TYPE_OOBMSM && version == 0;
116118
}
117119

118-
static void pmt_crashlog_set_disable(struct intel_pmt_entry *entry,
120+
static void pmt_crashlog_set_disable(struct crashlog_entry *crashlog,
119121
bool disable)
120122
{
121-
pmt_crashlog_rmw(entry, CRASHLOG_FLAG_DISABLE, disable);
123+
pmt_crashlog_rmw(crashlog, CRASHLOG_FLAG_DISABLE, disable);
122124
}
123125

124-
static void pmt_crashlog_set_clear(struct intel_pmt_entry *entry)
126+
static void pmt_crashlog_set_clear(struct crashlog_entry *crashlog)
125127
{
126-
pmt_crashlog_rmw(entry, CRASHLOG_FLAG_TRIGGER_CLEAR, true);
128+
pmt_crashlog_rmw(crashlog, CRASHLOG_FLAG_TRIGGER_CLEAR, true);
127129
}
128130

129-
static void pmt_crashlog_set_execute(struct intel_pmt_entry *entry)
131+
static void pmt_crashlog_set_execute(struct crashlog_entry *crashlog)
130132
{
131-
pmt_crashlog_rmw(entry, CRASHLOG_FLAG_TRIGGER_EXECUTE, true);
133+
pmt_crashlog_rmw(crashlog, CRASHLOG_FLAG_TRIGGER_EXECUTE, true);
132134
}
133135

134136
/*
@@ -137,8 +139,8 @@ static void pmt_crashlog_set_execute(struct intel_pmt_entry *entry)
137139
static ssize_t
138140
enable_show(struct device *dev, struct device_attribute *attr, char *buf)
139141
{
140-
struct intel_pmt_entry *entry = dev_get_drvdata(dev);
141-
bool enabled = !pmt_crashlog_disabled(entry);
142+
struct crashlog_entry *crashlog = dev_get_drvdata(dev);
143+
bool enabled = !pmt_crashlog_disabled(crashlog);
142144

143145
return sprintf(buf, "%d\n", enabled);
144146
}
@@ -147,19 +149,19 @@ static ssize_t
147149
enable_store(struct device *dev, struct device_attribute *attr,
148150
const char *buf, size_t count)
149151
{
150-
struct crashlog_entry *entry;
152+
struct crashlog_entry *crashlog;
151153
bool enabled;
152154
int result;
153155

154-
entry = dev_get_drvdata(dev);
156+
crashlog = dev_get_drvdata(dev);
155157

156158
result = kstrtobool(buf, &enabled);
157159
if (result)
158160
return result;
159161

160-
guard(mutex)(&entry->control_mutex);
162+
guard(mutex)(&crashlog->control_mutex);
161163

162-
pmt_crashlog_set_disable(&entry->entry, !enabled);
164+
pmt_crashlog_set_disable(crashlog, !enabled);
163165

164166
return count;
165167
}
@@ -168,11 +170,11 @@ static DEVICE_ATTR_RW(enable);
168170
static ssize_t
169171
trigger_show(struct device *dev, struct device_attribute *attr, char *buf)
170172
{
171-
struct intel_pmt_entry *entry;
173+
struct crashlog_entry *crashlog;
172174
bool trigger;
173175

174-
entry = dev_get_drvdata(dev);
175-
trigger = pmt_crashlog_complete(entry);
176+
crashlog = dev_get_drvdata(dev);
177+
trigger = pmt_crashlog_complete(crashlog);
176178

177179
return sprintf(buf, "%d\n", trigger);
178180
}
@@ -181,32 +183,32 @@ static ssize_t
181183
trigger_store(struct device *dev, struct device_attribute *attr,
182184
const char *buf, size_t count)
183185
{
184-
struct crashlog_entry *entry;
186+
struct crashlog_entry *crashlog;
185187
bool trigger;
186188
int result;
187189

188-
entry = dev_get_drvdata(dev);
190+
crashlog = dev_get_drvdata(dev);
189191

190192
result = kstrtobool(buf, &trigger);
191193
if (result)
192194
return result;
193195

194-
guard(mutex)(&entry->control_mutex);
196+
guard(mutex)(&crashlog->control_mutex);
195197

196198
/* if device is currently disabled, return busy */
197-
if (pmt_crashlog_disabled(&entry->entry))
199+
if (pmt_crashlog_disabled(crashlog))
198200
return -EBUSY;
199201

200202
if (!trigger) {
201-
pmt_crashlog_set_clear(&entry->entry);
203+
pmt_crashlog_set_clear(crashlog);
202204
return count;
203205
}
204206

205207
/* we cannot trigger a new crash if one is still pending */
206-
if (pmt_crashlog_complete(&entry->entry))
208+
if (pmt_crashlog_complete(crashlog))
207209
return -EEXIST;
208210

209-
pmt_crashlog_set_execute(&entry->entry);
211+
pmt_crashlog_set_execute(crashlog);
210212

211213
return count;
212214
}

0 commit comments

Comments
 (0)