[Skiboot] [PATCH V4 1/6] opal/errorlog : Modification as per coding guidelines to make the code more legible

Mukesh Ojha mukesh02 at linux.vnet.ibm.com
Tue Jul 26 15:45:33 AEST 2016


Some modifications related to typo errors, alignment, case letter mismatch etc.
to add more clarity to the code.

Signed-off-by: Mukesh Ojha <mukesh02 at linux.vnet.ibm.com>
---
Changes in V4:
 - V3 2/6 becomes V4 1/6 .
 - Some modification in core/errorlog.c .
 - Changes are rebased on master.

Changes in V3:
 -Some more correction moved from 3/6 and 6/6 to this patch.

Changes in V2:
 - New Patch.

 core/errorlog.c         |  30 +++----
 hw/fsp/fsp-elog-read.c  | 204 +++++++++++++++++++++---------------------------
 hw/fsp/fsp-elog-write.c | 111 +++++++++++++-------------
 hw/ipmi/ipmi-sel.c      |  94 ++++++++++------------
 4 files changed, 204 insertions(+), 235 deletions(-)

diff --git a/core/errorlog.c b/core/errorlog.c
index c34251b..3c320f4 100644
--- a/core/errorlog.c
+++ b/core/errorlog.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,19 +27,18 @@
 /*
  * Maximum number buffers that are pre-allocated
  * to hold elogs that are reported on Sapphire and
- * powernv.
+ * PowerNV.
  */
 #define ELOG_WRITE_MAX_RECORD		64
-
-/* Platform Log ID as per the spec */
+/* Platform log id as per the spec */
 static uint32_t sapphire_elog_id = 0xB0000000;
+
 /* Reserved for future use */
 /* static uint32_t powernv_elog_id = 0xB1000000; */
 
 /* Pool to allocate elog messages from */
 static struct pool elog_pool;
 static struct lock elog_lock = LOCK_UNLOCKED;
-
 static bool elog_available = false;
 
 static struct errorlog *get_write_buffer(int opal_event_severity)
@@ -54,6 +53,7 @@ static struct errorlog *get_write_buffer(int opal_event_severity)
 		buf = pool_get(&elog_pool, POOL_HIGH);
 	else
 		buf = pool_get(&elog_pool, POOL_NORMAL);
+
 	unlock(&elog_lock);
 	return buf;
 }
@@ -72,11 +72,9 @@ struct errorlog *opal_elog_create(struct opal_err_info *e_info, uint32_t tag)
 		buf->event_subtype = e_info->event_subtype;
 		buf->reason_code = e_info->reason_code;
 		buf->elog_origin = ORG_SAPPHIRE;
-
 		lock(&elog_lock);
 		buf->plid = ++sapphire_elog_id;
 		unlock(&elog_lock);
-
 		/* Initialise the first user dump section */
 		log_add_section(buf, tag);
 	}
@@ -106,7 +104,6 @@ void log_add_section(struct errorlog *buf, uint32_t tag)
 	/* Use DESC if no other tag provided */
 	tmp->tag = tag ? tag : 0x44455343;
 	tmp->size = size;
-
 	buf->user_section_size += tmp->size;
 	buf->user_section_count++;
 }
@@ -132,8 +129,10 @@ void log_commit(struct errorlog *elog)
 		rc = platform.elog_commit(elog);
 		if (rc)
 			prerror("ELOG: Platform commit error %d\n", rc);
+
 		return;
 	}
+
 	opal_elog_complete(elog, false);
 }
 
@@ -156,7 +155,6 @@ void log_append_data(struct errorlog *buf, unsigned char *data, uint16_t size)
 	/* Step through user sections to find latest dump section */
 	buffer = buf->user_data_dump;
 	n_sections = buf->user_section_count;
-
 	if (!n_sections) {
 		prerror("ELOG: User section invalid\n");
 		return;
@@ -170,7 +168,6 @@ void log_append_data(struct errorlog *buf, unsigned char *data, uint16_t size)
 	section = (struct elog_user_data_section *)buffer;
 	buffer += section->size;
 	memcpy(buffer, data, size);
-
 	section->size += size;
 	buf->user_section_size += size;
 }
@@ -188,10 +185,8 @@ void log_append_msg(struct errorlog *buf, const char *fmt, ...)
 	va_start(list, fmt);
 	vsnprintf(err_msg, sizeof(err_msg), fmt, list);
 	va_end(list);
-
 	/* Log the error on to Sapphire console */
 	prerror("%s", err_msg);
-
 	log_append_data(buf, err_msg, strlen(err_msg));
 }
 
@@ -204,14 +199,12 @@ void log_simple_error(struct opal_err_info *e_info, const char *fmt, ...)
 	va_start(list, fmt);
 	vsnprintf(err_msg, sizeof(err_msg), fmt, list);
 	va_end(list);
-
 	/* Log the error on to Sapphire console */
 	prerror("%s", err_msg);
-
 	buf = opal_elog_create(e_info, 0);
