summaryrefslogtreecommitdiffstats
path: root/Documentation
AgeCommit message (Expand)Author
2018-08-30Merge tag 'for-linus-20180830' of git://git.kernel.dk/linux-blockLinus Torvalds
2018-08-30vfs: add the fadvise() file operationAmir Goldstein
2018-08-30Documentation/filesystems: update documentation of file_operationsAmir Goldstein
2018-08-29ethtool: drop get_settings and set_settings callbacksMichal Kubecek
2018-08-29Merge tag 'riscv-for-linus-4.19-rc2' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds
2018-08-29sh_eth: Add R7S9210 supportChris Brandt
2018-08-29dt-bindings: watchdog: renesas-wdt: Document r8a774a1 supportFabrizio Castro
2018-08-29media: video_function_calls.rst: drop obsolete video-set-attributes referenceHans Verkuil
2018-08-29Documentation/arm64/sve: Couple of improvements and typosJulien Grall
2018-08-29xfrm: allow driver to quietly refuse offloadShannon Nelson
2018-08-28xen: export device state to sysfsJoe Jin
2018-08-28dt-bindings: riscv,cpu-intc: Cleanups from a missed reviewPalmer Dabbelt
2018-08-27Merge branch 'stable/for-jens-4.19' of git://git.kernel.org/pub/scm/linux/ker...Jens Axboe
2018-08-27scsi: documentation: add scsi_mod.use_blk_mq to scsi-parametersJohn Pittman
2018-08-27xen/blkback: don't keep persistent grants too longJuergen Gross
2018-08-26hwmon: (ina2xx) fix sysfs shunt resistor read accessLothar Felten
2018-08-26Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ker...Linus Torvalds
2018-08-25Merge tag 'armsoc-late' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/...Linus Torvalds
2018-08-25Merge tag 'kbuild-v4.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/m...Linus Torvalds
2018-08-24Merge branch 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/l...Linus Torvalds
2018-08-24Merge tag 'iommu-updates-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/...Linus Torvalds
2018-08-24Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/l...Linus Torvalds
2018-08-24arm64: dts: Fix various entry-method properties to reflect documentationAmit Kucheria
2018-08-24Merge tag 'reset-for-4.19-2' of git://git.pengutronix.de/git/pza/linux into n...Olof Johansson
2018-08-24Merge tag 'irqchip-4.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/m...Thomas Gleixner
2018-08-24i2c: ocores: update my email addressPeter Korsgaard
2018-08-23Merge branch 'akpm' (patches from Andrew)Linus Torvalds
2018-08-23treewide: convert ISO_8859-1 text comments to utf-8Arnd Bergmann
2018-08-23docs/core-api: mm-api: add section about GFP flagsMike Rapoport
2018-08-23docs/core-api: split memory management API to a separate fileMike Rapoport
2018-08-23docs/core-api: move *{str,mem}dup* to "String Manipulation"Mike Rapoport
2018-08-23docs/core-api: kill trailing whitespace in kernel-api.rstMike Rapoport
2018-08-23treewide: correct "differenciate" and "instanciate" typosFinn Thain
2018-08-23namei: allow restricted O_CREAT of FIFOs and regular filesSalvatore Mesoraca
2018-08-23Merge tag 'pwm/for-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...Linus Torvalds
2018-08-23Merge tag 'fbdev-v4.19' of https://github.com/bzolnier/linuxLinus Torvalds
2018-08-23Merge tag 'armsoc-dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/ar...Linus Torvalds
2018-08-23Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/a...Linus Torvalds
2018-08-22Merge tag 'platform-drivers-x86-v4.19-1' of git://git.infradead.org/linux-pla...Linus Torvalds
2018-08-22Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvmLinus Torvalds
2018-08-22Merge tag 'f2fs-for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ja...Linus Torvalds
2018-08-22Merge branch 'akpm' (patches from Andrew)Linus Torvalds
2018-08-22ipc: reorganize initialization of kern_ipc_perm.seqManfred Spraul
2018-08-22kernel/hung_task.c: allow to set checking interval separately from timeoutDmitry Vyukov
2018-08-22/proc/meminfo: add percpu populated pages countDennis Zhou (Facebook)
2018-08-22mm, oom: introduce memory.oom.groupRoman Gushchin
2018-08-22Documentation/sysctl/vm.txt: update __vm_enough_memory()'s pathjuviliu
2018-08-22mm: clarify CONFIG_PAGE_POISONING and usageKees Cook
2018-08-22ata: libahci_platform: add reset control supportKunihiko Hayashi
2018-08-22initramfs: move gen_initramfs_list.sh from scripts/ to usr/Masahiro Yamada
n389'>389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870
/*
 * file for managing the edac_device subsystem of devices for EDAC
 *
 * (C) 2007 SoftwareBitMaker
 *
 * This file may be distributed under the terms of the
 * GNU General Public License.
 *
 * Written Doug Thompson <norsk5@xmission.com>
 *
 */

