Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2bf54ed authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "spmi: prevent showing the address of spmidev"

parents ec4dcecc 35277268
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, 2016 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -32,6 +32,7 @@ struct spmii_boardinfo {
static DEFINE_MUTEX(board_lock);
static LIST_HEAD(board_list);
static DEFINE_IDR(ctrl_idr);
static DEFINE_IDA(spmi_devid_ida);
static struct device_type spmi_dev_type;
static struct device_type spmi_ctrl_type;

@@ -229,22 +230,32 @@ int spmi_add_device(struct spmi_device *spmidev)
{
	int rc;
	struct device *dev = get_valid_device(spmidev);
	int id;

	if (!dev) {
		pr_err("invalid SPMI device\n");
		return -EINVAL;
	}

	id = ida_simple_get(&spmi_devid_ida, 0, 0, GFP_KERNEL);
	if (id < 0) {
		pr_err("No id available, status = %d\n", id);
		return id;
	}

	/* Set the device name */
	dev_set_name(dev, "%s-%p", spmidev->name, spmidev);
	spmidev->id = id;
	dev_set_name(dev, "%s-%d", spmidev->name, spmidev->id);

	/* Device may be bound to an active driver when this returns */
	rc = device_add(dev);

	if (rc < 0)
	if (rc < 0) {
		ida_simple_remove(&spmi_devid_ida, spmidev->id);
		dev_err(dev, "Can't add %s, status %d\n", dev_name(dev), rc);
	else
	} else {
		dev_dbg(dev, "device %s registered\n", dev_name(dev));
	}

	return rc;
}
@@ -292,6 +303,7 @@ EXPORT_SYMBOL_GPL(spmi_new_device);
void spmi_remove_device(struct spmi_device *spmi_dev)
{
	device_unregister(&spmi_dev->dev);
	ida_simple_remove(&spmi_devid_ida, spmi_dev->id);
}
EXPORT_SYMBOL_GPL(spmi_remove_device);

+4 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, 2016 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -120,6 +120,8 @@ struct spmi_resource {
 *  @dev_node: array of SPMI resources when used with spmi-dev-container.
 *  @num_dev_node: number of device_node structures.
 *  @sid: Slave Identifier.
 *  @id: Unique identifier to differentiate from other spmi devices with
 *	 possibly same name.
 */
struct spmi_device {
	struct device		dev;
@@ -129,6 +131,7 @@ struct spmi_device {
	struct spmi_resource	*dev_node;
	u32			num_dev_node;
	u8			sid;
	int			id;
};
#define to_spmi_device(d) container_of(d, struct spmi_device, dev)