-	if (buf == NULL)
+	if (buf == NULL) {
 		prerror("ELOG: Error getting buffer to log error\n");
-	else {
+	} else {
 		log_append_data(buf, err_msg, strlen(err_msg));
 		log_commit(buf);
 	}
@@ -219,8 +212,9 @@ void log_simple_error(struct opal_err_info *e_info, const char *fmt, ...)
 
 int elog_init(void)
 {
-	/* pre-allocate memory for records */
-	if (pool_init(&elog_pool, sizeof(struct errorlog), ELOG_WRITE_MAX_RECORD, 1))
+	/* Pre-allocate memory for records */
+	if (pool_init(&elog_pool, sizeof(struct errorlog),
+					ELOG_WRITE_MAX_RECORD, 1))
 		return OPAL_RESOURCE;
 
 	elog_available = true;
diff --git a/hw/fsp/fsp-elog-read.c b/hw/fsp/fsp-elog-read.c
index 4f0bf16..3a0aa5a 100644
--- a/hw/fsp/fsp-elog-read.c
+++ b/hw/fsp/fsp-elog-read.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,44 +16,39 @@
 
 
 /*
- * This code will enable retrieving of error log from fsp->sapphire
- * in sequence.
- * Here, FSP would send next log only when sapphire sends a new
- * log notification response to FSP. On Completion of reading
- * the log from FSP, OPAL_EVENT_ERROR_LOG_AVAIL is signaled.
- * This will remain raised until a call to opal_elog_read()
- * is made and OPAL_SUCCESS is returned, upon which.
- * the operation is complete and the event is cleared.
- * This is READ action from FSP.
+ * This code will enable retrieving of error log from fsp->sapphire in sequence.
+ * Here, FSP would send next log only when Sapphire sends a new log notification
+ * response to FSP. On Completion of reading the log from FSP,
+ * OPAL_EVENT_ERROR_LOG_AVAIL is signaled. This will remain raised until a call
+ * to opal_elog_read() is made and OPAL_SUCCESS is returned. Upon which, the
+ * operation is complete and the event is cleared. This is READ action from FSP.
  */
 
 /*
  * Design of READ error log :
- * When we receive a new error log entry notificatiion from FSP,
- * we queue it into the "pending" list.
- * If the "pending" list is not empty, then we start the fetching log from FSP.
+ * When we receive a new error log entry notification from FSP, we queue it into
+ * the "pending" list. If the "pending" list is not empty, then we start
+ * fetching log from FSP.
  *
- * When Linux reads a log entry, we dequeue it from the "pending" list
- * and enqueue it to another "processed" list. At this point, if the
- * "pending" list is not empty, we continue to fetch the next log.
+ * When Linux reads a log entry, we dequeue it from the "pending" list and
+ * enqueue it to another "processed" list. At this point, if the "pending"
+ * list is not empty, we continue to fetch the next log.
  *
- * When Linux calls opal_resend_pending_logs(), we fetch the log
- * corresponding to the head of the pending list and move it to the
- * processed list, and continue this process this until the pending list is
- * empty. If the pending list was empty earlier and is currently non-empty, we
- * initiate an error log fetch.
+ * When Linux calls opal_resend_pending_logs(), we fetch the log corresponding
+ * to the head of the pending list and move it to the processed list, and
+ * continue this process until the pending list is empty. If the pending list
+ * was empty earlier and is currently non-empty, we initiate an error log fetch.
  *
  * When Linux acks an error log, we remove it from processed list.
  */
 
-#include <skiboot.h>
-#include <fsp.h>
-#include <cpu.h>
-#include <lock.h>
 #include <errno.h>
-#include <psi.h>
+#include <fsp.h>
 #include <fsp-elog.h>
+#include <lock.h>
 #include <opal-api.h>
+#include <psi.h>
+#include <skiboot.h>
 
 /*
  * Maximum number of entries that are pre-allocated
@@ -61,7 +56,7 @@
  */
 #define ELOG_READ_MAX_RECORD		128
 
-/* structure to maintain log-id,log-size, pending and processed list */
+/* Structure to maintain log-id, log-size, pending and processed list. */
 struct fsp_log_entry {
 	uint32_t log_id;
 	size_t log_size;
@@ -71,30 +66,28 @@ struct fsp_log_entry {
 static LIST_HEAD(elog_read_pending);
 static LIST_HEAD(elog_read_processed);
 static LIST_HEAD(elog_read_free);
-
 /*
- * lock is used to protect overwriting of processed and pending list
- * and also used while updating state of each log
+ * Lock is used to protect overwriting of processed and pending list
+ * and also used while updating state of each log.
  */
 static struct lock elog_read_lock = LOCK_UNLOCKED;
 
-/* log buffer  to copy FSP log for READ */
-#define ELOG_READ_BUFFER_SIZE	0x00004000
+#define ELOG_READ_BUFFER_SIZE		0x00004000
+/* Log buffer to copy FSP log for read */
 static void *elog_read_buffer;
 static uint32_t elog_head_id;	/* FSP entry ID */
-static size_t elog_head_size;	/* actual FSP log size */
-static uint32_t elog_read_retries;	/* bad response status count */
+static size_t elog_head_size;	/* Actual FSP log size */
+static uint32_t elog_read_retries;	/* Bad response status count */
 
 /* Initialize the state of the log */
 static enum elog_head_state elog_read_from_fsp_head_state = ELOG_STATE_NONE;
-
 static bool elog_enabled;
 
-/* Need forward declaration because of Circular dependency */
+/* Need forward declaration because of circular dependency. */
 static void fsp_elog_queue_fetch(void);
 
 /*
- * check the response message for mbox acknowledgment
+ * Check the response message for mbox acknowledgement
  * command send to FSP.
  */
 static void fsp_elog_ack_complete(struct fsp_msg *msg)
@@ -103,14 +96,14 @@ static void fsp_elog_ack_complete(struct fsp_msg *msg)
 
 	val = (msg->resp->word1 >> 8) & 0xff;
 	if (val != 0)
-		prerror("ELOG: Acknowledgment error\n");
+		prerror("ELOG: Acknowledgement error\n");
+
 	fsp_freemsg(msg);
 }
 
-/* send Error Log PHYP Acknowledgment to FSP with entry ID */
+/* Send error log PHYP acknowledgement to FSP with entry ID. */
 static int64_t fsp_send_elog_ack(uint32_t log_id)
 {
-
 	struct fsp_msg *ack_msg;
 
 	ack_msg = fsp_mkmsg(FSP_CMD_ERRLOG_PHYP_ACK, 1, log_id);
@@ -118,23 +111,24 @@ static int64_t fsp_send_elog_ack(uint32_t log_id)
 		prerror("ELOG: Failed to allocate ack message\n");
 		return OPAL_INTERNAL_ERROR;
 	}
+
 	if (fsp_queue_msg(ack_msg, fsp_elog_ack_complete)) {
 		fsp_freemsg(ack_msg);
 		ack_msg = NULL;
 		prerror("ELOG: Error queueing elog ack complete\n");
 		return OPAL_INTERNAL_ERROR;
 	}
+
 	return OPAL_SUCCESS;
 }
 
-/* retrive error log from FSP with TCE for the data transfer */
+/* Retrieve error log from FSP with TCE for the data transfer. */
 static void fsp_elog_check_and_fetch_head(void)
 {
 	if (!elog_enabled)
 		return;
 
 	lock(&elog_read_lock);
-
 	if (elog_read_from_fsp_head_state != ELOG_STATE_NONE ||
 			list_empty(&elog_read_pending)) {
 		unlock(&elog_read_lock);
@@ -142,7 +136,6 @@ static void fsp_elog_check_and_fetch_head(void)
 	}
 
 	elog_read_retries = 0;
-
 	/* Start fetching first entry from the pending list */
 	fsp_elog_queue_fetch();
 	unlock(&elog_read_lock);
@@ -163,14 +156,14 @@ void elog_set_head_state(bool opal_logs, enum elog_head_state state)
 		fsp_logs_state = state;
 
 	if (fsp_logs_state == ELOG_STATE_FETCHED_DATA ||
-	    opal_logs_state == ELOG_STATE_FETCHED_DATA)
+		opal_logs_state == ELOG_STATE_FETCHED_DATA)
 		opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL,
 					OPAL_EVENT_ERROR_LOG_AVAIL);
 	else
 		opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL, 0);
 }
 
