summaryrefslogtreecommitdiffstats
path: root/arch/microblaze/pci
AgeCommit message (Expand)Author
2017-11-02License cleanup: add SPDX GPL-2.0 license identifier to files with no licenseGreg Kroah-Hartman
2017-09-08Merge tag 'pci-v4.14-changes' of git://git.kernel.org/pub/scm/linux/kernel/gi...Linus Torvalds
2017-08-29microblaze: Convert to using %pOF instead of full_nameRob Herring
2017-08-10microblaze/PCI: Remove pcibios_setup_bus_{self/devices} dead codeLorenzo Pieralisi
2017-08-02PCI: Add a generic weak pcibios_align_resource()Palmer Dabbelt
2017-08-02PCI: Add a generic weak pcibios_fixup_bus()Palmer Dabbelt
2017-04-20PCI: Add BAR index argument to pci_mmap_page_range()David Woodhouse
2017-02-24mm: remove shmem_mapping() shmem_zero_setup() duplicatesHugh Dickins
2016-09-13microblaze/PCI: Add multidomain support for procfsBharat Kumar Gogada
2016-06-17microblaze/PCI: Implement pci_resource_to_user() with pcibios_resource_to_bus()Bjorn Helgaas
2016-06-17microblaze/PCI: Remove useless __pci_mmap_set_pgprot()Bjorn Helgaas
2016-05-16microblaze: pci: export isa_io_base to fix link errorsFengguang Wu
2016-03-08microblaze/PCI: Support generic Xilinx AXI PCIe Host Bridge IP driverBharat Kumar Gogada
2015-09-15PCI: Revert "PCI: Call pci_read_bridge_bases() from core instead of arch code"Bjorn Helgaas
2015-07-23PCI: Call pci_read_bridge_bases() from core instead of arch codeLorenzo Pieralisi
2015-03-19PCI: Assign resources before drivers claim devices (pci_scan_root_bus())Yijing Wang
2015-01-16microblaze/PCI: Clip bridge windows to fit in upstream windowsYinghai Lu
2014-10-27microblaze: Fix IO space breakage after of_pci_range_to_resource() changeMichal Simek
2014-06-05Merge tag 'microblaze-3.16-rc1' of git://git.monstr.eu/linux-2.6-microblaze i...Linus Torvalds
2014-06-04microblaze: Cleanup PCI_DRAM_OFFSET handlingMichal Simek
2014-06-04microblaze: Do not setup pci_dma_opsMichal Simek
2014-04-30PCI: Move Open Firmware devspec attribute to PCI common codeSebastian Ott
2014-03-19microblaze/PCI: Use default pcibios_enable_device()Bjorn Helgaas
2013-11-07Merge remote-tracking branch 'grant/devicetree/next' into for-nextRob Herring
2013-10-24microblaze/pci: Drop PowerPC-ism from irq parsingGrant Likely
2013-10-24of/irq: simplify args to irq_create_of_mappingGrant Likely
2013-10-24of/irq: Replace of_irq with of_phandle_argsGrant Likely
2013-10-24of/irq: Rename of_irq_map_* functions to of_irq_parse_*Grant Likely
2013-10-09microblaze: clean-up prom.h implicit includesRob Herring
2013-09-03of/pci: Use of_pci_range_parserAndrew Murray
2013-05-09microblaze: pci: Remove duplicated include from pci-common.cWei Yongjun
2013-02-12microblaze: Do not use module.h in files which are not modulesMichal Simek
2013-02-12microblaze: Fix coding style issuesMichal Simek
2013-01-07Merge branch 'next' of git://git.monstr.eu/linux-2.6-microblazeLinus Torvalds
2013-01-04microblaze: Fix pci compilation and sparse warningsMichal Simek
2013-01-03ARCH: drivers remove __dev* attributes.Greg Kroah-Hartman
2012-11-28microblaze/PCI: Remove CONFIG_HOTPLUG ifdefsBill Pemberton
2012-07-24Merge tag 'for-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pciLinus Torvalds
2012-07-06devicetree: add helper inline for retrieving a node's full nameGrant Likely
2012-07-05Merge branch 'pci/myron-pcibios_setup' into nextBjorn Helgaas
2012-07-05microblaze/PCI: factor out pcibios_setup()Myron Stowe
2012-06-13PCI: replace struct pci_bus secondary/subordinate with busn_resYinghai Lu
2012-05-15microblaze/PCI: fix "io_offset undeclared" errorBjorn Helgaas
2012-02-23microblaze/PCI: get rid of device resource fixupsBjorn Helgaas
2012-02-23microblaze/PCI: remove unused pci_flagsBjorn Helgaas
2012-01-11Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jb...Linus Torvalds
2012-01-10Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhostLinus Torvalds
2012-01-06microblaze/PCI: use pci_scan_root_bus()Bjorn Helgaas
2012-01-06microblaze/PCI: convert to pci_create_root_bus() for correct root bus resourcesBjorn Helgaas
2012-01-06microblaze/PCI: make pcibios_setup_phb_resources() staticBjorn Helgaas
='n396' href='#n396'>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
/*
 * drivers/acpi/device_sysfs.c - ACPI device sysfs attributes and modalias.
 *
 * Copyright (C) 2015, Intel Corp.
 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/export.h>
#include <linux/nls.h>

#include "internal.h"

static ssize_t acpi_object_path(acpi_handle handle, char *buf)
{
	struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
	int result;

	result = acpi_get_name(handle, ACPI_FULL_PATHNAME, &path);
	if (result)
		return result;

	result = sprintf(buf, "%s\n", (char *)path.pointer);
	kfree(path.pointer);
	return result;
}

struct acpi_data_node_attr {
	struct attribute attr;
	ssize_t (*show)(struct acpi_data_node *, char *);
	ssize_t (*store)(struct acpi_data_node *, const char *, size_t count);
};

#define DATA_NODE_ATTR(_name)			\
	static struct acpi_data_node_attr data_node_##_name =	\
		__ATTR(_name, 0444, data_node_show_##_name, NULL)

static ssize_t data_node_show_path(struct acpi_data_node *dn, char *buf)
{
	return acpi_object_path(dn->handle, buf);
}

DATA_NODE_ATTR(path);

static struct attribute *acpi_data_node_default_attrs[] = {
	&data_node_path.attr,
	NULL
};

#define to_data_node(k) container_of(k, struct acpi_data_node, kobj)
#define to_attr(a) container_of(a, struct acpi_data_node_attr, attr)

static ssize_t acpi_data_node_attr_show(struct kobject *kobj,
					struct attribute *attr, char *buf)
{
	struct acpi_data_node *dn = to_data_node(kobj);
	struct acpi_data_node_attr *dn_attr = to_attr(attr);

	return dn_attr->show ? dn_attr->show(dn, buf) : -ENXIO;
}

static const struct sysfs_ops acpi_data_node_sysfs_ops = {
	.show	= acpi_data_node_attr_show,
};

static void acpi_data_node_release(struct kobject *kobj)
{
	struct acpi_data_node *dn = to_data_node(kobj);
	complete(&dn->kobj_done);
}

static struct kobj_type acpi_data_node_ktype = {
	.sysfs_ops = &acpi_data_node_sysfs_ops,
	.default_attrs = acpi_data_node_default_attrs,
	.release = acpi_data_node_release,
};

static void acpi_expose_nondev_subnodes(struct kobject *kobj,
					struct acpi_device_data *data)
{
	struct list_head *list = &data->subnodes;
	struct acpi_data_node *dn;

	if (list_empty(list))
		return;

	list_for_each_entry(dn, list, sibling) {
		int ret;

		init_completion(&dn->kobj_done);
		ret = kobject_init_and_add(&dn->kobj, &acpi_data_node_ktype,
					   kobj, "%s", dn->name);
		if (ret)
			acpi_handle_err(dn->handle, "Failed to expose (%d)\n", ret);
		else
			acpi_expose_nondev_subnodes(&dn->kobj, &dn->data);
	}
}

static void acpi_hide_nondev_subnodes(struct acpi_device_data *data)
{
	struct list_head *list = &data->subnodes;
	struct acpi_data_node *dn;

	if (list_empty(list))
		return;

	list_for_each_entry_reverse(dn, list, sibling) {
		acpi_hide_nondev_subnodes(&dn->data);
		kobject_put(&dn->kobj);
	}
}

/**
 * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
 * @acpi_dev: ACPI device object.
 * @modalias: Buffer to print into.
 * @size: Size of the buffer.
 *
 * Creates hid/cid(s) string needed for modalias and uevent
 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
 * char *modalias: "acpi:IBM0001:ACPI0001"
 * Return: 0: no _HID and no _CID
 *         -EINVAL: output error
 *         -ENOMEM: output is truncated
*/
static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
			       int size)
{
	int len;
	int count;
	struct acpi_hardware_id *id;

	/*
	 * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
	 * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
	 * device's list.
	 */
	count = 0;
	list_for_each_entry(id, &acpi_dev->pnp.ids, list)
		if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
			count++;

	if (!count)
		return 0;

	len = snprintf(modalias, size, "acpi:");
	if (len <= 0)
		return len;

	size -= len;

	list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
		if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
			continue;

		count = snprintf(&modalias[len], size, "%s:", id->id);
		if (count < 0)
			return -EINVAL;

		if (count >= size)
			return -ENOMEM;

		len += count;
		size -= count;
	}
	modalias[len] = '\0';
	return len;
}

/**
 * create_of_modalias - Creates DT compatible string for modalias and uevent
 * @acpi_dev: ACPI device object.
 * @modalias: Buffer to print into.
 * @size: Size of the buffer.
 *
 * Expose DT compatible modalias as of:NnameTCcompatible.  This function should
 * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
 * ACPI/PNP IDs.
 */
static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
			      int size)
{
	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
	const union acpi_object *of_compatible, *obj;
	int len, count;
	int i, nval;
	char *c;

	acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
	/* DT strings are all in lower case */
	for (c = buf.pointer; *c != '\0'; c++)
		*c = tolower(*c);

	len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
	ACPI_FREE(buf.pointer);

	if (len <= 0)
		return len;

	of_compatible = acpi_dev->data.of_compatible;
	if (of_compatible->type == ACPI_TYPE_PACKAGE) {
		nval = of_compatible->package.count;
		obj = of_compatible->package.elements;
	} else { /* Must be ACPI_TYPE_STRING. */
		nval = 1;
		obj = of_compatible;
	}
	for (i = 0; i < nval; i++, obj++) {
		count = snprintf(&modalias[len], size, "C%s",
				 obj->string.pointer);
		if