device.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) | device.c (140b932f8cb6cced10b96860651a198b1b89cbb9) |
---|---|
1#include <linux/string.h> 2#include <linux/kernel.h> 3#include <linux/of.h> 4#include <linux/of_device.h> 5#include <linux/init.h> 6#include <linux/module.h> 7#include <linux/mod_devicetable.h> 8#include <linux/slab.h> --- 34 unchanged lines hidden (view full) --- 43 44void of_dev_put(struct of_device *dev) 45{ 46 if (dev) 47 put_device(&dev->dev); 48} 49EXPORT_SYMBOL(of_dev_put); 50 | 1#include <linux/string.h> 2#include <linux/kernel.h> 3#include <linux/of.h> 4#include <linux/of_device.h> 5#include <linux/init.h> 6#include <linux/module.h> 7#include <linux/mod_devicetable.h> 8#include <linux/slab.h> --- 34 unchanged lines hidden (view full) --- 43 44void of_dev_put(struct of_device *dev) 45{ 46 if (dev) 47 put_device(&dev->dev); 48} 49EXPORT_SYMBOL(of_dev_put); 50 |
51static ssize_t dev_show_devspec(struct device *dev, | 51static ssize_t devspec_show(struct device *dev, |
52 struct device_attribute *attr, char *buf) 53{ 54 struct of_device *ofdev; 55 56 ofdev = to_of_device(dev); | 52 struct device_attribute *attr, char *buf) 53{ 54 struct of_device *ofdev; 55 56 ofdev = to_of_device(dev); |
57 return sprintf(buf, "%s", ofdev->node->full_name); | 57 return sprintf(buf, "%s\n", ofdev->node->full_name); |
58} 59 | 58} 59 |
60static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); | 60static ssize_t modalias_show(struct device *dev, 61 struct device_attribute *attr, char *buf) 62{ 63 struct of_device *ofdev = to_of_device(dev); 64 ssize_t len = 0; |
61 | 65 |
66 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); 67 buf[len] = '\n'; 68 buf[len+1] = 0; 69 return len+1; 70} 71 72struct device_attribute of_platform_device_attrs[] = { 73 __ATTR_RO(devspec), 74 __ATTR_RO(modalias), 75 __ATTR_NULL 76}; 77 |
|
62/** 63 * of_release_dev - free an of device structure when all users of it are finished. 64 * @dev: device that's been disconnected 65 * 66 * Will be called only by the device core when all users of this of device are 67 * done. 68 */ 69void of_release_dev(struct device *dev) 70{ 71 struct of_device *ofdev; 72 73 ofdev = to_of_device(dev); 74 of_node_put(ofdev->node); 75 kfree(ofdev); 76} 77EXPORT_SYMBOL(of_release_dev); 78 79int of_device_register(struct of_device *ofdev) 80{ | 78/** 79 * of_release_dev - free an of device structure when all users of it are finished. 80 * @dev: device that's been disconnected 81 * 82 * Will be called only by the device core when all users of this of device are 83 * done. 84 */ 85void of_release_dev(struct device *dev) 86{ 87 struct of_device *ofdev; 88 89 ofdev = to_of_device(dev); 90 of_node_put(ofdev->node); 91 kfree(ofdev); 92} 93EXPORT_SYMBOL(of_release_dev); 94 95int of_device_register(struct of_device *ofdev) 96{ |
81 int rc; 82 | |
83 BUG_ON(ofdev->node == NULL); | 97 BUG_ON(ofdev->node == NULL); |
84 85 rc = device_register(&ofdev->dev); 86 if (rc) 87 return rc; 88 89 rc = device_create_file(&ofdev->dev, &dev_attr_devspec); 90 if (rc) 91 device_unregister(&ofdev->dev); 92 93 return rc; | 98 return device_register(&ofdev->dev); |
94} 95EXPORT_SYMBOL(of_device_register); 96 97void of_device_unregister(struct of_device *ofdev) 98{ | 99} 100EXPORT_SYMBOL(of_device_register); 101 102void of_device_unregister(struct of_device *ofdev) 103{ |
99 device_remove_file(&ofdev->dev, &dev_attr_devspec); | |
100 device_unregister(&ofdev->dev); 101} 102EXPORT_SYMBOL(of_device_unregister); | 104 device_unregister(&ofdev->dev); 105} 106EXPORT_SYMBOL(of_device_unregister); |