| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ioport.h,v 1.3 2021/12/19 01:35:04 riastradh Exp $ */ | | 1 | /* $NetBSD: ioport.h,v 1.4 2021/12/19 01:38:58 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -30,33 +30,34 @@ | | | @@ -30,33 +30,34 @@ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #ifndef _LINUX_IOPORT_H_ | | 32 | #ifndef _LINUX_IOPORT_H_ |
33 | #define _LINUX_IOPORT_H_ | | 33 | #define _LINUX_IOPORT_H_ |
34 | | | 34 | |
35 | #include <sys/types.h> | | 35 | #include <sys/types.h> |
36 | #include <sys/bus.h> | | 36 | #include <sys/bus.h> |
37 | | | 37 | |
38 | #define IORESOURCE_IO 0 | | 38 | #define IORESOURCE_IO 0 |
39 | #define IORESOURCE_MEM 1 | | 39 | #define IORESOURCE_MEM 1 |
40 | | | 40 | |
41 | struct resource { | | 41 | struct resource { |
42 | bus_addr_t start; | | 42 | bus_addr_t start; |
43 | bus_size_t size; | | 43 | bus_addr_t end; /* WARNING: Inclusive! */ |
44 | const char *name; | | 44 | const char *name; |
45 | unsigned int flags; | | 45 | unsigned int flags; |
46 | bus_space_tag_t r_bst; /* This milk is not organic. */ | | 46 | bus_space_tag_t r_bst; /* This milk is not organic. */ |
47 | bus_space_handle_t r_bsh; | | 47 | bus_space_handle_t r_bsh; |
48 | }; | | 48 | }; |
49 | | | 49 | |
50 | static inline bus_size_t | | 50 | static inline bus_size_t |
51 | resource_size(struct resource *resource) | | 51 | resource_size(struct resource *resource) |
52 | { | | 52 | { |
53 | return resource->size; | | 53 | return resource->end - resource->start + 1; |
54 | } | | 54 | } |
55 | | | 55 | |
56 | static inline void | | 56 | static inline void |
57 | release_resource(struct resource *resource) | | 57 | release_resource(struct resource *resource) |
58 | { | | 58 | { |
59 | bus_space_free(resource->r_bst, resource->r_bsh, resource->size); | | 59 | bus_space_free(resource->r_bst, resource->r_bsh, |
| | | 60 | resource_size(resource)); |
60 | } | | 61 | } |
61 | | | 62 | |
62 | #endif /* _LINUX_IOPORT_H_ */ | | 63 | #endif /* _LINUX_IOPORT_H_ */ |