#include <linux/ctype.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/edac.h>

#include "edac_device.h"
#include "edac_module.h"

#define EDAC_DEVICE_SYMLINK	"device"

#define to_edacdev(k) container_of(k, struct edac_device_ctl_info, kobj)
#define to_edacdev_attr(a) container_of(a, struct edacdev_attribute, attr)


/*
 * Set of edac_device_ctl_info attribute store/show functions
 */

/* 'log_ue' */
static ssize_t edac_device_ctl_log_ue_show(struct edac_device_ctl_info
					*ctl_info, char *data)
{
	return sprintf(data, "%u\n", ctl_info->log_ue);
}

static ssize_t edac_device_ctl_log_ue_store(struct edac_device_ctl_info
					*ctl_info, const char *data,
					size_t count)
{
	/* if parameter is zero, turn off flag, if non-zero turn on flag */
	ctl_info->log_ue = (simple_strtoul(data, NULL, 0) != 0);

	return count;
}

/* 'log_ce' */
static ssize_t edac_device_ctl_log_ce_show(struct edac_device_ctl_info
					*ctl_info, char *data)
{
	return sprintf(data, "%u\n", ctl_info->log_ce);
}

static ssize_t edac_device_ctl_log_ce_store(struct edac_device_ctl_info
					*ctl_info, const char *data,
					size_t count)
{
	/* if parameter is zero, turn off flag, if non-zero turn on flag */
	ctl_info->log_ce = (simple_strtoul(data, NULL, 0) != 0);

	return count;
}

/* 'panic_on_ue' */
static ssize_t edac_device_ctl_panic_on_ue_show(struct edac_device_ctl_info
						*ctl_info, char *data)
{
	return sprintf(data, "%u\n", ctl_info->panic_on_ue);
}

static ssize_t edac_device_ctl_panic_on_ue_store(struct edac_device_ctl_info
						 *ctl_info, const char *data,
						 size_t count)
{
	/* if parameter is zero, turn off flag, if non-zero turn on flag */
	ctl_info->panic_on_ue = (simple_strtoul(data, NULL, 0) != 0);

	return count;
}

/* 'poll_msec' show and store functions*/
static ssize_t edac_device_ctl_poll_msec_show(struct edac_device_ctl_info
					*ctl_info, char *data)
{
	return sprintf(data, "%u\n", ctl_info->poll_msec);
}

static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
					*ctl_info, const char *data,
					size_t count)
{
	unsigned long value;

	/* get the value and enforce that it is non-zero, must be at least
	 * one millisecond for the delay period, between scans
	 * Then cancel last outstanding delay for the work request
	 * and set a new one.
	 */
	value = simple_strtoul(data, NULL, 0);
	edac_device_reset_delay_period(ctl_info, value);

	return count;
}

/* edac_device_ctl_info specific attribute structure */
struct ctl_info_attribute {
	struct attribute attr;
	ssize_t(*show) (struct edac_device_ctl_info *, char *);
	ssize_t(*store) (struct edac_device_ctl_info *, const char *, size_t);
};

