mirror of
https://github.com/joel16/android_kernel_sony_msm8994.git
synced 2024-11-23 12:10:29 +00:00
spmi: prevent showing the address of spmidev.
Creating devices with the address of the container spmidev is not indicative of the actual hardware device it represents. Instead use an unique id to indicate the device it represents. CRs-Fixed: 1024197 Change-Id: Id18e2a19f4fa1249901a3f275defa8f589270d69 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org> Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
This commit is contained in:
parent
008a17a426
commit
68eece5e5e
@ -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);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* 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,9 @@ 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 +132,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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user