-/* this function should be called with the lock held */
+/* This function should be called with the lock held. */
 static inline void fsp_elog_set_head_state(enum elog_head_state state)
 {
 	elog_set_head_state(false, state);
@@ -178,20 +171,20 @@ static inline void fsp_elog_set_head_state(enum elog_head_state state)
 }
 
 /*
- * when we try maximum time of fetching log from fsp
+ * When, we try maximum time of fetching log from FSP
  * we call following function to delete log from the
- * pending list and update the state to fetch next log
+ * pending list and update the state to fetch next log.
  *
- * this function should be called with the lock held
+ * This function should be called with the lock held.
  */
 static void fsp_elog_fetch_failure(uint8_t fsp_status)
 {
 	struct fsp_log_entry *log_data;
 
-	/* read top list and delete the node */
+	/* Read top list and delete the node */
 	log_data = list_top(&elog_read_pending, struct fsp_log_entry, link);
 	if (!log_data) {
-		/**
+		/*
 		 * @fwts-label ElogFetchFailureInconsistent
 		 * @fwts-advice Inconsistent state between OPAL and FSP
 		 * in code path for handling failure of fetching error log
@@ -204,8 +197,8 @@ static void fsp_elog_fetch_failure(uint8_t fsp_status)
 		list_add(&elog_read_free, &log_data->link);
 		prerror("ELOG: received invalid data: %x FSP status: 0x%x\n",
 			log_data->log_id, fsp_status);
-
 	}
+
 	fsp_elog_set_head_state(ELOG_STATE_NONE);
 }
 
@@ -213,12 +206,10 @@ static void fsp_elog_fetch_failure(uint8_t fsp_status)
 static void fsp_elog_read_complete(struct fsp_msg *read_msg)
 {
 	uint8_t val;
-	/*struct fsp_log_entry *log_data;*/
 
 	lock(&elog_read_lock);
 	val = (read_msg->resp->word1 >> 8) & 0xff;
 	fsp_freemsg(read_msg);
-
 	if (elog_read_from_fsp_head_state == ELOG_STATE_REJECTED) {
 		fsp_elog_set_head_state(ELOG_STATE_NONE);
 		goto elog_read_out;
@@ -232,14 +223,15 @@ static void fsp_elog_read_complete(struct fsp_msg *read_msg)
 	case FSP_STATUS_DMA_ERROR:
 		if (elog_read_retries++ < MAX_RETRIES) {
 			/*
-			 * for a error response value from FSP, we try to
+			 * For a error response value from FSP, we try to
 			 * send fetch sp data mbox command again for three
 			 * times if response from FSP is still not valid
-			 * we send generic error response to fsp.
+			 * we send generic error response to FSP.
 			 */
 			fsp_elog_queue_fetch();
 			break;
 		}
+
 		fsp_elog_fetch_failure(val);
 		break;
 
@@ -249,12 +241,11 @@ static void fsp_elog_read_complete(struct fsp_msg *read_msg)
 
 elog_read_out:
 	unlock(&elog_read_lock);
-
 	/* Check if a new log needs fetching */
 	fsp_elog_check_and_fetch_head();
 }
 
-/* read error log from FSP through mbox commands */
+/* Read error log from FSP through mbox commands */
 static void fsp_elog_queue_fetch(void)
 {
 	int rc;
@@ -263,21 +254,21 @@ static void fsp_elog_queue_fetch(void)
 
 	entry = list_top(&elog_read_pending, struct fsp_log_entry, link);
 	if (!entry) {
-		/**
+		/*
 		 * @fwts-label ElogQueueInconsistent
 		 * @fwts-advice Bug in interaction between FSP and OPAL. We
 		 * expected there to be a pending read from FSP but the list
 		 * was empty.
 		 */
 		prlog(PR_ERR, "%s: Inconsistent internal list state !\n",
-		      __func__);
+			__func__);
 		fsp_elog_set_head_state(ELOG_STATE_NONE);
 		return;
 	}
+
 	fsp_elog_set_head_state(ELOG_STATE_FETCHING);
 	elog_head_id = entry->log_id;
 	elog_head_size = entry->log_size;
-
 	rc = fsp_fetch_data_queue(flags, FSP_DATASET_ERRLOG, elog_head_id,
 				  0, (void *)PSI_DMA_ERRLOG_READ_BUF,
 				  &elog_head_size, fsp_elog_read_complete);
@@ -287,15 +278,14 @@ static void fsp_elog_queue_fetch(void)
 	}
 }
 
