summaryrefslogtreecommitdiffstats
path: root/drivers/misc
Commit message (Collapse)AuthorAgeFilesLines
* state: driver: handle EPROBE_DEFERSascha Hauer2016-10-201-2/+6
| | | | | | | | When state_new_from_node() returns -ENODEV that means that there is no device available for the node, so return -EPROBE_DEFER in this case and hope a device is there later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Refactor state frameworkMarkus Pargmann2016-07-081-63/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The state framework grew organically over the time. Unfortunately the architecture and abstractions disappeared during this period. This patch refactors the framework to recreate the abstractions. The main focus was the backend with its storage. The main use-case was to offer better NAND support with less erase cycles and interchangeable data formats (dtb,raw). The general architecture now has a backend which consists of a data format and storage. The storage consists of multiple storage buckets each holding exactly one copy of the state data. A data format describes a data serialization for the state framework. This can be either dtb or raw. A storage bucket is a storage location which is used to store any data. There is a (new) circular type which writes changes behind the last written data and therefore reduces the number of erases. The other type is a direct bucket which writes directly to a storage offset for all non-erase storage. Furthermore this patch splits up all classes into different files in a subdirectory. This is currently all in one patch as I can't see a good way to split the changes up without having a non-working state framework in between. The following diagram shows the new architecture roughly: .----------. | state | '----------' | | v .----------------------------. | state_backend | |----------------------------| | + state_load(*state); | | + state_save(*state); | | + state_backend_init(...); | | | | | '----------------------------' | | The format describes | | how the state data | '-------------> is serialized | .--------------------------------------------. | | state_backend_format <INTERFACE> | | |--------------------------------------------| | | + verify(*format, magic, *buf, len); | | | + pack(*format, *state, **buf, len); | | | + unpack(*format, *state, *buf, len); | | | + get_packed_len(*format, *state); | | | + free(*format); | | '--------------------------------------------' | ^ ^ | * * | * * | .--------------------. .--------------------. | | backend_format_dtb | | backend_format_raw | | '--------------------' '--------------------' | | | v .----------------------------------------------------------. | state_backend_storage | |----------------------------------------------------------| | + init(...); | | + free(*storage); | | + read(*storage, *format, magic, **buf, *len, len_hint); | | + write(*storage, *buf, len); | | + restore_consistency(*storage, *buf, len); | '----------------------------------------------------------' | The backend storage is responsible to manage multiple data copies and distribute them onto several buckets. Read data is verified against the given format to ensure that the read data is correct. | | | | | v .------------------------------------------. | state_backend_storage_bucket <INTERFACE> | |------------------------------------------| | + init(*bucket); | | + write(*bucket, *buf, len); | | + read(*bucket, **buf, len_hint); | | + free(*bucket); | '------------------------------------------' ^ ^ ^ * * * * * * A storage bucket represents*exactly one data copy at one data location. A circular b*cket writes any new data to the end of the bucket (for *educed erases on NAND). A direct bucket directly writ*s at one location. * * * * * * * * * .-----------------------. * .-------------------------. | backend_bucket_direct | * | backend_bucket_circular | '-----------------------' * '-------------------------' ^ * ^ | * | | * | | * | | .-----------------------. | '--| backend_bucket_cached |---' '-----------------------' A backend_bucket_cached is a transparent bucket that directly uses another bucket as backend device and caches all accesses. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-05-091-0/+1
|\
| * state: Fix Kconfig dependenciesSascha Hauer2016-04-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | State support does not need OF_BAREBOX_DRIVERS and never did, so drop the dependency there. It's the state driver which needs of_find_path(), since this symbol now is always enabled when OF is enabled, we don't have to add the dependency to the state driver, but instead can depend on OFDEVICE. We could depend on OF instead, but compiling the state driver without OFDEVICE makes no sense. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-2/+1
|/ | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: disable load commandEnrico Jorns2015-11-271-1/+0
| | | | | | | | | Explicitly loading environment is not required as it will be loaded if available during device probing Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: use name of device node as name if alias is not availableMarc Kleine-Budde2015-11-271-1/+1
| | | | | | | | | | | Wihtout this patch, when using more than one state device an alias is mandatory, otherwise the there will be two state devices with the name state. This patch fixes the limitation by using the device node's name if no alias is defined. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: make use of of_find_path_by_node() and add return -EPROBE_DEFER if ↵Marc Kleine-Budde2015-11-271-22/+9
| | | | | | | | device is not available Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: support phandle and of_path referencesMarc Kleine-Budde2015-05-151-14/+58
| | | | | | | | | | | This patch improves the backend property, it can be either a phandle or a of_path. During probe() of the state driver the backend property is dereferenced and the resulting of_path is saved in the state context. In a later patch it will be used to generate a phandle reference to the backend during DT fixup. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: of_find_path(): add possibility to return .bb deviceMarc Kleine-Budde2015-04-231-1/+1
| | | | | | | | | This patch adds a flags argument to the of_find_path() function. The only flag defined for now is OF_FIND_PATH_FLAGS_BB. When used on NAND devices, the function returns the bad block aware device (the ".bb" device). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: add framework for persistent state handlingSascha Hauer2015-03-123-0/+86
| | | | | | | | | | | | | | | | This patch adds a framework to describe, access, store and restore a set of variables. A state variable set can be fully described in a devicetree node. This node could be part of the regular devicetree blob or it could be an extra devicetree solely for the state. The state variable set contains variables of different types and a place to store the variable set. For more information see: Documentation/devicetree/bindings/barebox/barebox,state.rst Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-2/+3
| | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: Let dev_get_resource return an error pointerSascha Hauer2014-09-161-0/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ioresource'Sascha Hauer2014-05-051-1/+1
|\
| * common: Allow for I/O mapped I/OMichel Stam2014-04-081-1/+1
| | | | | | | | | | | | | | | | 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>
* | treewide: fix signedness mixups in printf format specifiersLucas Stach2014-04-231-1/+1
|/ | | | | | | | | This most likely doesn't fix any real bugs, but it's the right thing to do and reduces the noise level with static checkers. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* misc: Add devicetree SRAM driverSascha Hauer2014-01-293-0/+82
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* misc Kconfig: always ask for misc devicesSascha Hauer2014-01-291-8/+2
| | | | | | | The "Misc devices" menu does not enable anything by itself, so make it a regular menu rather than a menuconfig. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Attach info callback to device, not to driverSascha Hauer2013-05-301-20/+20
| | | | | | | | Since the info is device specific and not driver specific, attach the callback to the device. This makes it possible to have a info callback for a device which does not have a driver attached. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Use new device_platform_driver() macro for driversAlexander Shiyan2013-02-131-7/+1
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Cleanup Kconfig filesAlexander Shiyan2012-12-081-1/+1
| | | | | | | | | This patch provides a global cleanup barebox Kconfig files. This includes replacing spaces to tabs, formatting in accordance format, removing extraneous lines and spaces. No functional changes. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* misc JTAG: include fixesSascha Hauer2012-10-261-3/+1
| | | | | | | common.h should come first, other include files implicitely depend on it. Also, remove unused fs.h and remove commented line. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* misc JTAG: Let Jtag driver depend on GENERIC_GPIOSascha Hauer2012-10-261-0/+1
| | | | | | It uses the gpio functions, so let it depend on GENERIC_GPIO. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+1
| | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Add JTAG bitbang driverWjatscheslaw Stoljarski2012-08-133-0/+414
Signed-off-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>