drivers/scsi/esas2r/esas2r_log.c

Source file repositories/reference/linux-study-clean/drivers/scsi/esas2r/esas2r_log.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/esas2r/esas2r_log.c
Extension
.c
Size
7643 bytes
Lines
245
Domain
Driver Families
Bucket
drivers/scsi
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (dev == NULL) {
			snprintf(buffer, buflen, fmt_nodev, slevel,
				 ESAS2R_DRVR_NAME);
		} else {
			snprintf(buffer, buflen, fmt_dev, slevel,
				 ESAS2R_DRVR_NAME,
				 (dev->driver ? dev->driver->name : "unknown"),
				 (dev->bus ? dev->bus->name : "unknown"),
				 dev_name(dev));
		}

		buffer += strlen(event_buffer);
		buflen -= strlen(event_buffer);

		retval = vsnprintf(buffer, buflen, format, args);
		if (retval < 0) {
			spin_unlock_irqrestore(&event_buffer_lock, flags);
			return -1;
		}

		/*
		 * Put a line break at the end of the formatted string so that
		 * we don't wind up with run-on messages.
		 */
		printk("%s\n", event_buffer);

		spin_unlock_irqrestore(&event_buffer_lock, flags);
	}

	return 0;
}

/*
 * formats and logs a message to the system log.
 *
 * @param [in] level  the event level of the message
 * @param [in] format the formating string for the message
 * @param [in] ...    the substitution arguments to the formatting string
 *
 * @return 0 on success, or -1 if an error occurred.
 */
int esas2r_log(const long level, const char *format, ...)
{
	int retval = 0;
	va_list args;

	va_start(args, format);

	retval = esas2r_log_master(level, NULL, format, args);

	va_end(args);

	return retval;
}

/*
 * formats and logs a message to the system log.  this message will include
 * device information.
 *
 * @param [in] level   the event level of the message
 * @param [in] dev     the device information
 * @param [in] format  the formatting string for the message
 * @param [in] ...     the substitution arguments to the formatting string
 *
 * @return 0 on success, or -1 if an error occurred.
 */
int esas2r_log_dev(const long level,
		   const struct device *dev,
		   const char *format,
		   ...)
{
	int retval = 0;
	va_list args;

	va_start(args, format);

	retval = esas2r_log_master(level, dev, format, args);

	va_end(args);

	return retval;
}

/*
 * formats and logs a message to the system log.  this message will include
 * device information.
 *
 * @param [in] level   the event level of the message
 * @param [in] buf
 * @param [in] len

Annotation

Implementation Notes