-/* opal interface for powernv to read log size and log ID from sapphire */
+/* OPAL interface for PowerNV to read log size and log ID from Sapphire. */
 static int64_t fsp_opal_elog_info(uint64_t *opal_elog_id,
 				  uint64_t *opal_elog_size, uint64_t *elog_type)
 {
 	struct fsp_log_entry *log_data;
 
-	/* copy type of the error log */
+	/* Copy type of the error log */
 	*elog_type = ELOG_TYPE_PEL;
-
 	/* Check if any OPAL log needs to be reported to the host */
 	if (opal_elog_info(opal_elog_id, opal_elog_size))
 		return OPAL_SUCCESS;
@@ -305,9 +295,10 @@ static int64_t fsp_opal_elog_info(uint64_t *opal_elog_id,
 		unlock(&elog_read_lock);
 		return OPAL_WRONG_STATE;
 	}
+
 	log_data = list_top(&elog_read_pending, struct fsp_log_entry, link);
 	if (!log_data) {
-		/**
+		/*
 		 * @fwts-label ElogInfoInconsistentState
 		 * @fwts-advice We expected there to be an entry in the list
 		 * of error logs for the error log we're fetching information
@@ -319,6 +310,7 @@ static int64_t fsp_opal_elog_info(uint64_t *opal_elog_id,
 		unlock(&elog_read_lock);
 		return OPAL_WRONG_STATE;
 	}
+
 	*opal_elog_id = log_data->log_id;
 	*opal_elog_size = log_data->log_size;
 	fsp_elog_set_head_state(ELOG_STATE_HOST_INFO);
@@ -326,20 +318,20 @@ static int64_t fsp_opal_elog_info(uint64_t *opal_elog_id,
 	return OPAL_SUCCESS;
 }
 
-/* opal interface for powernv to read log from sapphire */
+/* OPAL interface for PowerNV to read log from Sapphire. */
 static int64_t fsp_opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
 				  uint64_t opal_elog_id)
 {
 	int size = opal_elog_size;
 	struct fsp_log_entry *log_data;
 
-
-	/* Check if any OPAL log needs to be reported to the host */
+	/* Check if any OPAL log needs to be reported to the PowerNV */
 	if (opal_elog_read(buffer, opal_elog_size, opal_elog_id))
 		return OPAL_SUCCESS;
+
 	/*
 	 * Read top entry from list.
-	 * as we know always top record of the list is fetched from FSP
+	 * As we know always top record of the list is fetched from FSP
 	 */
 	lock(&elog_read_lock);
 	if (elog_read_from_fsp_head_state != ELOG_STATE_HOST_INFO) {
@@ -349,7 +341,7 @@ static int64_t fsp_opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
 
 	log_data = list_top(&elog_read_pending, struct fsp_log_entry, link);
 	if (!log_data) {
-		/**
+		/*
 		 * @fwts-label ElogReadInconsistentState
 		 * @fwts-advice Inconsistent state while reading error log
 		 * from FSP. Bug in OPAL and FSP interaction.
@@ -373,25 +365,21 @@ static int64_t fsp_opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
 
 	memset((void *)buffer, 0, opal_elog_size);
 	memcpy((void *)buffer, elog_read_buffer, size);
-
 	/*
-	 * once log is read from linux move record from pending
+	 * Once log is read from linux move record from pending
 	 * to processed list and delete record from pending list
-	 * and change state of the log to fetch next record
+	 * and change state of the log to fetch next record.
 	 */
 	list_del(&log_data->link);
 	list_add(&elog_read_processed, &log_data->link);
 	fsp_elog_set_head_state(ELOG_STATE_NONE);
 	unlock(&elog_read_lock);
-
-
-	/* read error log from FSP */
+	/* Read error log from FSP */
 	fsp_elog_check_and_fetch_head();
-
 	return OPAL_SUCCESS;
 }
 
-/* set state of the log head before fetching the log */
+/* Set state of the log head before fetching the log. */
 static void elog_reject_head(void)
 {
 	if (elog_read_from_fsp_head_state == ELOG_STATE_FETCHING)
@@ -400,7 +388,7 @@ static void elog_reject_head(void)
 		fsp_elog_set_head_state(ELOG_STATE_NONE);
 }
 
-/* opal Interface for powernv to send ack to fsp with log ID */
+/* OPAL interface for PowerNV to send ack to FSP with log ID */
 static int64_t fsp_opal_elog_ack(uint64_t ack_id)
 {
 	int rc = 0;
@@ -415,6 +403,7 @@ static int64_t fsp_opal_elog_ack(uint64_t ack_id)
 		prerror("ELOG: failed to send acknowledgement: %d\n", rc);
 		return rc;
 	}
+
 	lock(&elog_read_lock);
 	list_for_each_safe(&elog_read_processed, record, next_record, link) {
 		if (record->log_id != ack_id)
@@ -424,13 +413,15 @@ static int64_t fsp_opal_elog_ack(uint64_t ack_id)
 		unlock(&elog_read_lock);
 		return rc;
 	}
+
 	list_for_each_safe(&elog_read_pending, record, next_record, link) {
 		if (record->log_id != ack_id)
 			continue;
-		/* It means host has sent ACK without reading actual data.
+
+		/* It means PowerNV has sent ACK without reading actual data.
 		 * Because of this elog_read_from_fsp_head_state may be
 		 * stuck in wrong state (ELOG_STATE_HOST_INFO) and not able
-		 * to send remaining ELOGs to host. Hence reset ELOG state
+		 * to send remaining ELOGs to PowerNV. Hence reset ELOG state
 		 * and start sending remaining ELOGs.
 		 */
 		list_del(&record->link);
@@ -440,14 +431,14 @@ static int64_t fsp_opal_elog_ack(uint64_t ack_id)
 		fsp_elog_check_and_fetch_head();
 		return rc;
 	}
-	unlock(&elog_read_lock);
 
+	unlock(&elog_read_lock);
 	return OPAL_PARAMETER;
 }
 
 /*
- * once linux kexec's it ask to resend all logs which
- * are not acknowledged from  linux
+ * Once Linux kexec's it ask to resend all logs which
+ * are not acknowledged from Linux.
  */
 static void fsp_opal_resend_pending_logs(void)
 {
@@ -456,10 +447,8 @@ static void fsp_opal_resend_pending_logs(void)
 	lock(&elog_read_lock);
 	elog_enabled = true;
 	unlock(&elog_read_lock);
-
-	/* Check if any Sapphire logs are pending */
+	/* Check if any Sapphire logs are pending. */
 	opal_resend_pending_logs();
-
 	lock(&elog_read_lock);
 	/*
 	 * If processed list is not empty add all record from
@@ -473,13 +462,12 @@ static void fsp_opal_resend_pending_logs(void)
 	}
 
 	unlock(&elog_read_lock);
-
 	/* Read error log from FSP */
 	elog_reject_head();
 	fsp_elog_check_and_fetch_head();
 }
 
-/* Disable ELOG event flag until host is ready to receive event */
+/* Disable ELOG event flag until PowerNV is ready to receive event */
 static bool opal_kexec_elog_notify(void *data __unused)
 {
 	lock(&elog_read_lock);
@@ -487,11 +475,10 @@ static bool opal_kexec_elog_notify(void *data __unused)
 	elog_enabled = false;
 	opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL, 0);
 	unlock(&elog_read_lock);
-
 	return true;
 }
 
-/* fsp elog notify function  */
+/* FSP elog notify function */
 static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
 {
 	int rc = 0;
@@ -499,16 +486,13 @@ static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
 	uint32_t log_id;
 	uint32_t log_size;
 
-
 	if (cmd_sub_mod != FSP_CMD_ERRLOG_NOTIFICATION)
 		return false;
 
 	log_id = msg->data.words[0];
 	log_size = msg->data.words[1];
-
 	printf("ELOG: Notified of log 0x%08x (size: %d)\n",
 	       log_id, log_size);
-
 	/* Make sure we don't cross read buffer size */
 	if (log_size > ELOG_READ_BUFFER_SIZE) {
 		log_size = ELOG_READ_BUFFER_SIZE;
@@ -516,40 +500,37 @@ static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
 		       log_id, log_size);
 	}
 
-	/* take a lock until we take out the node from elog_read_free */
+	/* Take a lock until we take out the node from elog_read_free */
 	lock(&elog_read_lock);
 	if (!list_empty(&elog_read_free)) {
-		/* Create a new entry in the pending list */
+		/* Create a new entry in the pending list. */
 		record = list_pop(&elog_read_free, struct fsp_log_entry, link);
 		record->log_id = log_id;
 		record->log_size = log_size;
 		list_add_tail(&elog_read_pending, &record->link);
 		unlock(&elog_read_lock);
-
-		/* Send response back to FSP for a new elog notify message */
+		/* Send response back to FSP for a new elog notify message. */
 		rc = fsp_queue_msg(fsp_mkmsg(FSP_RSP_ERRLOG_NOTIFICATION,
 					1, log_id), fsp_freemsg);
 		if (rc)
 			prerror("ELOG: Failed to queue errlog notification"
 				" response: %d\n", rc);
 
-		/* read error log from FSP */
+		/* Read error log from FSP */
 		fsp_elog_check_and_fetch_head();
-
 	} else {
 		printf("ELOG: Log entry 0x%08x discarded\n", log_id);
-
-		/* unlock if elog_read_free is empty */
+		/* Unlock if elog_read_free is empty. */
 		unlock(&elog_read_lock);
-
 		rc = fsp_queue_msg(fsp_mkmsg(FSP_RSP_ERRLOG_NOTIFICATION,
 					     1, log_id), fsp_freemsg);
 		if (rc)
 			prerror("ELOG: Failed to queue errlog notification"
 				" response: %d\n", rc);
+
 		/*
-		 * if list is full with max record then we
-		 * send discarded by phyp (condition full) ack to FSP.
+		 * If list is full with max record then we send discarded by
+		 * phyp (condition full) ack to FSP.
 		 *
 		 * At some point in the future, we'll get notified again.
 		 * This is largely up to FSP as to when they tell us about
@@ -583,13 +564,14 @@ static int init_elog_read_free_list(uint32_t num_entries)
 		list_add_tail(&elog_read_free, &entry->link);
 		entry++;
 	}
+
 	return 0;
 
 out_err:
 	return -ENOMEM;
 }
 
-/* fsp elog read init function */
+/* FSP elog read init function */
 void fsp_elog_read_init(void)
 {
 	int val = 0;
@@ -606,21 +588,17 @@ void fsp_elog_read_init(void)
 	/* Map TCEs */
 	fsp_tce_map(PSI_DMA_ERRLOG_READ_BUF, elog_read_buffer,
 					PSI_DMA_ERRLOG_READ_BUF_SZ);
-
-	/* pre allocate memory for 128 record */
+	/* Pre allocate memory for 128 record */
 	val = init_elog_read_free_list(ELOG_READ_MAX_RECORD);
 	if (val != 0)
 		return;
 
 	elog_enabled = true;
-
-	/* register Eror log Class D2 */
+	/* Register error log class D2 */
 	fsp_register_client(&fsp_get_elog_notify, FSP_MCLASS_ERR_LOG);
-
-	/* Register for sync on host reboot call */
+	/* Register for sync on PowerNV reboot call */
 	opal_add_host_sync_notifier(opal_kexec_elog_notify, NULL);
-
-	/* register opal Interface */
+	/* Register OPAL interface */
 	opal_register(OPAL_ELOG_READ, fsp_opal_elog_read, 3);
 	opal_register(OPAL_ELOG_ACK, fsp_opal_elog_ack, 1);
 	opal_register(OPAL_ELOG_RESEND, fsp_opal_resend_pending_logs, 0);
diff --git a/hw/fsp/fsp-elog-write.c b/hw/fsp/fsp-elog-write.c
index f38c236..26bef95 100644
--- a/hw/fsp/fsp-elog-write.c
+++ b/hw/fsp/fsp-elog-write.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,24 @@
 
 
 /*
- * This code will enable generation and pushing of error log
- * from powernv, sapphire to FSP
- * Critical events from sapphire that needs to be reported
- * will be pushed on to FSP after converting the
- * error log to Platform Error Log (PEL) format.
- * This is termed as WRITE action to FSP.
+ * This code will enable generation and pushing of error log from PowerNV,
+ * Sapphire to FSP.
+ *
+ * Critical events from Sapphire that needs to be reported will be pushed
+ * on to FSP after converting the error log to Platform Error Log(PEL) format.
+ * This is termed as write action to FSP.
  */
 
-#include <skiboot.h>
-#include <fsp.h>
 #include <cpu.h>
-#include <lock.h>
 #include <errno.h>
+#include <fsp.h>
 #include <fsp-elog.h>
-#include <timebase.h>
+#include <lock.h>
+#include <opal-api.h>
 #include <pel.h>
 #include <pool.h>
-#include <opal-api.h>
+#include <skiboot.h>
+#include <timebase.h>
 
 static LIST_HEAD(elog_write_to_fsp_pending);
 static LIST_HEAD(elog_write_to_host_pending);
@@ -43,8 +43,8 @@ static struct lock elog_write_lock = LOCK_UNLOCKED;
 static struct lock elog_panic_write_lock = LOCK_UNLOCKED;
 static struct lock elog_write_to_host_lock = LOCK_UNLOCKED;
 
-/* log buffer  to copy FSP log for READ */
 #define ELOG_WRITE_TO_FSP_BUFFER_SIZE	0x00004000
+/* Log buffer to copy OPAL log for write to FSP */
 static void *elog_write_to_fsp_buffer;
 
 #define ELOG_PANIC_WRITE_BUFFER_SIZE	0x00004000
@@ -52,14 +52,13 @@ static void *elog_panic_write_buffer;
 
 #define ELOG_WRITE_TO_HOST_BUFFER_SIZE	0x00004000
 static void *elog_write_to_host_buffer;
-
 static uint32_t elog_write_retries;
 
 /* Manipulate this only with write_lock held */
 static uint32_t elog_plid_fsp_commit = -1;
 static enum elog_head_state elog_write_to_host_head_state = ELOG_STATE_NONE;
 
-/* Need forward declaration because of Circular dependency */
+/* Need forward declaration because of circular dependency */
 static int opal_send_elog_to_fsp(void);
 
 static void remove_elog_head_entry(void)
@@ -73,11 +72,13 @@ static void remove_elog_head_entry(void)
 		if (head->plid == elog_plid_fsp_commit) {
 			entry = list_pop(&elog_write_to_fsp_pending,
 					struct errorlog, link);
-			opal_elog_complete(entry, elog_write_retries < MAX_RETRIES);
+			opal_elog_complete(entry,
+					elog_write_retries < MAX_RETRIES);
 			/* Reset the counter */
 			elog_plid_fsp_commit = -1;
 		}
 	}
+
 	elog_write_retries = 0;
 	unlock(&elog_write_lock);
 }
@@ -88,17 +89,16 @@ static void opal_fsp_write_complete(struct fsp_msg *read_msg)
 
 	val = (read_msg->resp->word1 >> 8) & 0xff;
 	fsp_freemsg(read_msg);
-
 	switch (val) {
 	case FSP_STATUS_SUCCESS:
-			remove_elog_head_entry();
-			break;
-
+		remove_elog_head_entry();
+		break;
 	default:
 		if (elog_write_retries++ >= MAX_RETRIES) {
 			remove_elog_head_entry();
 			prerror("ELOG: Error in writing to FSP (0x%x)!\n", val);
 		}
+
 		break;
 	}
 
@@ -106,7 +106,7 @@ static void opal_fsp_write_complete(struct fsp_msg *read_msg)
 		prerror("ELOG: Error sending elog to FSP !\n");
 }
 
