summaryrefslogtreecommitdiffstats
path: root/drivers/w1/slaves/w1_ds2780.c
diff options
context:
space:
mode:
authorAndrew F. Davis <afd@ti.com>2016-08-02 14:07:06 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:39 -0400
commit098f9fb0c962eb2fdba5f9d34f4cf7a938237184 (patch)
tree9f0ed4b3613e27b22c200e1f6f64a1089673f87c /drivers/w1/slaves/w1_ds2780.c
parent0b9364b5cf11c6e504f4b77e24b15a0dc8a82df0 (diff)
downloadlinux-098f9fb0c962eb2fdba5f9d34f4cf7a938237184.tar.bz2
w1: remove need for ida and use PLATFORM_DEVID_AUTO
PLATFORM_DEVID_AUTO can be used to have the platform core assign a unique ID instead of manually creating one with IDA. Do this in all applicable drivers. Link: http://lkml.kernel.org/r/20160531204313.20979-1-afd@ti.com Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1/slaves/w1_ds2780.c')
-rw-r--r--drivers/w1/slaves/w1_ds2780.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/drivers/w1/slaves/w1_ds2780.c b/drivers/w1/slaves/w1_ds2780.c
index 50e85f7929d4..e63eb86d66f1 100644
--- a/drivers/w1/slaves/w1_ds2780.c
+++ b/drivers/w1/slaves/w1_ds2780.c
@@ -113,25 +113,14 @@ static const struct attribute_group *w1_ds2780_groups[] = {
NULL,
};
-static DEFINE_IDA(bat_ida);
-
static int w1_ds2780_add_slave(struct w1_slave *sl)
{
int ret;
- int id;
struct platform_device *pdev;
- id = ida_simple_get(&bat_ida, 0, 0, GFP_KERNEL);
- if (id < 0) {
- ret = id;
- goto noid;
- }
-
- pdev = platform_device_alloc("ds2780-battery", id);
- if (!pdev) {
- ret = -ENOMEM;
- goto pdev_alloc_failed;
- }
+ pdev = platform_device_alloc("ds2780-battery", PLATFORM_DEVID_AUTO);
+ if (!pdev)
+ return -ENOMEM;
pdev->dev.parent = &sl->dev;
ret = platform_device_add(pdev);
@@ -144,19 +133,15 @@ static int w1_ds2780_add_slave(struct w1_slave *sl)
pdev_add_failed:
platform_device_put(pdev);
-pdev_alloc_failed:
- ida_simple_remove(&bat_ida, id);
-noid:
+
return ret;
}
static void w1_ds2780_remove_slave(struct w1_slave *sl)
{
struct platform_device *pdev = dev_get_drvdata(&sl->dev);
- int id = pdev->id;
platform_device_unregister(pdev);
- ida_simple_remove(&bat_ida, id);
}
static struct w1_family_ops w1_ds2780_fops = {
@@ -172,14 +157,12 @@ static struct w1_family w1_ds2780_family = {
static int __init w1_ds2780_init(void)
{
- ida_init(&bat_ida);
return w1_register_family(&w1_ds2780_family);
}
static void __exit w1_ds2780_exit(void)
{
w1_unregister_family(&w1_ds2780_family);
- ida_destroy(&bat_ida);
}
module_init(w1_ds2780_init);