Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (62 commits)
msi-laptop: depends on RFKILL
msi-laptop: Detect 3G device exists by standard ec command
msi-laptop: Add resume method for set the SCM load again
msi-laptop: Support some MSI 3G netbook that is need load SCM
msi-laptop: Add threeg sysfs file for support query 3G state by standard 66/62 ec command
msi-laptop: Support standard ec 66/62 command on MSI notebook and nebook
Driver core: create lock/unlock functions for struct device
sysfs: fix for thinko with sysfs_bin_attr_init()
sysfs: Kill unused sysfs_sb variable.
sysfs: Pass super_block to sysfs_get_inode
driver core: Use sysfs_rename_link in device_rename
sysfs: Implement sysfs_rename_link
sysfs: Pack sysfs_dirent more tightly.
sysfs: Serialize updates to the vfs inode
sysfs: windfarm: init sysfs attributes
sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on module dynamic attributes
sysfs: Document sysfs_attr_init and sysfs_bin_attr_init
sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on dynamic attributes
sysfs: Use one lockdep class per sysfs attribute.
sysfs: Only take active references on attributes.
...

+1465 -795
+32 -73
Documentation/HOWTO
··· 221 221 - main 2.6.x kernel tree 222 222 - 2.6.x.y -stable kernel tree 223 223 - 2.6.x -git kernel patches 224 - - 2.6.x -mm kernel patches 225 224 - subsystem specific kernel trees and patches 225 + - the 2.6.x -next kernel tree for integration tests 226 226 227 227 2.6.x kernel tree 228 228 ----------------- ··· 232 232 - As soon as a new kernel is released a two weeks window is open, 233 233 during this period of time maintainers can submit big diffs to 234 234 Linus, usually the patches that have already been included in the 235 - -mm kernel for a few weeks. The preferred way to submit big changes 235 + -next kernel for a few weeks. The preferred way to submit big changes 236 236 is using git (the kernel's source management tool, more information 237 237 can be found at http://git.or.cz/) but plain patches are also just 238 238 fine. ··· 293 293 experimental than -rc kernels since they are generated automatically 294 294 without even a cursory glance to see if they are sane. 295 295 296 - 2.6.x -mm kernel patches 297 - ------------------------ 298 - These are experimental kernel patches released by Andrew Morton. Andrew 299 - takes all of the different subsystem kernel trees and patches and mushes 300 - them together, along with a lot of patches that have been plucked from 301 - the linux-kernel mailing list. This tree serves as a proving ground for 302 - new features and patches. Once a patch has proved its worth in -mm for 303 - a while Andrew or the subsystem maintainer pushes it on to Linus for 304 - inclusion in mainline. 305 - 306 - It is heavily encouraged that all new patches get tested in the -mm tree 307 - before they are sent to Linus for inclusion in the main kernel tree. Code 308 - which does not make an appearance in -mm before the opening of the merge 309 - window will prove hard to merge into the mainline. 310 - 311 - These kernels are not appropriate for use on systems that are supposed 312 - to be stable and they are more risky to run than any of the other 313 - branches. 314 - 315 - If you wish to help out with the kernel development process, please test 316 - and use these kernel releases and provide feedback to the linux-kernel 317 - mailing list if you have any problems, and if everything works properly. 318 - 319 - In addition to all the other experimental patches, these kernels usually 320 - also contain any changes in the mainline -git kernels available at the 321 - time of release. 322 - 323 - The -mm kernels are not released on a fixed schedule, but usually a few 324 - -mm kernels are released in between each -rc kernel (1 to 3 is common). 325 - 326 296 Subsystem Specific kernel trees and patches 327 297 ------------------------------------------- 328 - A number of the different kernel subsystem developers expose their 329 - development trees so that others can see what is happening in the 330 - different areas of the kernel. These trees are pulled into the -mm 331 - kernel releases as described above. 298 + The maintainers of the various kernel subsystems --- and also many 299 + kernel subsystem developers --- expose their current state of 300 + development in source repositories. That way, others can see what is 301 + happening in the different areas of the kernel. In areas where 302 + development is rapid, a developer may be asked to base his submissions 303 + onto such a subsystem kernel tree so that conflicts between the 304 + submission and other already ongoing work are avoided. 332 305 333 - Here is a list of some of the different kernel trees available: 334 - git trees: 335 - - Kbuild development tree, Sam Ravnborg <sam@ravnborg.org> 336 - git.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git 306 + Most of these repositories are git trees, but there are also other SCMs 307 + in use, or patch queues being published as quilt series. Addresses of 308 + these subsystem repositories are listed in the MAINTAINERS file. Many 309 + of them can be browsed at http://git.kernel.org/. 337 310 338 - - ACPI development tree, Len Brown <len.brown@intel.com> 339 - git.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git 311 + Before a proposed patch is committed to such a subsystem tree, it is 312 + subject to review which primarily happens on mailing lists (see the 313 + respective section below). For several kernel subsystems, this review 314 + process is tracked with the tool patchwork. Patchwork offers a web 315 + interface which shows patch postings, any comments on a patch or 316 + revisions to it, and maintainers can mark patches as under review, 317 + accepted, or rejected. Most of these patchwork sites are listed at 318 + http://patchwork.kernel.org/ or http://patchwork.ozlabs.org/. 340 319 341 - - Block development tree, Jens Axboe <jens.axboe@oracle.com> 342 - git.kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git 320 + 2.6.x -next kernel tree for integration tests 321 + --------------------------------------------- 322 + Before updates from subsystem trees are merged into the mainline 2.6.x 323 + tree, they need to be integration-tested. For this purpose, a special 324 + testing repository exists into which virtually all subsystem trees are 325 + pulled on an almost daily basis: 326 + http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git 327 + http://linux.f-seidel.de/linux-next/pmwiki/ 343 328 344 - - DRM development tree, Dave Airlie <airlied@linux.ie> 345 - git.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git 329 + This way, the -next kernel gives a summary outlook onto what will be 330 + expected to go into the mainline kernel at the next merge period. 331 + Adventurous testers are very welcome to runtime-test the -next kernel. 346 332 347 - - ia64 development tree, Tony Luck <tony.luck@intel.com> 348 - git.kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git 349 - 350 - - infiniband, Roland Dreier <rolandd@cisco.com> 351 - git.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git 352 - 353 - - libata, Jeff Garzik <jgarzik@pobox.com> 354 - git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git 355 - 356 - - network drivers, Jeff Garzik <jgarzik@pobox.com> 357 - git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git 358 - 359 - - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net> 360 - git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git 361 - 362 - - SCSI, James Bottomley <James.Bottomley@hansenpartnership.com> 363 - git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git 364 - 365 - - x86, Ingo Molnar <mingo@elte.hu> 366 - git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git 367 - 368 - quilt trees: 369 - - USB, Driver Core, and I2C, Greg Kroah-Hartman <gregkh@suse.de> 370 - kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 371 - 372 - Other kernel trees can be found listed at http://git.kernel.org/ and in 373 - the MAINTAINERS file. 374 333 375 334 Bug Reporting 376 335 -------------
+1 -1
Documentation/kobject.txt
··· 266 266 267 267 struct kobj_type { 268 268 void (*release)(struct kobject *); 269 - struct sysfs_ops *sysfs_ops; 269 + const struct sysfs_ops *sysfs_ops; 270 270 struct attribute **default_attrs; 271 271 }; 272 272
+1 -1
arch/arm/mach-pxa/corgi_ssp.c
··· 204 204 ssp_machinfo = machinfo; 205 205 } 206 206 207 - static int __init corgi_ssp_probe(struct platform_device *dev) 207 + static int __devinit corgi_ssp_probe(struct platform_device *dev) 208 208 { 209 209 int ret; 210 210
+1 -1
arch/arm/mach-pxa/sharpsl_pm.c
··· 900 900 }; 901 901 #endif 902 902 903 - static int __init sharpsl_pm_probe(struct platform_device *pdev) 903 + static int __devinit sharpsl_pm_probe(struct platform_device *pdev) 904 904 { 905 905 int ret; 906 906
+1 -1
arch/arm/mach-s3c2410/h1940-bluetooth.c
··· 56 56 .set_block = h1940bt_set_block, 57 57 }; 58 58 59 - static int __init h1940bt_probe(struct platform_device *pdev) 59 + static int __devinit h1940bt_probe(struct platform_device *pdev) 60 60 { 61 61 struct rfkill *rfk; 62 62 int ret = 0;
+1 -1
arch/arm/mach-sa1100/jornada720_ssp.c
··· 130 130 }; 131 131 EXPORT_SYMBOL(jornada_ssp_end); 132 132 133 - static int __init jornada_ssp_probe(struct platform_device *dev) 133 + static int __devinit jornada_ssp_probe(struct platform_device *dev) 134 134 { 135 135 int ret; 136 136
+1 -1
arch/ia64/kernel/topology.c
··· 282 282 return ret; 283 283 } 284 284 285 - static struct sysfs_ops cache_sysfs_ops = { 285 + static const struct sysfs_ops cache_sysfs_ops = { 286 286 .show = cache_show 287 287 }; 288 288
+4 -1
arch/mips/txx9/generic/7segled.c
··· 58 58 static SYSDEV_ATTR(ascii, 0200, NULL, ascii_store); 59 59 static SYSDEV_ATTR(raw, 0200, NULL, raw_store); 60 60 61 - static ssize_t map_seg7_show(struct sysdev_class *class, char *buf) 61 + static ssize_t map_seg7_show(struct sysdev_class *class, 62 + struct sysdev_class_attribute *attr, 63 + char *buf) 62 64 { 63 65 memcpy(buf, &txx9_seg7map, sizeof(txx9_seg7map)); 64 66 return sizeof(txx9_seg7map); 65 67 } 66 68 67 69 static ssize_t map_seg7_store(struct sysdev_class *class, 70 + struct sysdev_class_attribute *attr, 68 71 const char *buf, size_t size) 69 72 { 70 73 if (size != sizeof(txx9_seg7map))
+1 -1
arch/powerpc/kernel/cacheinfo.c
··· 642 642 &cache_assoc_attr, 643 643 }; 644 644 645 - static struct sysfs_ops cache_index_ops = { 645 + static const struct sysfs_ops cache_index_ops = { 646 646 .show = cache_index_show, 647 647 }; 648 648
+9 -3
arch/s390/kernel/smp.c
··· 1020 1020 return rc; 1021 1021 } 1022 1022 1023 - static ssize_t __ref rescan_store(struct sysdev_class *class, const char *buf, 1023 + static ssize_t __ref rescan_store(struct sysdev_class *class, 1024 + struct sysdev_class_attribute *attr, 1025 + const char *buf, 1024 1026 size_t count) 1025 1027 { 1026 1028 int rc; ··· 1033 1031 static SYSDEV_CLASS_ATTR(rescan, 0200, NULL, rescan_store); 1034 1032 #endif /* CONFIG_HOTPLUG_CPU */ 1035 1033 1036 - static ssize_t dispatching_show(struct sysdev_class *class, char *buf) 1034 + static ssize_t dispatching_show(struct sysdev_class *class, 1035 + struct sysdev_class_attribute *attr, 1036 + char *buf) 1037 1037 { 1038 1038 ssize_t count; 1039 1039 ··· 1045 1041 return count; 1046 1042 } 1047 1043 1048 - static ssize_t dispatching_store(struct sysdev_class *dev, const char *buf, 1044 + static ssize_t dispatching_store(struct sysdev_class *dev, 1045 + struct sysdev_class_attribute *attr, 1046 + const char *buf, 1049 1047 size_t count) 1050 1048 { 1051 1049 int val, rc;
+37 -12
arch/s390/kernel/time.c
··· 1116 1116 /* 1117 1117 * ETR class attributes 1118 1118 */ 1119 - static ssize_t etr_stepping_port_show(struct sysdev_class *class, char *buf) 1119 + static ssize_t etr_stepping_port_show(struct sysdev_class *class, 1120 + struct sysdev_class_attribute *attr, 1121 + char *buf) 1120 1122 { 1121 1123 return sprintf(buf, "%i\n", etr_port0.esw.p); 1122 1124 } 1123 1125 1124 1126 static SYSDEV_CLASS_ATTR(stepping_port, 0400, etr_stepping_port_show, NULL); 1125 1127 1126 - static ssize_t etr_stepping_mode_show(struct sysdev_class *class, char *buf) 1128 + static ssize_t etr_stepping_mode_show(struct sysdev_class *class, 1129 + struct sysdev_class_attribute *attr, 1130 + char *buf) 1127 1131 { 1128 1132 char *mode_str; 1129 1133 ··· 1588 1584 .name = "stp", 1589 1585 }; 1590 1586 1591 - static ssize_t stp_ctn_id_show(struct sysdev_class *class, char *buf) 1587 + static ssize_t stp_ctn_id_show(struct sysdev_class *class, 1588 + struct sysdev_class_attribute *attr, 1589 + char *buf) 1592 1590 { 1593 1591 if (!stp_online) 1594 1592 return -ENODATA; ··· 1600 1594 1601 1595 static SYSDEV_CLASS_ATTR(ctn_id, 0400, stp_ctn_id_show, NULL); 1602 1596 1603 - static ssize_t stp_ctn_type_show(struct sysdev_class *class, char *buf) 1597 + static ssize_t stp_ctn_type_show(struct sysdev_class *class, 1598 + struct sysdev_class_attribute *attr, 1599 + char *buf) 1604 1600 { 1605 1601 if (!stp_online) 1606 1602 return -ENODATA; ··· 1611 1603 1612 1604 static SYSDEV_CLASS_ATTR(ctn_type, 0400, stp_ctn_type_show, NULL); 1613 1605 1614 - static ssize_t stp_dst_offset_show(struct sysdev_class *class, char *buf) 1606 + static ssize_t stp_dst_offset_show(struct sysdev_class *class, 1607 + struct sysdev_class_attribute *attr, 1608 + char *buf) 1615 1609 { 1616 1610 if (!stp_online || !(stp_info.vbits & 0x2000)) 1617 1611 return -ENODATA; ··· 1622 1612 1623 1613 static SYSDEV_CLASS_ATTR(dst_offset, 0400, stp_dst_offset_show, NULL); 1624 1614 1625 - static ssize_t stp_leap_seconds_show(struct sysdev_class *class, char *buf) 1615 + static ssize_t stp_leap_seconds_show(struct sysdev_class *class, 1616 + struct sysdev_class_attribute *attr, 1617 + char *buf) 1626 1618 { 1627 1619 if (!stp_online || !(stp_info.vbits & 0x8000)) 1628 1620 return -ENODATA; ··· 1633 1621 1634 1622 static SYSDEV_CLASS_ATTR(leap_seconds, 0400, stp_leap_seconds_show, NULL); 1635 1623 1636 - static ssize_t stp_stratum_show(struct sysdev_class *class, char *buf) 1624 + static ssize_t stp_stratum_show(struct sysdev_class *class, 1625 + struct sysdev_class_attribute *attr, 1626 + char *buf) 1637 1627 { 1638 1628 if (!stp_online) 1639 1629 return -ENODATA; ··· 1644 1630 1645 1631 static SYSDEV_CLASS_ATTR(stratum, 0400, stp_stratum_show, NULL); 1646 1632 1647 - static ssize_t stp_time_offset_show(struct sysdev_class *class, char *buf) 1633 + static ssize_t stp_time_offset_show(struct sysdev_class *class, 1634 + struct sysdev_class_attribute *attr, 1635 + char *buf) 1648 1636 { 1649 1637 if (!stp_online || !(stp_info.vbits & 0x0800)) 1650 1638 return -ENODATA; ··· 1655 1639 1656 1640 static SYSDEV_CLASS_ATTR(time_offset, 0400, stp_time_offset_show, NULL); 1657 1641 1658 - static ssize_t stp_time_zone_offset_show(struct sysdev_class *class, char *buf) 1642 + static ssize_t stp_time_zone_offset_show(struct sysdev_class *class, 1643 + struct sysdev_class_attribute *attr, 1644 + char *buf) 1659 1645 { 1660 1646 if (!stp_online || !(stp_info.vbits & 0x4000)) 1661 1647 return -ENODATA; ··· 1667 1649 static SYSDEV_CLASS_ATTR(time_zone_offset, 0400, 1668 1650 stp_time_zone_offset_show, NULL); 1669 1651 1670 - static ssize_t stp_timing_mode_show(struct sysdev_class *class, char *buf) 1652 + static ssize_t stp_timing_mode_show(struct sysdev_class *class, 1653 + struct sysdev_class_attribute *attr, 1654 + char *buf) 1671 1655 { 1672 1656 if (!stp_online) 1673 1657 return -ENODATA; ··· 1678 1658 1679 1659 static SYSDEV_CLASS_ATTR(timing_mode, 0400, stp_timing_mode_show, NULL); 1680 1660 1681 - static ssize_t stp_timing_state_show(struct sysdev_class *class, char *buf) 1661 + static ssize_t stp_timing_state_show(struct sysdev_class *class, 1662 + struct sysdev_class_attribute *attr, 1663 + char *buf) 1682 1664 { 1683 1665 if (!stp_online) 1684 1666 return -ENODATA; ··· 1689 1667 1690 1668 static SYSDEV_CLASS_ATTR(timing_state, 0400, stp_timing_state_show, NULL); 1691 1669 1692 - static ssize_t stp_online_show(struct sysdev_class *class, char *buf) 1670 + static ssize_t stp_online_show(struct sysdev_class *class, 1671 + struct sysdev_class_attribute *attr, 1672 + char *buf) 1693 1673 { 1694 1674 return sprintf(buf, "%i\n", stp_online); 1695 1675 } 1696 1676 1697 1677 static ssize_t stp_online_store(struct sysdev_class *class, 1678 + struct sysdev_class_attribute *attr, 1698 1679 const char *buf, size_t count) 1699 1680 { 1700 1681 unsigned int value;
+1 -1
arch/sh/kernel/cpu/sh4/sq.c
··· 326 326 NULL, 327 327 }; 328 328 329 - static struct sysfs_ops sq_sysfs_ops = { 329 + static const struct sysfs_ops sq_sysfs_ops = { 330 330 .show = sq_sysfs_show, 331 331 .store = sq_sysfs_store, 332 332 };
+1 -1
arch/x86/kernel/cpu/intel_cacheinfo.c
··· 903 903 return ret; 904 904 } 905 905 906 - static struct sysfs_ops sysfs_ops = { 906 + static const struct sysfs_ops sysfs_ops = { 907 907 .show = show, 908 908 .store = store, 909 909 };
+1
arch/x86/kernel/cpu/mcheck/mce.c
··· 2044 2044 struct mce_bank *b = &mce_banks[i]; 2045 2045 struct sysdev_attribute *a = &b->attr; 2046 2046 2047 + sysfs_attr_init(&a->attr); 2047 2048 a->attr.name = b->attrname; 2048 2049 snprintf(b->attrname, ATTR_LEN, "bank%d", i); 2049 2050
+1 -1
arch/x86/kernel/cpu/mcheck/mce_amd.c
··· 388 388 return ret; 389 389 } 390 390 391 - static struct sysfs_ops threshold_ops = { 391 + static const struct sysfs_ops threshold_ops = { 392 392 .show = show, 393 393 .store = store, 394 394 };
+1 -1
block/blk-integrity.c
··· 278 278 NULL, 279 279 }; 280 280 281 - static struct sysfs_ops integrity_ops = { 281 + static const struct sysfs_ops integrity_ops = { 282 282 .show = &integrity_attr_show, 283 283 .store = &integrity_attr_store, 284 284 };
+1 -1
block/blk-sysfs.c
··· 450 450 kmem_cache_free(blk_requestq_cachep, q); 451 451 } 452 452 453 - static struct sysfs_ops queue_sysfs_ops = { 453 + static const struct sysfs_ops queue_sysfs_ops = { 454 454 .show = queue_attr_show, 455 455 .store = queue_attr_store, 456 456 };
+1 -1
block/elevator.c
··· 892 892 return error; 893 893 } 894 894 895 - static struct sysfs_ops elv_sysfs_ops = { 895 + static const struct sysfs_ops elv_sysfs_ops = { 896 896 .show = elv_attr_show, 897 897 .store = elv_attr_store, 898 898 };
+2
drivers/acpi/system.c
··· 101 101 struct acpi_table_header *header = NULL; 102 102 struct acpi_table_attr *attr = NULL; 103 103 104 + sysfs_attr_init(&table_attr->attr.attr); 104 105 if (table_header->signature[0] != '\0') 105 106 memcpy(table_attr->name, table_header->signature, 106 107 ACPI_NAME_SIZE); ··· 476 475 goto fail; 477 476 strncpy(name, buffer, strlen(buffer) + 1); 478 477 478 + sysfs_attr_init(&counter_attrs[i].attr); 479 479 counter_attrs[i].attr.name = name; 480 480 counter_attrs[i].attr.mode = 0644; 481 481 counter_attrs[i].show = counter_show;
+1 -1
drivers/auxdisplay/cfag12864bfb.c
··· 81 81 .fb_mmap = cfag12864bfb_mmap, 82 82 }; 83 83 84 - static int __init cfag12864bfb_probe(struct platform_device *device) 84 + static int __devinit cfag12864bfb_probe(struct platform_device *device) 85 85 { 86 86 int ret = -EINVAL; 87 87 struct fb_info *info = framebuffer_alloc(0, &device->dev);
+33 -18
drivers/base/Kconfig
··· 3 3 config UEVENT_HELPER_PATH 4 4 string "path to uevent helper" 5 5 depends on HOTPLUG 6 - default "/sbin/hotplug" 6 + default "" 7 7 help 8 8 Path to uevent helper program forked by the kernel for 9 9 every uevent. 10 + Before the switch to the netlink-based uevent source, this was 11 + used to hook hotplug scripts into kernel device events. It 12 + usually pointed to a shell script at /sbin/hotplug. 13 + This should not be used today, because usual systems create 14 + many events at bootup or device discovery in a very short time 15 + frame. One forked process per event can create so many processes 16 + that it creates a high system load, or on smaller systems 17 + it is known to create out-of-memory situations during bootup. 10 18 11 19 config DEVTMPFS 12 - bool "Create a kernel maintained /dev tmpfs (EXPERIMENTAL)" 20 + bool "Maintain a devtmpfs filesystem to mount at /dev" 13 21 depends on HOTPLUG && SHMEM && TMPFS 14 22 help 15 - This creates a tmpfs filesystem, and mounts it at bootup 16 - and mounts it at /dev. The kernel driver core creates device 17 - nodes for all registered devices in that filesystem. All device 18 - nodes are owned by root and have the default mode of 0600. 19 - Userspace can add and delete the nodes as needed. This is 20 - intended to simplify bootup, and make it possible to delay 21 - the initial coldplug at bootup done by udev in userspace. 22 - It should also provide a simpler way for rescue systems 23 - to bring up a kernel with dynamic major/minor numbers. 24 - Meaningful symlinks, permissions and device ownership must 25 - still be handled by userspace. 26 - If unsure, say N here. 23 + This creates a tmpfs filesystem instance early at bootup. 24 + In this filesystem, the kernel driver core maintains device 25 + nodes with their default names and permissions for all 26 + registered devices with an assigned major/minor number. 27 + Userspace can modify the filesystem content as needed, add 28 + symlinks, and apply needed permissions. 29 + It provides a fully functional /dev directory, where usually 30 + udev runs on top, managing permissions and adding meaningful 31 + symlinks. 32 + In very limited environments, it may provide a sufficient 33 + functional /dev without any further help. It also allows simple 34 + rescue systems, and reliably handles dynamic major/minor numbers. 27 35 28 36 config DEVTMPFS_MOUNT 29 - bool "Automount devtmpfs at /dev" 37 + bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" 30 38 depends on DEVTMPFS 31 39 help 32 - This will mount devtmpfs at /dev if the kernel mounts the root 33 - filesystem. It will not affect initramfs based mounting. 34 - If unsure, say N here. 40 + This will instruct the kernel to automatically mount the 41 + devtmpfs filesystem at /dev, directly after the kernel has 42 + mounted the root filesystem. The behavior can be overridden 43 + with the commandline parameter: devtmpfs.mount=0|1. 44 + This option does not affect initramfs based booting, here 45 + the devtmpfs filesystem always needs to be mounted manually 46 + after the roots is mounted. 47 + With this option enabled, it allows to bring up a system in 48 + rescue mode with init=/bin/sh, even when the /dev directory 49 + on the rootfs is completely empty. 35 50 36 51 config STANDALONE 37 52 bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL
+13 -13
drivers/base/bus.c
··· 70 70 return ret; 71 71 } 72 72 73 - static struct sysfs_ops driver_sysfs_ops = { 73 + static const struct sysfs_ops driver_sysfs_ops = { 74 74 .show = drv_attr_show, 75 75 .store = drv_attr_store, 76 76 }; ··· 115 115 return ret; 116 116 } 117 117 118 - static struct sysfs_ops bus_sysfs_ops = { 118 + static const struct sysfs_ops bus_sysfs_ops = { 119 119 .show = bus_attr_show, 120 120 .store = bus_attr_store, 121 121 }; ··· 154 154 return 0; 155 155 } 156 156 157 - static struct kset_uevent_ops bus_uevent_ops = { 157 + static const struct kset_uevent_ops bus_uevent_ops = { 158 158 .filter = bus_uevent_filter, 159 159 }; 160 160 ··· 173 173 dev = bus_find_device_by_name(bus, NULL, buf); 174 174 if (dev && dev->driver == drv) { 175 175 if (dev->parent) /* Needed for USB */ 176 - down(&dev->parent->sem); 176 + device_lock(dev->parent); 177 177 device_release_driver(dev); 178 178 if (dev->parent) 179 - up(&dev->parent->sem); 179 + device_unlock(dev->parent); 180 180 err = count; 181 181 } 182 182 put_device(dev); ··· 200 200 dev = bus_find_device_by_name(bus, NULL, buf); 201 201 if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { 202 202 if (dev->parent) /* Needed for USB */ 203 - down(&dev->parent->sem); 204 - down(&dev->sem); 203 + device_lock(dev->parent); 204 + device_lock(dev); 205 205 err = driver_probe_device(drv, dev); 206 - up(&dev->sem); 206 + device_unlock(dev); 207 207 if (dev->parent) 208 - up(&dev->parent->sem); 208 + device_unlock(dev->parent); 209 209 210 210 if (err > 0) { 211 211 /* success */ ··· 744 744 745 745 if (!dev->driver) { 746 746 if (dev->parent) /* Needed for USB */ 747 - down(&dev->parent->sem); 747 + device_lock(dev->parent); 748 748 ret = device_attach(dev); 749 749 if (dev->parent) 750 - up(&dev->parent->sem); 750 + device_unlock(dev->parent); 751 751 } 752 752 return ret < 0 ? ret : 0; 753 753 } ··· 779 779 { 780 780 if (dev->driver) { 781 781 if (dev->parent) /* Needed for USB */ 782 - down(&dev->parent->sem); 782 + device_lock(dev->parent); 783 783 device_release_driver(dev); 784 784 if (dev->parent) 785 - up(&dev->parent->sem); 785 + device_unlock(dev->parent); 786 786 } 787 787 return bus_rescan_devices_helper(dev, NULL); 788 788 }
+13 -3
drivers/base/class.c
··· 31 31 ssize_t ret = -EIO; 32 32 33 33 if (class_attr->show) 34 - ret = class_attr->show(cp->class, buf); 34 + ret = class_attr->show(cp->class, class_attr, buf); 35 35 return ret; 36 36 } 37 37 ··· 43 43 ssize_t ret = -EIO; 44 44 45 45 if (class_attr->store) 46 - ret = class_attr->store(cp->class, buf, count); 46 + ret = class_attr->store(cp->class, class_attr, buf, count); 47 47 return ret; 48 48 } 49 49 ··· 63 63 kfree(cp); 64 64 } 65 65 66 - static struct sysfs_ops class_sysfs_ops = { 66 + static const struct sysfs_ops class_sysfs_ops = { 67 67 .show = class_attr_show, 68 68 .store = class_attr_store, 69 69 }; ··· 489 489 490 490 class_put(parent); 491 491 } 492 + 493 + ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, 494 + char *buf) 495 + { 496 + struct class_attribute_string *cs; 497 + cs = container_of(attr, struct class_attribute_string, attr); 498 + return snprintf(buf, PAGE_SIZE, "%s\n", cs->str); 499 + } 500 + 501 + EXPORT_SYMBOL_GPL(show_class_attr_string); 492 502 493 503 struct class_compat { 494 504 struct kobject *kobj;
+22 -24
drivers/base/core.c
··· 100 100 return ret; 101 101 } 102 102 103 - static struct sysfs_ops dev_sysfs_ops = { 103 + static const struct sysfs_ops dev_sysfs_ops = { 104 104 .show = dev_attr_show, 105 105 .store = dev_attr_store, 106 106 }; ··· 252 252 return retval; 253 253 } 254 254 255 - static struct kset_uevent_ops device_uevent_ops = { 255 + static const struct kset_uevent_ops device_uevent_ops = { 256 256 .filter = dev_uevent_filter, 257 257 .name = dev_uevent_name, 258 258 .uevent = dev_uevent, ··· 306 306 { 307 307 enum kobject_action action; 308 308 309 - if (kobject_action_type(buf, count, &action) == 0) { 309 + if (kobject_action_type(buf, count, &action) == 0) 310 310 kobject_uevent(&dev->kobj, action); 311 - goto out; 312 - } 313 - 314 - dev_err(dev, "uevent: unsupported action-string; this will " 315 - "be ignored in a future kernel version\n"); 316 - kobject_uevent(&dev->kobj, KOBJ_ADD); 317 - out: 311 + else 312 + dev_err(dev, "uevent: unknown action-string\n"); 318 313 return count; 319 314 } 320 315 ··· 602 607 int retval; 603 608 604 609 if (dev->class) { 610 + static DEFINE_MUTEX(gdp_mutex); 605 611 struct kobject *kobj = NULL; 606 612 struct kobject *parent_kobj; 607 613 struct kobject *k; ··· 619 623 else 620 624 parent_kobj = &parent->kobj; 621 625 626 + mutex_lock(&gdp_mutex); 627 + 622 628 /* find our class-directory at the parent and reference it */ 623 629 spin_lock(&dev->class->p->class_dirs.list_lock); 624 630 list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) ··· 629 631 break; 630 632 } 631 633 spin_unlock(&dev->class->p->class_dirs.list_lock); 632 - if (kobj) 634 + if (kobj) { 635 + mutex_unlock(&gdp_mutex); 633 636 return kobj; 637 + } 634 638 635 639 /* or create a new class-directory at the parent device */ 636 640 k = kobject_create(); 637 - if (!k) 641 + if (!k) { 642 + mutex_unlock(&gdp_mutex); 638 643 return NULL; 644 + } 639 645 k->kset = &dev->class->p->class_dirs; 640 646 retval = kobject_add(k, parent_kobj, "%s", dev->class->name); 641 647 if (retval < 0) { 648 + mutex_unlock(&gdp_mutex); 642 649 kobject_put(k); 643 650 return NULL; 644 651 } 645 652 /* do not emit an uevent for this simple "glue" directory */ 653 + mutex_unlock(&gdp_mutex); 646 654 return k; 647 655 } 648 656 ··· 1578 1574 if (old_class_name) { 1579 1575 new_class_name = make_class_name(dev->class->name, &dev->kobj); 1580 1576 if (new_class_name) { 1581 - error = sysfs_create_link_nowarn(&dev->parent->kobj, 1582 - &dev->kobj, 1583 - new_class_name); 1584 - if (error) 1585 - goto out; 1586 - sysfs_remove_link(&dev->parent->kobj, old_class_name); 1577 + error = sysfs_rename_link(&dev->parent->kobj, 1578 + &dev->kobj, 1579 + old_class_name, 1580 + new_class_name); 1587 1581 } 1588 1582 } 1589 1583 #else 1590 1584 if (dev->class) { 1591 - error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj, 1592 - &dev->kobj, dev_name(dev)); 1593 - if (error) 1594 - goto out; 1595 - sysfs_remove_link(&dev->class->p->class_subsys.kobj, 1596 - old_device_name); 1585 + error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, 1586 + &dev->kobj, old_device_name, new_name); 1597 1587 } 1598 1588 #endif 1599 1589
+47 -58
drivers/base/cpu.c
··· 13 13 14 14 #include "base.h" 15 15 16 + static struct sysdev_class_attribute *cpu_sysdev_class_attrs[]; 17 + 16 18 struct sysdev_class cpu_sysdev_class = { 17 19 .name = "cpu", 20 + .attrs = cpu_sysdev_class_attrs, 18 21 }; 19 22 EXPORT_SYMBOL(cpu_sysdev_class); 20 23 ··· 79 76 } 80 77 81 78 #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 82 - static ssize_t cpu_probe_store(struct class *class, const char *buf, 79 + static ssize_t cpu_probe_store(struct sys_device *dev, 80 + struct sysdev_attribute *attr, 81 + const char *buf, 83 82 size_t count) 84 83 { 85 84 return arch_cpu_probe(buf, count); 86 85 } 87 86 88 - static ssize_t cpu_release_store(struct class *class, const char *buf, 87 + static ssize_t cpu_release_store(struct sys_device *dev, 88 + struct sysdev_attribute *attr, 89 + const char *buf, 89 90 size_t count) 90 91 { 91 92 return arch_cpu_release(buf, count); 92 93 } 93 94 94 - static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 95 - static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); 96 - 97 - int __init cpu_probe_release_init(void) 98 - { 99 - int rc; 100 - 101 - rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, 102 - &class_attr_probe.attr); 103 - if (!rc) 104 - rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, 105 - &class_attr_release.attr); 106 - 107 - return rc; 108 - } 109 - device_initcall(cpu_probe_release_init); 95 + static SYSDEV_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 96 + static SYSDEV_ATTR(release, S_IWUSR, NULL, cpu_release_store); 110 97 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 111 98 112 99 #else /* ... !CONFIG_HOTPLUG_CPU */ ··· 134 141 /* 135 142 * Print cpu online, possible, present, and system maps 136 143 */ 137 - static ssize_t print_cpus_map(char *buf, const struct cpumask *map) 144 + 145 + struct cpu_attr { 146 + struct sysdev_class_attribute attr; 147 + const struct cpumask *const * const map; 148 + }; 149 + 150 + static ssize_t show_cpus_attr(struct sysdev_class *class, 151 + struct sysdev_class_attribute *attr, 152 + char *buf) 138 153 { 139 - int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map); 154 + struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr); 155 + int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *(ca->map)); 140 156 141 157 buf[n++] = '\n'; 142 158 buf[n] = '\0'; 143 159 return n; 144 160 } 145 161 146 - #define print_cpus_func(type) \ 147 - static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \ 148 - { \ 149 - return print_cpus_map(buf, cpu_##type##_mask); \ 150 - } \ 151 - static struct sysdev_class_attribute attr_##type##_map = \ 152 - _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL) 162 + #define _CPU_ATTR(name, map) \ 163 + { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map } 153 164 154 - print_cpus_func(online); 155 - print_cpus_func(possible); 156 - print_cpus_func(present); 165 + /* Keep in sync with cpu_sysdev_class_attrs */ 166 + static struct cpu_attr cpu_attrs[] = { 167 + _CPU_ATTR(online, &cpu_online_mask), 168 + _CPU_ATTR(possible, &cpu_possible_mask), 169 + _CPU_ATTR(present, &cpu_present_mask), 170 + }; 157 171 158 172 /* 159 173 * Print values for NR_CPUS and offlined cpus 160 174 */ 161 - static ssize_t print_cpus_kernel_max(struct sysdev_class *class, char *buf) 175 + static ssize_t print_cpus_kernel_max(struct sysdev_class *class, 176 + struct sysdev_class_attribute *attr, char *buf) 162 177 { 163 178 int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); 164 179 return n; ··· 176 175 /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ 177 176 unsigned int total_cpus; 178 177 179 - static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf) 178 + static ssize_t print_cpus_offline(struct sysdev_class *class, 179 + struct sysdev_class_attribute *attr, char *buf) 180 180 { 181 181 int n = 0, len = PAGE_SIZE-2; 182 182 cpumask_var_t offline; ··· 205 203 return n; 206 204 } 207 205 static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); 208 - 209 - static struct sysdev_class_attribute *cpu_state_attr[] = { 210 - &attr_online_map, 211 - &attr_possible_map, 212 - &attr_present_map, 213 - &attr_kernel_max, 214 - &attr_offline, 215 - }; 216 - 217 - static int cpu_states_init(void) 218 - { 219 - int i; 220 - int err = 0; 221 - 222 - for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) { 223 - int ret; 224 - ret = sysdev_class_create_file(&cpu_sysdev_class, 225 - cpu_state_attr[i]); 226 - if (!err) 227 - err = ret; 228 - } 229 - return err; 230 - } 231 206 232 207 /* 233 208 * register_cpu - Setup a sysfs device for a CPU. ··· 251 272 int err; 252 273 253 274 err = sysdev_class_register(&cpu_sysdev_class); 254 - if (!err) 255 - err = cpu_states_init(); 256 - 257 275 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 258 276 if (!err) 259 277 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); ··· 258 282 259 283 return err; 260 284 } 285 + 286 + static struct sysdev_class_attribute *cpu_sysdev_class_attrs[] = { 287 + #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 288 + &attr_probe, 289 + &attr_release, 290 + #endif 291 + &cpu_attrs[0].attr, 292 + &cpu_attrs[1].attr, 293 + &cpu_attrs[2].attr, 294 + &attr_kernel_max, 295 + &attr_offline, 296 + NULL 297 + };
+19 -19
drivers/base/dd.c
··· 85 85 * for before calling this. (It is ok to call with no other effort 86 86 * from a driver's probe() method.) 87 87 * 88 - * This function must be called with @dev->sem held. 88 + * This function must be called with the device lock held. 89 89 */ 90 90 int device_bind_driver(struct device *dev) 91 91 { ··· 190 190 * This function returns -ENODEV if the device is not registered, 191 191 * 1 if the device is bound successfully and 0 otherwise. 192 192 * 193 - * This function must be called with @dev->sem held. When called for a 194 - * USB interface, @dev->parent->sem must be held as well. 193 + * This function must be called with @dev lock held. When called for a 194 + * USB interface, @dev->parent lock must be held as well. 195 195 */ 196 196 int driver_probe_device(struct device_driver *drv, struct device *dev) 197 197 { ··· 233 233 * 0 if no matching driver was found; 234 234 * -ENODEV if the device is not registered. 235 235 * 236 - * When called for a USB interface, @dev->parent->sem must be held. 236 + * When called for a USB interface, @dev->parent lock must be held. 237 237 */ 238 238 int device_attach(struct device *dev) 239 239 { 240 240 int ret = 0; 241 241 242 - down(&dev->sem); 242 + device_lock(dev); 243 243 if (dev->driver) { 244 244 ret = device_bind_driver(dev); 245 245 if (ret == 0) ··· 253 253 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); 254 254 pm_runtime_put_sync(dev); 255 255 } 256 - up(&dev->sem); 256 + device_unlock(dev); 257 257 return ret; 258 258 } 259 259 EXPORT_SYMBOL_GPL(device_attach); ··· 276 276 return 0; 277 277 278 278 if (dev->parent) /* Needed for USB */ 279 - down(&dev->parent->sem); 280 - down(&dev->sem); 279 + device_lock(dev->parent); 280 + device_lock(dev); 281 281 if (!dev->driver) 282 282 driver_probe_device(drv, dev); 283 - up(&dev->sem); 283 + device_unlock(dev); 284 284 if (dev->parent) 285 - up(&dev->parent->sem); 285 + device_unlock(dev->parent); 286 286 287 287 return 0; 288 288 } ··· 303 303 EXPORT_SYMBOL_GPL(driver_attach); 304 304 305 305 /* 306 - * __device_release_driver() must be called with @dev->sem held. 307 - * When called for a USB interface, @dev->parent->sem must be held as well. 306 + * __device_release_driver() must be called with @dev lock held. 307 + * When called for a USB interface, @dev->parent lock must be held as well. 308 308 */ 309 309 static void __device_release_driver(struct device *dev) 310 310 { ··· 343 343 * @dev: device. 344 344 * 345 345 * Manually detach device from driver. 346 - * When called for a USB interface, @dev->parent->sem must be held. 346 + * When called for a USB interface, @dev->parent lock must be held. 347 347 */ 348 348 void device_release_driver(struct device *dev) 349 349 { ··· 352 352 * within their ->remove callback for the same device, they 353 353 * will deadlock right here. 354 354 */ 355 - down(&dev->sem); 355 + device_lock(dev); 356 356 __device_release_driver(dev); 357 - up(&dev->sem); 357 + device_unlock(dev); 358 358 } 359 359 EXPORT_SYMBOL_GPL(device_release_driver); 360 360 ··· 381 381 spin_unlock(&drv->p->klist_devices.k_lock); 382 382 383 383 if (dev->parent) /* Needed for USB */ 384 - down(&dev->parent->sem); 385 - down(&dev->sem); 384 + device_lock(dev->parent); 385 + device_lock(dev); 386 386 if (dev->driver == drv) 387 387 __device_release_driver(dev); 388 - up(&dev->sem); 388 + device_unlock(dev); 389 389 if (dev->parent) 390 - up(&dev->parent->sem); 390 + device_unlock(dev->parent); 391 391 put_device(dev); 392 392 } 393 393 }
+13
drivers/base/devtmpfs.c
··· 301 301 if (dentry->d_inode) { 302 302 err = vfs_getattr(nd.path.mnt, dentry, &stat); 303 303 if (!err && dev_mynode(dev, dentry->d_inode, &stat)) { 304 + struct iattr newattrs; 305 + /* 306 + * before unlinking this node, reset permissions 307 + * of possible references like hardlinks 308 + */ 309 + newattrs.ia_uid = 0; 310 + newattrs.ia_gid = 0; 311 + newattrs.ia_mode = stat.mode & ~0777; 312 + newattrs.ia_valid = 313 + ATTR_UID|ATTR_GID|ATTR_MODE; 314 + mutex_lock(&dentry->d_inode->i_mutex); 315 + notify_change(dentry, &newattrs); 316 + mutex_unlock(&dentry->d_inode->i_mutex); 304 317 err = vfs_unlink(nd.path.dentry->d_inode, 305 318 dentry); 306 319 if (!err || err == -ENOENT)
+7 -4
drivers/base/firmware_class.c
··· 19 19 #include <linux/kthread.h> 20 20 #include <linux/highmem.h> 21 21 #include <linux/firmware.h> 22 - #include "base.h" 23 22 24 23 #define to_dev(obj) container_of(obj, struct device, kobj) 25 24 ··· 68 69 } 69 70 70 71 static ssize_t 71 - firmware_timeout_show(struct class *class, char *buf) 72 + firmware_timeout_show(struct class *class, 73 + struct class_attribute *attr, 74 + char *buf) 72 75 { 73 76 return sprintf(buf, "%d\n", loading_timeout); 74 77 } ··· 88 87 * Note: zero means 'wait forever'. 89 88 **/ 90 89 static ssize_t 91 - firmware_timeout_store(struct class *class, const char *buf, size_t count) 90 + firmware_timeout_store(struct class *class, 91 + struct class_attribute *attr, 92 + const char *buf, size_t count) 92 93 { 93 94 loading_timeout = simple_strtol(buf, NULL, 10); 94 95 if (loading_timeout < 0) ··· 613 610 } 614 611 615 612 /** 616 - * request_firmware_nowait: asynchronous version of request_firmware 613 + * request_firmware_nowait - asynchronous version of request_firmware 617 614 * @module: module requesting the firmware 618 615 * @uevent: sends uevent to copy the firmware image if this flag 619 616 * is non-zero else the firmware copy must be done manually.
+13 -7
drivers/base/memory.c
··· 44 44 return retval; 45 45 } 46 46 47 - static struct kset_uevent_ops memory_uevent_ops = { 47 + static const struct kset_uevent_ops memory_uevent_ops = { 48 48 .name = memory_uevent_name, 49 49 .uevent = memory_uevent, 50 50 }; ··· 309 309 * Block size attribute stuff 310 310 */ 311 311 static ssize_t 312 - print_block_size(struct class *class, char *buf) 312 + print_block_size(struct sysdev_class *class, struct sysdev_class_attribute *attr, 313 + char *buf) 313 314 { 314 315 return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); 315 316 } 316 317 317 - static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); 318 + static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); 318 319 319 320 static int block_size_init(void) 320 321 { 321 322 return sysfs_create_file(&memory_sysdev_class.kset.kobj, 322 - &class_attr_block_size_bytes.attr); 323 + &attr_block_size_bytes.attr); 323 324 } 324 325 325 326 /* ··· 331 330 */ 332 331 #ifdef CONFIG_ARCH_MEMORY_PROBE 333 332 static ssize_t 334 - memory_probe_store(struct class *class, const char *buf, size_t count) 333 + memory_probe_store(struct class *class, struct class_attribute *attr, 334 + const char *buf, size_t count) 335 335 { 336 336 u64 phys_addr; 337 337 int nid; ··· 369 367 370 368 /* Soft offline a page */ 371 369 static ssize_t 372 - store_soft_offline_page(struct class *class, const char *buf, size_t count) 370 + store_soft_offline_page(struct class *class, 371 + struct class_attribute *attr, 372 + const char *buf, size_t count) 373 373 { 374 374 int ret; 375 375 u64 pfn; ··· 388 384 389 385 /* Forcibly offline a page, including killing processes. */ 390 386 static ssize_t 391 - store_hard_offline_page(struct class *class, const char *buf, size_t count) 387 + store_hard_offline_page(struct class *class, 388 + struct class_attribute *attr, 389 + const char *buf, size_t count) 392 390 { 393 391 int ret; 394 392 u64 pfn;
+37 -58
drivers/base/node.c
··· 16 16 #include <linux/device.h> 17 17 #include <linux/swap.h> 18 18 19 + static struct sysdev_class_attribute *node_state_attrs[]; 20 + 19 21 static struct sysdev_class node_class = { 20 22 .name = "node", 23 + .attrs = node_state_attrs, 21 24 }; 22 25 23 26 ··· 547 544 return n; 548 545 } 549 546 550 - static ssize_t print_nodes_possible(struct sysdev_class *class, char *buf) 551 - { 552 - return print_nodes_state(N_POSSIBLE, buf); 553 - } 554 - 555 - static ssize_t print_nodes_online(struct sysdev_class *class, char *buf) 556 - { 557 - return print_nodes_state(N_ONLINE, buf); 558 - } 559 - 560 - static ssize_t print_nodes_has_normal_memory(struct sysdev_class *class, 561 - char *buf) 562 - { 563 - return print_nodes_state(N_NORMAL_MEMORY, buf); 564 - } 565 - 566 - static ssize_t print_nodes_has_cpu(struct sysdev_class *class, char *buf) 567 - { 568 - return print_nodes_state(N_CPU, buf); 569 - } 570 - 571 - static SYSDEV_CLASS_ATTR(possible, 0444, print_nodes_possible, NULL); 572 - static SYSDEV_CLASS_ATTR(online, 0444, print_nodes_online, NULL); 573 - static SYSDEV_CLASS_ATTR(has_normal_memory, 0444, print_nodes_has_normal_memory, 574 - NULL); 575 - static SYSDEV_CLASS_ATTR(has_cpu, 0444, print_nodes_has_cpu, NULL); 576 - 577 - #ifdef CONFIG_HIGHMEM 578 - static ssize_t print_nodes_has_high_memory(struct sysdev_class *class, 579 - char *buf) 580 - { 581 - return print_nodes_state(N_HIGH_MEMORY, buf); 582 - } 583 - 584 - static SYSDEV_CLASS_ATTR(has_high_memory, 0444, print_nodes_has_high_memory, 585 - NULL); 586 - #endif 587 - 588 - struct sysdev_class_attribute *node_state_attr[] = { 589 - &attr_possible, 590 - &attr_online, 591 - &attr_has_normal_memory, 592 - #ifdef CONFIG_HIGHMEM 593 - &attr_has_high_memory, 594 - #endif 595 - &attr_has_cpu, 547 + struct node_attr { 548 + struct sysdev_class_attribute attr; 549 + enum node_states state; 596 550 }; 597 551 598 - static int node_states_init(void) 552 + static ssize_t show_node_state(struct sysdev_class *class, 553 + struct sysdev_class_attribute *attr, char *buf) 599 554 { 600 - int i; 601 - int err = 0; 602 - 603 - for (i = 0; i < NR_NODE_STATES; i++) { 604 - int ret; 605 - ret = sysdev_class_create_file(&node_class, node_state_attr[i]); 606 - if (!err) 607 - err = ret; 608 - } 609 - return err; 555 + struct node_attr *na = container_of(attr, struct node_attr, attr); 556 + return print_nodes_state(na->state, buf); 610 557 } 558 + 559 + #define _NODE_ATTR(name, state) \ 560 + { _SYSDEV_CLASS_ATTR(name, 0444, show_node_state, NULL), state } 561 + 562 + static struct node_attr node_state_attr[] = { 563 + _NODE_ATTR(possible, N_POSSIBLE), 564 + _NODE_ATTR(online, N_ONLINE), 565 + _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY), 566 + _NODE_ATTR(has_cpu, N_CPU), 567 + #ifdef CONFIG_HIGHMEM 568 + _NODE_ATTR(has_high_memory, N_HIGH_MEMORY), 569 + #endif 570 + }; 571 + 572 + static struct sysdev_class_attribute *node_state_attrs[] = { 573 + &node_state_attr[0].attr, 574 + &node_state_attr[1].attr, 575 + &node_state_attr[2].attr, 576 + &node_state_attr[3].attr, 577 + #ifdef CONFIG_HIGHMEM 578 + &node_state_attr[4].attr, 579 + #endif 580 + NULL 581 + }; 611 582 612 583 #define NODE_CALLBACK_PRI 2 /* lower than SLAB */ 613 584 static int __init register_node_type(void) 614 585 { 615 586 int ret; 616 587 588 + BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); 589 + BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES); 590 + 617 591 ret = sysdev_class_register(&node_class); 618 592 if (!ret) { 619 - ret = node_states_init(); 620 593 hotplug_memory_notifier(node_memory_callback, 621 594 NODE_CALLBACK_PRI); 622 595 }
+67 -9
drivers/base/platform.c
··· 128 128 }; 129 129 130 130 /** 131 - * platform_device_put 131 + * platform_device_put - destroy a platform device 132 132 * @pdev: platform device to free 133 133 * 134 134 * Free all memory associated with a platform device. This function must ··· 152 152 } 153 153 154 154 /** 155 - * platform_device_alloc 155 + * platform_device_alloc - create a platform device 156 156 * @name: base name of the device we're adding 157 157 * @id: instance id 158 158 * ··· 177 177 EXPORT_SYMBOL_GPL(platform_device_alloc); 178 178 179 179 /** 180 - * platform_device_add_resources 180 + * platform_device_add_resources - add resources to a platform device 181 181 * @pdev: platform device allocated by platform_device_alloc to add resources to 182 182 * @res: set of resources that needs to be allocated for the device 183 183 * @num: number of resources ··· 202 202 EXPORT_SYMBOL_GPL(platform_device_add_resources); 203 203 204 204 /** 205 - * platform_device_add_data 205 + * platform_device_add_data - add platform-specific data to a platform device 206 206 * @pdev: platform device allocated by platform_device_alloc to add resources to 207 207 * @data: platform specific data for this platform device 208 208 * @size: size of platform specific data ··· 344 344 EXPORT_SYMBOL_GPL(platform_device_unregister); 345 345 346 346 /** 347 - * platform_device_register_simple 347 + * platform_device_register_simple - add a platform-level device and its resources 348 348 * @name: base name of the device we're adding 349 349 * @id: instance id 350 350 * @res: set of resources that needs to be allocated for the device ··· 396 396 EXPORT_SYMBOL_GPL(platform_device_register_simple); 397 397 398 398 /** 399 - * platform_device_register_data 399 + * platform_device_register_data - add a platform-level device with platform-specific data 400 400 * @parent: parent device for the device we're adding 401 401 * @name: base name of the device we're adding 402 402 * @id: instance id ··· 473 473 } 474 474 475 475 /** 476 - * platform_driver_register 476 + * platform_driver_register - register a driver for platform-level devices 477 477 * @drv: platform driver structure 478 478 */ 479 479 int platform_driver_register(struct platform_driver *drv) ··· 491 491 EXPORT_SYMBOL_GPL(platform_driver_register); 492 492 493 493 /** 494 - * platform_driver_unregister 494 + * platform_driver_unregister - unregister a driver for platform-level devices 495 495 * @drv: platform driver structure 496 496 */ 497 497 void platform_driver_unregister(struct platform_driver *drv) ··· 548 548 } 549 549 EXPORT_SYMBOL_GPL(platform_driver_probe); 550 550 551 + /** 552 + * platform_create_bundle - register driver and create corresponding device 553 + * @driver: platform driver structure 554 + * @probe: the driver probe routine, probably from an __init section 555 + * @res: set of resources that needs to be allocated for the device 556 + * @n_res: number of resources 557 + * @data: platform specific data for this platform device 558 + * @size: size of platform specific data 559 + * 560 + * Use this in legacy-style modules that probe hardware directly and 561 + * register a single platform device and corresponding platform driver. 562 + */ 563 + struct platform_device * __init_or_module platform_create_bundle( 564 + struct platform_driver *driver, 565 + int (*probe)(struct platform_device *), 566 + struct resource *res, unsigned int n_res, 567 + const void *data, size_t size) 568 + { 569 + struct platform_device *pdev; 570 + int error; 571 + 572 + pdev = platform_device_alloc(driver->driver.name, -1); 573 + if (!pdev) { 574 + error = -ENOMEM; 575 + goto err_out; 576 + } 577 + 578 + if (res) { 579 + error = platform_device_add_resources(pdev, res, n_res); 580 + if (error) 581 + goto err_pdev_put; 582 + } 583 + 584 + if (data) { 585 + error = platform_device_add_data(pdev, data, size); 586 + if (error) 587 + goto err_pdev_put; 588 + } 589 + 590 + error = platform_device_add(pdev); 591 + if (error) 592 + goto err_pdev_put; 593 + 594 + error = platform_driver_probe(driver, probe); 595 + if (error) 596 + goto err_pdev_del; 597 + 598 + return pdev; 599 + 600 + err_pdev_del: 601 + platform_device_del(pdev); 602 + err_pdev_put: 603 + platform_device_put(pdev); 604 + err_out: 605 + return ERR_PTR(error); 606 + } 607 + EXPORT_SYMBOL_GPL(platform_create_bundle); 608 + 551 609 /* modalias support enables more hands-off userspace setup: 552 610 * (a) environment variable lets new-style hotplug events work once system is 553 611 * fully running: "modprobe $MODALIAS" ··· 636 578 } 637 579 638 580 static const struct platform_device_id *platform_match_id( 639 - struct platform_device_id *id, 581 + const struct platform_device_id *id, 640 582 struct platform_device *pdev) 641 583 { 642 584 while (id->name[0]) {
+10 -10
drivers/base/power/main.c
··· 35 35 * because children are guaranteed to be discovered after parents, and 36 36 * are inserted at the back of the list on discovery. 37 37 * 38 - * Since device_pm_add() may be called with a device semaphore held, 39 - * we must never try to acquire a device semaphore while holding 38 + * Since device_pm_add() may be called with a device lock held, 39 + * we must never try to acquire a device lock while holding 40 40 * dpm_list_mutex. 41 41 */ 42 42 ··· 508 508 TRACE_RESUME(0); 509 509 510 510 dpm_wait(dev->parent, async); 511 - down(&dev->sem); 511 + device_lock(dev); 512 512 513 513 dev->power.status = DPM_RESUMING; 514 514 ··· 543 543 } 544 544 } 545 545 End: 546 - up(&dev->sem); 546 + device_unlock(dev); 547 547 complete_all(&dev->power.completion); 548 548 549 549 TRACE_RESUME(error); ··· 629 629 */ 630 630 static void device_complete(struct device *dev, pm_message_t state) 631 631 { 632 - down(&dev->sem); 632 + device_lock(dev); 633 633 634 634 if (dev->class && dev->class->pm && dev->class->pm->complete) { 635 635 pm_dev_dbg(dev, state, "completing class "); ··· 646 646 dev->bus->pm->complete(dev); 647 647 } 648 648 649 - up(&dev->sem); 649 + device_unlock(dev); 650 650 } 651 651 652 652 /** ··· 809 809 int error = 0; 810 810 811 811 dpm_wait_for_children(dev, async); 812 - down(&dev->sem); 812 + device_lock(dev); 813 813 814 814 if (async_error) 815 815 goto End; ··· 849 849 dev->power.status = DPM_OFF; 850 850 851 851 End: 852 - up(&dev->sem); 852 + device_unlock(dev); 853 853 complete_all(&dev->power.completion); 854 854 855 855 return error; ··· 938 938 { 939 939 int error = 0; 940 940 941 - down(&dev->sem); 941 + device_lock(dev); 942 942 943 943 if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) { 944 944 pm_dev_dbg(dev, state, "preparing "); ··· 962 962 suspend_report_result(dev->class->pm->prepare, error); 963 963 } 964 964 End: 965 - up(&dev->sem); 965 + device_unlock(dev); 966 966 967 967 return error; 968 968 }
+12 -5
drivers/base/sys.c
··· 54 54 return -EIO; 55 55 } 56 56 57 - static struct sysfs_ops sysfs_ops = { 57 + static const struct sysfs_ops sysfs_ops = { 58 58 .show = sysdev_show, 59 59 .store = sysdev_store, 60 60 }; ··· 89 89 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 90 90 91 91 if (class_attr->show) 92 - return class_attr->show(class, buffer); 92 + return class_attr->show(class, class_attr, buffer); 93 93 return -EIO; 94 94 } 95 95 ··· 100 100 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 101 101 102 102 if (class_attr->store) 103 - return class_attr->store(class, buffer, count); 103 + return class_attr->store(class, class_attr, buffer, count); 104 104 return -EIO; 105 105 } 106 106 107 - static struct sysfs_ops sysfs_class_ops = { 107 + static const struct sysfs_ops sysfs_class_ops = { 108 108 .show = sysdev_class_show, 109 109 .store = sysdev_class_store, 110 110 }; ··· 145 145 if (retval) 146 146 return retval; 147 147 148 - return kset_register(&cls->kset); 148 + retval = kset_register(&cls->kset); 149 + if (!retval && cls->attrs) 150 + retval = sysfs_create_files(&cls->kset.kobj, 151 + (const struct attribute **)cls->attrs); 152 + return retval; 149 153 } 150 154 151 155 void sysdev_class_unregister(struct sysdev_class *cls) 152 156 { 153 157 pr_debug("Unregistering sysdev class '%s'\n", 154 158 kobject_name(&cls->kset.kobj)); 159 + if (cls->attrs) 160 + sysfs_remove_files(&cls->kset.kobj, 161 + (const struct attribute **)cls->attrs); 155 162 kset_unregister(&cls->kset); 156 163 } 157 164
+9 -3
drivers/block/osdblk.c
··· 476 476 kfree(cls); 477 477 } 478 478 479 - static ssize_t class_osdblk_list(struct class *c, char *data) 479 + static ssize_t class_osdblk_list(struct class *c, 480 + struct class_attribute *attr, 481 + char *data) 480 482 { 481 483 int n = 0; 482 484 struct list_head *tmp; ··· 502 500 return n; 503 501 } 504 502 505 - static ssize_t class_osdblk_add(struct class *c, const char *buf, size_t count) 503 + static ssize_t class_osdblk_add(struct class *c, 504 + struct class_attribute *attr, 505 + const char *buf, size_t count) 506 506 { 507 507 struct osdblk_device *osdev; 508 508 ssize_t rc; ··· 596 592 return rc; 597 593 } 598 594 599 - static ssize_t class_osdblk_remove(struct class *c, const char *buf, 595 + static ssize_t class_osdblk_remove(struct class *c, 596 + struct class_attribute *attr, 597 + const char *buf, 600 598 size_t count) 601 599 { 602 600 struct osdblk_device *osdev = NULL;
+10 -4
drivers/block/pktcdvd.c
··· 284 284 return len; 285 285 } 286 286 287 - static struct sysfs_ops kobj_pkt_ops = { 287 + static const struct sysfs_ops kobj_pkt_ops = { 288 288 .show = kobj_pkt_show, 289 289 .store = kobj_pkt_store 290 290 }; ··· 337 337 { 338 338 kfree(cls); 339 339 } 340 - static ssize_t class_pktcdvd_show_map(struct class *c, char *data) 340 + static ssize_t class_pktcdvd_show_map(struct class *c, 341 + struct class_attribute *attr, 342 + char *data) 341 343 { 342 344 int n = 0; 343 345 int idx; ··· 358 356 return n; 359 357 } 360 358 361 - static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf, 359 + static ssize_t class_pktcdvd_store_add(struct class *c, 360 + struct class_attribute *attr, 361 + const char *buf, 362 362 size_t count) 363 363 { 364 364 unsigned int major, minor; ··· 380 376 return -EINVAL; 381 377 } 382 378 383 - static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf, 379 + static ssize_t class_pktcdvd_store_remove(struct class *c, 380 + struct class_attribute *attr, 381 + const char *buf, 384 382 size_t count) 385 383 { 386 384 unsigned int major, minor;
+1 -1
drivers/cpufreq/cpufreq.c
··· 766 766 complete(&policy->kobj_unregister); 767 767 } 768 768 769 - static struct sysfs_ops sysfs_ops = { 769 + static const struct sysfs_ops sysfs_ops = { 770 770 .show = show, 771 771 .store = store, 772 772 };
+6 -2
drivers/cpuidle/sysfs.c
··· 22 22 __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); 23 23 24 24 static ssize_t show_available_governors(struct sysdev_class *class, 25 + struct sysdev_class_attribute *attr, 25 26 char *buf) 26 27 { 27 28 ssize_t i = 0; ··· 42 41 } 43 42 44 43 static ssize_t show_current_driver(struct sysdev_class *class, 44 + struct sysdev_class_attribute *attr, 45 45 char *buf) 46 46 { 47 47 ssize_t ret; ··· 58 56 } 59 57 60 58 static ssize_t show_current_governor(struct sysdev_class *class, 59 + struct sysdev_class_attribute *attr, 61 60 char *buf) 62 61 { 63 62 ssize_t ret; ··· 74 71 } 75 72 76 73 static ssize_t store_current_governor(struct sysdev_class *class, 74 + struct sysdev_class_attribute *attr, 77 75 const char *buf, size_t count) 78 76 { 79 77 char gov_name[CPUIDLE_NAME_LEN]; ··· 195 191 return ret; 196 192 } 197 193 198 - static struct sysfs_ops cpuidle_sysfs_ops = { 194 + static const struct sysfs_ops cpuidle_sysfs_ops = { 199 195 .show = cpuidle_show, 200 196 .store = cpuidle_store, 201 197 }; ··· 281 277 return ret; 282 278 } 283 279 284 - static struct sysfs_ops cpuidle_state_sysfs_ops = { 280 + static const struct sysfs_ops cpuidle_state_sysfs_ops = { 285 281 .show = cpuidle_state_show, 286 282 }; 287 283
+1 -1
drivers/dma/ioat/dma.c
··· 1138 1138 return entry->show(&chan->common, page); 1139 1139 } 1140 1140 1141 - struct sysfs_ops ioat_sysfs_ops = { 1141 + const struct sysfs_ops ioat_sysfs_ops = { 1142 1142 .show = ioat_attr_show, 1143 1143 }; 1144 1144
+1 -1
drivers/dma/ioat/dma.h
··· 346 346 unsigned long *phys_complete); 347 347 void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); 348 348 void ioat_kobject_del(struct ioatdma_device *device); 349 - extern struct sysfs_ops ioat_sysfs_ops; 349 + extern const struct sysfs_ops ioat_sysfs_ops; 350 350 extern struct ioat_sysfs_entry ioat_version_attr; 351 351 extern struct ioat_sysfs_entry ioat_cap_attr; 352 352 #endif /* IOATDMA_H */
+3 -3
drivers/edac/edac_device_sysfs.c
··· 137 137 } 138 138 139 139 /* edac_dev file operations for an 'ctl_info' */ 140 - static struct sysfs_ops device_ctl_info_ops = { 140 + static const struct sysfs_ops device_ctl_info_ops = { 141 141 .show = edac_dev_ctl_info_show, 142 142 .store = edac_dev_ctl_info_store 143 143 }; ··· 373 373 } 374 374 375 375 /* edac_dev file operations for an 'instance' */ 376 - static struct sysfs_ops device_instance_ops = { 376 + static const struct sysfs_ops device_instance_ops = { 377 377 .show = edac_dev_instance_show, 378 378 .store = edac_dev_instance_store 379 379 }; ··· 476 476 } 477 477 478 478 /* edac_dev file operations for a 'block' */ 479 - static struct sysfs_ops device_block_ops = { 479 + static const struct sysfs_ops device_block_ops = { 480 480 .show = edac_dev_block_show, 481 481 .store = edac_dev_block_store 482 482 };
+2 -2
drivers/edac/edac_mc_sysfs.c
··· 245 245 return -EIO; 246 246 } 247 247 248 - static struct sysfs_ops csrowfs_ops = { 248 + static const struct sysfs_ops csrowfs_ops = { 249 249 .show = csrowdev_show, 250 250 .store = csrowdev_store 251 251 }; ··· 575 575 } 576 576 577 577 /* Intermediate show/store table */ 578 - static struct sysfs_ops mci_ops = { 578 + static const struct sysfs_ops mci_ops = { 579 579 .show = mcidev_show, 580 580 .store = mcidev_store 581 581 };
+2 -2
drivers/edac/edac_pci_sysfs.c
··· 121 121 } 122 122 123 123 /* fs_ops table */ 124 - static struct sysfs_ops pci_instance_ops = { 124 + static const struct sysfs_ops pci_instance_ops = { 125 125 .show = edac_pci_instance_show, 126 126 .store = edac_pci_instance_store 127 127 }; ··· 261 261 return -EIO; 262 262 } 263 263 264 - static struct sysfs_ops edac_pci_sysfs_ops = { 264 + static const struct sysfs_ops edac_pci_sysfs_ops = { 265 265 .show = edac_pci_dev_show, 266 266 .store = edac_pci_dev_store 267 267 };
+2 -3
drivers/firewire/core-device.c
··· 33 33 #include <linux/module.h> 34 34 #include <linux/mutex.h> 35 35 #include <linux/rwsem.h> 36 - #include <linux/semaphore.h> 37 36 #include <linux/spinlock.h> 38 37 #include <linux/string.h> 39 38 #include <linux/workqueue.h> ··· 827 828 struct fw_driver *driver = (struct fw_driver *)dev->driver; 828 829 829 830 if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) { 830 - down(&dev->sem); 831 + device_lock(dev); 831 832 driver->update(unit); 832 - up(&dev->sem); 833 + device_unlock(dev); 833 834 } 834 835 835 836 return 0;
+1 -1
drivers/firmware/edd.c
··· 122 122 return ret; 123 123 } 124 124 125 - static struct sysfs_ops edd_attr_ops = { 125 + static const struct sysfs_ops edd_attr_ops = { 126 126 .show = edd_attr_show, 127 127 }; 128 128
+1 -1
drivers/firmware/efivars.c
··· 362 362 return ret; 363 363 } 364 364 365 - static struct sysfs_ops efivar_attr_ops = { 365 + static const struct sysfs_ops efivar_attr_ops = { 366 366 .show = efivar_attr_show, 367 367 .store = efivar_attr_store, 368 368 };
+1 -1
drivers/firmware/iscsi_ibft.c
··· 519 519 return ret; 520 520 } 521 521 522 - static struct sysfs_ops ibft_attr_ops = { 522 + static const struct sysfs_ops ibft_attr_ops = { 523 523 .show = ibft_show_attribute, 524 524 }; 525 525
+1 -1
drivers/firmware/memmap.c
··· 74 74 NULL 75 75 }; 76 76 77 - static struct sysfs_ops memmap_attr_ops = { 77 + static const struct sysfs_ops memmap_attr_ops = { 78 78 .show = memmap_attr_show, 79 79 }; 80 80
+6 -2
drivers/gpio/gpiolib.c
··· 623 623 * /sys/class/gpio/unexport ... write-only 624 624 * integer N ... number of GPIO to unexport 625 625 */ 626 - static ssize_t export_store(struct class *class, const char *buf, size_t len) 626 + static ssize_t export_store(struct class *class, 627 + struct class_attribute *attr, 628 + const char *buf, size_t len) 627 629 { 628 630 long gpio; 629 631 int status; ··· 655 653 return status ? : len; 656 654 } 657 655 658 - static ssize_t unexport_store(struct class *class, const char *buf, size_t len) 656 + static ssize_t unexport_store(struct class *class, 657 + struct class_attribute *attr, 658 + const char *buf, size_t len) 659 659 { 660 660 long gpio; 661 661 int status;
+8 -10
drivers/gpu/drm/drm_sysfs.c
··· 70 70 return 0; 71 71 } 72 72 73 - /* Display the version of drm_core. This doesn't work right in current design */ 74 - static ssize_t version_show(struct class *dev, char *buf) 75 - { 76 - return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR, 77 - CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); 78 - } 79 - 80 73 static char *drm_devnode(struct device *dev, mode_t *mode) 81 74 { 82 75 return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); 83 76 } 84 77 85 - static CLASS_ATTR(version, S_IRUGO, version_show, NULL); 78 + static CLASS_ATTR_STRING(version, S_IRUGO, 79 + CORE_NAME " " 80 + __stringify(CORE_MAJOR) "." 81 + __stringify(CORE_MINOR) "." 82 + __stringify(CORE_PATCHLEVEL) " " 83 + CORE_DATE); 86 84 87 85 /** 88 86 * drm_sysfs_create - create a struct drm_sysfs_class structure ··· 107 109 class->suspend = drm_class_suspend; 108 110 class->resume = drm_class_resume; 109 111 110 - err = class_create_file(class, &class_attr_version); 112 + err = class_create_file(class, &class_attr_version.attr); 111 113 if (err) 112 114 goto err_out_class; 113 115 ··· 130 132 { 131 133 if ((drm_class == NULL) || (IS_ERR(drm_class))) 132 134 return; 133 - class_remove_file(drm_class, &class_attr_version); 135 + class_remove_file(drm_class, &class_attr_version.attr); 134 136 class_destroy(drm_class); 135 137 } 136 138
+1 -1
drivers/gpu/drm/ttm/ttm_bo.c
··· 128 128 NULL 129 129 }; 130 130 131 - static struct sysfs_ops ttm_bo_global_ops = { 131 + static const struct sysfs_ops ttm_bo_global_ops = { 132 132 .show = &ttm_bo_global_show 133 133 }; 134 134
+1 -1
drivers/gpu/drm/ttm/ttm_memory.c
··· 152 152 NULL 153 153 }; 154 154 155 - static struct sysfs_ops ttm_mem_zone_ops = { 155 + static const struct sysfs_ops ttm_mem_zone_ops = { 156 156 .show = &ttm_mem_zone_show, 157 157 .store = &ttm_mem_zone_store 158 158 };
+1 -1
drivers/i2c/busses/i2c-omap.c
··· 850 850 .functionality = omap_i2c_func, 851 851 }; 852 852 853 - static int __init 853 + static int __devinit 854 854 omap_i2c_probe(struct platform_device *pdev) 855 855 { 856 856 struct omap_i2c_dev *dev;
+2 -3
drivers/ieee1394/nodemgr.c
··· 19 19 #include <linux/moduleparam.h> 20 20 #include <linux/mutex.h> 21 21 #include <linux/freezer.h> 22 - #include <linux/semaphore.h> 23 22 #include <asm/atomic.h> 24 23 25 24 #include "csr.h" ··· 1396 1397 pdrv = container_of(drv, struct hpsb_protocol_driver, 1397 1398 driver); 1398 1399 if (pdrv->update) { 1399 - down(&ud->device.sem); 1400 + device_lock(&ud->device); 1400 1401 error = pdrv->update(ud); 1401 - up(&ud->device.sem); 1402 + device_unlock(&ud->device); 1402 1403 } 1403 1404 if (error) 1404 1405 device_release_driver(&ud->device);
+1 -1
drivers/infiniband/core/cm.c
··· 3597 3597 atomic_long_read(&group->counter[cm_attr->index])); 3598 3598 } 3599 3599 3600 - static struct sysfs_ops cm_counter_ops = { 3600 + static const struct sysfs_ops cm_counter_ops = { 3601 3601 .show = cm_show_counter 3602 3602 }; 3603 3603
+1 -1
drivers/infiniband/core/sysfs.c
··· 79 79 return port_attr->show(p, port_attr, buf); 80 80 } 81 81 82 - static struct sysfs_ops port_sysfs_ops = { 82 + static const struct sysfs_ops port_sysfs_ops = { 83 83 .show = port_attr_show 84 84 }; 85 85
+5 -8
drivers/infiniband/core/ucm.c
··· 1336 1336 device_unregister(&ucm_dev->dev); 1337 1337 } 1338 1338 1339 - static ssize_t show_abi_version(struct class *class, char *buf) 1340 - { 1341 - return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION); 1342 - } 1343 - static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); 1339 + static CLASS_ATTR_STRING(abi_version, S_IRUGO, 1340 + __stringify(IB_USER_CM_ABI_VERSION)); 1344 1341 1345 1342 static int __init ib_ucm_init(void) 1346 1343 { ··· 1350 1353 goto error1; 1351 1354 } 1352 1355 1353 - ret = class_create_file(&cm_class, &class_attr_abi_version); 1356 + ret = class_create_file(&cm_class, &class_attr_abi_version.attr); 1354 1357 if (ret) { 1355 1358 printk(KERN_ERR "ucm: couldn't create abi_version attribute\n"); 1356 1359 goto error2; ··· 1364 1367 return 0; 1365 1368 1366 1369 error3: 1367 - class_remove_file(&cm_class, &class_attr_abi_version); 1370 + class_remove_file(&cm_class, &class_attr_abi_version.attr); 1368 1371 error2: 1369 1372 unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); 1370 1373 error1: ··· 1374 1377 static void __exit ib_ucm_cleanup(void) 1375 1378 { 1376 1379 ib_unregister_client(&ucm_client); 1377 - class_remove_file(&cm_class, &class_attr_abi_version); 1380 + class_remove_file(&cm_class, &class_attr_abi_version.attr); 1378 1381 unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); 1379 1382 if (overflow_maj) 1380 1383 unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES);
+3 -6
drivers/infiniband/core/user_mad.c
··· 965 965 } 966 966 static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 967 967 968 - static ssize_t show_abi_version(struct class *class, char *buf) 969 - { 970 - return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION); 971 - } 972 - static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); 968 + static CLASS_ATTR_STRING(abi_version, S_IRUGO, 969 + __stringify(IB_USER_MAD_ABI_VERSION)); 973 970 974 971 static dev_t overflow_maj; 975 972 static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); ··· 1191 1194 goto out_chrdev; 1192 1195 } 1193 1196 1194 - ret = class_create_file(umad_class, &class_attr_abi_version); 1197 + ret = class_create_file(umad_class, &class_attr_abi_version.attr); 1195 1198 if (ret) { 1196 1199 printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); 1197 1200 goto out_class;
+3 -6
drivers/infiniband/core/uverbs_main.c
··· 691 691 } 692 692 static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); 693 693 694 - static ssize_t show_abi_version(struct class *class, char *buf) 695 - { 696 - return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION); 697 - } 698 - static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); 694 + static CLASS_ATTR_STRING(abi_version, S_IRUGO, 695 + __stringify(IB_USER_VERBS_ABI_VERSION)); 699 696 700 697 static dev_t overflow_maj; 701 698 static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES); ··· 838 841 goto out_chrdev; 839 842 } 840 843 841 - ret = class_create_file(uverbs_class, &class_attr_abi_version); 844 + ret = class_create_file(uverbs_class, &class_attr_abi_version.attr); 842 845 if (ret) { 843 846 printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); 844 847 goto out_class;
+1
drivers/macintosh/windfarm_core.c
··· 321 321 kref_init(&new_sr->ref); 322 322 list_add(&new_sr->link, &wf_sensors); 323 323 324 + sysfs_attr_init(&new_sr->attr.attr); 324 325 new_sr->attr.attr.name = new_sr->name; 325 326 new_sr->attr.attr.mode = 0444; 326 327 new_sr->attr.show = wf_show_sensor;
+1
drivers/macintosh/windfarm_smu_controls.c
··· 173 173 174 174 fct->fan_type = pwm_fan; 175 175 fct->ctrl.type = pwm_fan ? WF_CONTROL_PWM_FAN : WF_CONTROL_RPM_FAN; 176 + sysfs_attr_init(&fct->ctrl.attr.attr); 176 177 177 178 /* We use the name & location here the same way we do for SMU sensors, 178 179 * see the comment in windfarm_smu_sensors.c. The locations are a bit
+1 -1
drivers/md/dm-sysfs.c
··· 75 75 NULL, 76 76 }; 77 77 78 - static struct sysfs_ops dm_sysfs_ops = { 78 + static const struct sysfs_ops dm_sysfs_ops = { 79 79 .show = dm_attr_show, 80 80 }; 81 81
+2 -2
drivers/md/md.c
··· 2642 2642 mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj); 2643 2643 kfree(rdev); 2644 2644 } 2645 - static struct sysfs_ops rdev_sysfs_ops = { 2645 + static const struct sysfs_ops rdev_sysfs_ops = { 2646 2646 .show = rdev_attr_show, 2647 2647 .store = rdev_attr_store, 2648 2648 }; ··· 4059 4059 kfree(mddev); 4060 4060 } 4061 4061 4062 - static struct sysfs_ops md_sysfs_ops = { 4062 + static const struct sysfs_ops md_sysfs_ops = { 4063 4063 .show = md_attr_show, 4064 4064 .store = md_attr_store, 4065 4065 };
+1 -1
drivers/media/video/omap24xxcam.c
··· 1735 1735 * 1736 1736 */ 1737 1737 1738 - static int __init omap24xxcam_probe(struct platform_device *pdev) 1738 + static int __devinit omap24xxcam_probe(struct platform_device *pdev) 1739 1739 { 1740 1740 struct omap24xxcam_device *cam; 1741 1741 struct resource *mem;
+4 -9
drivers/misc/phantom.c
··· 497 497 .resume = phantom_resume 498 498 }; 499 499 500 - static ssize_t phantom_show_version(struct class *cls, char *buf) 501 - { 502 - return sprintf(buf, PHANTOM_VERSION "\n"); 503 - } 504 - 505 - static CLASS_ATTR(version, 0444, phantom_show_version, NULL); 500 + static CLASS_ATTR_STRING(version, 0444, PHANTOM_VERSION); 506 501 507 502 static int __init phantom_init(void) 508 503 { ··· 510 515 printk(KERN_ERR "phantom: can't register phantom class\n"); 511 516 goto err; 512 517 } 513 - retval = class_create_file(phantom_class, &class_attr_version); 518 + retval = class_create_file(phantom_class, &class_attr_version.attr); 514 519 if (retval) { 515 520 printk(KERN_ERR "phantom: can't create sysfs version file\n"); 516 521 goto err_class; ··· 536 541 err_unchr: 537 542 unregister_chrdev_region(dev, PHANTOM_MAX_MINORS); 538 543 err_attr: 539 - class_remove_file(phantom_class, &class_attr_version); 544 + class_remove_file(phantom_class, &class_attr_version.attr); 540 545 err_class: 541 546 class_destroy(phantom_class); 542 547 err: ··· 549 554 550 555 unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS); 551 556 552 - class_remove_file(phantom_class, &class_attr_version); 557 + class_remove_file(phantom_class, &class_attr_version.attr); 553 558 class_destroy(phantom_class); 554 559 555 560 pr_debug("phantom: module successfully removed\n");
+2 -1
drivers/mtd/ubi/build.c
··· 89 89 static DEFINE_SPINLOCK(ubi_devices_lock); 90 90 91 91 /* "Show" method for files in '/<sysfs>/class/ubi/' */ 92 - static ssize_t ubi_version_show(struct class *class, char *buf) 92 + static ssize_t ubi_version_show(struct class *class, struct class_attribute *attr, 93 + char *buf) 93 94 { 94 95 return sprintf(buf, "%d\n", UBI_VERSION); 95 96 }
+4 -1
drivers/net/bonding/bond_sysfs.c
··· 51 51 * "show" function for the bond_masters attribute. 52 52 * The class parameter is ignored. 53 53 */ 54 - static ssize_t bonding_show_bonds(struct class *cls, char *buf) 54 + static ssize_t bonding_show_bonds(struct class *cls, 55 + struct class_attribute *attr, 56 + char *buf) 55 57 { 56 58 struct net *net = current->nsproxy->net_ns; 57 59 struct bond_net *bn = net_generic(net, bond_net_id); ··· 100 98 */ 101 99 102 100 static ssize_t bonding_store_bonds(struct class *cls, 101 + struct class_attribute *attr, 103 102 const char *buffer, size_t count) 104 103 { 105 104 struct net *net = current->nsproxy->net_ns;
+1 -1
drivers/net/ibmveth.c
··· 1577 1577 NULL, 1578 1578 }; 1579 1579 1580 - static struct sysfs_ops veth_pool_ops = { 1580 + static const struct sysfs_ops veth_pool_ops = { 1581 1581 .show = veth_pool_show, 1582 1582 .store = veth_pool_store, 1583 1583 };
+2 -2
drivers/net/iseries_veth.c
··· 384 384 NULL 385 385 }; 386 386 387 - static struct sysfs_ops veth_cnx_sysfs_ops = { 387 + static const struct sysfs_ops veth_cnx_sysfs_ops = { 388 388 .show = veth_cnx_attribute_show 389 389 }; 390 390 ··· 441 441 NULL 442 442 }; 443 443 444 - static struct sysfs_ops veth_port_sysfs_ops = { 444 + static const struct sysfs_ops veth_port_sysfs_ops = { 445 445 .show = veth_port_attribute_show 446 446 }; 447 447
+1 -1
drivers/parisc/pdc_stable.c
··· 481 481 return ret; 482 482 } 483 483 484 - static struct sysfs_ops pdcspath_attr_ops = { 484 + static const struct sysfs_ops pdcspath_attr_ops = { 485 485 .show = pdcspath_attr_show, 486 486 .store = pdcspath_attr_store, 487 487 };
+2 -2
drivers/pci/bus.c
··· 288 288 next = dev->bus_list.next; 289 289 290 290 /* Run device routines with the device locked */ 291 - down(&dev->dev.sem); 291 + device_lock(&dev->dev); 292 292 retval = cb(dev, userdata); 293 - up(&dev->dev.sem); 293 + device_unlock(&dev->dev); 294 294 if (retval) 295 295 break; 296 296 }
+1 -1
drivers/pci/hotplug/fakephp.c
··· 73 73 } 74 74 75 75 static struct kobj_type legacy_ktype = { 76 - .sysfs_ops = &(struct sysfs_ops){ 76 + .sysfs_ops = &(const struct sysfs_ops){ 77 77 .store = legacy_store, .show = legacy_show 78 78 }, 79 79 .release = &legacy_release,
+5
drivers/pci/pci-sysfs.c
··· 642 642 if (!b->legacy_io) 643 643 goto kzalloc_err; 644 644 645 + sysfs_bin_attr_init(b->legacy_io); 645 646 b->legacy_io->attr.name = "legacy_io"; 646 647 b->legacy_io->size = 0xffff; 647 648 b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; ··· 655 654 goto legacy_io_err; 656 655 657 656 /* Allocated above after the legacy_io struct */ 657 + sysfs_bin_attr_init(b->legacy_mem); 658 658 b->legacy_mem = b->legacy_io + 1; 659 659 b->legacy_mem->attr.name = "legacy_mem"; 660 660 b->legacy_mem->size = 1024*1024; ··· 802 800 if (res_attr) { 803 801 char *res_attr_name = (char *)(res_attr + 1); 804 802 803 + sysfs_bin_attr_init(res_attr); 805 804 if (write_combine) { 806 805 pdev->res_attr_wc[num] = res_attr; 807 806 sprintf(res_attr_name, "resource%d_wc", num); ··· 975 972 if (!attr) 976 973 return -ENOMEM; 977 974 975 + sysfs_bin_attr_init(attr); 978 976 attr->size = dev->vpd->len; 979 977 attr->attr.name = "vpd"; 980 978 attr->attr.mode = S_IRUSR | S_IWUSR; ··· 1042 1038 retval = -ENOMEM; 1043 1039 goto err_resource_files; 1044 1040 } 1041 + sysfs_bin_attr_init(attr); 1045 1042 attr->size = rom_size; 1046 1043 attr->attr.name = "rom"; 1047 1044 attr->attr.mode = S_IRUSR;
+2 -2
drivers/pci/pci.c
··· 2486 2486 if (!probe) { 2487 2487 pci_block_user_cfg_access(dev); 2488 2488 /* block PM suspend, driver probe, etc. */ 2489 - down(&dev->dev.sem); 2489 + device_lock(&dev->dev); 2490 2490 } 2491 2491 2492 2492 rc = pci_dev_specific_reset(dev, probe); ··· 2508 2508 rc = pci_parent_bus_reset(dev, probe); 2509 2509 done: 2510 2510 if (!probe) { 2511 - up(&dev->dev.sem); 2511 + device_unlock(&dev->dev); 2512 2512 pci_unblock_user_cfg_access(dev); 2513 2513 } 2514 2514
+1 -1
drivers/pci/slot.c
··· 29 29 return attribute->store ? attribute->store(slot, buf, len) : -EIO; 30 30 } 31 31 32 - static struct sysfs_ops pci_slot_sysfs_ops = { 32 + static const struct sysfs_ops pci_slot_sysfs_ops = { 33 33 .show = pci_slot_attr_show, 34 34 .store = pci_slot_attr_store, 35 35 };
+4 -4
drivers/pcmcia/ds.c
··· 971 971 { 972 972 int rc; 973 973 974 - down(&dev->sem); 974 + device_lock(dev); 975 975 rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND); 976 - up(&dev->sem); 976 + device_unlock(dev); 977 977 return rc; 978 978 } 979 979 ··· 981 981 { 982 982 int rc; 983 983 984 - down(&dev->sem); 984 + device_lock(dev); 985 985 rc = pcmcia_dev_resume(dev); 986 - up(&dev->sem); 986 + device_unlock(dev); 987 987 return rc; 988 988 } 989 989
+1
drivers/platform/x86/Kconfig
··· 150 150 tristate "MSI Laptop Extras" 151 151 depends on ACPI 152 152 depends on BACKLIGHT_CLASS_DEVICE 153 + depends on RFKILL 153 154 ---help--- 154 155 This is a driver for laptops built by MSI (MICRO-STAR 155 156 INTERNATIONAL):
+2 -2
drivers/platform/x86/hp-wmi.c
··· 57 57 HPWMI_WWAN = 2, 58 58 }; 59 59 60 - static int __init hp_wmi_bios_setup(struct platform_device *device); 60 + static int __devinit hp_wmi_bios_setup(struct platform_device *device); 61 61 static int __exit hp_wmi_bios_remove(struct platform_device *device); 62 62 static int hp_wmi_resume_handler(struct device *device); 63 63 ··· 447 447 device_remove_file(&device->dev, &dev_attr_tablet); 448 448 } 449 449 450 - static int __init hp_wmi_bios_setup(struct platform_device *device) 450 + static int __devinit hp_wmi_bios_setup(struct platform_device *device) 451 451 { 452 452 int err; 453 453 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+355 -5
drivers/platform/x86/msi-laptop.c
··· 58 58 #include <linux/dmi.h> 59 59 #include <linux/backlight.h> 60 60 #include <linux/platform_device.h> 61 + #include <linux/rfkill.h> 61 62 62 63 #define MSI_DRIVER_VERSION "0.5" 63 64 ··· 67 66 #define MSI_EC_COMMAND_WIRELESS 0x10 68 67 #define MSI_EC_COMMAND_LCD_LEVEL 0x11 69 68 69 + #define MSI_STANDARD_EC_COMMAND_ADDRESS 0x2e 70 + #define MSI_STANDARD_EC_BLUETOOTH_MASK (1 << 0) 71 + #define MSI_STANDARD_EC_WEBCAM_MASK (1 << 1) 72 + #define MSI_STANDARD_EC_WLAN_MASK (1 << 3) 73 + #define MSI_STANDARD_EC_3G_MASK (1 << 4) 74 + 75 + /* For set SCM load flag to disable BIOS fn key */ 76 + #define MSI_STANDARD_EC_SCM_LOAD_ADDRESS 0x2d 77 + #define MSI_STANDARD_EC_SCM_LOAD_MASK (1 << 0) 78 + 79 + static int msi_laptop_resume(struct platform_device *device); 80 + 81 + #define MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS 0x2f 82 + 70 83 static int force; 71 84 module_param(force, bool, 0); 72 85 MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); ··· 88 73 static int auto_brightness; 89 74 module_param(auto_brightness, int, 0); 90 75 MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)"); 76 + 77 + static bool old_ec_model; 78 + static int wlan_s, bluetooth_s, threeg_s; 79 + static int threeg_exists; 80 + 81 + /* Some MSI 3G netbook only have one fn key to control Wlan/Bluetooth/3G, 82 + * those netbook will load the SCM (windows app) to disable the original 83 + * Wlan/Bluetooth control by BIOS when user press fn key, then control 84 + * Wlan/Bluetooth/3G by SCM (software control by OS). Without SCM, user 85 + * cann't on/off 3G module on those 3G netbook. 86 + * On Linux, msi-laptop driver will do the same thing to disable the 87 + * original BIOS control, then might need use HAL or other userland 88 + * application to do the software control that simulate with SCM. 89 + * e.g. MSI N034 netbook 90 + */ 91 + static bool load_scm_model; 92 + static struct rfkill *rfk_wlan, *rfk_bluetooth, *rfk_threeg; 91 93 92 94 /* Hardware access */ 93 95 ··· 162 130 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0, 1); 163 131 } 164 132 133 + static ssize_t set_device_state(const char *buf, size_t count, u8 mask) 134 + { 135 + int status; 136 + u8 wdata = 0, rdata; 137 + int result; 138 + 139 + if (sscanf(buf, "%i", &status) != 1 || (status < 0 || status > 1)) 140 + return -EINVAL; 141 + 142 + /* read current device state */ 143 + result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata); 144 + if (result < 0) 145 + return -EINVAL; 146 + 147 + if (!!(rdata & mask) != status) { 148 + /* reverse device bit */ 149 + if (rdata & mask) 150 + wdata = rdata & ~mask; 151 + else 152 + wdata = rdata | mask; 153 + 154 + result = ec_write(MSI_STANDARD_EC_COMMAND_ADDRESS, wdata); 155 + if (result < 0) 156 + return -EINVAL; 157 + } 158 + 159 + return count; 160 + } 161 + 165 162 static int get_wireless_state(int *wlan, int *bluetooth) 166 163 { 167 164 u8 wdata = 0, rdata; ··· 205 144 206 145 if (bluetooth) 207 146 *bluetooth = !!(rdata & 128); 147 + 148 + return 0; 149 + } 150 + 151 + static int get_wireless_state_ec_standard(void) 152 + { 153 + u8 rdata; 154 + int result; 155 + 156 + result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata); 157 + if (result < 0) 158 + return -1; 159 + 160 + wlan_s = !!(rdata & MSI_STANDARD_EC_WLAN_MASK); 161 + 162 + bluetooth_s = !!(rdata & MSI_STANDARD_EC_BLUETOOTH_MASK); 163 + 164 + threeg_s = !!(rdata & MSI_STANDARD_EC_3G_MASK); 165 + 166 + return 0; 167 + } 168 + 169 + static int get_threeg_exists(void) 170 + { 171 + u8 rdata; 172 + int result; 173 + 174 + result = ec_read(MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS, &rdata); 175 + if (result < 0) 176 + return -1; 177 + 178 + threeg_exists = !!(rdata & MSI_STANDARD_EC_3G_MASK); 208 179 209 180 return 0; 210 181 } ··· 269 176 270 177 int ret, enabled; 271 178 272 - ret = get_wireless_state(&enabled, NULL); 179 + if (old_ec_model) { 180 + ret = get_wireless_state(&enabled, NULL); 181 + } else { 182 + ret = get_wireless_state_ec_standard(); 183 + enabled = wlan_s; 184 + } 273 185 if (ret < 0) 274 186 return ret; 275 187 276 188 return sprintf(buf, "%i\n", enabled); 189 + } 190 + 191 + static ssize_t store_wlan(struct device *dev, 192 + struct device_attribute *attr, const char *buf, size_t count) 193 + { 194 + return set_device_state(buf, count, MSI_STANDARD_EC_WLAN_MASK); 277 195 } 278 196 279 197 static ssize_t show_bluetooth(struct device *dev, ··· 293 189 294 190 int ret, enabled; 295 191 296 - ret = get_wireless_state(NULL, &enabled); 192 + if (old_ec_model) { 193 + ret = get_wireless_state(NULL, &enabled); 194 + } else { 195 + ret = get_wireless_state_ec_standard(); 196 + enabled = bluetooth_s; 197 + } 297 198 if (ret < 0) 298 199 return ret; 299 200 300 201 return sprintf(buf, "%i\n", enabled); 202 + } 203 + 204 + static ssize_t store_bluetooth(struct device *dev, 205 + struct device_attribute *attr, const char *buf, size_t count) 206 + { 207 + return set_device_state(buf, count, MSI_STANDARD_EC_BLUETOOTH_MASK); 208 + } 209 + 210 + static ssize_t show_threeg(struct device *dev, 211 + struct device_attribute *attr, char *buf) 212 + { 213 + 214 + int ret; 215 + 216 + /* old msi ec not support 3G */ 217 + if (old_ec_model) 218 + return -1; 219 + 220 + ret = get_wireless_state_ec_standard(); 221 + if (ret < 0) 222 + return ret; 223 + 224 + return sprintf(buf, "%i\n", threeg_s); 225 + } 226 + 227 + static ssize_t store_threeg(struct device *dev, 228 + struct device_attribute *attr, const char *buf, size_t count) 229 + { 230 + return set_device_state(buf, count, MSI_STANDARD_EC_3G_MASK); 301 231 } 302 232 303 233 static ssize_t show_lcd_level(struct device *dev, ··· 396 258 static DEVICE_ATTR(auto_brightness, 0644, show_auto_brightness, store_auto_brightness); 397 259 static DEVICE_ATTR(bluetooth, 0444, show_bluetooth, NULL); 398 260 static DEVICE_ATTR(wlan, 0444, show_wlan, NULL); 261 + static DEVICE_ATTR(threeg, 0444, show_threeg, NULL); 399 262 400 263 static struct attribute *msipf_attributes[] = { 401 264 &dev_attr_lcd_level.attr, ··· 414 275 .driver = { 415 276 .name = "msi-laptop-pf", 416 277 .owner = THIS_MODULE, 417 - } 278 + }, 279 + .resume = msi_laptop_resume, 418 280 }; 419 281 420 282 static struct platform_device *msipf_device; ··· 472 332 { } 473 333 }; 474 334 335 + static struct dmi_system_id __initdata msi_load_scm_models_dmi_table[] = { 336 + { 337 + .ident = "MSI N034", 338 + .matches = { 339 + DMI_MATCH(DMI_SYS_VENDOR, 340 + "MICRO-STAR INTERNATIONAL CO., LTD"), 341 + DMI_MATCH(DMI_PRODUCT_NAME, "MS-N034"), 342 + DMI_MATCH(DMI_CHASSIS_VENDOR, 343 + "MICRO-STAR INTERNATIONAL CO., LTD") 344 + }, 345 + .callback = dmi_check_cb 346 + }, 347 + { } 348 + }; 349 + 350 + static int rfkill_bluetooth_set(void *data, bool blocked) 351 + { 352 + /* Do something with blocked...*/ 353 + /* 354 + * blocked == false is on 355 + * blocked == true is off 356 + */ 357 + if (blocked) 358 + set_device_state("0", 0, MSI_STANDARD_EC_BLUETOOTH_MASK); 359 + else 360 + set_device_state("1", 0, MSI_STANDARD_EC_BLUETOOTH_MASK); 361 + 362 + return 0; 363 + } 364 + 365 + static int rfkill_wlan_set(void *data, bool blocked) 366 + { 367 + if (blocked) 368 + set_device_state("0", 0, MSI_STANDARD_EC_WLAN_MASK); 369 + else 370 + set_device_state("1", 0, MSI_STANDARD_EC_WLAN_MASK); 371 + 372 + return 0; 373 + } 374 + 375 + static int rfkill_threeg_set(void *data, bool blocked) 376 + { 377 + if (blocked) 378 + set_device_state("0", 0, MSI_STANDARD_EC_3G_MASK); 379 + else 380 + set_device_state("1", 0, MSI_STANDARD_EC_3G_MASK); 381 + 382 + return 0; 383 + } 384 + 385 + static struct rfkill_ops rfkill_bluetooth_ops = { 386 + .set_block = rfkill_bluetooth_set 387 + }; 388 + 389 + static struct rfkill_ops rfkill_wlan_ops = { 390 + .set_block = rfkill_wlan_set 391 + }; 392 + 393 + static struct rfkill_ops rfkill_threeg_ops = { 394 + .set_block = rfkill_threeg_set 395 + }; 396 + 397 + static void rfkill_cleanup(void) 398 + { 399 + if (rfk_bluetooth) { 400 + rfkill_unregister(rfk_bluetooth); 401 + rfkill_destroy(rfk_bluetooth); 402 + } 403 + 404 + if (rfk_threeg) { 405 + rfkill_unregister(rfk_threeg); 406 + rfkill_destroy(rfk_threeg); 407 + } 408 + 409 + if (rfk_wlan) { 410 + rfkill_unregister(rfk_wlan); 411 + rfkill_destroy(rfk_wlan); 412 + } 413 + } 414 + 415 + static int rfkill_init(struct platform_device *sdev) 416 + { 417 + /* add rfkill */ 418 + int retval; 419 + 420 + rfk_bluetooth = rfkill_alloc("msi-bluetooth", &sdev->dev, 421 + RFKILL_TYPE_BLUETOOTH, 422 + &rfkill_bluetooth_ops, NULL); 423 + if (!rfk_bluetooth) { 424 + retval = -ENOMEM; 425 + goto err_bluetooth; 426 + } 427 + retval = rfkill_register(rfk_bluetooth); 428 + if (retval) 429 + goto err_bluetooth; 430 + 431 + rfk_wlan = rfkill_alloc("msi-wlan", &sdev->dev, RFKILL_TYPE_WLAN, 432 + &rfkill_wlan_ops, NULL); 433 + if (!rfk_wlan) { 434 + retval = -ENOMEM; 435 + goto err_wlan; 436 + } 437 + retval = rfkill_register(rfk_wlan); 438 + if (retval) 439 + goto err_wlan; 440 + 441 + if (threeg_exists) { 442 + rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev, 443 + RFKILL_TYPE_WWAN, &rfkill_threeg_ops, NULL); 444 + if (!rfk_threeg) { 445 + retval = -ENOMEM; 446 + goto err_threeg; 447 + } 448 + retval = rfkill_register(rfk_threeg); 449 + if (retval) 450 + goto err_threeg; 451 + } 452 + 453 + return 0; 454 + 455 + err_threeg: 456 + rfkill_destroy(rfk_threeg); 457 + if (rfk_wlan) 458 + rfkill_unregister(rfk_wlan); 459 + err_wlan: 460 + rfkill_destroy(rfk_wlan); 461 + if (rfk_bluetooth) 462 + rfkill_unregister(rfk_bluetooth); 463 + err_bluetooth: 464 + rfkill_destroy(rfk_bluetooth); 465 + 466 + return retval; 467 + } 468 + 469 + static int msi_laptop_resume(struct platform_device *device) 470 + { 471 + u8 data; 472 + int result; 473 + 474 + if (!load_scm_model) 475 + return 0; 476 + 477 + /* set load SCM to disable hardware control by fn key */ 478 + result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); 479 + if (result < 0) 480 + return result; 481 + 482 + result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, 483 + data | MSI_STANDARD_EC_SCM_LOAD_MASK); 484 + if (result < 0) 485 + return result; 486 + 487 + return 0; 488 + } 489 + 490 + static int load_scm_model_init(struct platform_device *sdev) 491 + { 492 + u8 data; 493 + int result; 494 + 495 + /* allow userland write sysfs file */ 496 + dev_attr_bluetooth.store = store_bluetooth; 497 + dev_attr_wlan.store = store_wlan; 498 + dev_attr_threeg.store = store_threeg; 499 + dev_attr_bluetooth.attr.mode |= S_IWUSR; 500 + dev_attr_wlan.attr.mode |= S_IWUSR; 501 + dev_attr_threeg.attr.mode |= S_IWUSR; 502 + 503 + /* disable hardware control by fn key */ 504 + result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); 505 + if (result < 0) 506 + return result; 507 + 508 + result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, 509 + data | MSI_STANDARD_EC_SCM_LOAD_MASK); 510 + if (result < 0) 511 + return result; 512 + 513 + /* initial rfkill */ 514 + result = rfkill_init(sdev); 515 + if (result < 0) 516 + return result; 517 + 518 + return 0; 519 + } 520 + 475 521 static int __init msi_init(void) 476 522 { 477 523 int ret; ··· 665 339 if (acpi_disabled) 666 340 return -ENODEV; 667 341 668 - if (!force && !dmi_check_system(msi_dmi_table)) 669 - return -ENODEV; 342 + if (force || dmi_check_system(msi_dmi_table)) 343 + old_ec_model = 1; 344 + 345 + if (!old_ec_model) 346 + get_threeg_exists(); 347 + 348 + if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table)) 349 + load_scm_model = 1; 670 350 671 351 if (auto_brightness < 0 || auto_brightness > 2) 672 352 return -EINVAL; ··· 706 374 if (ret) 707 375 goto fail_platform_device1; 708 376 377 + if (load_scm_model && (load_scm_model_init(msipf_device) < 0)) { 378 + ret = -EINVAL; 379 + goto fail_platform_device1; 380 + } 381 + 709 382 ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group); 710 383 if (ret) 711 384 goto fail_platform_device2; 385 + 386 + if (!old_ec_model) { 387 + if (threeg_exists) 388 + ret = device_create_file(&msipf_device->dev, 389 + &dev_attr_threeg); 390 + if (ret) 391 + goto fail_platform_device2; 392 + } 712 393 713 394 /* Disable automatic brightness control by default because 714 395 * this module was probably loaded to do brightness control in ··· 757 412 { 758 413 759 414 sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); 415 + if (!old_ec_model && threeg_exists) 416 + device_remove_file(&msipf_device->dev, &dev_attr_threeg); 760 417 platform_device_unregister(msipf_device); 761 418 platform_driver_unregister(&msipf_driver); 762 419 backlight_device_unregister(msibl_device); 420 + 421 + rfkill_cleanup(); 763 422 764 423 /* Enable automatic brightness control again */ 765 424 if (auto_brightness != 2) ··· 784 435 MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*"); 785 436 MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); 786 437 MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); 438 + MODULE_ALIAS("dmi:*:svnMICRO-STARINTERNATIONAL*:pnMS-N034:*");
+1 -1
drivers/scsi/sgiwd93.c
··· 226 226 .use_clustering = DISABLE_CLUSTERING, 227 227 }; 228 228 229 - static int __init sgiwd93_probe(struct platform_device *pdev) 229 + static int __devinit sgiwd93_probe(struct platform_device *pdev) 230 230 { 231 231 struct sgiwd93_platform_data *pd = pdev->dev.platform_data; 232 232 unsigned char *wdregs = pd->wdregs;
+1 -1
drivers/scsi/sni_53c710.c
··· 64 64 .module = THIS_MODULE, 65 65 }; 66 66 67 - static int __init snirm710_probe(struct platform_device *dev) 67 + static int __devinit snirm710_probe(struct platform_device *dev) 68 68 { 69 69 unsigned long base; 70 70 struct NCR_700_Host_Parameters *hostdata;
+4 -9
drivers/staging/asus_oled/asus_oled.c
··· 770 770 .id_table = id_table, 771 771 }; 772 772 773 - static ssize_t version_show(struct class *dev, char *buf) 774 - { 775 - return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n", 776 - ASUS_OLED_VERSION); 777 - } 778 - 779 - static CLASS_ATTR(version, S_IRUGO, version_show, NULL); 773 + static CLASS_ATTR_STRING(version, S_IRUGO, 774 + ASUS_OLED_UNDERSCORE_NAME " " ASUS_OLED_VERSION); 780 775 781 776 static int __init asus_oled_init(void) 782 777 { ··· 783 788 return PTR_ERR(oled_class); 784 789 } 785 790 786 - retval = class_create_file(oled_class, &class_attr_version); 791 + retval = class_create_file(oled_class, &class_attr_version.attr); 787 792 if (retval) { 788 793 err("Error creating class version file"); 789 794 goto error; ··· 805 810 806 811 static void __exit asus_oled_exit(void) 807 812 { 808 - class_remove_file(oled_class, &class_attr_version); 813 + class_remove_file(oled_class, &class_attr_version.attr); 809 814 class_destroy(oled_class); 810 815 811 816 usb_deregister(&oled_driver);
+12 -12
drivers/uio/Kconfig
··· 44 44 45 45 If you don't know what to do here, say N. 46 46 47 - config UIO_SMX 48 - tristate "SMX cryptengine UIO interface" 49 - help 50 - Userspace IO interface to the Cryptography engine found on the 51 - Nias Digital SMX boards. These will be available from Q4 2008 52 - from http://www.niasdigital.com. The userspace part of this 53 - driver will be released under the GPL at the same time as the 54 - hardware and will be able to be downloaded from the same site. 55 - 56 - If you compile this as a module, it will be called uio_smx. 57 - 58 47 config UIO_AEC 59 48 tristate "AEC video timestamp device" 60 49 depends on PCI ··· 63 74 64 75 config UIO_SERCOS3 65 76 tristate "Automata Sercos III PCI card driver" 77 + depends on PCI 66 78 help 67 79 Userspace I/O interface for the Sercos III PCI card from 68 80 Automata GmbH. The userspace part of this driver will be ··· 77 87 config UIO_PCI_GENERIC 78 88 tristate "Generic driver for PCI 2.3 and PCI Express cards" 79 89 depends on PCI 80 - default n 81 90 help 82 91 Generic driver that you can bind, dynamically, to any 83 92 PCI 2.3 compliant and PCI Express card. It is useful, 84 93 primarily, for virtualization scenarios. 85 94 If you compile this as a module, it will be called uio_pci_generic. 95 + 96 + config UIO_NETX 97 + tristate "Hilscher NetX Card driver" 98 + depends on PCI 99 + help 100 + Driver for Hilscher NetX based fieldbus cards (cifX, comX). 101 + This driver requires a userspace component that comes with the card 102 + or is available from Hilscher (http://www.hilscher.com). 103 + 104 + To compile this driver as a module, choose M here; the module 105 + will be called uio_netx. 86 106 87 107 endif
+1 -1
drivers/uio/Makefile
··· 2 2 obj-$(CONFIG_UIO_CIF) += uio_cif.o 3 3 obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o 4 4 obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o 5 - obj-$(CONFIG_UIO_SMX) += uio_smx.o 6 5 obj-$(CONFIG_UIO_AEC) += uio_aec.o 7 6 obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o 8 7 obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o 8 + obj-$(CONFIG_UIO_NETX) += uio_netx.o
+2 -2
drivers/uio/uio.c
··· 129 129 return entry->show(mem, buf); 130 130 } 131 131 132 - static struct sysfs_ops map_sysfs_ops = { 132 + static const struct sysfs_ops map_sysfs_ops = { 133 133 .show = map_type_show, 134 134 }; 135 135 ··· 217 217 return entry->show(port, buf); 218 218 } 219 219 220 - static struct sysfs_ops portio_sysfs_ops = { 220 + static const struct sysfs_ops portio_sysfs_ops = { 221 221 .show = portio_type_show, 222 222 }; 223 223
+172
drivers/uio/uio_netx.c
··· 1 + /* 2 + * UIO driver for Hilscher NetX based fieldbus cards (cifX, comX). 3 + * See http://www.hilscher.com for details. 4 + * 5 + * (C) 2007 Hans J. Koch <hjk@linutronix.de> 6 + * (C) 2008 Manuel Traut <manut@linutronix.de> 7 + * 8 + * Licensed under GPL version 2 only. 9 + * 10 + */ 11 + 12 + #include <linux/device.h> 13 + #include <linux/io.h> 14 + #include <linux/module.h> 15 + #include <linux/pci.h> 16 + #include <linux/uio_driver.h> 17 + 18 + #define PCI_VENDOR_ID_HILSCHER 0x15CF 19 + #define PCI_DEVICE_ID_HILSCHER_NETX 0x0000 20 + #define PCI_SUBDEVICE_ID_NXSB_PCA 0x3235 21 + #define PCI_SUBDEVICE_ID_NXPCA 0x3335 22 + 23 + #define DPM_HOST_INT_EN0 0xfff0 24 + #define DPM_HOST_INT_STAT0 0xffe0 25 + 26 + #define DPM_HOST_INT_MASK 0xe600ffff 27 + #define DPM_HOST_INT_GLOBAL_EN 0x80000000 28 + 29 + static irqreturn_t netx_handler(int irq, struct uio_info *dev_info) 30 + { 31 + void __iomem *int_enable_reg = dev_info->mem[0].internal_addr 32 + + DPM_HOST_INT_EN0; 33 + void __iomem *int_status_reg = dev_info->mem[0].internal_addr 34 + + DPM_HOST_INT_STAT0; 35 + 36 + /* Is one of our interrupts enabled and active ? */ 37 + if (!(ioread32(int_enable_reg) & ioread32(int_status_reg) 38 + & DPM_HOST_INT_MASK)) 39 + return IRQ_NONE; 40 + 41 + /* Disable interrupt */ 42 + iowrite32(ioread32(int_enable_reg) & ~DPM_HOST_INT_GLOBAL_EN, 43 + int_enable_reg); 44 + return IRQ_HANDLED; 45 + } 46 + 47 + static int __devinit netx_pci_probe(struct pci_dev *dev, 48 + const struct pci_device_id *id) 49 + { 50 + struct uio_info *info; 51 + int bar; 52 + 53 + info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 54 + if (!info) 55 + return -ENOMEM; 56 + 57 + if (pci_enable_device(dev)) 58 + goto out_free; 59 + 60 + if (pci_request_regions(dev, "netx")) 61 + goto out_disable; 62 + 63 + switch (id->device) { 64 + case PCI_DEVICE_ID_HILSCHER_NETX: 65 + bar = 0; 66 + info->name = "netx"; 67 + break; 68 + default: 69 + bar = 2; 70 + info->name = "netx_plx"; 71 + } 72 + 73 + /* BAR0 or 2 points to the card's dual port memory */ 74 + info->mem[0].addr = pci_resource_start(dev, bar); 75 + if (!info->mem[0].addr) 76 + goto out_release; 77 + info->mem[0].internal_addr = ioremap(pci_resource_start(dev, bar), 78 + pci_resource_len(dev, bar)); 79 + 80 + if (!info->mem[0].internal_addr) 81 + goto out_release; 82 + 83 + info->mem[0].size = pci_resource_len(dev, bar); 84 + info->mem[0].memtype = UIO_MEM_PHYS; 85 + info->irq = dev->irq; 86 + info->irq_flags = IRQF_SHARED; 87 + info->handler = netx_handler; 88 + info->version = "0.0.1"; 89 + 90 + /* Make sure all interrupts are disabled */ 91 + iowrite32(0, info->mem[0].internal_addr + DPM_HOST_INT_EN0); 92 + 93 + if (uio_register_device(&dev->dev, info)) 94 + goto out_unmap; 95 + 96 + pci_set_drvdata(dev, info); 97 + dev_info(&dev->dev, "Found %s card, registered UIO device.\n", 98 + info->name); 99 + 100 + return 0; 101 + 102 + out_unmap: 103 + iounmap(info->mem[0].internal_addr); 104 + out_release: 105 + pci_release_regions(dev); 106 + out_disable: 107 + pci_disable_device(dev); 108 + out_free: 109 + kfree(info); 110 + return -ENODEV; 111 + } 112 + 113 + static void netx_pci_remove(struct pci_dev *dev) 114 + { 115 + struct uio_info *info = pci_get_drvdata(dev); 116 + 117 + /* Disable all interrupts */ 118 + iowrite32(0, info->mem[0].internal_addr + DPM_HOST_INT_EN0); 119 + uio_unregister_device(info); 120 + pci_release_regions(dev); 121 + pci_disable_device(dev); 122 + pci_set_drvdata(dev, NULL); 123 + iounmap(info->mem[0].internal_addr); 124 + 125 + kfree(info); 126 + } 127 + 128 + static struct pci_device_id netx_pci_ids[] = { 129 + { 130 + .vendor = PCI_VENDOR_ID_HILSCHER, 131 + .device = PCI_DEVICE_ID_HILSCHER_NETX, 132 + .subvendor = 0, 133 + .subdevice = 0, 134 + }, 135 + { 136 + .vendor = PCI_VENDOR_ID_PLX, 137 + .device = PCI_DEVICE_ID_PLX_9030, 138 + .subvendor = PCI_VENDOR_ID_PLX, 139 + .subdevice = PCI_SUBDEVICE_ID_NXSB_PCA, 140 + }, 141 + { 142 + .vendor = PCI_VENDOR_ID_PLX, 143 + .device = PCI_DEVICE_ID_PLX_9030, 144 + .subvendor = PCI_VENDOR_ID_PLX, 145 + .subdevice = PCI_SUBDEVICE_ID_NXPCA, 146 + }, 147 + { 0, } 148 + }; 149 + 150 + static struct pci_driver netx_pci_driver = { 151 + .name = "netx", 152 + .id_table = netx_pci_ids, 153 + .probe = netx_pci_probe, 154 + .remove = netx_pci_remove, 155 + }; 156 + 157 + static int __init netx_init_module(void) 158 + { 159 + return pci_register_driver(&netx_pci_driver); 160 + } 161 + 162 + static void __exit netx_exit_module(void) 163 + { 164 + pci_unregister_driver(&netx_pci_driver); 165 + } 166 + 167 + module_init(netx_init_module); 168 + module_exit(netx_exit_module); 169 + 170 + MODULE_DEVICE_TABLE(pci, netx_pci_ids); 171 + MODULE_LICENSE("GPL v2"); 172 + MODULE_AUTHOR("Hans J. Koch, Manuel Traut");
-140
drivers/uio/uio_smx.c
··· 1 - /* 2 - * UIO SMX Cryptengine driver. 3 - * 4 - * (C) 2008 Nias Digital P/L <bn@niasdigital.com> 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 as 8 - * published by the Free Software Foundation. 9 - * 10 - */ 11 - 12 - #include <linux/device.h> 13 - #include <linux/module.h> 14 - #include <linux/platform_device.h> 15 - #include <linux/uio_driver.h> 16 - #include <linux/io.h> 17 - 18 - #define DRV_NAME "smx-ce" 19 - #define DRV_VERSION "0.03" 20 - 21 - #define SMX_CSR 0x00000000 22 - #define SMX_EnD 0x00000001 23 - #define SMX_RUN 0x00000002 24 - #define SMX_DRDY 0x00000004 25 - #define SMX_ERR 0x00000008 26 - 27 - static irqreturn_t smx_handler(int irq, struct uio_info *dev_info) 28 - { 29 - void __iomem *csr = dev_info->mem[0].internal_addr + SMX_CSR; 30 - 31 - u32 status = ioread32(csr); 32 - 33 - if (!(status & SMX_DRDY)) 34 - return IRQ_NONE; 35 - 36 - /* Disable interrupt */ 37 - iowrite32(status & ~SMX_DRDY, csr); 38 - return IRQ_HANDLED; 39 - } 40 - 41 - static int __devinit smx_ce_probe(struct platform_device *dev) 42 - { 43 - 44 - int ret = -ENODEV; 45 - struct uio_info *info; 46 - struct resource *regs; 47 - 48 - info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 49 - if (!info) 50 - return -ENOMEM; 51 - 52 - regs = platform_get_resource(dev, IORESOURCE_MEM, 0); 53 - if (!regs) { 54 - dev_err(&dev->dev, "No memory resource specified\n"); 55 - goto out_free; 56 - } 57 - 58 - info->mem[0].addr = regs->start; 59 - if (!info->mem[0].addr) { 60 - dev_err(&dev->dev, "Invalid memory resource\n"); 61 - goto out_free; 62 - } 63 - 64 - info->mem[0].size = regs->end - regs->start + 1; 65 - info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size); 66 - 67 - if (!info->mem[0].internal_addr) { 68 - dev_err(&dev->dev, "Can't remap memory address range\n"); 69 - goto out_free; 70 - } 71 - 72 - info->mem[0].memtype = UIO_MEM_PHYS; 73 - 74 - info->name = "smx-ce"; 75 - info->version = "0.03"; 76 - 77 - info->irq = platform_get_irq(dev, 0); 78 - if (info->irq < 0) { 79 - ret = info->irq; 80 - dev_err(&dev->dev, "No (or invalid) IRQ resource specified\n"); 81 - goto out_unmap; 82 - } 83 - 84 - info->irq_flags = IRQF_SHARED; 85 - info->handler = smx_handler; 86 - 87 - platform_set_drvdata(dev, info); 88 - 89 - ret = uio_register_device(&dev->dev, info); 90 - 91 - if (ret) 92 - goto out_unmap; 93 - 94 - return 0; 95 - 96 - out_unmap: 97 - iounmap(info->mem[0].internal_addr); 98 - out_free: 99 - kfree(info); 100 - 101 - return ret; 102 - } 103 - 104 - static int __devexit smx_ce_remove(struct platform_device *dev) 105 - { 106 - struct uio_info *info = platform_get_drvdata(dev); 107 - 108 - uio_unregister_device(info); 109 - platform_set_drvdata(dev, NULL); 110 - iounmap(info->mem[0].internal_addr); 111 - 112 - kfree(info); 113 - 114 - return 0; 115 - } 116 - 117 - static struct platform_driver smx_ce_driver = { 118 - .probe = smx_ce_probe, 119 - .remove = __devexit_p(smx_ce_remove), 120 - .driver = { 121 - .name = DRV_NAME, 122 - .owner = THIS_MODULE, 123 - }, 124 - }; 125 - 126 - static int __init smx_ce_init_module(void) 127 - { 128 - return platform_driver_register(&smx_ce_driver); 129 - } 130 - module_init(smx_ce_init_module); 131 - 132 - static void __exit smx_ce_exit_module(void) 133 - { 134 - platform_driver_unregister(&smx_ce_driver); 135 - } 136 - module_exit(smx_ce_exit_module); 137 - 138 - MODULE_LICENSE("GPL v2"); 139 - MODULE_VERSION(DRV_VERSION); 140 - MODULE_AUTHOR("Ben Nizette <bn@niasdigital.com>");
+2 -2
drivers/usb/core/driver.c
··· 489 489 if (device_is_registered(dev)) { 490 490 device_release_driver(dev); 491 491 } else { 492 - down(&dev->sem); 492 + device_lock(dev); 493 493 usb_unbind_interface(dev); 494 494 dev->driver = NULL; 495 - up(&dev->sem); 495 + device_unlock(dev); 496 496 } 497 497 } 498 498 EXPORT_SYMBOL_GPL(usb_driver_release_interface);
+4 -1
drivers/uwb/driver.c
··· 74 74 unsigned long beacon_timeout_ms = 500; 75 75 76 76 static 77 - ssize_t beacon_timeout_ms_show(struct class *class, char *buf) 77 + ssize_t beacon_timeout_ms_show(struct class *class, 78 + struct class_attribute *attr, 79 + char *buf) 78 80 { 79 81 return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms); 80 82 } 81 83 82 84 static 83 85 ssize_t beacon_timeout_ms_store(struct class *class, 86 + struct class_attribute *attr, 84 87 const char *buf, size_t size) 85 88 { 86 89 unsigned long bt;
+2 -2
drivers/uwb/umc-bus.c
··· 62 62 struct device *parent = umc->dev.parent; 63 63 int ret = 0; 64 64 65 - if(down_trylock(&parent->sem)) 65 + if (device_trylock(parent)) 66 66 return -EAGAIN; 67 67 ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper); 68 68 if (ret >= 0) 69 69 ret = device_for_each_child(parent, parent, umc_bus_post_reset_helper); 70 - up(&parent->sem); 70 + device_unlock(parent); 71 71 72 72 return ret; 73 73 }
+2 -2
drivers/uwb/uwb-internal.h
··· 366 366 367 367 static inline void uwb_dev_lock(struct uwb_dev *uwb_dev) 368 368 { 369 - down(&uwb_dev->dev.sem); 369 + device_lock(&uwb_dev->dev); 370 370 } 371 371 372 372 static inline void uwb_dev_unlock(struct uwb_dev *uwb_dev) 373 373 { 374 - up(&uwb_dev->dev.sem); 374 + device_unlock(&uwb_dev->dev); 375 375 } 376 376 377 377 #endif /* #ifndef __UWB_INTERNAL_H__ */
+1 -2
drivers/uwb/wlp/sysfs.c
··· 615 615 return ret; 616 616 } 617 617 618 - static 619 - struct sysfs_ops wss_sysfs_ops = { 618 + static const struct sysfs_ops wss_sysfs_ops = { 620 619 .show = wlp_wss_attr_show, 621 620 .store = wlp_wss_attr_store, 622 621 };
+1 -1
drivers/video/acornfb.c
··· 1221 1221 printk("acornfb: freed %dK memory\n", mb_freed); 1222 1222 } 1223 1223 1224 - static int __init acornfb_probe(struct platform_device *dev) 1224 + static int __devinit acornfb_probe(struct platform_device *dev) 1225 1225 { 1226 1226 unsigned long size; 1227 1227 u_int h_sync, v_sync;
+1 -1
drivers/video/arcfb.c
··· 504 504 .fb_ioctl = arcfb_ioctl, 505 505 }; 506 506 507 - static int __init arcfb_probe(struct platform_device *dev) 507 + static int __devinit arcfb_probe(struct platform_device *dev) 508 508 { 509 509 struct fb_info *info; 510 510 int retval = -ENOMEM;
+1 -1
drivers/video/cobalt_lcdfb.c
··· 287 287 .fb_cursor = cobalt_lcdfb_cursor, 288 288 }; 289 289 290 - static int __init cobalt_lcdfb_probe(struct platform_device *dev) 290 + static int __devinit cobalt_lcdfb_probe(struct platform_device *dev) 291 291 { 292 292 struct fb_info *info; 293 293 struct resource *res;
+1 -1
drivers/video/efifb.c
··· 210 210 return 0; 211 211 } 212 212 213 - static int __init efifb_probe(struct platform_device *dev) 213 + static int __devinit efifb_probe(struct platform_device *dev) 214 214 { 215 215 struct fb_info *info; 216 216 int err;
+1 -1
drivers/video/epson1355fb.c
··· 602 602 return 0; 603 603 } 604 604 605 - int __init epson1355fb_probe(struct platform_device *dev) 605 + int __devinit epson1355fb_probe(struct platform_device *dev) 606 606 { 607 607 struct epson1355_par *default_par; 608 608 struct fb_info *info;
+1 -1
drivers/video/gbefb.c
··· 1128 1128 return 0; 1129 1129 } 1130 1130 1131 - static int __init gbefb_probe(struct platform_device *p_dev) 1131 + static int __devinit gbefb_probe(struct platform_device *p_dev) 1132 1132 { 1133 1133 int i, ret = 0; 1134 1134 struct fb_info *info;
+1 -1
drivers/video/hgafb.c
··· 551 551 * Initialization 552 552 */ 553 553 554 - static int __init hgafb_probe(struct platform_device *pdev) 554 + static int __devinit hgafb_probe(struct platform_device *pdev) 555 555 { 556 556 struct fb_info *info; 557 557
+1 -1
drivers/video/hitfb.c
··· 325 325 .fb_imageblit = cfb_imageblit, 326 326 }; 327 327 328 - static int __init hitfb_probe(struct platform_device *dev) 328 + static int __devinit hitfb_probe(struct platform_device *dev) 329 329 { 330 330 unsigned short lcdclor, ldr3, ldvndr; 331 331 struct fb_info *info;
+1 -1
drivers/video/omap2/dss/manager.c
··· 341 341 return manager_attr->store(manager, buf, size); 342 342 } 343 343 344 - static struct sysfs_ops manager_sysfs_ops = { 344 + static const struct sysfs_ops manager_sysfs_ops = { 345 345 .show = manager_attr_show, 346 346 .store = manager_attr_store, 347 347 };
+1 -1
drivers/video/omap2/dss/overlay.c
··· 320 320 return overlay_attr->store(overlay, buf, size); 321 321 } 322 322 323 - static struct sysfs_ops overlay_sysfs_ops = { 323 + static const struct sysfs_ops overlay_sysfs_ops = { 324 324 .show = overlay_attr_show, 325 325 .store = overlay_attr_store, 326 326 };
+1 -1
drivers/video/q40fb.c
··· 85 85 .fb_imageblit = cfb_imageblit, 86 86 }; 87 87 88 - static int __init q40fb_probe(struct platform_device *dev) 88 + static int __devinit q40fb_probe(struct platform_device *dev) 89 89 { 90 90 struct fb_info *info; 91 91
+2 -2
drivers/video/s3c2410fb.c
··· 1004 1004 return ret; 1005 1005 } 1006 1006 1007 - static int __init s3c2410fb_probe(struct platform_device *pdev) 1007 + static int __devinit s3c2410fb_probe(struct platform_device *pdev) 1008 1008 { 1009 1009 return s3c24xxfb_probe(pdev, DRV_S3C2410); 1010 1010 } 1011 1011 1012 - static int __init s3c2412fb_probe(struct platform_device *pdev) 1012 + static int __devinit s3c2412fb_probe(struct platform_device *pdev) 1013 1013 { 1014 1014 return s3c24xxfb_probe(pdev, DRV_S3C2412); 1015 1015 }
+1 -1
drivers/video/sa1100fb.c
··· 1435 1435 return fbi; 1436 1436 } 1437 1437 1438 - static int __init sa1100fb_probe(struct platform_device *pdev) 1438 + static int __devinit sa1100fb_probe(struct platform_device *pdev) 1439 1439 { 1440 1440 struct sa1100fb_info *fbi; 1441 1441 int ret, irq;
+1 -1
drivers/video/sgivwfb.c
··· 745 745 /* 746 746 * Initialisation 747 747 */ 748 - static int __init sgivwfb_probe(struct platform_device *dev) 748 + static int __devinit sgivwfb_probe(struct platform_device *dev) 749 749 { 750 750 struct sgivw_par *par; 751 751 struct fb_info *info;
+1 -1
drivers/video/sh_mobile_lcdcfb.c
··· 943 943 944 944 static int sh_mobile_lcdc_remove(struct platform_device *pdev); 945 945 946 - static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) 946 + static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) 947 947 { 948 948 struct fb_info *info; 949 949 struct sh_mobile_lcdc_priv *priv;
+1 -1
drivers/video/vesafb.c
··· 226 226 return 0; 227 227 } 228 228 229 - static int __init vesafb_probe(struct platform_device *dev) 229 + static int __devinit vesafb_probe(struct platform_device *dev) 230 230 { 231 231 struct fb_info *info; 232 232 int i, err;
+1 -1
drivers/video/vfb.c
··· 479 479 * Initialisation 480 480 */ 481 481 482 - static int __init vfb_probe(struct platform_device *dev) 482 + static int __devinit vfb_probe(struct platform_device *dev) 483 483 { 484 484 struct fb_info *info; 485 485 int retval = -ENOMEM;
+1 -1
drivers/video/vga16fb.c
··· 1293 1293 } 1294 1294 #endif 1295 1295 1296 - static int __init vga16fb_probe(struct platform_device *dev) 1296 + static int __devinit vga16fb_probe(struct platform_device *dev) 1297 1297 { 1298 1298 struct fb_info *info; 1299 1299 struct vga16fb_par *par;
+1 -1
drivers/video/w100fb.c
··· 628 628 #endif 629 629 630 630 631 - int __init w100fb_probe(struct platform_device *pdev) 631 + int __devinit w100fb_probe(struct platform_device *pdev) 632 632 { 633 633 int err = -EIO; 634 634 struct w100fb_mach_info *inf;
+2 -2
drivers/w1/masters/omap_hdq.c
··· 72 72 int init_trans; 73 73 }; 74 74 75 - static int __init omap_hdq_probe(struct platform_device *pdev); 75 + static int __devinit omap_hdq_probe(struct platform_device *pdev); 76 76 static int omap_hdq_remove(struct platform_device *pdev); 77 77 78 78 static struct platform_driver omap_hdq_driver = { ··· 558 558 return; 559 559 } 560 560 561 - static int __init omap_hdq_probe(struct platform_device *pdev) 561 + static int __devinit omap_hdq_probe(struct platform_device *pdev) 562 562 { 563 563 struct hdq_data *hdq_data; 564 564 struct resource *res;
+1 -1
drivers/xen/sys-hypervisor.c
··· 426 426 return 0; 427 427 } 428 428 429 - static struct sysfs_ops hyp_sysfs_ops = { 429 + static const struct sysfs_ops hyp_sysfs_ops = { 430 430 .show = hyp_sysfs_show, 431 431 .store = hyp_sysfs_store, 432 432 };
+2 -2
fs/btrfs/sysfs.c
··· 164 164 complete(&root->kobj_unregister); 165 165 } 166 166 167 - static struct sysfs_ops btrfs_super_attr_ops = { 167 + static const struct sysfs_ops btrfs_super_attr_ops = { 168 168 .show = btrfs_super_attr_show, 169 169 .store = btrfs_super_attr_store, 170 170 }; 171 171 172 - static struct sysfs_ops btrfs_root_attr_ops = { 172 + static const struct sysfs_ops btrfs_root_attr_ops = { 173 173 .show = btrfs_root_attr_show, 174 174 .store = btrfs_root_attr_store, 175 175 };
+1 -1
fs/dlm/lockspace.c
··· 148 148 kfree(ls); 149 149 } 150 150 151 - static struct sysfs_ops dlm_attr_ops = { 151 + static const struct sysfs_ops dlm_attr_ops = { 152 152 .show = dlm_attr_show, 153 153 .store = dlm_attr_store, 154 154 };
+1 -1
fs/ext4/super.c
··· 2358 2358 } 2359 2359 2360 2360 2361 - static struct sysfs_ops ext4_attr_ops = { 2361 + static const struct sysfs_ops ext4_attr_ops = { 2362 2362 .show = ext4_attr_show, 2363 2363 .store = ext4_attr_store, 2364 2364 };
+2 -2
fs/gfs2/sys.c
··· 49 49 return a->store ? a->store(sdp, buf, len) : len; 50 50 } 51 51 52 - static struct sysfs_ops gfs2_attr_ops = { 52 + static const struct sysfs_ops gfs2_attr_ops = { 53 53 .show = gfs2_attr_show, 54 54 .store = gfs2_attr_store, 55 55 }; ··· 574 574 return 0; 575 575 } 576 576 577 - static struct kset_uevent_ops gfs2_uevent_ops = { 577 + static const struct kset_uevent_ops gfs2_uevent_ops = { 578 578 .uevent = gfs2_uevent, 579 579 }; 580 580
+1 -1
fs/ocfs2/cluster/masklog.c
··· 136 136 return mlog_mask_store(mlog_attr->mask, buf, count); 137 137 } 138 138 139 - static struct sysfs_ops mlog_attr_ops = { 139 + static const struct sysfs_ops mlog_attr_ops = { 140 140 .show = mlog_show, 141 141 .store = mlog_store, 142 142 };
+25 -25
fs/sysfs/bin.c
··· 54 54 int rc; 55 55 56 56 /* need attr_sd for attr, its parent for kobj */ 57 - if (!sysfs_get_active_two(attr_sd)) 57 + if (!sysfs_get_active(attr_sd)) 58 58 return -ENODEV; 59 59 60 60 rc = -EIO; 61 61 if (attr->read) 62 62 rc = attr->read(kobj, attr, buffer, off, count); 63 63 64 - sysfs_put_active_two(attr_sd); 64 + sysfs_put_active(attr_sd); 65 65 66 66 return rc; 67 67 } ··· 125 125 int rc; 126 126 127 127 /* need attr_sd for attr, its parent for kobj */ 128 - if (!sysfs_get_active_two(attr_sd)) 128 + if (!sysfs_get_active(attr_sd)) 129 129 return -ENODEV; 130 130 131 131 rc = -EIO; 132 132 if (attr->write) 133 133 rc = attr->write(kobj, attr, buffer, offset, count); 134 134 135 - sysfs_put_active_two(attr_sd); 135 + sysfs_put_active(attr_sd); 136 136 137 137 return rc; 138 138 } ··· 184 184 if (!bb->vm_ops || !bb->vm_ops->open) 185 185 return; 186 186 187 - if (!sysfs_get_active_two(attr_sd)) 187 + if (!sysfs_get_active(attr_sd)) 188 188 return; 189 189 190 190 bb->vm_ops->open(vma); 191 191 192 - sysfs_put_active_two(attr_sd); 192 + sysfs_put_active(attr_sd); 193 193 } 194 194 195 195 static void bin_vma_close(struct vm_area_struct *vma) ··· 201 201 if (!bb->vm_ops || !bb->vm_ops->close) 202 202 return; 203 203 204 - if (!sysfs_get_active_two(attr_sd)) 204 + if (!sysfs_get_active(attr_sd)) 205 205 return; 206 206 207 207 bb->vm_ops->close(vma); 208 208 209 - sysfs_put_active_two(attr_sd); 209 + sysfs_put_active(attr_sd); 210 210 } 211 211 212 212 static int bin_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ··· 219 219 if (!bb->vm_ops || !bb->vm_ops->fault) 220 220 return VM_FAULT_SIGBUS; 221 221 222 - if (!sysfs_get_active_two(attr_sd)) 222 + if (!sysfs_get_active(attr_sd)) 223 223 return VM_FAULT_SIGBUS; 224 224 225 225 ret = bb->vm_ops->fault(vma, vmf); 226 226 227 - sysfs_put_active_two(attr_sd); 227 + sysfs_put_active(attr_sd); 228 228 return ret; 229 229 } 230 230 ··· 241 241 if (!bb->vm_ops->page_mkwrite) 242 242 return 0; 243 243 244 - if (!sysfs_get_active_two(attr_sd)) 244 + if (!sysfs_get_active(attr_sd)) 245 245 return VM_FAULT_SIGBUS; 246 246 247 247 ret = bb->vm_ops->page_mkwrite(vma, vmf); 248 248 249 - sysfs_put_active_two(attr_sd); 249 + sysfs_put_active(attr_sd); 250 250 return ret; 251 251 } 252 252 ··· 261 261 if (!bb->vm_ops || !bb->vm_ops->access) 262 262 return -EINVAL; 263 263 264 - if (!sysfs_get_active_two(attr_sd)) 264 + if (!sysfs_get_active(attr_sd)) 265 265 return -EINVAL; 266 266 267 267 ret = bb->vm_ops->access(vma, addr, buf, len, write); 268 268 269 - sysfs_put_active_two(attr_sd); 269 + sysfs_put_active(attr_sd); 270 270 return ret; 271 271 } 272 272 ··· 281 281 if (!bb->vm_ops || !bb->vm_ops->set_policy) 282 282 return 0; 283 283 284 - if (!sysfs_get_active_two(attr_sd)) 284 + if (!sysfs_get_active(attr_sd)) 285 285 return -EINVAL; 286 286 287 287 ret = bb->vm_ops->set_policy(vma, new); 288 288 289 - sysfs_put_active_two(attr_sd); 289 + sysfs_put_active(attr_sd); 290 290 return ret; 291 291 } 292 292 ··· 301 301 if (!bb->vm_ops || !bb->vm_ops->get_policy) 302 302 return vma->vm_policy; 303 303 304 - if (!sysfs_get_active_two(attr_sd)) 304 + if (!sysfs_get_active(attr_sd)) 305 305 return vma->vm_policy; 306 306 307 307 pol = bb->vm_ops->get_policy(vma, addr); 308 308 309 - sysfs_put_active_two(attr_sd); 309 + sysfs_put_active(attr_sd); 310 310 return pol; 311 311 } 312 312 ··· 321 321 if (!bb->vm_ops || !bb->vm_ops->migrate) 322 322 return 0; 323 323 324 - if (!sysfs_get_active_two(attr_sd)) 324 + if (!sysfs_get_active(attr_sd)) 325 325 return 0; 326 326 327 327 ret = bb->vm_ops->migrate(vma, from, to, flags); 328 328 329 - sysfs_put_active_two(attr_sd); 329 + sysfs_put_active(attr_sd); 330 330 return ret; 331 331 } 332 332 #endif ··· 356 356 357 357 /* need attr_sd for attr, its parent for kobj */ 358 358 rc = -ENODEV; 359 - if (!sysfs_get_active_two(attr_sd)) 359 + if (!sysfs_get_active(attr_sd)) 360 360 goto out_unlock; 361 361 362 362 rc = -EINVAL; ··· 384 384 bb->vm_ops = vma->vm_ops; 385 385 vma->vm_ops = &bin_vm_ops; 386 386 out_put: 387 - sysfs_put_active_two(attr_sd); 387 + sysfs_put_active(attr_sd); 388 388 out_unlock: 389 389 mutex_unlock(&bb->mutex); 390 390 ··· 399 399 int error; 400 400 401 401 /* binary file operations requires both @sd and its parent */ 402 - if (!sysfs_get_active_two(attr_sd)) 402 + if (!sysfs_get_active(attr_sd)) 403 403 return -ENODEV; 404 404 405 405 error = -EACCES; ··· 426 426 mutex_unlock(&sysfs_bin_lock); 427 427 428 428 /* open succeeded, put active references */ 429 - sysfs_put_active_two(attr_sd); 429 + sysfs_put_active(attr_sd); 430 430 return 0; 431 431 432 432 err_out: 433 - sysfs_put_active_two(attr_sd); 433 + sysfs_put_active(attr_sd); 434 434 kfree(bb); 435 435 return error; 436 436 }
+66 -64
fs/sysfs/dir.c
··· 93 93 * RETURNS: 94 94 * Pointer to @sd on success, NULL on failure. 95 95 */ 96 - static struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd) 96 + struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd) 97 97 { 98 98 if (unlikely(!sd)) 99 99 return NULL; ··· 124 124 * Put an active reference to @sd. This function is noop if @sd 125 125 * is NULL. 126 126 */ 127 - static void sysfs_put_active(struct sysfs_dirent *sd) 127 + void sysfs_put_active(struct sysfs_dirent *sd) 128 128 { 129 129 struct completion *cmpl; 130 130 int v; ··· 145 145 } 146 146 147 147 /** 148 - * sysfs_get_active_two - get active references to sysfs_dirent and parent 149 - * @sd: sysfs_dirent of interest 150 - * 151 - * Get active reference to @sd and its parent. Parent's active 152 - * reference is grabbed first. This function is noop if @sd is 153 - * NULL. 154 - * 155 - * RETURNS: 156 - * Pointer to @sd on success, NULL on failure. 157 - */ 158 - struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd) 159 - { 160 - if (sd) { 161 - if (sd->s_parent && unlikely(!sysfs_get_active(sd->s_parent))) 162 - return NULL; 163 - if (unlikely(!sysfs_get_active(sd))) { 164 - sysfs_put_active(sd->s_parent); 165 - return NULL; 166 - } 167 - } 168 - return sd; 169 - } 170 - 171 - /** 172 - * sysfs_put_active_two - put active references to sysfs_dirent and parent 173 - * @sd: sysfs_dirent of interest 174 - * 175 - * Put active references to @sd and its parent. This function is 176 - * noop if @sd is NULL. 177 - */ 178 - void sysfs_put_active_two(struct sysfs_dirent *sd) 179 - { 180 - if (sd) { 181 - sysfs_put_active(sd); 182 - sysfs_put_active(sd->s_parent); 183 - } 184 - } 185 - 186 - /** 187 148 * sysfs_deactivate - deactivate sysfs_dirent 188 149 * @sd: sysfs_dirent to deactivate 189 150 * ··· 156 195 int v; 157 196 158 197 BUG_ON(sd->s_sibling || !(sd->s_flags & SYSFS_FLAG_REMOVED)); 198 + 199 + if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF)) 200 + return; 201 + 159 202 sd->s_sibling = (void *)&wait; 160 203 161 204 rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_); ··· 319 354 320 355 atomic_set(&sd->s_count, 1); 321 356 atomic_set(&sd->s_active, 0); 322 - sysfs_dirent_init_lockdep(sd); 323 357 324 358 sd->s_name = name; 325 359 sd->s_mode = mode; ··· 645 681 } 646 682 647 683 /* attach dentry and inode */ 648 - inode = sysfs_get_inode(sd); 684 + inode = sysfs_get_inode(dir->i_sb, sd); 649 685 if (!inode) { 650 686 ret = ERR_PTR(-ENOMEM); 651 687 goto out_unlock; ··· 801 837 return (sd->s_mode >> 12) & 15; 802 838 } 803 839 840 + static int sysfs_dir_release(struct inode *inode, struct file *filp) 841 + { 842 + sysfs_put(filp->private_data); 843 + return 0; 844 + } 845 + 846 + static struct sysfs_dirent *sysfs_dir_pos(struct sysfs_dirent *parent_sd, 847 + ino_t ino, struct sysfs_dirent *pos) 848 + { 849 + if (pos) { 850 + int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) && 851 + pos->s_parent == parent_sd && 852 + ino == pos->s_ino; 853 + sysfs_put(pos); 854 + if (valid) 855 + return pos; 856 + } 857 + pos = NULL; 858 + if ((ino > 1) && (ino < INT_MAX)) { 859 + pos = parent_sd->s_dir.children; 860 + while (pos && (ino > pos->s_ino)) 861 + pos = pos->s_sibling; 862 + } 863 + return pos; 864 + } 865 + 866 + static struct sysfs_dirent *sysfs_dir_next_pos(struct sysfs_dirent *parent_sd, 867 + ino_t ino, struct sysfs_dirent *pos) 868 + { 869 + pos = sysfs_dir_pos(parent_sd, ino, pos); 870 + if (pos) 871 + pos = pos->s_sibling; 872 + return pos; 873 + } 874 + 804 875 static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) 805 876 { 806 877 struct dentry *dentry = filp->f_path.dentry; 807 878 struct sysfs_dirent * parent_sd = dentry->d_fsdata; 808 - struct sysfs_dirent *pos; 879 + struct sysfs_dirent *pos = filp->private_data; 809 880 ino_t ino; 810 881 811 882 if (filp->f_pos == 0) { ··· 856 857 if (filldir(dirent, "..", 2, filp->f_pos, ino, DT_DIR) == 0) 857 858 filp->f_pos++; 858 859 } 859 - if ((filp->f_pos > 1) && (filp->f_pos < INT_MAX)) { 860 - mutex_lock(&sysfs_mutex); 860 + mutex_lock(&sysfs_mutex); 861 + for (pos = sysfs_dir_pos(parent_sd, filp->f_pos, pos); 862 + pos; 863 + pos = sysfs_dir_next_pos(parent_sd, filp->f_pos, pos)) { 864 + const char * name; 865 + unsigned int type; 866 + int len, ret; 861 867 862 - /* Skip the dentries we have already reported */ 863 - pos = parent_sd->s_dir.children; 864 - while (pos && (filp->f_pos > pos->s_ino)) 865 - pos = pos->s_sibling; 868 + name = pos->s_name; 869 + len = strlen(name); 870 + ino = pos->s_ino; 871 + type = dt_type(pos); 872 + filp->f_pos = ino; 873 + filp->private_data = sysfs_get(pos); 866 874 867 - for ( ; pos; pos = pos->s_sibling) { 868 - const char * name; 869 - int len; 870 - 871 - name = pos->s_name; 872 - len = strlen(name); 873 - filp->f_pos = ino = pos->s_ino; 874 - 875 - if (filldir(dirent, name, len, filp->f_pos, ino, 876 - dt_type(pos)) < 0) 877 - break; 878 - } 879 - if (!pos) 880 - filp->f_pos = INT_MAX; 881 875 mutex_unlock(&sysfs_mutex); 876 + ret = filldir(dirent, name, len, filp->f_pos, ino, type); 877 + mutex_lock(&sysfs_mutex); 878 + if (ret < 0) 879 + break; 880 + } 881 + mutex_unlock(&sysfs_mutex); 882 + if ((filp->f_pos > 1) && !pos) { /* EOF */ 883 + filp->f_pos = INT_MAX; 884 + filp->private_data = NULL; 882 885 } 883 886 return 0; 884 887 } ··· 889 888 const struct file_operations sysfs_dir_operations = { 890 889 .read = generic_read_dir, 891 890 .readdir = sysfs_readdir, 891 + .release = sysfs_dir_release, 892 892 .llseek = generic_file_llseek, 893 893 };
+34 -13
fs/sysfs/file.c
··· 53 53 size_t count; 54 54 loff_t pos; 55 55 char * page; 56 - struct sysfs_ops * ops; 56 + const struct sysfs_ops * ops; 57 57 struct mutex mutex; 58 58 int needs_read_fill; 59 59 int event; ··· 75 75 { 76 76 struct sysfs_dirent *attr_sd = dentry->d_fsdata; 77 77 struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; 78 - struct sysfs_ops * ops = buffer->ops; 78 + const struct sysfs_ops * ops = buffer->ops; 79 79 int ret = 0; 80 80 ssize_t count; 81 81 ··· 85 85 return -ENOMEM; 86 86 87 87 /* need attr_sd for attr and ops, its parent for kobj */ 88 - if (!sysfs_get_active_two(attr_sd)) 88 + if (!sysfs_get_active(attr_sd)) 89 89 return -ENODEV; 90 90 91 91 buffer->event = atomic_read(&attr_sd->s_attr.open->event); 92 92 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page); 93 93 94 - sysfs_put_active_two(attr_sd); 94 + sysfs_put_active(attr_sd); 95 95 96 96 /* 97 97 * The code works fine with PAGE_SIZE return but it's likely to ··· 199 199 { 200 200 struct sysfs_dirent *attr_sd = dentry->d_fsdata; 201 201 struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; 202 - struct sysfs_ops * ops = buffer->ops; 202 + const struct sysfs_ops * ops = buffer->ops; 203 203 int rc; 204 204 205 205 /* need attr_sd for attr and ops, its parent for kobj */ 206 - if (!sysfs_get_active_two(attr_sd)) 206 + if (!sysfs_get_active(attr_sd)) 207 207 return -ENODEV; 208 208 209 209 rc = ops->store(kobj, attr_sd->s_attr.attr, buffer->page, count); 210 210 211 - sysfs_put_active_two(attr_sd); 211 + sysfs_put_active(attr_sd); 212 212 213 213 return rc; 214 214 } ··· 335 335 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 336 336 struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; 337 337 struct sysfs_buffer *buffer; 338 - struct sysfs_ops *ops; 338 + const struct sysfs_ops *ops; 339 339 int error = -EACCES; 340 340 char *p; 341 341 ··· 344 344 memmove(last_sysfs_file, p, strlen(p) + 1); 345 345 346 346 /* need attr_sd for attr and ops, its parent for kobj */ 347 - if (!sysfs_get_active_two(attr_sd)) 347 + if (!sysfs_get_active(attr_sd)) 348 348 return -ENODEV; 349 349 350 350 /* every kobject with an attribute needs a ktype assigned */ ··· 393 393 goto err_free; 394 394 395 395 /* open succeeded, put active references */ 396 - sysfs_put_active_two(attr_sd); 396 + sysfs_put_active(attr_sd); 397 397 return 0; 398 398 399 399 err_free: 400 400 kfree(buffer); 401 401 err_out: 402 - sysfs_put_active_two(attr_sd); 402 + sysfs_put_active(attr_sd); 403 403 return error; 404 404 } 405 405 ··· 437 437 struct sysfs_open_dirent *od = attr_sd->s_attr.open; 438 438 439 439 /* need parent for the kobj, grab both */ 440 - if (!sysfs_get_active_two(attr_sd)) 440 + if (!sysfs_get_active(attr_sd)) 441 441 goto trigger; 442 442 443 443 poll_wait(filp, &od->poll, wait); 444 444 445 - sysfs_put_active_two(attr_sd); 445 + sysfs_put_active(attr_sd); 446 446 447 447 if (buffer->event != atomic_read(&od->event)) 448 448 goto trigger; ··· 509 509 if (!sd) 510 510 return -ENOMEM; 511 511 sd->s_attr.attr = (void *)attr; 512 + sysfs_dirent_init_lockdep(sd); 512 513 513 514 sysfs_addrm_start(&acxt, dir_sd); 514 515 rc = sysfs_add_one(&acxt, sd); ··· 543 542 544 543 } 545 544 545 + int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr) 546 + { 547 + int err = 0; 548 + int i; 549 + 550 + for (i = 0; ptr[i] && !err; i++) 551 + err = sysfs_create_file(kobj, ptr[i]); 552 + if (err) 553 + while (--i >= 0) 554 + sysfs_remove_file(kobj, ptr[i]); 555 + return err; 556 + } 546 557 547 558 /** 548 559 * sysfs_add_file_to_group - add an attribute file to a pre-existing group. ··· 627 614 sysfs_hash_and_remove(kobj->sd, attr->name); 628 615 } 629 616 617 + void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) 618 + { 619 + int i; 620 + for (i = 0; ptr[i]; i++) 621 + sysfs_remove_file(kobj, ptr[i]); 622 + } 630 623 631 624 /** 632 625 * sysfs_remove_file_from_group - remove an attribute file from a group. ··· 751 732 752 733 EXPORT_SYMBOL_GPL(sysfs_create_file); 753 734 EXPORT_SYMBOL_GPL(sysfs_remove_file); 735 + EXPORT_SYMBOL_GPL(sysfs_remove_files); 736 + EXPORT_SYMBOL_GPL(sysfs_create_files);
+7 -6
fs/sysfs/inode.c
··· 111 111 if (!sd) 112 112 return -EINVAL; 113 113 114 + mutex_lock(&sysfs_mutex); 114 115 error = inode_change_ok(inode, iattr); 115 116 if (error) 116 - return error; 117 + goto out; 117 118 118 119 iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */ 119 120 120 121 error = inode_setattr(inode, iattr); 121 122 if (error) 122 - return error; 123 + goto out; 123 124 124 - mutex_lock(&sysfs_mutex); 125 125 error = sysfs_sd_setattr(sd, iattr); 126 + out: 126 127 mutex_unlock(&sysfs_mutex); 127 - 128 128 return error; 129 129 } 130 130 ··· 283 283 284 284 /** 285 285 * sysfs_get_inode - get inode for sysfs_dirent 286 + * @sb: super block 286 287 * @sd: sysfs_dirent to allocate inode for 287 288 * 288 289 * Get inode for @sd. If such inode doesn't exist, a new inode ··· 296 295 * RETURNS: 297 296 * Pointer to allocated inode on success, NULL on failure. 298 297 */ 299 - struct inode * sysfs_get_inode(struct sysfs_dirent *sd) 298 + struct inode * sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd) 300 299 { 301 300 struct inode *inode; 302 301 303 - inode = iget_locked(sysfs_sb, sd->s_ino); 302 + inode = iget_locked(sb, sd->s_ino); 304 303 if (inode && (inode->i_state & I_NEW)) 305 304 sysfs_init_inode(sd, inode); 306 305
+1 -3
fs/sysfs/mount.c
··· 23 23 24 24 25 25 static struct vfsmount *sysfs_mount; 26 - struct super_block * sysfs_sb = NULL; 27 26 struct kmem_cache *sysfs_dir_cachep; 28 27 29 28 static const struct super_operations sysfs_ops = { ··· 49 50 sb->s_magic = SYSFS_MAGIC; 50 51 sb->s_op = &sysfs_ops; 51 52 sb->s_time_gran = 1; 52 - sysfs_sb = sb; 53 53 54 54 /* get root inode, initialize and unlock it */ 55 55 mutex_lock(&sysfs_mutex); 56 - inode = sysfs_get_inode(&sysfs_root); 56 + inode = sysfs_get_inode(sb, &sysfs_root); 57 57 mutex_unlock(&sysfs_mutex); 58 58 if (!inode) { 59 59 pr_debug("sysfs: could not get root inode\n");
+38
fs/sysfs/symlink.c
··· 123 123 sysfs_hash_and_remove(parent_sd, name); 124 124 } 125 125 126 + /** 127 + * sysfs_rename_link - rename symlink in object's directory. 128 + * @kobj: object we're acting for. 129 + * @targ: object we're pointing to. 130 + * @old: previous name of the symlink. 131 + * @new: new name of the symlink. 132 + * 133 + * A helper function for the common rename symlink idiom. 134 + */ 135 + int sysfs_rename_link(struct kobject *kobj, struct kobject *targ, 136 + const char *old, const char *new) 137 + { 138 + struct sysfs_dirent *parent_sd, *sd = NULL; 139 + int result; 140 + 141 + if (!kobj) 142 + parent_sd = &sysfs_root; 143 + else 144 + parent_sd = kobj->sd; 145 + 146 + result = -ENOENT; 147 + sd = sysfs_get_dirent(parent_sd, old); 148 + if (!sd) 149 + goto out; 150 + 151 + result = -EINVAL; 152 + if (sysfs_type(sd) != SYSFS_KOBJ_LINK) 153 + goto out; 154 + if (sd->s_symlink.target_sd->s_dir.kobj != targ) 155 + goto out; 156 + 157 + result = sysfs_rename(sd, parent_sd, new); 158 + 159 + out: 160 + sysfs_put(sd); 161 + return result; 162 + } 163 + 126 164 static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, 127 165 struct sysfs_dirent *target_sd, char *path) 128 166 {
+10 -7
fs/sysfs/sysfs.h
··· 66 66 }; 67 67 68 68 unsigned int s_flags; 69 + unsigned short s_mode; 69 70 ino_t s_ino; 70 - umode_t s_mode; 71 71 struct sysfs_inode_attrs *s_iattr; 72 72 }; 73 73 ··· 79 79 #define SYSFS_KOBJ_BIN_ATTR 0x0004 80 80 #define SYSFS_KOBJ_LINK 0x0008 81 81 #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) 82 + #define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) 82 83 83 84 #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK 84 85 #define SYSFS_FLAG_REMOVED 0x0200 ··· 92 91 #ifdef CONFIG_DEBUG_LOCK_ALLOC 93 92 #define sysfs_dirent_init_lockdep(sd) \ 94 93 do { \ 95 - static struct lock_class_key __key; \ 94 + struct attribute *attr = sd->s_attr.attr; \ 95 + struct lock_class_key *key = attr->key; \ 96 + if (!key) \ 97 + key = &attr->skey; \ 96 98 \ 97 - lockdep_init_map(&sd->dep_map, "s_active", &__key, 0); \ 99 + lockdep_init_map(&sd->dep_map, "s_active", key, 0); \ 98 100 } while(0) 99 101 #else 100 102 #define sysfs_dirent_init_lockdep(sd) do {} while(0) ··· 115 111 * mount.c 116 112 */ 117 113 extern struct sysfs_dirent sysfs_root; 118 - extern struct super_block *sysfs_sb; 119 114 extern struct kmem_cache *sysfs_dir_cachep; 120 115 121 116 /* ··· 127 124 extern const struct inode_operations sysfs_dir_inode_operations; 128 125 129 126 struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd); 130 - struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd); 131 - void sysfs_put_active_two(struct sysfs_dirent *sd); 127 + struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); 128 + void sysfs_put_active(struct sysfs_dirent *sd); 132 129 void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, 133 130 struct sysfs_dirent *parent_sd); 134 131 int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); ··· 171 168 /* 172 169 * inode.c 173 170 */ 174 - struct inode *sysfs_get_inode(struct sysfs_dirent *sd); 171 + struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd); 175 172 void sysfs_delete_inode(struct inode *inode); 176 173 int sysfs_sd_setattr(struct sysfs_dirent *sd, struct iattr *iattr); 177 174 int sysfs_permission(struct inode *inode, int mask);
+37 -3
include/linux/device.h
··· 106 106 107 107 /* All 4 notifers below get called with the target struct device * 108 108 * as an argument. Note that those functions are likely to be called 109 - * with the device semaphore held in the core, so be careful. 109 + * with the device lock held in the core, so be careful. 110 110 */ 111 111 #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ 112 112 #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ ··· 251 251 252 252 struct class_attribute { 253 253 struct attribute attr; 254 - ssize_t (*show)(struct class *class, char *buf); 255 - ssize_t (*store)(struct class *class, const char *buf, size_t count); 254 + ssize_t (*show)(struct class *class, struct class_attribute *attr, 255 + char *buf); 256 + ssize_t (*store)(struct class *class, struct class_attribute *attr, 257 + const char *buf, size_t count); 256 258 }; 257 259 258 260 #define CLASS_ATTR(_name, _mode, _show, _store) \ ··· 264 262 const struct class_attribute *attr); 265 263 extern void class_remove_file(struct class *class, 266 264 const struct class_attribute *attr); 265 + 266 + /* Simple class attribute that is just a static string */ 267 + 268 + struct class_attribute_string { 269 + struct class_attribute attr; 270 + char *str; 271 + }; 272 + 273 + /* Currently read-only only */ 274 + #define _CLASS_ATTR_STRING(_name, _mode, _str) \ 275 + { __ATTR(_name, _mode, show_class_attr_string, NULL), _str } 276 + #define CLASS_ATTR_STRING(_name, _mode, _str) \ 277 + struct class_attribute_string class_attr_##_name = \ 278 + _CLASS_ATTR_STRING(_name, _mode, _str) 279 + 280 + extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, 281 + char *buf); 267 282 268 283 struct class_interface { 269 284 struct list_head node; ··· 506 487 static inline bool device_async_suspend_enabled(struct device *dev) 507 488 { 508 489 return !!dev->power.async_suspend; 490 + } 491 + 492 + static inline void device_lock(struct device *dev) 493 + { 494 + down(&dev->sem); 495 + } 496 + 497 + static inline int device_trylock(struct device *dev) 498 + { 499 + return down_trylock(&dev->sem); 500 + } 501 + 502 + static inline void device_unlock(struct device *dev) 503 + { 504 + up(&dev->sem); 509 505 } 510 506 511 507 void driver_init(void);
+7 -7
include/linux/kobject.h
··· 106 106 107 107 struct kobj_type { 108 108 void (*release)(struct kobject *kobj); 109 - struct sysfs_ops *sysfs_ops; 109 + const struct sysfs_ops *sysfs_ops; 110 110 struct attribute **default_attrs; 111 111 }; 112 112 ··· 118 118 }; 119 119 120 120 struct kset_uevent_ops { 121 - int (*filter)(struct kset *kset, struct kobject *kobj); 122 - const char *(*name)(struct kset *kset, struct kobject *kobj); 123 - int (*uevent)(struct kset *kset, struct kobject *kobj, 121 + int (* const filter)(struct kset *kset, struct kobject *kobj); 122 + const char *(* const name)(struct kset *kset, struct kobject *kobj); 123 + int (* const uevent)(struct kset *kset, struct kobject *kobj, 124 124 struct kobj_uevent_env *env); 125 125 }; 126 126 ··· 132 132 const char *buf, size_t count); 133 133 }; 134 134 135 - extern struct sysfs_ops kobj_sysfs_ops; 135 + extern const struct sysfs_ops kobj_sysfs_ops; 136 136 137 137 /** 138 138 * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. ··· 155 155 struct list_head list; 156 156 spinlock_t list_lock; 157 157 struct kobject kobj; 158 - struct kset_uevent_ops *uevent_ops; 158 + const struct kset_uevent_ops *uevent_ops; 159 159 }; 160 160 161 161 extern void kset_init(struct kset *kset); 162 162 extern int __must_check kset_register(struct kset *kset); 163 163 extern void kset_unregister(struct kset *kset); 164 164 extern struct kset * __must_check kset_create_and_add(const char *name, 165 - struct kset_uevent_ops *u, 165 + const struct kset_uevent_ops *u, 166 166 struct kobject *parent_kobj); 167 167 168 168 static inline struct kset *to_kset(struct kobject *kobj)
+7 -2
include/linux/platform_device.h
··· 21 21 u32 num_resources; 22 22 struct resource * resource; 23 23 24 - struct platform_device_id *id_entry; 24 + const struct platform_device_id *id_entry; 25 25 26 26 /* arch specific additions */ 27 27 struct pdev_archdata archdata; ··· 62 62 int (*suspend)(struct platform_device *, pm_message_t state); 63 63 int (*resume)(struct platform_device *); 64 64 struct device_driver driver; 65 - struct platform_device_id *id_table; 65 + const struct platform_device_id *id_table; 66 66 }; 67 67 68 68 extern int platform_driver_register(struct platform_driver *); ··· 76 76 77 77 #define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) 78 78 #define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) 79 + 80 + extern struct platform_device *platform_create_bundle(struct platform_driver *driver, 81 + int (*probe)(struct platform_device *), 82 + struct resource *res, unsigned int n_res, 83 + const void *data, size_t size); 79 84 80 85 /* early platform driver interface */ 81 86 struct early_platform_driver {
+19 -2
include/linux/sysdev.h
··· 27 27 28 28 29 29 struct sys_device; 30 + struct sysdev_class_attribute; 30 31 31 32 struct sysdev_class { 32 33 const char *name; 33 34 struct list_head drivers; 35 + struct sysdev_class_attribute **attrs; 34 36 35 37 /* Default operations for these types of devices */ 36 38 int (*shutdown)(struct sys_device *); ··· 43 41 44 42 struct sysdev_class_attribute { 45 43 struct attribute attr; 46 - ssize_t (*show)(struct sysdev_class *, char *); 47 - ssize_t (*store)(struct sysdev_class *, const char *, size_t); 44 + ssize_t (*show)(struct sysdev_class *, struct sysdev_class_attribute *, 45 + char *); 46 + ssize_t (*store)(struct sysdev_class *, struct sysdev_class_attribute *, 47 + const char *, size_t); 48 48 }; 49 49 50 50 #define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \ ··· 122 118 123 119 extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); 124 120 extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); 121 + 122 + /* Create/remove NULL terminated attribute list */ 123 + static inline int 124 + sysdev_create_files(struct sys_device *d, struct sysdev_attribute **a) 125 + { 126 + return sysfs_create_files(&d->kobj, (const struct attribute **)a); 127 + } 128 + 129 + static inline void 130 + sysdev_remove_files(struct sys_device *d, struct sysdev_attribute **a) 131 + { 132 + return sysfs_remove_files(&d->kobj, (const struct attribute **)a); 133 + } 125 134 126 135 struct sysdev_ext_attribute { 127 136 struct sysdev_attribute attr;
+61
include/linux/sysfs.h
··· 15 15 #include <linux/compiler.h> 16 16 #include <linux/errno.h> 17 17 #include <linux/list.h> 18 + #include <linux/lockdep.h> 18 19 #include <asm/atomic.h> 19 20 20 21 struct kobject; ··· 30 29 const char *name; 31 30 struct module *owner; 32 31 mode_t mode; 32 + #ifdef CONFIG_DEBUG_LOCK_ALLOC 33 + struct lock_class_key *key; 34 + struct lock_class_key skey; 35 + #endif 33 36 }; 37 + 38 + /** 39 + * sysfs_attr_init - initialize a dynamically allocated sysfs attribute 40 + * @attr: struct attribute to initialize 41 + * 42 + * Initialize a dynamically allocated struct attribute so we can 43 + * make lockdep happy. This is a new requirement for attributes 44 + * and initially this is only needed when lockdep is enabled. 45 + * Lockdep gives a nice error when your attribute is added to 46 + * sysfs if you don't have this. 47 + */ 48 + #ifdef CONFIG_DEBUG_LOCK_ALLOC 49 + #define sysfs_attr_init(attr) \ 50 + do { \ 51 + static struct lock_class_key __key; \ 52 + \ 53 + (attr)->key = &__key; \ 54 + } while(0) 55 + #else 56 + #define sysfs_attr_init(attr) do {} while(0) 57 + #endif 34 58 35 59 struct attribute_group { 36 60 const char *name; ··· 100 74 struct vm_area_struct *vma); 101 75 }; 102 76 77 + /** 78 + * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute 79 + * @attr: struct bin_attribute to initialize 80 + * 81 + * Initialize a dynamically allocated struct bin_attribute so we 82 + * can make lockdep happy. This is a new requirement for 83 + * attributes and initially this is only needed when lockdep is 84 + * enabled. Lockdep gives a nice error when your attribute is 85 + * added to sysfs if you don't have this. 86 + */ 87 + #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) 88 + 103 89 struct sysfs_ops { 104 90 ssize_t (*show)(struct kobject *, struct attribute *,char *); 105 91 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); ··· 132 94 133 95 int __must_check sysfs_create_file(struct kobject *kobj, 134 96 const struct attribute *attr); 97 + int __must_check sysfs_create_files(struct kobject *kobj, 98 + const struct attribute **attr); 135 99 int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, 136 100 mode_t mode); 137 101 void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); 102 + void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); 138 103 139 104 int __must_check sysfs_create_bin_file(struct kobject *kobj, 140 105 const struct bin_attribute *attr); ··· 150 109 struct kobject *target, 151 110 const char *name); 152 111 void sysfs_remove_link(struct kobject *kobj, const char *name); 112 + 113 + int sysfs_rename_link(struct kobject *kobj, struct kobject *target, 114 + const char *old_name, const char *new_name); 153 115 154 116 int __must_check sysfs_create_group(struct kobject *kobj, 155 117 const struct attribute_group *grp); ··· 208 164 return 0; 209 165 } 210 166 167 + static inline int sysfs_create_files(struct kobject *kobj, 168 + const struct attribute **attr) 169 + { 170 + return 0; 171 + } 172 + 211 173 static inline int sysfs_chmod_file(struct kobject *kobj, 212 174 struct attribute *attr, mode_t mode) 213 175 { ··· 222 172 223 173 static inline void sysfs_remove_file(struct kobject *kobj, 224 174 const struct attribute *attr) 175 + { 176 + } 177 + 178 + static inline void sysfs_remove_files(struct kobject *kobj, 179 + const struct attribute **attr) 225 180 { 226 181 } 227 182 ··· 256 201 257 202 static inline void sysfs_remove_link(struct kobject *kobj, const char *name) 258 203 { 204 + } 205 + 206 + static inline int sysfs_rename_link(struct kobject *k, struct kobject *t, 207 + const char *old_name, const char *new_name) 208 + { 209 + return 0; 259 210 } 260 211 261 212 static inline int sysfs_create_group(struct kobject *kobj,
+3 -3
include/linux/usb.h
··· 512 512 extern void usb_put_dev(struct usb_device *dev); 513 513 514 514 /* USB device locking */ 515 - #define usb_lock_device(udev) down(&(udev)->dev.sem) 516 - #define usb_unlock_device(udev) up(&(udev)->dev.sem) 517 - #define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) 515 + #define usb_lock_device(udev) device_lock(&(udev)->dev) 516 + #define usb_unlock_device(udev) device_unlock(&(udev)->dev) 517 + #define usb_trylock_device(udev) device_trylock(&(udev)->dev) 518 518 extern int usb_lock_device_for_reset(struct usb_device *udev, 519 519 const struct usb_interface *iface); 520 520
+3
kernel/module.c
··· 1085 1085 if (sattr->name == NULL) 1086 1086 goto out; 1087 1087 sect_attrs->nsections++; 1088 + sysfs_attr_init(&sattr->mattr.attr); 1088 1089 sattr->mattr.show = module_sect_show; 1089 1090 sattr->mattr.store = NULL; 1090 1091 sattr->mattr.attr.name = sattr->name; ··· 1181 1180 if (sect_empty(&sechdrs[i])) 1182 1181 continue; 1183 1182 if (sechdrs[i].sh_type == SHT_NOTE) { 1183 + sysfs_bin_attr_init(nattr); 1184 1184 nattr->attr.name = mod->sect_attrs->attrs[loaded].name; 1185 1185 nattr->attr.mode = S_IRUGO; 1186 1186 nattr->size = sechdrs[i].sh_size; ··· 1254 1252 if (!attr->test || 1255 1253 (attr->test && attr->test(mod))) { 1256 1254 memcpy(temp_attr, attr, sizeof(*temp_attr)); 1255 + sysfs_attr_init(&temp_attr->attr); 1257 1256 error = sysfs_create_file(&mod->mkobj.kobj,&temp_attr->attr); 1258 1257 ++temp_attr; 1259 1258 }
+3 -2
kernel/params.c
··· 516 516 new->grp.attrs = attrs; 517 517 518 518 /* Tack new one on the end. */ 519 + sysfs_attr_init(&new->attrs[num].mattr.attr); 519 520 new->attrs[num].param = kp; 520 521 new->attrs[num].mattr.show = param_attr_show; 521 522 new->attrs[num].mattr.store = param_attr_store; ··· 723 722 return ret; 724 723 } 725 724 726 - static struct sysfs_ops module_sysfs_ops = { 725 + static const struct sysfs_ops module_sysfs_ops = { 727 726 .show = module_attr_show, 728 727 .store = module_attr_store, 729 728 }; ··· 737 736 return 0; 738 737 } 739 738 740 - static struct kset_uevent_ops module_uevent_ops = { 739 + static const struct kset_uevent_ops module_uevent_ops = { 741 740 .filter = uevent_filter, 742 741 }; 743 742
+10 -3
kernel/perf_event.c
··· 5481 5481 register_cpu_notifier(&perf_cpu_nb); 5482 5482 } 5483 5483 5484 - static ssize_t perf_show_reserve_percpu(struct sysdev_class *class, char *buf) 5484 + static ssize_t perf_show_reserve_percpu(struct sysdev_class *class, 5485 + struct sysdev_class_attribute *attr, 5486 + char *buf) 5485 5487 { 5486 5488 return sprintf(buf, "%d\n", perf_reserved_percpu); 5487 5489 } 5488 5490 5489 5491 static ssize_t 5490 5492 perf_set_reserve_percpu(struct sysdev_class *class, 5493 + struct sysdev_class_attribute *attr, 5491 5494 const char *buf, 5492 5495 size_t count) 5493 5496 { ··· 5519 5516 return count; 5520 5517 } 5521 5518 5522 - static ssize_t perf_show_overcommit(struct sysdev_class *class, char *buf) 5519 + static ssize_t perf_show_overcommit(struct sysdev_class *class, 5520 + struct sysdev_class_attribute *attr, 5521 + char *buf) 5523 5522 { 5524 5523 return sprintf(buf, "%d\n", perf_overcommit); 5525 5524 } 5526 5525 5527 5526 static ssize_t 5528 - perf_set_overcommit(struct sysdev_class *class, const char *buf, size_t count) 5527 + perf_set_overcommit(struct sysdev_class *class, 5528 + struct sysdev_class_attribute *attr, 5529 + const char *buf, size_t count) 5529 5530 { 5530 5531 unsigned long val; 5531 5532 int err;
+4
kernel/sched.c
··· 7406 7406 7407 7407 #ifdef CONFIG_SCHED_MC 7408 7408 static ssize_t sched_mc_power_savings_show(struct sysdev_class *class, 7409 + struct sysdev_class_attribute *attr, 7409 7410 char *page) 7410 7411 { 7411 7412 return sprintf(page, "%u\n", sched_mc_power_savings); 7412 7413 } 7413 7414 static ssize_t sched_mc_power_savings_store(struct sysdev_class *class, 7415 + struct sysdev_class_attribute *attr, 7414 7416 const char *buf, size_t count) 7415 7417 { 7416 7418 return sched_power_savings_store(buf, count, 0); ··· 7424 7422 7425 7423 #ifdef CONFIG_SCHED_SMT 7426 7424 static ssize_t sched_smt_power_savings_show(struct sysdev_class *dev, 7425 + struct sysdev_class_attribute *attr, 7427 7426 char *page) 7428 7427 { 7429 7428 return sprintf(page, "%u\n", sched_smt_power_savings); 7430 7429 } 7431 7430 static ssize_t sched_smt_power_savings_store(struct sysdev_class *dev, 7431 + struct sysdev_class_attribute *attr, 7432 7432 const char *buf, size_t count) 7433 7433 { 7434 7434 return sched_power_savings_store(buf, count, 1);
+3 -3
lib/kobject.c
··· 700 700 return ret; 701 701 } 702 702 703 - struct sysfs_ops kobj_sysfs_ops = { 703 + const struct sysfs_ops kobj_sysfs_ops = { 704 704 .show = kobj_attr_show, 705 705 .store = kobj_attr_store, 706 706 }; ··· 789 789 * If the kset was not able to be created, NULL will be returned. 790 790 */ 791 791 static struct kset *kset_create(const char *name, 792 - struct kset_uevent_ops *uevent_ops, 792 + const struct kset_uevent_ops *uevent_ops, 793 793 struct kobject *parent_kobj) 794 794 { 795 795 struct kset *kset; ··· 832 832 * If the kset was not able to be created, NULL will be returned. 833 833 */ 834 834 struct kset *kset_create_and_add(const char *name, 835 - struct kset_uevent_ops *uevent_ops, 835 + const struct kset_uevent_ops *uevent_ops, 836 836 struct kobject *parent_kobj) 837 837 { 838 838 struct kset *kset;
+1 -1
lib/kobject_uevent.c
··· 95 95 const char *subsystem; 96 96 struct kobject *top_kobj; 97 97 struct kset *kset; 98 - struct kset_uevent_ops *uevent_ops; 98 + const struct kset_uevent_ops *uevent_ops; 99 99 u64 seq; 100 100 int i = 0; 101 101 int retval = 0;
+2 -2
mm/slub.c
··· 4390 4390 kfree(s); 4391 4391 } 4392 4392 4393 - static struct sysfs_ops slab_sysfs_ops = { 4393 + static const struct sysfs_ops slab_sysfs_ops = { 4394 4394 .show = slab_attr_show, 4395 4395 .store = slab_attr_store, 4396 4396 }; ··· 4409 4409 return 0; 4410 4410 } 4411 4411 4412 - static struct kset_uevent_ops slab_uevent_ops = { 4412 + static const struct kset_uevent_ops slab_uevent_ops = { 4413 4413 .filter = uevent_filter, 4414 4414 }; 4415 4415
+3 -1
net/bluetooth/l2cap.c
··· 3937 3937 return 0; 3938 3938 } 3939 3939 3940 - static ssize_t l2cap_sysfs_show(struct class *dev, char *buf) 3940 + static ssize_t l2cap_sysfs_show(struct class *dev, 3941 + struct class_attribute *attr, 3942 + char *buf) 3941 3943 { 3942 3944 struct sock *sk; 3943 3945 struct hlist_node *node;
+3 -1
net/bluetooth/rfcomm/core.c
··· 2098 2098 .security_cfm = rfcomm_security_cfm 2099 2099 }; 2100 2100 2101 - static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf) 2101 + static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, 2102 + struct class_attribute *attr, 2103 + char *buf) 2102 2104 { 2103 2105 struct rfcomm_session *s; 2104 2106 struct list_head *pp, *p;
+3 -1
net/bluetooth/rfcomm/sock.c
··· 1061 1061 return result; 1062 1062 } 1063 1063 1064 - static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf) 1064 + static ssize_t rfcomm_sock_sysfs_show(struct class *dev, 1065 + struct class_attribute *attr, 1066 + char *buf) 1065 1067 { 1066 1068 struct sock *sk; 1067 1069 struct hlist_node *node;
+3 -1
net/bluetooth/sco.c
··· 953 953 return 0; 954 954 } 955 955 956 - static ssize_t sco_sysfs_show(struct class *dev, char *buf) 956 + static ssize_t sco_sysfs_show(struct class *dev, 957 + struct class_attribute *attr, 958 + char *buf) 957 959 { 958 960 struct sock *sk; 959 961 struct hlist_node *node;
+1 -1
net/bridge/br_private.h
··· 423 423 424 424 #ifdef CONFIG_SYSFS 425 425 /* br_sysfs_if.c */ 426 - extern struct sysfs_ops brport_sysfs_ops; 426 + extern const struct sysfs_ops brport_sysfs_ops; 427 427 extern int br_sysfs_addif(struct net_bridge_port *p); 428 428 429 429 /* br_sysfs_br.c */
+1 -1
net/bridge/br_sysfs_if.c
··· 238 238 return ret; 239 239 } 240 240 241 - struct sysfs_ops brport_sysfs_ops = { 241 + const struct sysfs_ops brport_sysfs_ops = { 242 242 .show = brport_show, 243 243 .store = brport_store, 244 244 };
+2 -2
samples/kobject/kobject-example.c
··· 44 44 __ATTR(foo, 0666, foo_show, foo_store); 45 45 46 46 /* 47 - * More complex function where we determine which varible is being accessed by 47 + * More complex function where we determine which variable is being accessed by 48 48 * looking at the attribute for the "baz" and "bar" files. 49 49 */ 50 50 static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr, ··· 79 79 80 80 81 81 /* 82 - * Create a group of attributes so that we can create and destory them all 82 + * Create a group of attributes so that we can create and destroy them all 83 83 * at once. 84 84 */ 85 85 static struct attribute *attrs[] = {
+3 -3
samples/kobject/kset-example.c
··· 87 87 } 88 88 89 89 /* Our custom sysfs_ops that we will associate with our ktype later on */ 90 - static struct sysfs_ops foo_sysfs_ops = { 90 + static const struct sysfs_ops foo_sysfs_ops = { 91 91 .show = foo_attr_show, 92 92 .store = foo_attr_store, 93 93 }; ··· 127 127 __ATTR(foo, 0666, foo_show, foo_store); 128 128 129 129 /* 130 - * More complex function where we determine which varible is being accessed by 130 + * More complex function where we determine which variable is being accessed by 131 131 * looking at the attribute for the "baz" and "bar" files. 132 132 */ 133 133 static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr, ··· 161 161 __ATTR(bar, 0666, b_show, b_store); 162 162 163 163 /* 164 - * Create a group of attributes so that we can create and destory them all 164 + * Create a group of attributes so that we can create and destroy them all 165 165 * at once. 166 166 */ 167 167 static struct attribute *foo_default_attrs[] = {