-/* write PEL format hex dump of the log to FSP */
+/* Write PEL format hex dump of the log to FSP */
 static int64_t fsp_opal_elog_write(size_t opal_elog_size)
 {
 	struct fsp_msg *elog_msg;
@@ -117,12 +117,14 @@ static int64_t fsp_opal_elog_write(size_t opal_elog_size)
 		prerror("ELOG: Failed to create message for WRITE to FSP\n");
 		return OPAL_INTERNAL_ERROR;
 	}
+
 	if (fsp_queue_msg(elog_msg, opal_fsp_write_complete)) {
 		fsp_freemsg(elog_msg);
 		elog_msg = NULL;
 		prerror("FSP: Error queueing elog update\n");
 		return OPAL_INTERNAL_ERROR;
 	}
+
 	return OPAL_SUCCESS;
 }
 
@@ -143,7 +145,7 @@ bool opal_elog_info(uint64_t *opal_elog_id, uint64_t *opal_elog_size)
 		head = list_top(&elog_write_to_host_pending,
 					struct errorlog, link);
 		if (!head) {
-			/**
+			/*
 			 * @fwts-label ElogListInconsistent
 			 * @fwts-advice Bug in interaction between FSP and
 			 * OPAL. The state maintained by OPAL didn't match
@@ -160,13 +162,13 @@ bool opal_elog_info(uint64_t *opal_elog_id, uint64_t *opal_elog_size)
 			rc = true;
 		}
 	}
+
 	unlock(&elog_write_to_host_lock);
 	return rc;
 }
 
 static void opal_commit_elog_in_host(void)
 {
-
 	struct errorlog *buf;
 
 	lock(&elog_write_to_host_lock);
@@ -175,14 +177,14 @@ static void opal_commit_elog_in_host(void)
 		buf = list_top(&elog_write_to_host_pending,
 				struct errorlog, link);
 		buf->log_size = create_pel_log(buf,
-					       (char *)elog_write_to_host_buffer,
-					       ELOG_WRITE_TO_HOST_BUFFER_SIZE);
+					(char *)elog_write_to_host_buffer,
+					ELOG_WRITE_TO_HOST_BUFFER_SIZE);
 		fsp_elog_write_set_head_state(ELOG_STATE_FETCHED_DATA);
 	}
+
 	unlock(&elog_write_to_host_lock);
 }
 
-
 bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
 		    uint64_t opal_elog_id)
 {
@@ -198,6 +200,7 @@ bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
 			unlock(&elog_write_to_host_lock);
 			return rc;
 		}
+
 		if ((opal_elog_id != log_data->plid) &&
 		    (opal_elog_size != log_data->log_size)) {
 			unlock(&elog_write_to_host_lock);
@@ -206,12 +209,12 @@ bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
 
 		memcpy((void *)buffer, elog_write_to_host_buffer,
 							opal_elog_size);
-
 		list_del(&log_data->link);
 		list_add(&elog_write_to_host_processed, &log_data->link);
 		fsp_elog_write_set_head_state(ELOG_STATE_NONE);
 		rc = true;
 	}
+
 	unlock(&elog_write_to_host_lock);
 	opal_commit_elog_in_host();
 	return rc;
@@ -229,6 +232,7 @@ bool opal_elog_ack(uint64_t ack_id)
 							next_record, link) {
 			if (record->plid != ack_id)
 				continue;
+
 			list_del(&record->link);
 			opal_elog_complete(record, true);
 			rc = true;
@@ -237,14 +241,15 @@ bool opal_elog_ack(uint64_t ack_id)
 
 	if ((!rc) && (!list_empty(&elog_write_to_host_pending))) {
 		log_data = list_top(&elog_write_to_host_pending,
-					struct errorlog, link);
+						struct errorlog, link);
 		if (ack_id == log_data->plid)
 			fsp_elog_write_set_head_state(ELOG_STATE_NONE);
 
 		list_for_each_safe(&elog_write_to_host_pending, record,
-							next_record, link) {
+						next_record, link) {
 			if (record->plid != ack_id)
 				continue;
+
 			list_del(&record->link);
 			opal_elog_complete(record, true);
 			rc = true;
@@ -253,6 +258,7 @@ bool opal_elog_ack(uint64_t ack_id)
 			return rc;
 		}
 	}
+
 	unlock(&elog_write_to_host_lock);
 	return rc;
 }
@@ -267,6 +273,7 @@ void opal_resend_pending_logs(void)
 					struct errorlog, link);
 		list_add_tail(&elog_write_to_host_pending, &record->link);
 	}
+
 	fsp_elog_write_set_head_state(ELOG_STATE_NONE);
 	unlock(&elog_write_to_host_lock);
 	opal_commit_elog_in_host();
@@ -277,9 +284,9 @@ static int opal_send_elog_to_fsp(void)
 	struct errorlog *head;
 	int rc = OPAL_SUCCESS;
 
-	/* Convert entry to PEL
-	 * and push it down to FSP. We wait for the ack from
-	 * FSP.
+	/*
+	 * Convert entry to PEL and push it down to FSP. We wait for the ack
+	 * from FSP.
 	 */
 	lock(&elog_write_lock);
 	if (!list_empty(&elog_write_to_fsp_pending)) {
@@ -287,12 +294,13 @@ static int opal_send_elog_to_fsp(void)
 					 struct errorlog, link);
 		elog_plid_fsp_commit = head->plid;
 		head->log_size = create_pel_log(head,
-						(char *)elog_write_to_fsp_buffer,
-						ELOG_WRITE_TO_FSP_BUFFER_SIZE);
+					(char *)elog_write_to_fsp_buffer,
+					ELOG_WRITE_TO_FSP_BUFFER_SIZE);
 		rc = fsp_opal_elog_write(head->log_size);
 		unlock(&elog_write_lock);
 		return rc;
 	}
