summaryrefslogtreecommitdiff
path: root/sys/dev/ow
AgeCommit message (Collapse)Author
2025-01-02Use bus_generic_detach instead of device_delete_children in detachJohn Baldwin
While here, check for errors from bus_generic_detach and move it to the start of detach if necessary. Differential Revision: https://reviews.freebsd.org/D47969
2025-01-02bus_generic_detach: Delete children after detaching themJohn Baldwin
This provides better semantics as a standalone DEVMETHOD for device_attach as bus drivers should remove child devices they created as part of detach cleanup. The implementation calls bus_detach_children() first to permit child devices an opportunity to veto the detach operation. If that succeeds, device_delete_children() is used to delete the child devices. This requires fixing various drivers that were deleting devices explicitly (via a device_t pointer cached in the softc) after calling bus_generic_detach to stop doing that and just rely on bus_generic_detach to remove child devices. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47959
2024-12-06bus_delayed_attach_children: Switch return type to voidJohn Baldwin
This function never fails similar to bus_attach_children. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47677
2024-12-06Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
2024-11-01ow: Use a bus_child_deleted method to free ivars for childrenJohn Baldwin
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47364
2024-07-24newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh
Sponsored by: Netflix
2023-11-26sys: Automated cleanup of cdefs and other formattingWarner Losh
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
2023-08-16sys: Remove $FreeBSD$: one-line bare tagWarner Losh
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16sys: Remove $FreeBSD$: one-line sh patternWarner Losh
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16sys: Remove $FreeBSD$: one-line .c patternWarner Losh
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16sys: Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2022-05-09ow: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin
2021-06-22newbus: Move from bus_child_{pnpinfo,location}_src to ↵Warner Losh
bus_child_{pnpinfo,location} with sbuf Now that the upper layers all go through a layer to tie into these information functions that translates an sbuf into char * and len. The current interface suffers issues of what to do in cases of truncation, etc. Instead, migrate all these functions to using struct sbuf and these issues go away. The caller is also in charge of any memory allocation and/or expansion that's needed during this process. Create a bus_generic_child_{pnpinfo,location} and make it default. It just returns success. This is for those busses that have no information for these items. Migrate the now-empty routines to using this as appropriate. Document these new interfaces with man pages, and oversight from before. Reviewed by: jhb, bcr Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29937
2021-01-23Revert "Define PNP info after defining driver modules"Mark Johnston
This reverts commit aa37baf3d7cf51da92fd367476182802e71838ae. The reverted commit was motivated by a problem observed on stable/12, but it turns out that a better solution was committed in r348309 but not MFCed. So, revert this change since it is unnecessary and not really correct: it assumes that the order in which module metadata records is defined determines their order in the output linker set. While this seems to hold in my testing, it is not guaranteed. Reported by: cem Discussed with: imp MFC after: 3 days
2021-01-21Define PNP info after defining driver modulesMark Johnston
PNP info definitions currently have an unfortunate requirement in that they must follow the associated module definition in the module metadata linker set. Otherwise devmatch can segfault while processing the linker hints file since kldxref maintains the order in the linker set. A number of drivers violate this requirement. In some cases this can cause devmatch(8) to segfault when processing the linker hints file. Work around the problem for now simply by adjusting the drivers. Reviewed by: imp MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D28260
2020-09-01ow: clean up empty lines in .c and .h filesMateusz Guzik
Notes: svn path=/head/; revision=365183
2020-05-13kernel: provide panicky version of __unreachableKyle Evans
__builtin_unreachable doesn't raise any compile-time warnings/errors on its own, so problems with its usage can't be easily detected. While it would be nice for this situation to change and compilers to at least add a warning for trivial cases where local state means the instruction can't be reached, this isn't the case at the moment and likely will not happen. This commit adds an __assert_unreachable, whose intent is incredibly clear: it asserts that this instruction is unreachable. On INVARIANTS builds, it's a panic(), and on non-INVARIANTS it expands to __unreachable(). Existing users of __unreachable() are converted to __assert_unreachable, to improve debuggability if this assumption is violated. Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D23793 Notes: svn path=/head/; revision=361011
2020-02-26Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
2019-12-17Update owc_gpiobus (one-wire over gpio) to the modern gpio_pin interface.Ian Lepore
It used to be required that a device be a child of gpiobus(4) to manipulate gpio pins. That requirement didn't work well for FDT-based systems with many cross-hierarchy users of gpio, so a more modern framework was created that removed the old hierarchy requirement. These changes adapt the owc_gpiobus driver to use the newer gpio_pin_* functions to acquire, release, and manipulate gpio pins. This allows a single driver to work for both hinted-attachment and fdt-based systems, and removes the requirement that any one-wire fdt nodes must appear at the root of the devicetree. Differential Revision: https://reviews.freebsd.org/D22710 Notes: svn path=/head/; revision=355858
2019-12-13Be consistent about checking return value from bus_delayed_attach_children.Warner Losh
Most places checked, but a couple last minute changes didn't. Make them all use the return value. Noticed by: rpokala@ Notes: svn path=/head/; revision=355735
2019-12-13Create new wrapper function: bus_delayed_attach_children()Warner Losh
Delay the attachment of children, when requested, until after interrutps are running. This is often needed to allow children to run transactions on i2c or spi busses. It's a common enough idiom that it will be useful to have its own wrapper. Reviewed by: ian Differential Revision: https://reviews.freebsd.org/D21465 Notes: svn path=/head/; revision=355727
2019-12-10Do not attach children of owc_gpiobus until interrupts are working.Ian Lepore
The children of the bus need to do IO on the bus to probe for hardware presence. Doing IO means timing the bus states using sbinuptime(), and that requires working timecounters, which are not initialized until after device attachment has completed. PR: 242526 Notes: svn path=/head/; revision=355598
2019-12-04Regularize my copyright noticeWarner Losh
o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
2019-10-30Remove redundant hw sysctl declaration. gcc CI complains, but clang doesn't.Warner Losh
Notes: svn path=/head/; revision=354205
2019-10-30ow(4): clean up stray white spaceAndriy Gapon
MFC after: 2 weeks Notes: svn path=/head/; revision=354183
2019-10-30ow(4): protocol timings can now be changed as sysctl-s / tunablesAndriy Gapon
I limited potentially infinite timings by 960 us based on a footnote on page 38 of Maxim Integrated Application Note 937, Book of iButton Standards: "In order not to mask interrupt signalling by other devices on the 1–Wire bus, tRSTL + tR should always be less than 960 us." MFC after: 3 weeks Notes: svn path=/head/; revision=354181
2019-10-30ow(4): increase regular mode recovery time, t_rec, to 15 usAndriy Gapon
Previously we used the minimal value of 1 us and it was really tight. Application Note 3829 has a table describing recommended t_rec values for various bus voltages, temperature conditions and numbers of slave devices. The new value decreases the maximum possible data rate from 16.3 Kbit/s to 13.3 Kbit/s, but it allows for up to four slaves on a 3.3V bus (under room temperature). References: - Maxim Integrated Application Note 3829 Determining the Recovery Time for Multiple-Slave 1-Wire(R) Networks - Maxim Integrated Application Note 937 Book of iButton Standards Discussed with: imp (D22108) MFC after: 3 weeks Notes: svn path=/head/; revision=354180
2019-10-25owc_gpiobus: add missing space in r354077Andriy Gapon
Notes: svn path=/head/; revision=354078
2019-10-25owc_gpiobus_read_data: add recovery time to the read slotAndriy Gapon
Reviewed by: imp MFC after: 2 weeks Notes: svn path=/head/; revision=354077
2019-10-25owc_gpiobus_read_data: compare times in sbintime_t unitsAndriy Gapon
Previously the code used sbttous() before microseconds comparison in one place, sbttons() and nanoseconds in another, division by SBT_1US and microseconds in yet another. Now the code consistently uses multiplication by SBT_1US to convert microseconds to sbintime_t before comparing them with periods between calls to sbinuptime(). This is fast, this is precise enough (below 0.03%) and the periods defined by the protocol cannot overflow. Reviewed by: imp (D22108) MFC after: 2 weeks Notes: svn path=/head/; revision=354076
2019-10-25owc_gpiobus_read_data: disable preemption earlierAndriy Gapon
Now this is done before starting the low pulse that has rather tight timing. Reviewed by: imp (D22108) MFC after: 2 weeks Notes: svn path=/head/; revision=354069
2019-10-25ow_temp: better scopes for the lockAndriy Gapon
The lock is used only for start / stop signaling. It is used only for 'flags' field and the related condition variable. This change is a follow-up to r354067, it was suggested by Warner in D22107. Suggested by: imp MFC after: 1 week Notes: svn path=/head/; revision=354068
2019-10-25ow_temp: drop the lock around a call that can sleepAndriy Gapon
This is similar to what is done around other calls that lead to own_command_wait() that can sleep. Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22107 Notes: svn path=/head/; revision=354067
2019-07-10owc_gpiobus: small formatting cleanupAndriy Gapon
MFC after: 1 week Notes: svn path=/head/; revision=349883
2019-06-26fix up r349428, fix a typo made during "fdt" removalAndriy Gapon
Reported by: ian MFC after: 11 days Notes: svn path=/head/; revision=349433
2019-06-26owc_gpiobus: clean / fix up the driver module thingsAndriy Gapon
"fdt" is removed from the driver module name as the driver does not require FDT and can work very well on hints based systems. A module dependency is added for gpiobus. Without that owc cannot resolve symbols in gpiobus if both are loaded as kernel modules. Finally, a driver module module version is added. Reviewed by: imp MFC after: 11 days Notes: svn path=/head/; revision=349428
2019-05-20Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
2018-12-20Fix panic message when we can't create thread for one wire temperatureWarner Losh
reading. Notes: svn path=/head/; revision=342275
2018-03-20[ofw] fix errneous checks for OF_finddevice(9) return valueOleksandr Tymoshenko
OF_finddevices returns ((phandle_t)-1) in case of failure. Some code in existing drivers checked return value to be equal to 0 or less/equal to 0 which is also wrong because phandle_t is unsigned type. Most of these checks were for negative cases that were never triggered so trhere was no impact on functionality. Reviewed by: nwhitehorn MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D14645 Notes: svn path=/head/; revision=331229
2017-07-29Add inline functions to convert between sbintime_t and decimal time units.Ian Lepore
Use them in some existing code that is vulnerable to roundoff errors. The existing constant SBT_1NS is a honeypot, luring unsuspecting folks into writing code such as long_timeout_ns*SBT_1NS to generate the argument for a sleep call. The actual value of 1ns in sbt units is ~4.3, leading to a large roundoff error giving a shorter sleep than expected when multiplying by the trucated value of 4 in SBT_1NS. (The evil honeypot aspect becomes clear after you waste a whole day figuring out why your sleeps return early.) Notes: svn path=/head/; revision=321686
2016-12-22ow_temp: Update the temperature visible via the sysctl atomically, ratherGavin Atkinson
than using it as temporary calculation space. Notes: svn path=/head/; revision=310381
2016-12-21ow_temp: Correct typo in commentGavin Atkinson
Notes: svn path=/head/; revision=310379
2016-05-17Don't repeat the the word 'the'Eitan Adler
(one manual change to fix grammar) Confirmed With: db Approved by: secteam (not really, but this is a comment typo fix) Notes: svn path=/head/; revision=300050
2016-05-16dev/ow: Tag an unreachable switch default.Pedro F. Giffuni
Coverity reports an uninitialized "dir" in case the switch defaults without hitting any case. Respect the original intent and quell the false positive with the relatively new __unreachable() builtin. CID: 1331566 Notes: svn path=/head/; revision=299973
2016-04-10Cleanup unnecessary semicolons from the kernel.Pedro F. Giffuni
Found with devel/coccinelle. Notes: svn path=/head/; revision=297793
2015-08-28Simply to appease gcc's warnings.Warner Losh
Notes: svn path=/head/; revision=287239
2015-08-27New 1-Wire bus implementation. 1-Wire controller is abstracted, thoughWarner Losh
only gpiobus configured via FDT is supported. Bus enumeration is supported. Devices are created for each device found. 1-Wire temperature controllers are supported, but other drivers could be written. Temperatures are polled and reported via a sysctl. Errors are reported via sysctl counters. Mis-wired bus detection is included for more trouble shooting. See ow(4), owc(4) and ow_temp(4) for details of what's supported and known issues. This has been tested on Raspberry Pi-B, Pi2 and Beagle Bone Black with up to 7 devices. Differential Revision: https://reviews.freebsd.org/D2956 Relnotes: yes MFC after: 2 weeks Reviewed by: loos@ (with many insightful comments) Notes: svn path=/head/; revision=287225