summaryrefslogtreecommitdiffstats
path: root/include/driver.h
Commit message (Collapse)AuthorAgeFilesLines
* drivers: Drop dummy_probe()Andrey Smirnov2019-02-271-3/+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>
* include: Drop mem_memmap()Andrey Smirnov2019-02-271-1/+0
| | | | | | | Drop what looks like a leftover function prototype. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs: Change .lseek callbacks to return 'int'Andrey Smirnov2019-02-041-1/+1
| | | | | | | | | | | Returning requested offset from .lseek() callback doesn't really give us any new information while bringing unnecessary complications. Change all .lseek() types (both in struct struct cdev_operations and in struct fs_driver_d) to return 'int' and adjust the rest of the codebase accordingly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-5/+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>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-6/+19
|\
| * drivers: base: Convert device_d name to be dynamically allocatedAndrey Smirnov2018-10-181-3/+2
| | | | | | | | | | | | | | | | 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-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-181-3/+8
| | | | | | | | | | | | | | | | 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: Drop dev_get_mem_region_by_name()Andrey Smirnov2018-10-291-4/+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>
* driver: Adopt DMA mask concept from LinuxAndrey Smirnov2018-08-311-0/+2
| | | | | | | | | | In order to be able to detect cases where DMA isn't capable of reaching every memory address, port the concept of DMA mask, dma_set_mask() function and add appropriate check to dma_mapping_error(). 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-2/+2
| | | | | | | | 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>
* fs: add support loop mount offsetPhilipp Zabel2018-02-051-1/+1
| | | | | | | | When loop mounting, allow to specify an offset into the file, similarly to the losetup offset option. Multiplicative suffixes are supported. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Add device_detect_all() functionSascha Hauer2017-12-011-0/+1
| | | | | | | | 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>
* devfs-core: add function to find cdev by partuuidSteffen Trumtrar2017-07-101-0/+1
| | | | | Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* fs: add cdev_create_loop and cdev_remove_loop for loop mount optionPhilipp Zabel2017-06-061-0/+2
| | | | | | | | | | | | | | | | | | | Allow to create a loopback cdev from a file. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Fixed up with: fs: Makefile: Add parseopt to all builds parseopt.h was included to fs.c with commit 9248b, but parseopt.o has a dependency to CONFIG_FS_NFS. Moved parseopt.o to the default build to eliminate build failures. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: make file operations constPhilipp Zabel2017-06-011-1/+1
| | | | | | | | | | | | | | scripts/checkpatch.pl warns that struct file_operations should be const, but cdev->ops is not const, so without this patch we can choose between a warning from checkpatch and a warning from the compiler about discarding the const attribute when assigning the struct file_operations cdev->ops. Since there is no reason to modify the contents of cdev->ops after probing, make it const. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Create automount entries for the default mount pathesSascha Hauer2017-05-101-0/+8
| | | | | | | | | | In barebox the default mount path for a cdev is /mnt/<cdevname> which can be mounted with "mount <cdevname>" without specifying a target path explicitly. Simplify this further by creating automount entries for the default mount pathes which makes a manual mount completely unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partitions: flag partitions from a partition tableSascha Hauer2017-03-311-0/+1
| | | | | | | | | We are going to call the of_partition_fixup for regular block devices like MMC/SD aswell. Add a flag to partitions indicating they are instanciated from a on-disk partition table so that they won't be added as device tree partitions during fixup. 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>
* cdev: Collect partitions on listSascha Hauer2017-03-311-0/+1
| | | | | | | We currently do not have a way to iterate over all partitions of a cdev. Change this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Add optional truncate callback for device filesTeresa Remmet2017-01-111-0/+1
| | | | | | | | Not all device files have trivial fix device sizes like static ubi volumes. Here the device file size equals the image size it contains. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2016-03-111-2/+2
|\
| * mtd: Fix erasing of devices >4GiBSascha Hauer2016-02-091-2/+2
| | | | | | | | | | | | | | | | | | When a device >4GiB is erased, not only the offset can be bigger than 4GiB, but also the size. This happens with the simplest command to erase a device: erase /dev/nand0. Make the size argument a 64bit type to make this work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: Introduce dev_request_mem_resourceSascha Hauer2016-02-231-0/+6
|/ | | | | | | | | | | | 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>
* devfs: Add symlink supportSascha Hauer2016-01-081-0/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: Add function to find cdev by device_nodeSascha Hauer2015-09-011-0/+2
| | | | | | | | | | This adds a device_node member to struct cdev and a function to find a cdev by device_node. This also removes the setting of cdev->dev->device_node in the of partition parser. We must not set the device since it may not refer to a partition but to a whole device with partitions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move device_shutdown to exitcall infrastructureHerve Codina2015-07-131-5/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: Add partuuid string to struct cdevSascha Hauer2015-06-181-0/+3
| | | | | | | | This adds the partuuid string to struct cdev in order to have this available for constructing a suitable Linux root=PARTUUID= option for booting Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-061-1/+1
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | drivers/base: Mark (of|platform)_device_id data as constantUwe Kleine-König2015-04-171-3/+3
|/ | | | | | | | | | 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>
* drivers: remove unused function dev_protect()Marc Kleine-Budde2015-03-031-2/+0
| | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: add postcore_platform_driverJean-Christophe PLAGNIOL-VILLARD2015-02-041-0/+2
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.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/+8
| | | | | | | | | | | | | | | | 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>
* Documentation: remove doxygen documentationSascha Hauer2014-06-261-26/+0
| | | | | | | The doxygen documentation is long outdated. Remove it. It will be replaced with sphinx based documentation later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* x86: ns16550: Rework driver to allow for x86 I/O spaceMichel Stam2014-04-091-1/+1
| | | | | | | | | | | | The current implementation fakes a memory-mapped I/O device at 0x3f8 and 0x2f8, then uses platform read/write functions to do the actual reading and writing. These platform functions only exist for the x86 platform; better to move the I/O routines into the driver and have the driver request I/O ports using request_ioport_region. Signed-off-by: Michel Stam <michel@reverze.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: Allow for I/O mapped I/OMichel Stam2014-04-081-1/+4
| | | | | | | | 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/partitionhelper'Sascha Hauer2014-03-071-4/+37
|\ | | | | | | | | Conflicts: fs/devfs-core.c
| * devfs: partitioning: add new helper devfs_create_partitionsUwe Kleine-König2014-02-281-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compared to devfs_add_partition which adds a single partition devfs_create_partitions creates several partitions at once. One nice benefit is that this simplifies appending partitions because the start of the latter partition doesn't need to be specified explicitly. Also dev_add_bb_dev() is called by the new helper if the bbname is specified for a partition. Note that adding partitions is also more flexible now (also via devfs_add_partition) because negative values for offset and size now have a proper meaning instead of creating broken partitions. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * devfs_add_partition: make flags parameter unsignedUwe Kleine-König2014-02-281-4/+4
| | | | | | | | | | | | | | | | | | The value is only used to assign to a (*struct cdev)->flags which is an unsigned int and it is passed as fourth parameter of mtd_add_partition which is an unsigned long. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c/spi: match of_modaliasesSascha Hauer2014-02-071-1/+2
|/ | | | | | | | i2c/spi devices in the devicetree often come with a "vendor,device" comaptible string. These do not match in barebox, so add a device_match_of_modalias function which does exactly that. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* device: Add functions to add resourcesSascha Hauer2013-11-271-0/+9
| | | | | | | | | We currently have functions to add a device based on function parameters. This adds the corresponding functions to add resources to a device without registering the device itself. This is useful to manipulate devices before registering them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: store dos partition type in struct cdevSascha Hauer2013-10-141-0/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of'Sascha Hauer2013-08-051-2/+7
|\ | | | | | | | | | | Conflicts: arch/arm/boards/freescale-mx53-loco/board.c drivers/of/Makefile
| * cdev: add device_find_partitionSascha Hauer2013-07-151-0/+1
| | | | | | | | | | | | | | device_find_partition allows to find a partition of a device with a particular name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * cdev: allow to open a struct cdevSascha Hauer2013-07-151-0/+1
| | | | | | | | | | | | | | cdev_open() opens a cdev by name. This introduces cdev_do_open which allows to open a cdev when the cdev is already found by other means. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * cdev: introduce partition namesSascha Hauer2013-07-151-1/+4
| | | | | | | | | | | | | | | | currently most partition cdevs have the name <devname>.<partname> This makes it hard to find a partition by <partname>. This introduces a partname field in struct cdev so that. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * devfs: let devfs_add_partition return the new partitionSascha Hauer2013-07-151-1/+1
| | | | | | | | | | | | Useful for unregistering later or for adding addional flags. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2013-08-051-0/+2
|\ \
| * | dma: apbh: Turn into a driverSascha Hauer2013-07-231-0/+2
| |/ | | | | | | | | | | This converts the apbh driver into a real driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>