+
 	unlock(&elog_write_lock);
 	return rc;
 }
@@ -307,7 +315,6 @@ static int opal_push_logs_sync_to_fsp(struct errorlog *buf)
 	opal_elog_size = create_pel_log(buf,
 					(char *)elog_panic_write_buffer,
 					ELOG_PANIC_WRITE_BUFFER_SIZE);
-
 	elog_msg = fsp_mkmsg(FSP_CMD_CREATE_ERRLOG, 3, opal_elog_size,
 					0, PSI_DMA_ELOG_PANIC_WRITE_BUF);
 	if (!elog_msg) {
@@ -325,12 +332,13 @@ static int opal_push_logs_sync_to_fsp(struct errorlog *buf)
 		rc = (elog_msg->resp->word1 >> 8) & 0xff;
 		fsp_freemsg(elog_msg);
 	}
-	unlock(&elog_panic_write_lock);
 
+	unlock(&elog_panic_write_lock);
 	if (rc != OPAL_SUCCESS)
 		opal_elog_complete(buf, false);
 	else
 		opal_elog_complete(buf, true);
+
 	return rc;
 }
 
@@ -345,7 +353,6 @@ int elog_fsp_commit(struct errorlog *buf)
 
 	/* Error needs to be committed, update the time out value */
 	buf->elog_timeout = get_elog_timeout();
-
 	if (buf->event_severity == OPAL_ERROR_PANIC) {
 		rc = opal_push_logs_sync_to_fsp(buf);
 		return rc;
@@ -358,6 +365,7 @@ int elog_fsp_commit(struct errorlog *buf)
 		rc = opal_send_elog_to_fsp();
 		return rc;
 	}
+
 	list_add_tail(&elog_write_to_fsp_pending, &buf->link);
 	unlock(&elog_write_lock);
 	return rc;
