lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190613185705.GA16951@ahmlpt0706>
Date:   Fri, 14 Jun 2019 00:27:05 +0530
From:   Saiyam Doshi <saiyamdoshi.in@...il.com>
To:     gregkh@...uxfoundation.org, groeck@...gle.com
Cc:     linux-kernel@...r.kernel.org, groeck@...omium.org,
        adurbin@...omium.org, dlaurie@...omium.org
Subject: [PATCH] gsmi: replace printk with relevant dev_<level>

Replace printk() with dev_* macros for logging consistency.
In process of replacing printk with dev_err, dev_info etc.,
removed unnecessary "out of memory" debug message.

This also fixes checkpatch.pl warnings.

Signed-off-by: Saiyam Doshi <saiyamdoshi.in@...il.com>
---
 drivers/firmware/google/gsmi.c | 68 ++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 31 deletions(-)

diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index edaa4e5d84ad..db11fc896c42 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -151,7 +151,6 @@ static struct gsmi_buf *gsmi_buf_alloc(void)
 
 	smibuf = kzalloc(sizeof(*smibuf), GFP_KERNEL);
 	if (!smibuf) {
-		printk(KERN_ERR "gsmi: out of memory\n");
 		return NULL;
 	}
 
@@ -159,7 +158,7 @@ static struct gsmi_buf *gsmi_buf_alloc(void)
 	smibuf->start = dma_pool_alloc(gsmi_dev.dma_pool, GFP_KERNEL,
 				       &smibuf->handle);
 	if (!smibuf->start) {
-		printk(KERN_ERR "gsmi: failed to allocate name buffer\n");
+		dev_err(&gsmi_dev.pdev->dev, "failed to allocate name buffer\n");
 		kfree(smibuf);
 		return NULL;
 	}
@@ -257,34 +256,40 @@ static int gsmi_exec(u8 func, u8 sub)
 		rc = 1;
 		break;
 	case GSMI_INVALID_PARAMETER:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Invalid parameter\n", cmd);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Invalid parameter\n", cmd);
 		rc = -EINVAL;
 		break;
 	case GSMI_BUFFER_TOO_SMALL:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Buffer too small\n", cmd);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Buffer too small\n", cmd);
 		rc = -ENOMEM;
 		break;
 	case GSMI_UNSUPPORTED:
 	case GSMI_UNSUPPORTED2:
 		if (sub != GSMI_CMD_HANDSHAKE_TYPE)
-			printk(KERN_ERR "gsmi: exec 0x%04x: Not supported\n",
-			       cmd);
+			dev_err(&gsmi_dev.pdev->dev,
+				"exec 0x%04x: Not supported\n", cmd);
 		rc = -ENOSYS;
 		break;
 	case GSMI_NOT_READY:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Not ready\n", cmd);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Not ready\n", cmd);
 		rc = -EBUSY;
 		break;
 	case GSMI_DEVICE_ERROR:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Device error\n", cmd);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Device error\n", cmd);
 		rc = -EFAULT;
 		break;
 	case GSMI_NOT_FOUND:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Data not found\n", cmd);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Data not found\n", cmd);
 		rc = -ENOENT;
 		break;
 	case GSMI_LOG_FULL:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Log full\n", cmd);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Log full\n", cmd);
 		rc = -ENOSPC;
 		break;
 	case GSMI_HANDSHAKE_CF:
@@ -293,8 +298,8 @@ static int gsmi_exec(u8 func, u8 sub)
 		rc = result;
 		break;
 	default:
-		printk(KERN_ERR "gsmi: exec 0x%04x: Unknown error 0x%04x\n",
-		       cmd, result);
+		dev_err(&gsmi_dev.pdev->dev,
+			"exec 0x%04x: Unknown error 0x%04x\n", cmd, result);
 		rc = -ENXIO;
 	}
 