#define to_ctl_info(k) container_of(k, struct edac_device_ctl_info, kobj)
#define to_ctl_info_attr(a) container_of(a,struct ctl_info_attribute,attr)

/* Function to 'show' fields from the edac_dev 'ctl_info' structure */
static ssize_t edac_dev_ctl_info_show(struct kobject *kobj,
				struct attribute *attr, char *buffer)
{
	struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj);
	struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);

	if (ctl_info_attr->show)
		return ctl_info_attr->show(edac_dev, buffer);
	return -EIO;
}

/* Function to 'store' fields into the edac_dev 'ctl_info' structure */
static ssize_t edac_dev_ctl_info_store(struct kobject *kobj,
				struct attribute *attr,
				const char *buffer, size_t count)
{
	struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj);
	struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);

	if (ctl_info_attr->store)
		return ctl_info_attr->store(edac_dev, buffer, count);
	return -EIO;
}

/* edac_dev file operations for an 'ctl_info' */
static const struct sysfs_ops device_ctl_info_ops = {
	.show = edac_dev_ctl_info_show,
	.store = edac_dev_ctl_info_store
};

#define CTL_INFO_ATTR(_name,_mode,_show,_store)        \
static struct ctl_info_attribute attr_ctl_info_##_name = {      \
	.attr = {.name = __stringify(_name), .mode = _mode },   \
	.show   = _show,                                        \
	.store  = _store,                                       \
};

/* Declare the various ctl_info attributes here and their respective ops */
CTL_INFO_ATTR(log_ue, S_IRUGO | S_IWUSR,
	edac_device_ctl_log_ue_show, edac_device_ctl_log_ue_store);
CTL_INFO_ATTR(log_ce, S_IRUGO | S_IWUSR,
	edac_device_ctl_log_ce_show, edac_device_ctl_log_ce_store);
CTL_INFO_ATTR(panic_on_ue, S_IRUGO | S_IWUSR,
	edac_device_ctl_panic_on_ue_show,
	edac_device_ctl_panic_on_ue_store);
CTL_INFO_ATTR(poll_msec, S_IRUGO | S_IWUSR,
	edac_device_ctl_poll_msec_show, edac_device_ctl_poll_msec_store);

/* Base Attributes of the EDAC_DEVICE ECC object */
static struct ctl_info_attribute *device_ctrl_attr[] = {
	&attr_ctl_info_panic_on_ue,
	&attr_ctl_info_log_ue,
	&attr_ctl_info_log_ce,
	&attr_ctl_info_poll_msec,
	NULL,
};

/*
 * edac_device_ctrl_master_release
 *
 *	called when the reference count for the 'main' kobj
 *	for a edac_device control struct reaches zero
 *
 *	Reference count model:
 *		One 'main' kobject for each control structure allocated.
 *		That main kobj is initially set to one AND
 *		the reference count for the EDAC 'core' module is
 *		bumped by one, thus added 'keep in memory' dependency.
 *
 *		Each new internal kobj (in instances and blocks) then
 *		bumps the 'main' kobject.
 *
 *		When they are released their release functions decrement
 *		the 'main' kobj.
 *
 *		When the main kobj reaches zero (0) then THIS function
 *		is called which then decrements the EDAC 'core' module.
 *		When the module reference count reaches zero then the
 *		module no longer has dependency on keeping the release
 *		function code in memory and module can be unloaded.
 *
 *		This will support several control objects as well, each
 *		with its own 'main' kobj.
 */
static void edac_device_ctrl_master_release(struct kobject *kobj)
{
	struct edac_device_ctl_info *edac_dev = to_edacdev(kobj);

	edac_dbg(4, "control index=%d\n", edac_dev->dev_idx);

	/* decrement the EDAC CORE module ref count */
	module_put(edac_dev->owner);

	/* free the control struct containing the 'main' kobj