@@ -365,7 +373,6 @@ int elog_fsp_commit(struct errorlog *buf)
 
 static void elog_append_write_to_host(struct errorlog *buf)
 {
-
 	lock(&elog_write_to_host_lock);
 	if (list_empty(&elog_write_to_host_pending)) {
 		list_add(&elog_write_to_host_pending, &buf->link);
@@ -386,22 +393,23 @@ static void elog_timeout_poll(void *data __unused)
 	if (list_empty(&elog_write_to_fsp_pending)) {
 		unlock(&elog_write_lock);
 		return;
-	} else {
-		head = list_top(&elog_write_to_fsp_pending,
-					struct errorlog, link);
-		now = mftb();
-		if ((tb_compare(now, head->elog_timeout) == TB_AAFTERB) ||
+	}
+
+	head = list_top(&elog_write_to_fsp_pending,
+			struct errorlog, link);
+	now = mftb();
+	if ((tb_compare(now, head->elog_timeout) == TB_AAFTERB) ||
 			(tb_compare(now, head->elog_timeout) == TB_AEQUALB)) {
-				entry = list_pop(&elog_write_to_fsp_pending,
-						struct errorlog, link);
-				unlock(&elog_write_lock);
-				elog_append_write_to_host(entry);
-		} else
-			unlock(&elog_write_lock);
+		entry = list_pop(&elog_write_to_fsp_pending,
+				struct errorlog, link);
+		unlock(&elog_write_lock);
+		elog_append_write_to_host(entry);
+	} else {
+		unlock(&elog_write_lock);
 	}
 }
 
-/* fsp elog init function */
+/* FSP elog init function */
 void fsp_elog_write_init(void)
 {
 	if (!fsp_present())
@@ -431,12 +439,9 @@ void fsp_elog_write_init(void)
 	/* Map TCEs */
 	fsp_tce_map(PSI_DMA_ELOG_PANIC_WRITE_BUF, elog_panic_write_buffer,
 					PSI_DMA_ELOG_PANIC_WRITE_BUF_SZ);
-
 	fsp_tce_map(PSI_DMA_ERRLOG_WRITE_BUF, elog_write_to_fsp_buffer,
 					PSI_DMA_ERRLOG_WRITE_BUF_SZ);
-
 	elog_init();
-
 	/* Add a poller */
 	opal_add_poller(elog_timeout_poll, NULL);
 }
diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c
index d26059b..e131b0e 100644
--- a/hw/ipmi/ipmi-sel.c
+++ b/hw/ipmi/ipmi-sel.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -146,14 +146,14 @@ void ipmi_sel_init(void)
 
 	memset(&ipmi_sel_panic_msg, 0, sizeof(struct ipmi_sel_panic_msg));
 	ipmi_sel_panic_msg.msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE,
-					    IPMI_RESERVE_SEL, ipmi_elog_poll,
-					    NULL, NULL, IPMI_MAX_REQ_SIZE, 2);
+					IPMI_RESERVE_SEL, ipmi_elog_poll,
+					NULL, NULL, IPMI_MAX_REQ_SIZE, 2);
 }
 
 /*
- * Allocate IPMI message
- *  For normal event, allocate memory using ipmi_mkmsg and for PANIC
- *  event, use pre-allocated buffer.
+ * Allocate IPMI message:
+ * For normal event, allocate memory using ipmi_mkmsg and for PANIC
+ * event, use pre-allocated buffer.
  */
 static struct ipmi_msg *ipmi_sel_alloc_msg(struct errorlog *elog_buf)
 {
@@ -174,14 +174,12 @@ static struct ipmi_msg *ipmi_sel_alloc_msg(struct errorlog *elog_buf)
 		msg = ipmi_sel_panic_msg.msg;
 		ipmi_sel_panic_msg.busy = true;
 		unlock(&ipmi_sel_panic_msg.lock);
-
-		ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE,
-			      IPMI_RESERVE_SEL, ipmi_elog_poll,
-			      elog_buf, IPMI_MAX_REQ_SIZE, 2);
+		ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE, IPMI_RESERVE_SEL,
+				ipmi_elog_poll, elog_buf, IPMI_MAX_REQ_SIZE, 2);
 	} else {
 		msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_RESERVE_SEL,
-				 ipmi_elog_poll, elog_buf,
-				 NULL, IPMI_MAX_REQ_SIZE, 2);
+				ipmi_elog_poll, elog_buf, NULL,
+				IPMI_MAX_REQ_SIZE, 2);
 	}
 
 	return msg;
@@ -196,6 +194,7 @@ static void ipmi_sel_free_msg(struct ipmi_msg *msg)
 	} else {
 		ipmi_free_msg(msg);
 	}
+
 	msg = NULL;
 }
 
@@ -277,27 +276,23 @@ static void ipmi_log_sel_event_error(struct ipmi_msg *msg)
 
 static void ipmi_log_sel_event_complete(struct ipmi_msg *msg)
 {
-	prlog(PR_INFO, "SEL: New event logged [ID : %x%x]\n",
-	      msg->data[1], msg->data[0]);
-
+	prlog(PR_INFO, "SEL: New event logged [ID : %x%x]\n", msg->data[1],
+		msg->data[0]);
 	ipmi_sel_free_msg(msg);
 }
 
 /* Log SEL event with eSEL record ID */
-static void ipmi_log_sel_event(struct ipmi_msg *msg,
-			       uint8_t event_severity, uint16_t esel_record_id)
+static void ipmi_log_sel_event(struct ipmi_msg *msg, uint8_t event_severity,
+				uint16_t esel_record_id)
 {
 	/* Fill required SEL event fields */
 	ipmi_update_sel_record(event_severity, esel_record_id);
-
 	/* Fill IPMI message */
 	ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE, IPMI_ADD_SEL_EVENT,
 		      ipmi_log_sel_event_complete, NULL,
 		      sizeof(struct sel_record), 2);
-
 	/* Copy SEL data */
 	memcpy(msg->data, &sel_record, sizeof(struct sel_record));
-
 	msg->error = ipmi_log_sel_event_error;
 	ipmi_queue_msg_head(msg);
 }
@@ -335,23 +330,23 @@ static void ipmi_elog_poll(struct ipmi_msg *msg)
 	size_t req_size;
 
 	ipmi_init_esel_record();
