aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/dma-contiguous.c2
-rw-r--r--drivers/base/platform.c80
-rw-r--r--drivers/base/regmap/internal.h6
-rw-r--r--drivers/base/regmap/regcache-lzo.c4
-rw-r--r--drivers/base/regmap/regcache.c24
-rw-r--r--drivers/base/soc.c21
7 files changed, 94 insertions, 45 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 334ec7ef1960..b7d56c5ea3c6 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1066,7 +1066,7 @@ int device_add(struct device *dev)
1066 dev->kobj.parent = kobj; 1066 dev->kobj.parent = kobj;
1067 1067
1068 /* use parent numa_node */ 1068 /* use parent numa_node */
1069 if (parent) 1069 if (parent && (dev_to_node(dev) == NUMA_NO_NODE))
1070 set_dev_node(dev, dev_to_node(parent)); 1070 set_dev_node(dev, dev_to_node(parent));
1071 1071
1072 /* first, register with generic layer. */ 1072 /* first, register with generic layer. */
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index a12ff9863d7e..e167a1e1bccb 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -46,7 +46,7 @@ struct cma *dma_contiguous_default_area;
46 * Users, who want to set the size of global CMA area for their system 46 * Users, who want to set the size of global CMA area for their system
47 * should use cma= kernel parameter. 47 * should use cma= kernel parameter.
48 */ 48 */
49static const phys_addr_t size_bytes = CMA_SIZE_MBYTES * SZ_1M; 49static const phys_addr_t size_bytes = (phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
50static phys_addr_t size_cmdline = -1; 50static phys_addr_t size_cmdline = -1;
51static phys_addr_t base_cmdline; 51static phys_addr_t base_cmdline;
52static phys_addr_t limit_cmdline; 52static phys_addr_t limit_cmdline;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f80aaaf9f610..1dd6d3bf1098 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -513,7 +513,7 @@ static int platform_drv_probe(struct device *_dev)
513 return ret; 513 return ret;
514 514
515 ret = dev_pm_domain_attach(_dev, true); 515 ret = dev_pm_domain_attach(_dev, true);
516 if (ret != -EPROBE_DEFER) { 516 if (ret != -EPROBE_DEFER && drv->probe) {
517 ret = drv->probe(dev); 517 ret = drv->probe(dev);
518 if (ret) 518 if (ret)
519 dev_pm_domain_detach(_dev, true); 519 dev_pm_domain_detach(_dev, true);
@@ -536,9 +536,10 @@ static int platform_drv_remove(struct device *_dev)
536{ 536{
537 struct platform_driver *drv = to_platform_driver(_dev->driver); 537 struct platform_driver *drv = to_platform_driver(_dev->driver);
538 struct platform_device *dev = to_platform_device(_dev); 538 struct platform_device *dev = to_platform_device(_dev);
539 int ret; 539 int ret = 0;
540 540
541 ret = drv->remove(dev); 541 if (drv->remove)
542 ret = drv->remove(dev);
542 dev_pm_domain_detach(_dev, true); 543 dev_pm_domain_detach(_dev, true);
543 544
544 return ret; 545 return ret;
@@ -549,7 +550,8 @@ static void platform_drv_shutdown(struct device *_dev)
549 struct platform_driver *drv = to_platform_driver(_dev->driver); 550 struct platform_driver *drv = to_platform_driver(_dev->driver);
550 struct platform_device *dev = to_platform_device(_dev); 551 struct platform_device *dev = to_platform_device(_dev);
551 552
552 drv->shutdown(dev); 553 if (drv->shutdown)
554 drv->shutdown(dev);
553 dev_pm_domain_detach(_dev, true); 555 dev_pm_domain_detach(_dev, true);
554} 556}
555 557
@@ -563,12 +565,9 @@ int __platform_driver_register(struct platform_driver *drv,
563{ 565{
564 drv->driver.owner = owner; 566 drv->driver.owner = owner;
565 drv->driver.bus = &platform_bus_type; 567 drv->driver.bus = &platform_bus_type;
566 if (drv->probe) 568 drv->driver.probe = platform_drv_probe;
567 drv->driver.probe = platform_drv_probe; 569 drv->driver.remove = platform_drv_remove;
568 if (drv->remove) 570 drv->driver.shutdown = platform_drv_shutdown;
569 drv->driver.remove = platform_drv_remove;
570 if (drv->shutdown)
571 drv->driver.shutdown = platform_drv_shutdown;
572 571
573 return driver_register(&drv->driver); 572 return driver_register(&drv->driver);
574} 573}
@@ -711,6 +710,67 @@ err_out:
711} 710}
712EXPORT_SYMBOL_GPL(__platform_create_bundle); 711EXPORT_SYMBOL_GPL(__platform_create_bundle);
713 712
713/**
714 * __platform_register_drivers - register an array of platform drivers
715 * @drivers: an array of drivers to register
716 * @count: the number of drivers to register
717 * @owner: module owning the drivers
718 *
719 * Registers platform drivers specified by an array. On failure to register a
720 * driver, all previously registered drivers will be unregistered. Callers of
721 * this API should use platform_unregister_drivers() to unregister drivers in
722 * the reverse order.
723 *
724 * Returns: 0 on success or a negative error code on failure.
725 */
726int __platform_register_drivers(struct platform_driver * const *drivers,
727 unsigned int count, struct module *owner)
728{
729 unsigned int i;
730 int err;
731
732 for (i = 0; i < count; i++) {
733 pr_debug("registering platform driver %ps\n", drivers[i]);
734
735 err = __platform_driver_register(drivers[i], owner);
736 if (err < 0) {
737 pr_err("failed to register platform driver %ps: %d\n",
738 drivers[i], err);
739 goto error;
740 }
741 }
742
743 return 0;
744
745error:
746 while (i--) {
747 pr_debug("unregistering platform driver %ps\n", drivers[i]);
748 platform_driver_unregister(drivers[i]);
749 }
750
751 return err;
752}
753EXPORT_SYMBOL_GPL(__platform_register_drivers);
754
755/**
756 * platform_unregister_drivers - unregister an array of platform drivers
757 * @drivers: an array of drivers to unregister
758 * @count: the number of drivers to unregister
759 *
760 * Unegisters platform drivers specified by an array. This is typically used
761 * to complement an earlier call to platform_register_drivers(). Drivers are
762 * unregistered in the reverse order in which they were registered.
763 */
764void platform_unregister_drivers(struct platform_driver * const *drivers,
765 unsigned int count)
766{
767 while (count--) {
768 pr_debug("unregistering platform driver %ps\n", drivers[count]);
769 platform_driver_unregister(drivers[count]);
770 }
771}
772EXPORT_SYMBOL_GPL(platform_unregister_drivers);
773
714/* modalias support enables more hands-off userspace setup: 774/* modalias support enables more hands-off userspace setup:
715 * (a) environment variable lets new-style hotplug events work once system is 775 * (a) environment variable lets new-style hotplug events work once system is
716 * fully running: "modprobe $MODALIAS" 776 * fully running: "modprobe $MODALIAS"
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 3250e53473a3..3df977054781 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -125,9 +125,9 @@ struct regmap {
125 unsigned int num_reg_defaults_raw; 125 unsigned int num_reg_defaults_raw;
126 126
127 /* if set, only the cache is modified not the HW */ 127 /* if set, only the cache is modified not the HW */
128 u32 cache_only; 128 bool cache_only;
129 /* if set, only the HW is modified not the cache */ 129 /* if set, only the HW is modified not the cache */
130 u32 cache_bypass; 130 bool cache_bypass;
131 /* if set, remember to free reg_defaults_raw */ 131 /* if set, remember to free reg_defaults_raw */
132 bool cache_free; 132 bool cache_free;
133 133
@@ -135,7 +135,7 @@ struct regmap {
135 const void *reg_defaults_raw; 135 const void *reg_defaults_raw;
136 void *cache; 136 void *cache;
137 /* if set, the cache contains newer data than the HW */ 137 /* if set, the cache contains newer data than the HW */
138 u32 cache_dirty; 138 bool cache_dirty;
139 /* if set, the HW registers are known to match map->reg_defaults */ 139 /* if set, the HW registers are known to match map->reg_defaults */
140 bool no_sync_defaults; 140 bool no_sync_defaults;
141 141
diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c
index 2d53f6f138e1..736e0d378567 100644
--- a/drivers/base/regmap/regcache-lzo.c
+++ b/drivers/base/regmap/regcache-lzo.c
@@ -355,9 +355,9 @@ static int regcache_lzo_sync(struct regmap *map, unsigned int min,
355 if (ret > 0 && val == map->reg_defaults[ret].def) 355 if (ret > 0 && val == map->reg_defaults[ret].def)
356 continue; 356 continue;
357 357
358 map->cache_bypass = 1; 358 map->cache_bypass = true;
359 ret = _regmap_write(map, i, val); 359 ret = _regmap_write(map, i, val);
360 map->cache_bypass = 0; 360 map->cache_bypass = false;
361 if (ret) 361 if (ret)
362 return ret; 362 return ret;
363 dev_dbg(map->dev, "Synced register %#x, value %#x\n", 363 dev_dbg(map->dev, "Synced register %#x, value %#x\n",
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 6f8a13ec32a4..4c07802986b2 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -54,11 +54,11 @@ static int regcache_hw_init(struct regmap *map)
54 return -ENOMEM; 54 return -ENOMEM;
55 55
56 if (!map->reg_defaults_raw) { 56 if (!map->reg_defaults_raw) {
57 u32 cache_bypass = map->cache_bypass; 57 bool cache_bypass = map->cache_bypass;
58 dev_warn(map->dev, "No cache defaults, reading back from HW\n"); 58 dev_warn(map->dev, "No cache defaults, reading back from HW\n");
59 59
60 /* Bypass the cache access till data read from HW*/ 60 /* Bypass the cache access till data read from HW*/
61 map->cache_bypass = 1; 61 map->cache_bypass = true;
62 tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL); 62 tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL);
63 if (!tmp_buf) { 63 if (!tmp_buf) {
64 ret = -ENOMEM; 64 ret = -ENOMEM;
@@ -285,9 +285,9 @@ static int regcache_default_sync(struct regmap *map, unsigned int min,
285 if (!regcache_reg_needs_sync(map, reg, val)) 285 if (!regcache_reg_needs_sync(map, reg, val))
286 continue; 286 continue;
287 287
288 map->cache_bypass = 1; 288 map->cache_bypass = true;
289 ret = _regmap_write(map, reg, val); 289 ret = _regmap_write(map, reg, val);
290 map->cache_bypass = 0; 290 map->cache_bypass = false;
291 if (ret) { 291 if (ret) {
292 dev_err(map->dev, "Unable to sync register %#x. %d\n", 292 dev_err(map->dev, "Unable to sync register %#x. %d\n",
293 reg, ret); 293 reg, ret);
@@ -315,7 +315,7 @@ int regcache_sync(struct regmap *map)
315 int ret = 0; 315 int ret = 0;
316 unsigned int i; 316 unsigned int i;
317 const char *name; 317 const char *name;
318 unsigned int bypass; 318 bool bypass;
319 319
320 BUG_ON(!map->cache_ops); 320 BUG_ON(!map->cache_ops);
321 321
@@ -333,7 +333,7 @@ int regcache_sync(struct regmap *map)
333 map->async = true; 333 map->async = true;
334 334
335 /* Apply any patch first */ 335 /* Apply any patch first */
336 map->cache_bypass = 1; 336 map->cache_bypass = true;
337 for (i = 0; i < map->patch_regs; i++) { 337 for (i = 0; i < map->patch_regs; i++) {
338 ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def); 338 ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
339 if (ret != 0) { 339 if (ret != 0) {
@@ -342,7 +342,7 @@ int regcache_sync(struct regmap *map)
342 goto out; 342 goto out;
343 } 343 }
344 } 344 }
345 map->cache_bypass = 0; 345 map->cache_bypass = false;
346 346
347 if (map->cache_ops->sync) 347 if (map->cache_ops->sync)
348 ret = map->cache_ops->sync(map, 0, map->max_register); 348 ret = map->cache_ops->sync(map, 0, map->max_register);
@@ -384,7 +384,7 @@ int regcache_sync_region(struct regmap *map, unsigned int min,
384{ 384{
385 int ret = 0; 385 int ret = 0;
386 const char *name; 386 const char *name;
387 unsigned int bypass; 387 bool bypass;
388 388
389 BUG_ON(!map->cache_ops); 389 BUG_ON(!map->cache_ops);
390 390
@@ -637,11 +637,11 @@ static int regcache_sync_block_single(struct regmap *map, void *block,
637 if (!regcache_reg_needs_sync(map, regtmp, val)) 637 if (!regcache_reg_needs_sync(map, regtmp, val))
638 continue; 638 continue;
639 639
640 map->cache_bypass = 1; 640 map->cache_bypass = true;
641 641
642 ret = _regmap_write(map, regtmp, val); 642 ret = _regmap_write(map, regtmp, val);
643 643
644 map->cache_bypass = 0; 644 map->cache_bypass = false;
645 if (ret != 0) { 645 if (ret != 0) {
646 dev_err(map->dev, "Unable to sync register %#x. %d\n", 646 dev_err(map->dev, "Unable to sync register %#x. %d\n",
647 regtmp, ret); 647 regtmp, ret);
@@ -668,14 +668,14 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
668 dev_dbg(map->dev, "Writing %zu bytes for %d registers from 0x%x-0x%x\n", 668 dev_dbg(map->dev, "Writing %zu bytes for %d registers from 0x%x-0x%x\n",
669 count * val_bytes, count, base, cur - map->reg_stride); 669 count * val_bytes, count, base, cur - map->reg_stride);
670 670
671 map->cache_bypass = 1; 671 map->cache_bypass = true;
672 672
673 ret = _regmap_raw_write(map, base, *data, count * val_bytes); 673 ret = _regmap_raw_write(map, base, *data, count * val_bytes);
674 if (ret) 674 if (ret)
675 dev_err(map->dev, "Unable to sync registers %#x-%#x. %d\n", 675 dev_err(map->dev, "Unable to sync registers %#x-%#x. %d\n",
676 base, cur - map->reg_stride, ret); 676 base, cur - map->reg_stride, ret);
677 677
678 map->cache_bypass = 0; 678 map->cache_bypass = false;
679 679
680 *data = NULL; 680 *data = NULL;
681 681
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 39fca01c8fa1..75b98aad6faf 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -16,7 +16,6 @@
16#include <linux/err.h> 16#include <linux/err.h>
17 17
18static DEFINE_IDA(soc_ida); 18static DEFINE_IDA(soc_ida);
19static DEFINE_SPINLOCK(soc_lock);
20 19
21static ssize_t soc_info_get(struct device *dev, 20static ssize_t soc_info_get(struct device *dev,
22 struct device_attribute *attr, 21 struct device_attribute *attr,
@@ -122,20 +121,10 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
122 } 121 }
123 122
124 /* Fetch a unique (reclaimable) SOC ID. */ 123 /* Fetch a unique (reclaimable) SOC ID. */
125 do { 124 ret = ida_simple_get(&soc_ida, 0, 0, GFP_KERNEL);
126 if (!ida_pre_get(&soc_ida, GFP_KERNEL)) { 125 if (ret < 0)
127 ret = -ENOMEM;
128 goto out2;
129 }
130
131 spin_lock(&soc_lock);
132 ret = ida_get_new(&soc_ida, &soc_dev->soc_dev_num);
133 spin_unlock(&soc_lock);
134
135 } while (ret == -EAGAIN);
136
137 if (ret)
138 goto out2; 126 goto out2;
127 soc_dev->soc_dev_num = ret;
139 128
140 soc_dev->attr = soc_dev_attr; 129 soc_dev->attr = soc_dev_attr;
141 soc_dev->dev.bus = &soc_bus_type; 130 soc_dev->dev.bus = &soc_bus_type;
@@ -151,7 +140,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
151 return soc_dev; 140 return soc_dev;
152 141
153out3: 142out3:
154 ida_remove(&soc_ida, soc_dev->soc_dev_num); 143 ida_simple_remove(&soc_ida, soc_dev->soc_dev_num);
155out2: 144out2:
156 kfree(soc_dev); 145 kfree(soc_dev);
157out1: 146out1:
@@ -161,7 +150,7 @@ out1:
161/* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */ 150/* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */
162void soc_device_unregister(struct soc_device *soc_dev) 151void soc_device_unregister(struct soc_device *soc_dev)
163{ 152{
164 ida_remove(&soc_ida, soc_dev->soc_dev_num); 153 ida_simple_remove(&soc_ida, soc_dev->soc_dev_num);
165 154
166 device_unregister(&soc_dev->dev); 155 device_unregister(&soc_dev->dev);
167} 156}