staging: gasket: sysfs: convert to standard logging

Drop gasket logging calls in favor of standard logging.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Todd Poynor 2018-07-26 20:07:33 -07:00 committed by Greg Kroah-Hartman
parent c423d34478
commit 0f647805c0

View file

@ -3,7 +3,9 @@
#include "gasket_sysfs.h" #include "gasket_sysfs.h"
#include "gasket_core.h" #include "gasket_core.h"
#include "gasket_logging.h"
#include <linux/device.h>
#include <linux/printk.h>
/* /*
* Pair of kernel device and user-specified pointer. Used in lookups in sysfs * Pair of kernel device and user-specified pointer. Used in lookups in sysfs
@ -66,7 +68,7 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device)
int i; int i;
if (!device) { if (!device) {
gasket_nodev_error("Received NULL device!"); pr_debug("%s: Received NULL device\n", __func__);
return NULL; return NULL;
} }
@ -80,7 +82,8 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device)
mutex_unlock(&dev_mappings[i].mutex); mutex_unlock(&dev_mappings[i].mutex);
} }
gasket_nodev_info("Mapping to device %s not found.", device->kobj.name); dev_dbg(device, "%s: Mapping to device %s not found\n",
__func__, device->kobj.name);
return NULL; return NULL;
} }
@ -103,16 +106,15 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
struct device *device; struct device *device;
if (!mapping) { if (!mapping) {
gasket_nodev_info("Mapping should not be NULL."); pr_debug("%s: Mapping should not be NULL\n", __func__);
return; return;
} }
mutex_lock(&mapping->mutex); mutex_lock(&mapping->mutex);
if (refcount_read(&mapping->refcount.refcount) == 0) if (refcount_read(&mapping->refcount.refcount) == 0)
gasket_nodev_error("Refcount is already 0!"); dev_err(mapping->device, "Refcount is already 0\n");
if (kref_put(&mapping->refcount, release_entry)) { if (kref_put(&mapping->refcount, release_entry)) {
gasket_nodev_info("Removing Gasket sysfs mapping, device %s", dev_dbg(mapping->device, "Removing Gasket sysfs mapping\n");
mapping->device->kobj.name);
/* /*
* We can't remove the sysfs nodes in the kref callback, since * We can't remove the sysfs nodes in the kref callback, since
* device_remove_file() blocks until the node is free. * device_remove_file() blocks until the node is free.
@ -182,16 +184,13 @@ int gasket_sysfs_create_mapping(
static DEFINE_MUTEX(function_mutex); static DEFINE_MUTEX(function_mutex);
mutex_lock(&function_mutex); mutex_lock(&function_mutex);
dev_dbg(device, "Creating sysfs entries for device\n");
gasket_nodev_info(
"Creating sysfs entries for device pointer 0x%p.", device);
/* Check that the device we're adding hasn't already been added. */ /* Check that the device we're adding hasn't already been added. */
mapping = get_mapping(device); mapping = get_mapping(device);
if (mapping) { if (mapping) {
gasket_nodev_error( dev_err(device,
"Attempting to re-initialize sysfs mapping for device " "Attempting to re-initialize sysfs mapping for device\n");
"0x%p.", device);
put_mapping(mapping); put_mapping(mapping);
mutex_unlock(&function_mutex); mutex_unlock(&function_mutex);
return -EBUSY; return -EBUSY;
@ -207,13 +206,13 @@ int gasket_sysfs_create_mapping(
} }
if (map_idx == GASKET_SYSFS_NUM_MAPPINGS) { if (map_idx == GASKET_SYSFS_NUM_MAPPINGS) {
gasket_nodev_error("All mappings have been exhausted!"); dev_err(device, "All mappings have been exhausted\n");
mutex_unlock(&function_mutex); mutex_unlock(&function_mutex);
return -ENOMEM; return -ENOMEM;
} }
gasket_nodev_info( dev_dbg(device, "Creating sysfs mapping for device %s\n",
"Creating sysfs mapping for device %s.", device->kobj.name); device->kobj.name);
mapping = &dev_mappings[map_idx]; mapping = &dev_mappings[map_idx];
kref_init(&mapping->refcount); kref_init(&mapping->refcount);
@ -224,7 +223,7 @@ int gasket_sysfs_create_mapping(
GFP_KERNEL); GFP_KERNEL);
mapping->attribute_count = 0; mapping->attribute_count = 0;
if (!mapping->attributes) { if (!mapping->attributes) {
gasket_nodev_error("Unable to allocate sysfs attribute array."); dev_dbg(device, "Unable to allocate sysfs attribute array\n");
mapping->device = NULL; mapping->device = NULL;
mapping->gasket_dev = NULL; mapping->gasket_dev = NULL;
mutex_unlock(&mapping->mutex); mutex_unlock(&mapping->mutex);
@ -247,10 +246,9 @@ int gasket_sysfs_create_entries(
struct gasket_sysfs_mapping *mapping = get_mapping(device); struct gasket_sysfs_mapping *mapping = get_mapping(device);
if (!mapping) { if (!mapping) {
gasket_nodev_error( dev_dbg(device,
"Creating entries for device 0x%p without first " "Creating entries for device without first "
"initializing mapping.", "initializing mapping\n");
device);
return -EINVAL; return -EINVAL;
} }
@ -258,9 +256,9 @@ int gasket_sysfs_create_entries(
for (i = 0; strcmp(attrs[i].attr.attr.name, GASKET_ARRAY_END_MARKER); for (i = 0; strcmp(attrs[i].attr.attr.name, GASKET_ARRAY_END_MARKER);
i++) { i++) {
if (mapping->attribute_count == GASKET_SYSFS_MAX_NODES) { if (mapping->attribute_count == GASKET_SYSFS_MAX_NODES) {
gasket_nodev_error( dev_err(device,
"Maximum number of sysfs nodes reached for " "Maximum number of sysfs nodes reached for "
"device."); "device\n");
mutex_unlock(&mapping->mutex); mutex_unlock(&mapping->mutex);
put_mapping(mapping); put_mapping(mapping);
return -ENOMEM; return -ENOMEM;
@ -268,7 +266,7 @@ int gasket_sysfs_create_entries(
ret = device_create_file(device, &attrs[i].attr); ret = device_create_file(device, &attrs[i].attr);
if (ret) { if (ret) {
gasket_nodev_error("Unable to create device entries"); dev_dbg(device, "Unable to create device entries\n");
mutex_unlock(&mapping->mutex); mutex_unlock(&mapping->mutex);
put_mapping(mapping); put_mapping(mapping);
return ret; return ret;
@ -289,10 +287,9 @@ void gasket_sysfs_remove_mapping(struct device *device)
struct gasket_sysfs_mapping *mapping = get_mapping(device); struct gasket_sysfs_mapping *mapping = get_mapping(device);
if (!mapping) { if (!mapping) {
gasket_nodev_error( dev_err(device,
"Attempted to remove non-existent sysfs mapping to " "Attempted to remove non-existent sysfs mapping to "
"device 0x%p", "device\n");
device);
return; return;
} }
@ -304,7 +301,7 @@ struct gasket_dev *gasket_sysfs_get_device_data(struct device *device)
struct gasket_sysfs_mapping *mapping = get_mapping(device); struct gasket_sysfs_mapping *mapping = get_mapping(device);
if (!mapping) { if (!mapping) {
gasket_nodev_error("device %p not registered.", device); dev_err(device, "device not registered\n");
return NULL; return NULL;
} }
@ -342,7 +339,7 @@ struct gasket_sysfs_attribute *gasket_sysfs_get_attr(
return &attrs[i]; return &attrs[i];
} }
gasket_nodev_error("Unable to find match for device_attribute %s", dev_err(device, "Unable to find match for device_attribute %s\n",
attr->attr.name); attr->attr.name);
return NULL; return NULL;
} }
@ -368,8 +365,8 @@ void gasket_sysfs_put_attr(
} }
} }
gasket_nodev_error( dev_err(device, "Unable to put unknown attribute: %s\n",
"Unable to put unknown attribute: %s", attr->attr.attr.name); attr->attr.attr.name);
} }
EXPORT_SYMBOL(gasket_sysfs_put_attr); EXPORT_SYMBOL(gasket_sysfs_put_attr);
@ -383,26 +380,26 @@ ssize_t gasket_sysfs_register_store(
struct gasket_sysfs_attribute *gasket_attr; struct gasket_sysfs_attribute *gasket_attr;
if (count < 3 || buf[0] != '0' || buf[1] != 'x') { if (count < 3 || buf[0] != '0' || buf[1] != 'x') {
gasket_nodev_error( dev_err(device,
"sysfs register write format: \"0x<hex value>\"."); "sysfs register write format: \"0x<hex value>\"\n");
return -EINVAL; return -EINVAL;
} }
if (kstrtoul(buf, 16, &parsed_value) != 0) { if (kstrtoul(buf, 16, &parsed_value) != 0) {
gasket_nodev_error( dev_err(device,
"Unable to parse input as 64-bit hex value: %s.", buf); "Unable to parse input as 64-bit hex value: %s\n", buf);
return -EINVAL; return -EINVAL;
} }
mapping = get_mapping(device); mapping = get_mapping(device);
if (!mapping) { if (!mapping) {
gasket_nodev_info("Device driver may have been removed."); dev_err(device, "Device driver may have been removed\n");
return 0; return 0;
} }
gasket_dev = mapping->gasket_dev; gasket_dev = mapping->gasket_dev;
if (!gasket_dev) { if (!gasket_dev) {
gasket_nodev_info("Device driver may have been removed."); dev_err(device, "Device driver may have been removed\n");
return 0; return 0;
} }