-
 	if (msg->cmd == IPMI_CMD(IPMI_RESERVE_SEL)) {
 		first = true;
 		reservation_id = msg->data[0];
 		reservation_id |= msg->data[1] << 8;
 		if (!reservation_id) {
-			/* According to specification we should never
+			/*
+			 * According to specification we should never
 			 * get here, but just in case we do we cancel
-			 * sending the message. */
+			 * sending the message.
+			 */
 			prerror("Invalid reservation id");
 			opal_elog_complete(elog_buf, false);
 			ipmi_sel_free_msg(msg);
 			return;
 		}
 
-		pel_size = create_pel_log(elog_buf,
-					  pel_buf, IPMI_MAX_PEL_SIZE);
+		pel_size = create_pel_log(elog_buf, pel_buf, IPMI_MAX_PEL_SIZE);
 		esel_size = pel_size + sizeof(struct sel_record);
 		esel_index = 0;
 		record_id = 0;
@@ -362,15 +357,15 @@ static void ipmi_elog_poll(struct ipmi_msg *msg)
 
 	/* Start or continue the IPMI_PARTIAL_ADD_SEL */
 	if (esel_index >= esel_size) {
-		/* We're all done. Invalidate the resevation id to
+		/*
+		 * We're all done. Invalidate the resevation id to
 		 * ensure we get an error if we cut in on another eSEL
-		 * message. */
+		 * message.
+		 */
 		reservation_id = 0;
 		esel_index = 0;
-
 		/* Log SEL event and free ipmi message */
 		ipmi_log_sel_event(msg, elog_buf->event_severity, record_id);
-
 		opal_elog_complete(elog_buf, true);
 		return;
 	}
@@ -386,24 +381,22 @@ static void ipmi_elog_poll(struct ipmi_msg *msg)
 
 	ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE, IPMI_PARTIAL_ADD_ESEL,
 		      ipmi_elog_poll, elog_buf, req_size, 2);
-
 	msg->data[0] = reservation_id & 0xff;
 	msg->data[1] = (reservation_id >> 8) & 0xff;
 	msg->data[2] = record_id & 0xff;
 	msg->data[3] = (record_id >> 8) & 0xff;
 	msg->data[4] = esel_index & 0xff;
 	msg->data[5] = (esel_index >> 8) & 0xff;
-
 	if (first) {
 		first = false;
-		memcpy(&msg->data[ESEL_HDR_SIZE],
-		       &sel_record, sizeof(struct sel_record));
+		memcpy(&msg->data[ESEL_HDR_SIZE], &sel_record,
+			sizeof(struct sel_record));
 		esel_index = sizeof(struct sel_record);
 		msg->req_size = esel_index + ESEL_HDR_SIZE;
 	} else {
 		pel_index = esel_index - sizeof(struct sel_record);
-		memcpy(&msg->data[ESEL_HDR_SIZE],
-		       &pel_buf[pel_index], msg->req_size - ESEL_HDR_SIZE);
+		memcpy(&msg->data[ESEL_HDR_SIZE], &pel_buf[pel_index],
+			msg->req_size - ESEL_HDR_SIZE);
 		esel_index += msg->req_size - ESEL_HDR_SIZE;
 	}
 
@@ -416,25 +409,26 @@ int ipmi_elog_commit(struct errorlog *elog_buf)
 	struct ipmi_msg *msg;
 
 	/* Only log events that needs attention */
-	if (elog_buf->event_severity < OPAL_PREDICTIVE_ERR_FAULT_RECTIFY_REBOOT ||
-	    elog_buf->elog_origin != ORG_SAPPHIRE) {
+	if (elog_buf->event_severity <
+			OPAL_PREDICTIVE_ERR_FAULT_RECTIFY_REBOOT ||
+			elog_buf->elog_origin != ORG_SAPPHIRE) {
 		prlog(PR_INFO, "dropping non severe PEL event\n");
 		opal_elog_complete(elog_buf, true);
 		return 0;
 	}
-
-	/* We pass a large request size in to mkmsg so that we have a
+	/*
+	 * We pass a large request size in to mkmsg so that we have a
 	 * large enough allocation to reuse the message to pass the
-	 * PEL data via a series of partial add commands.  */
+	 * PEL data via a series of partial add commands.
+	 */
 	msg = ipmi_sel_alloc_msg(elog_buf);
 	if (!msg) {
 		opal_elog_complete(elog_buf, false);
 		return OPAL_RESOURCE;
 	}
-	msg->error = ipmi_elog_error;
 
+	msg->error = ipmi_elog_error;
 	msg->req_size = 0;
-
 	if (elog_buf->event_severity == OPAL_ERROR_PANIC)
 		ipmi_queue_msg_sync(msg);
 	else
@@ -468,7 +462,7 @@ static void sel_pnor(uint8_t access)
 		occ_pnor_set_owner(PNOR_OWNER_HOST);
 		break;
 	default:
-		/**
+		/*
 		 * @fwts-label InvalidPNORAccessRequest
 		 * @fwts-advice In negotiating PNOR access with BMC, we
 		 * got an odd/invalid request from the BMC. Likely a bug
@@ -491,6 +485,7 @@ static void sel_power(uint8_t power)
 		} else {
 			opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_OFF);
 		}
+
 		break;
 	case SOFT_REBOOT:
 		prlog(PR_NOTICE, "Soft reboot requested\n");
@@ -501,6 +496,7 @@ static void sel_power(uint8_t power)
 		} else {
 			opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_REBOOT);
 		}
+
 		break;
 	default:
 		prlog(PR_WARNING, "requested bad power state: %02x\n",
@@ -510,7 +506,7 @@ static void sel_power(uint8_t power)
 
 static uint32_t occ_sensor_id_to_chip(uint8_t sensor, uint32_t *chip)
 {
-	/* todo: lookup sensor ID node in the DT, and map to a chip id */
+	/* TODO: Lookup sensor ID node in the DT, and map to a chip id */
 	(void)sensor;
 	*chip = 0;
 	return 0;
@@ -523,7 +519,7 @@ static void sel_occ_reset(uint8_t sensor)
 
 	rc = occ_sensor_id_to_chip(sensor, &chip);
 	if (rc) {
-		/**
+		/*
 		 * @fwts-label: SELUnknownOCCReset
 		 * @fwts-advice: Likely bug in what sent us the OCC reset.
 		 */
@@ -540,9 +536,7 @@ void ipmi_parse_sel(struct ipmi_msg *msg)
 	struct oem_sel sel;
 
 	assert(msg->resp_size <= 16);
-
 	memcpy(&sel, msg->data, msg->resp_size);
-
 	/* We do not process system event records */
 	if (sel.type == SEL_RECORD_TYPE_EVENT) {
 		prlog(PR_INFO, "dropping System Event Record SEL\n");
@@ -551,11 +545,9 @@ void ipmi_parse_sel(struct ipmi_msg *msg)
 
 	prlog(PR_DEBUG, "SEL received (%d bytes, netfn %d, cmd %d)\n",
 			msg->resp_size, sel.netfun, sel.cmd);
-
 	/* Only accept OEM SEL messages */
-	if (sel.id[0] != SEL_OEM_ID_0 ||
-	    sel.id[1] != SEL_OEM_ID_1 ||
-	    sel.type != SEL_RECORD_TYPE_OEM) {
+	if (sel.id[0] != SEL_OEM_ID_0 || sel.id[1] != SEL_OEM_ID_1 ||
+		sel.type != SEL_RECORD_TYPE_OEM) {
 		prlog(PR_WARNING, "unknown SEL %02x%02x (type %02x)\n",
 		      sel.id[0], sel.id[1], sel.type);
 		return;
-- 
2.7.4



More information about the Skiboot mailing list