@@ -341,7 +346,7 @@ static efi_status_t gsmi_get_variable(efi_char16_t *name,
 
 	rc = gsmi_exec(GSMI_CALLBACK, GSMI_CMD_GET_NVRAM_VAR);
 	if (rc < 0) {
-		printk(KERN_ERR "gsmi: Get Variable failed\n");
+		dev_err(&gsmi_dev.pdev->dev, "Get Variable failed\n");
 		ret = EFI_LOAD_ERROR;
 	} else if (rc == 1) {
 		/* variable was not found */
@@ -403,7 +408,7 @@ static efi_status_t gsmi_get_next_variable(unsigned long *name_size,
 
 	rc = gsmi_exec(GSMI_CALLBACK, GSMI_CMD_GET_NEXT_VAR);
 	if (rc < 0) {
-		printk(KERN_ERR "gsmi: Get Next Variable Name failed\n");
+		dev_err(&gsmi_dev.pdev->dev, "Get Next Variable Name failed\n");
 		ret = EFI_LOAD_ERROR;
 	} else if (rc == 1) {
 		/* variable not found -- end of list */
@@ -467,7 +472,7 @@ static efi_status_t gsmi_set_variable(efi_char16_t *name,
 
 	rc = gsmi_exec(GSMI_CALLBACK, GSMI_CMD_SET_NVRAM_VAR);
 	if (rc < 0) {
-		printk(KERN_ERR "gsmi: Set Variable failed\n");
+		dev_err(&gsmi_dev.pdev->dev, "Set Variable failed\n");
 		ret = EFI_INVALID_PARAMETER;
 	}
 
@@ -517,7 +522,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
 
 	rc = gsmi_exec(GSMI_CALLBACK, GSMI_CMD_SET_EVENT_LOG);
 	if (rc < 0)
-		printk(KERN_ERR "gsmi: Set Event Log failed\n");
+		dev_err(&gsmi_dev.pdev->dev, "Set Event Log failed\n");
 
 	spin_unlock_irqrestore(&gsmi_dev.lock, flags);
 
@@ -645,10 +650,10 @@ static int gsmi_shutdown_reason(int reason)
 	spin_unlock_irqrestore(&gsmi_dev.lock, flags);
 
 	if (rc < 0)
-		printk(KERN_ERR "gsmi: Log Shutdown Reason failed\n");
+		dev_err(&gsmi_dev.pdev->dev, "Log Shutdown Reason failed\n");
 	else
-		printk(KERN_EMERG "gsmi: Log Shutdown Reason 0x%02x\n",
-		       reason);
+		dev_emerg(&gsmi_dev.pdev->dev, "Log Shutdown Reason 0x%02x\n",
+			  reason);
 
 	return rc;
 }
@@ -759,7 +764,7 @@ static __init int gsmi_system_valid(void)
 	 * whitewash our board names out of the public driver.
 	 */
 	if (!strncmp(acpi_gbl_FADT.header.oem_table_id, "FACP", 4)) {
-		printk(KERN_INFO "gsmi: Board is too old\n");
+		dev_info(&gsmi_dev.pdev->dev, "Board is too old\n");
 		return -ENODEV;
 	}
 
@@ -879,7 +884,7 @@ static __init int gsmi_init(void)
 #ifdef CONFIG_PM
 	ret = platform_driver_register(&gsmi_driver_info);
 	if (unlikely(ret)) {
-		printk(KERN_ERR "gsmi: unable to register platform driver\n");
+		dev_err(&gsmi_dev.pdev->dev, "unable to register platform driver\n");
 		return ret;
 	}
 #endif
@@ -887,7 +892,7 @@ static __init int gsmi_init(void)
 	/* register device */
 	gsmi_dev.pdev = platform_device_register_full(&gsmi_dev_info);
 	if (IS_ERR(gsmi_dev.pdev)) {
-		printk(KERN_ERR "gsmi: unable to register platform device\n");
+		dev_err(&gsmi_dev.pdev->dev, "unable to register platform device\n");
 		return PTR_ERR(gsmi_dev.pdev);
 	}
 
@@ -906,19 +911,19 @@ static __init int gsmi_init(void)
 	 */
 	gsmi_dev.name_buf = gsmi_buf_alloc();
 	if (!gsmi_dev.name_buf) {
-		printk(KERN_ERR "gsmi: failed to allocate name buffer\n");
+		dev_err(&gsmi_dev.pdev->dev, "failed to allocate name buffer\n");
 		goto out_err;
 	}
 
 	gsmi_dev.data_buf = gsmi_buf_alloc();
 	if (!gsmi_dev.data_buf) {
-		printk(KERN_ERR "gsmi: failed to allocate data buffer\n");
+		dev_err(&gsmi_dev.pdev->dev, "failed to allocate data buffer\n");
 		goto out_err;
 	}
 
 	gsmi_dev.param_buf = gsmi_buf_alloc();
 	if (!gsmi_dev.param_buf) {
-		printk(KERN_ERR "gsmi: failed to allocate param buffer\n");
+		dev_err(&gsmi_dev.pdev->dev, "failed to allocate param buffer\n");
 		goto out_err;
 	}
 
@@ -960,7 +965,7 @@ static __init int gsmi_init(void)
 
 	/* Remove and clean up gsmi if the handshake could not complete. */
 	if (gsmi_dev.handshake_type == -ENXIO) {
-		printk(KERN_INFO "gsmi version " DRIVER_VERSION
+		dev_info(&gsmi_dev.pdev->dev, "gsmi version " DRIVER_VERSION
 		       " failed to load\n");
 		ret = -ENODEV;
 		goto out_err;
@@ -970,28 +975,28 @@ static __init int gsmi_init(void)
 	ret = -ENOMEM;
 	gsmi_kobj = kobject_create_and_add("gsmi", firmware_kobj);
 	if (!gsmi_kobj) {
-		printk(KERN_INFO "gsmi: Failed to create firmware kobj\n");
+		dev_info(&gsmi_dev.pdev->dev, "Failed to create firmware kobj\n");
 		goto out_err;
 	}
 
 	/* Setup eventlog access */
 	ret = sysfs_create_bin_file(gsmi_kobj, &eventlog_bin_attr);
 	if (ret) {
-		printk(KERN_INFO "gsmi: Failed to setup eventlog");
+		dev_info(&gsmi_dev.pdev->dev, "Failed to setup eventlog");
 		goto out_err;
 	}
 
 	/* Other attributes */
 	ret = sysfs_create_files(gsmi_kobj, gsmi_attrs);
 	if (ret) {
-		printk(KERN_INFO "gsmi: Failed to add attrs");
+		dev_info(&gsmi_dev.pdev->dev, "Failed to add attrs");
 		goto out_remove_bin_file;
 	}
 
 #ifdef CONFIG_EFI_VARS
 	ret = efivars_register(&efivars, &efivar_ops, gsmi_kobj);
 	if (ret) {
-		printk(KERN_INFO "gsmi: Failed to register efivars\n");
+		dev_info(&gsmi_dev.pdev->dev, "Failed to register efivars\n");
 		sysfs_remove_files(gsmi_kobj, gsmi_attrs);
 		goto out_remove_bin_file;
 	}
@@ -1002,7 +1007,8 @@ static __init int gsmi_init(void)
 	atomic_notifier_chain_register(&panic_notifier_list,
 				       &gsmi_panic_notifier);
 
-	printk(KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n");
+	dev_info(&gsmi_dev.pdev->dev,
+		 "gsmi version " DRIVER_VERSION " loaded\n");
 
 	return 0;
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