^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/drivers/scsi/esas2r/esas2r_log.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * For use with ATTO ExpressSAS R6xx SAS/SATA RAID controllers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2001-2013 ATTO Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * (mailto:linuxdrivers@attotech.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * modify it under the terms of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * as published by the Free Software Foundation; either version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * solely responsible for determining the appropriateness of using and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * distributing the Program and assumes all risks associated with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * exercise of rights under this Agreement, including but not limited to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * the risks and costs of program errors, damage to or loss of data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * programs or equipment, and unavailability or interruption of operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * DISCLAIMER OF LIABILITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include "esas2r.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * this module within the driver is tasked with providing logging functionality.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * the event_log_level module parameter controls the level of messages that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * written to the system log. the default level of messages that are written
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * are critical and warning messages. if other types of messages are desired,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * one simply needs to load the module with the correct value for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * event_log_level module parameter. for example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * insmod <module> event_log_level=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * will load the module and only critical events will be written by this module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * to the system log. if critical, warning, and information-level messages are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * desired, the correct value for the event_log_level module parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * would be as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * insmod <module> event_log_level=3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define EVENT_LOG_BUFF_SIZE 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static long event_log_level = ESAS2R_LOG_DFLT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) module_param(event_log_level, long, S_IRUGO | S_IRUSR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) MODULE_PARM_DESC(event_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) "Specifies the level of events to report to the system log. Critical and warning level events are logged by default.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* A shared buffer to use for formatting messages. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static char event_buffer[EVENT_LOG_BUFF_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* A lock to protect the shared buffer used for formatting messages. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static DEFINE_SPINLOCK(event_buffer_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * translates an esas2r-defined logging event level to a kernel logging level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * @param [in] level the esas2r-defined logging event level to translate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @return the corresponding kernel logging level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static const char *translate_esas2r_event_level_to_kernel(const long level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) switch (level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) case ESAS2R_LOG_CRIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return KERN_CRIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) case ESAS2R_LOG_WARN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return KERN_WARNING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) case ESAS2R_LOG_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return KERN_INFO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) case ESAS2R_LOG_DEBG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) case ESAS2R_LOG_TRCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return KERN_DEBUG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * the master logging function. this function will format the message as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * outlined by the formatting string, the input device information and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * substitution arguments and output the resulting string to the system log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * @param [in] level the event log level of the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * @param [in] dev the device information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * @param [in] format the formatting string for the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * @param [in] args the substition arguments to the formatting string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * @return 0 on success, or -1 if an error occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static int esas2r_log_master(const long level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) const struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) const char *format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) va_list args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (level <= event_log_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned long flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) char *buffer = event_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) size_t buflen = EVENT_LOG_BUFF_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) const char *fmt_nodev = "%s%s: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) const char *fmt_dev = "%s%s [%s, %s, %s]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) const char *slevel =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) translate_esas2r_event_level_to_kernel(level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) spin_lock_irqsave(&event_buffer_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) memset(buffer, 0, buflen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * format the level onto the beginning of the string and do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * some pointer arithmetic to move the pointer to the point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * where the actual message can be inserted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (dev == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) snprintf(buffer, buflen, fmt_nodev, slevel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ESAS2R_DRVR_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) snprintf(buffer, buflen, fmt_dev, slevel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ESAS2R_DRVR_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) (dev->driver ? dev->driver->name : "unknown"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) (dev->bus ? dev->bus->name : "unknown"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) buffer += strlen(event_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) buflen -= strlen(event_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) retval = vsnprintf(buffer, buflen, format, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (retval < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) spin_unlock_irqrestore(&event_buffer_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Put a line break at the end of the formatted string so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * we don't wind up with run-on messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) printk("%s\n", event_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) spin_unlock_irqrestore(&event_buffer_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * formats and logs a message to the system log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * @param [in] level the event level of the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * @param [in] format the formating string for the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * @param [in] ... the substitution arguments to the formatting string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * @return 0 on success, or -1 if an error occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int esas2r_log(const long level, const char *format, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) va_start(args, format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) retval = esas2r_log_master(level, NULL, format, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * formats and logs a message to the system log. this message will include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * device information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * @param [in] level the event level of the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * @param [in] dev the device information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * @param [in] format the formatting string for the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * @param [in] ... the substitution arguments to the formatting string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * @return 0 on success, or -1 if an error occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int esas2r_log_dev(const long level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) const struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) const char *format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) int retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) va_start(args, format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) retval = esas2r_log_master(level, dev, format, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * formats and logs a message to the system log. this message will include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * device information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * @param [in] level the event level of the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * @param [in] buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * @param [in] len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * @return 0 on success, or -1 if an error occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) int esas2r_log_hexdump(const long level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) const void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (level <= event_log_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) print_hex_dump(translate_esas2r_event_level_to_kernel(level),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) "", DUMP_PREFIX_OFFSET, 16, 1, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) len, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }