Skip to content

Commit 3a675f5

Browse files
sudeep-hollaJassi Brar
authored andcommitted
mailbox: pcc: Refactor error handling in irq handler into separate function
The existing error handling logic in pcc_mbox_irq() is intermixed with the main flow of the function. The command complete check and the complete complete update/acknowledgment are nicely factored into separate functions. Moves error detection and clearing logic into a separate function called: pcc_mbox_error_check_and_clear() by extracting error-handling logic from pcc_mbox_irq(). This ensures error checking and clearing are handled separately and it improves maintainability by keeping the IRQ handler focused on processing events. Acked-by: Huisong Li <lihuisong@huawei.com> Tested-by: Huisong Li <lihuisong@huawei.com> Tested-by: Adam Young <admiyo@os.amperecomputing.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
1 parent d181ace commit 3a675f5

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

drivers/mailbox/pcc.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,25 @@ static bool pcc_mbox_cmd_complete_check(struct pcc_chan_info *pchan)
269269
return !!val;
270270
}
271271

272+
static int pcc_mbox_error_check_and_clear(struct pcc_chan_info *pchan)
273+
{
274+
u64 val;
275+
int ret;
276+
277+
ret = pcc_chan_reg_read(&pchan->error, &val);
278+
if (ret)
279+
return ret;
280+
281+
val &= pchan->error.status_mask;
282+
if (val) {
283+
val &= ~pchan->error.status_mask;
284+
pcc_chan_reg_write(&pchan->error, val);
285+
return -EIO;
286+
}
287+
288+
return 0;
289+
}
290+
272291
static void check_and_ack(struct pcc_chan_info *pchan, struct mbox_chan *chan)
273292
{
274293
struct acpi_pcct_ext_pcc_shared_memory pcc_hdr;
@@ -309,8 +328,6 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
309328
{
310329
struct pcc_chan_info *pchan;
311330
struct mbox_chan *chan = p;
312-
u64 val;
313-
int ret;
314331

315332
pchan = chan->con_priv;
316333

@@ -324,15 +341,8 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
324341
if (!pcc_mbox_cmd_complete_check(pchan))
325342
return IRQ_NONE;
326343

327-
ret = pcc_chan_reg_read(&pchan->error, &val);
328-
if (ret)
344+
if (pcc_mbox_error_check_and_clear(pchan))
329345
return IRQ_NONE;
330-
val &= pchan->error.status_mask;
331-
if (val) {
332-
val &= ~pchan->error.status_mask;
333-
pcc_chan_reg_write(&pchan->error, val);
334-
return IRQ_NONE;
335-
}
336346

337347
/*
338348
* Clear this flag after updating interrupt ack register and just

0 commit comments

Comments
 (0)