summaryrefslogtreecommitdiffstats
path: root/drivers/base
Commit message (Collapse)AuthorAgeFilesLines
* drivers: Drop dummy_probe()Andrey Smirnov2019-02-271-6/+0
| | | | | | | Drop dummy_probe() due to lack of users in the tree. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/lseek'Sascha Hauer2019-02-131-1/+0
|\
| * devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: base: Port power management code from LinuxAndrey Smirnov2019-01-184-1/+262
| | | | | | | | | | | | | | | | | | Port an extremely abridged version of power management/power domain code from Linux as a dependency of i.MX7D PCIe work. Currenlty only bare minimum of functionality is implemented. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | base: driver: Drop redundant list_empty() checkAndrey Smirnov2019-01-181-4/+1
|/ | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Print message with pr_errSascha Hauer2018-11-141-1/+1
| | | | | | | print "already registered" message with pr_err() rather than printf() to make sure it also appears in the logs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-093-11/+38
|\
| * drivers: base: Convert device_d name to be dynamically allocatedAndrey Smirnov2018-10-181-6/+17
| | | | | | | | | | | | | | | | Convert device_d name to be dynamically allocated in order to lift MAX_DRIVER_NAME length limit needed for commits that follow. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * base: Don't use shared buffer for results of dev_id()Andrey Smirnov2018-10-181-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using shared memory buffer to return results of dev_id() leads to incorrect results when used as follows: dev_info(..., "... %s ...\n", ..., dev_name(foo), ...); since result returned for dev_name(foo) will be overwritten by dev_name() call that will happen as a part of dev_* logging functions. To prevent that allocate a dedicated field "unique_name" in struct device_d and use it to store unique name returned by dev_id()/dev_name(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-183-2/+23
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: base: Simplify dev_request_mem_region_err_null()Andrey Smirnov2018-10-291-12/+8
| | | | | | | | | | | | | | | | Simplify dev_request_mem_region_err_null() by making use of dev_request_mem_resource() to implement it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: base: Drop dev_get_mem_region_by_name()Andrey Smirnov2018-10-291-12/+0
| | | | | | | | | | | | | | | | Drop dev_get_mem_region_by_name() which doesn't seem to have any users in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: base: Simplify generic_memmap_ro()Andrey Smirnov2018-10-291-14/+7
|/ | | | | | | | Simplify generic_memmap_ro() by re-implementing it using generic_memmap_rw(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-1/+1
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Add device_detect_all() functionSascha Hauer2017-12-011-0/+8
| | | | | | | | Add a device_detect_all function to detect all devices and use it in the detect command. This makes the functionality reusable in other code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* regmap: port regmap_update_bits from linuxSteffen Trumtrar2017-10-161-0/+29
| | | | | | | Port the regmap_update_bits function from linux v4.14-rc1 to barebox. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs-core: replace DEVFS_IS_PARTITION flag with pointer to the master cdevSascha Hauer2017-03-311-1/+1
| | | | | | | | Instead of having a flag indicating a cdev is a partition on some master cdev, just add a master pointer to the cdev, so that we can also find out who the master is. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* regmap: Add regmap_write_bits() functionAndrey Smirnov2017-01-101-0/+27
| | | | | | | Add code implementing a simple version of regmap_write_bits(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Introduce dev_request_mem_resourceSascha Hauer2016-02-231-2/+9
| | | | | | | | | | | | dev_request_mem_region returns a void * which shall be checked with IS_ERR(), but in some cases the valid pointer returned clashes with error values. This is especially the case on some Atmel SoCs. This introduces dev_request_mem_resource which returns a struct resource instead which in any case can be checked with IS_ERR(). It's the drivers responsibility then to get the IOMEM pointer from the resource. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Fix unregister device after device probe failureSascha Hauer2016-02-081-0/+4
| | | | | | | | | When a device probe fails the device is removed from the active list. If then the device is unregistered afterwards it is removed from the active list again resulting in a crash. To fix this initialize the devices active list entry when removing it from the active list. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add initial regmap supportSascha Hauer2016-02-054-0/+374
| | | | | | | | This adds initial regmap support. Function prototypes are from the Kernel, the implemention is mostly rewritten. Currently the regmap support is limited to the bare minimum to get started. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mips'Sascha Hauer2015-12-081-2/+2
|\
| * driver: make all dev_request_mem_region_* routines MIPS compatibleYegor Yefremov2015-12-011-2/+2
| | | | | | | | | | | | | | | | Use IOMEM() macro in all dev_request_mem_region_* routines to allow the proper mapping on all platforms. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: bus: Match against id_table firstAndrey Smirnov2015-12-071-3/+2
|/ | | | | | | | | | | | | | | | Matching against driver's name before looking throught its id_table can lead to a somewhat strange and unintuitive behaviour where a device whose driver's name matches one of the lines in id_table (which is not unheard of in Linux kernel) will be probed against said driver with 'id_table' field set to NULL which in turn will result in dev_get_drvdata erroring out with -ENODEV. This patch changes the behaviour such that device_match() only tries to match against driver's name only if id_table of that driver is not present. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move device_shutdown to exitcall infrastructureHerve Codina2015-07-131-1/+2
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: detect: detect parent devices aswellSascha Hauer2015-06-261-5/+20
| | | | | | | | | | | | | | Let device_detect_by_name detect parent devices aswell. We separate the devname strings by colons and call device_detect() for each component. This makes it possible for example to detect nand0.root.ubi.root With the above detect will be called for nand0, nand0.root, nand0.root.ubi and nand0.root.ubi.root. The nand0.root detection step will detect the UBI volume and attach it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-061-2/+2
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2015-05-061-2/+2
|\ \
| * | drivers/base: Mark (of|platform)_device_id data as constantUwe Kleine-König2015-04-171-2/+2
| |/ | | | | | | | | | | | | | | | | | | There should be no reason to ever change the data pointed to by id_table or of_compatible. So make this offical by adding some 'const's. In Linux the corresponding pointers are marked as const, too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / base: Introduce deferred probingSebastian Hesselbarth2015-04-171-3/+53
|/ | | | | | | | | As expected, we would need deferred probing sooner or later. This is a first approach to allow devices to return -EPROBE_DEFER and get sorted into a list of deferred devices that will be re-probed later. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Call bus->remove instead of driver->removeSascha Hauer2015-03-171-2/+2
| | | | | | | | | In devices_shutdown we should call the busses remove function which in turn calls the drivers remove function. Otherwise for example PCI devices never get removed since they do not have a remove function but a pcidev->remove function instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Call remove function only when availableSascha Hauer2015-03-171-1/+2
| | | | | | | | The bus implementations currently call the drivers remove hook unconditionally, but this hook is seldomly populated. Only call it when it's actually populated. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: fix device remove orderSascha Hauer2015-03-171-2/+3
| | | | | | | | | | | The active list is supposed to collect active devices in the opposite order they are probed. This is used to remove the devices in the correct order in devices_shutdown. The order is wrong though when in a drivers probe function other devices are registered. To get the order right we have to add the new device to the active list before it is probed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: remove unused function dev_protect()Marc Kleine-Budde2015-03-031-6/+0
| | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: dev_request_mem_region: fix return value for MIPSAntony Pavlov2015-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit commit 0d7a21334536cb36b3c9b64d868acc55aec41332 Author: Antony Pavlov <antonynpavlov at gmail.com> Date: Wed Sep 10 11:42:19 2014 +0400 MIPS: dts: use physical addresses (as Linux does) With IOMEM() adapted for MIPS we can use physical addresses in device tree reg property. has switched MIPS dts files to physical addresses usage. The patch was tested on qemu, but qemu malta board is tolerant of using physical addresses for accesing to device (Ingenic JZ4755 and JZ4780 processors are tolerant too!). But other CPUs (e.g. Loongson LS1B) can throw an exception in this situation. Additional physical address to virtual address translation on MIPS is needed. We already have this in include/common.h #if defined(CONFIG_MIPS) #include <asm/addrspace.h> #define IOMEM(addr) ((void __force __iomem *)CKSEG1ADDR(addr)) #else #define IOMEM(addr) ((void __force __iomem *)(addr)) #endif So use IOMEM() to fix dev_request_mem_region() return value. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: workaroud resource request that conflicts with errno PTRJean-Christophe PLAGNIOL-VILLARD2015-01-081-0/+16
| | | | | | | | | | | | | | | | broken since commit ed6e965824303255cacc1c1a195d3684caa26bce Author: Sascha Hauer <s.hauer@pengutronix.de> resource: Let dev_request_mem_region return an error pointer Introduce dev_request_mem_region_err_null only used on platform like at91 where the resource address conflicts with errno PTR. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/resource-err-ptr'Sascha Hauer2014-10-021-14/+20
|\
| * resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-2/+2
| | | | | | | | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * resource: Let dev_request_mem_region_by_name return an error pointerSascha Hauer2014-09-161-2/+2
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * resource: Let dev_get_mem_region return an error pointerSascha Hauer2014-09-161-1/+6
| | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
| * resource: Let dev_get_resource return an error pointerSascha Hauer2014-09-161-3/+3
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * resource: Let request_iomem_region return an error pointerSascha Hauer2014-09-161-2/+2
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * resource: Let dev_get_mem_region_by_name return an error pointerSascha Hauer2014-09-161-1/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * resource: Let dev_get_resource_by_name return an error pointerSascha Hauer2014-09-161-3/+4
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Introduce message logging supportSascha Hauer2014-09-301-22/+0
|/ | | | | | | | | | This adds a buffer for log messages and a 'dmesg' command to print the messages. The log buffer is implemented as log objects rather than a string buffer. This makes it easy to implement limiting the messages, cleaning the buffer and timestamping the messages. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: Allow for I/O mapped I/OMichel Stam2014-04-081-7/+9
| | | | | | | | Rework the current framework so that I/O mapped I/O resources are also possible. Signed-off-by: Michel Stam <michel@reverze.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2014-03-071-0/+3
|\ | | | | | | | | | | Conflicts: drivers/mtd/core.c net/eth.c
| * device: remove parameters when unregistering a deviceSascha Hauer2014-02-131-0/+2
| | | | | | | | | | | | | | | | Otherwise we loose memory on each device_unregister. The ethernet code used to do this before calling unregister_device. This can now be removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * device: init bus listSascha Hauer2014-02-131-0/+1
| | | | | | | | | | | | | | | | bus_list is only initialized when the device has a bus, but it needs to be initialized in unregister_device, so initialize the list unconditionally. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>