public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] binder: convert `BINDER_*` ioctl `#define`s into an `enum`
@ 2022-05-17 10:28 Miguel Ojeda
  2022-05-18 13:39 ` Miguel Ojeda
  0 siblings, 1 reply; 3+ messages in thread
From: Miguel Ojeda @ 2022-05-17 10:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: rust-for-linux, Arnd Bergmann, Masahiro Yamada, Li Li,
	linux-kernel, Miguel Ojeda, Wedson Almeida Filho

bindgen (a tool which generates the "raw" C bindings for Rust) only
works (so far) with "simple" C `#define`s. In order to avoid having
to manually maintain these constants in the (potential) Rust side,
this patch converts them into an `enum`.

There may be support in the future for expanding macros that end up in
a "numeric" one: https://github.com/rust-lang/rust-bindgen/issues/753.

Link: https://lore.kernel.org/lkml/YoIK2l6xbQMPGZHy@kroah.com/
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
v2:
  - Rebased on top of Greg's char-misc-next.
  - Added Link tag for future reference.

v1: https://lore.kernel.org/lkml/20220516100401.7639-1-ojeda@kernel.org/

 include/uapi/linux/android/binder.h | 30 +++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h
index e6ee8cae303b..a4c3e750168a 100644
--- a/include/uapi/linux/android/binder.h
+++ b/include/uapi/linux/android/binder.h
@@ -251,20 +251,22 @@ struct binder_extended_error {
 	__s32	param;
 };
 
-#define BINDER_WRITE_READ		_IOWR('b', 1, struct binder_write_read)
-#define BINDER_SET_IDLE_TIMEOUT		_IOW('b', 3, __s64)
-#define BINDER_SET_MAX_THREADS		_IOW('b', 5, __u32)
-#define BINDER_SET_IDLE_PRIORITY	_IOW('b', 6, __s32)
-#define BINDER_SET_CONTEXT_MGR		_IOW('b', 7, __s32)
-#define BINDER_THREAD_EXIT		_IOW('b', 8, __s32)
-#define BINDER_VERSION			_IOWR('b', 9, struct binder_version)
-#define BINDER_GET_NODE_DEBUG_INFO	_IOWR('b', 11, struct binder_node_debug_info)
-#define BINDER_GET_NODE_INFO_FOR_REF	_IOWR('b', 12, struct binder_node_info_for_ref)
-#define BINDER_SET_CONTEXT_MGR_EXT	_IOW('b', 13, struct flat_binder_object)
-#define BINDER_FREEZE			_IOW('b', 14, struct binder_freeze_info)
-#define BINDER_GET_FROZEN_INFO		_IOWR('b', 15, struct binder_frozen_status_info)
-#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION	_IOW('b', 16, __u32)
-#define BINDER_GET_EXTENDED_ERROR	_IOWR('b', 17, struct binder_extended_error)
+enum {
+	BINDER_WRITE_READ			= _IOWR('b', 1, struct binder_write_read),
+	BINDER_SET_IDLE_TIMEOUT			= _IOW('b', 3, __s64),
+	BINDER_SET_MAX_THREADS			= _IOW('b', 5, __u32),
+	BINDER_SET_IDLE_PRIORITY		= _IOW('b', 6, __s32),
+	BINDER_SET_CONTEXT_MGR			= _IOW('b', 7, __s32),
+	BINDER_THREAD_EXIT			= _IOW('b', 8, __s32),
+	BINDER_VERSION				= _IOWR('b', 9, struct binder_version),
+	BINDER_GET_NODE_DEBUG_INFO		= _IOWR('b', 11, struct binder_node_debug_info),
+	BINDER_GET_NODE_INFO_FOR_REF		= _IOWR('b', 12, struct binder_node_info_for_ref),
+	BINDER_SET_CONTEXT_MGR_EXT		= _IOW('b', 13, struct flat_binder_object),
+	BINDER_FREEZE				= _IOW('b', 14, struct binder_freeze_info),
+	BINDER_GET_FROZEN_INFO			= _IOWR('b', 15, struct binder_frozen_status_info),
+	BINDER_ENABLE_ONEWAY_SPAM_DETECTION	= _IOW('b', 16, __u32),
+	BINDER_GET_EXTENDED_ERROR		= _IOWR('b', 17, struct binder_extended_error),
+};
 
 /*
  * NOTE: Two special error codes you should check for when calling

base-commit: 33a1c6618677fe33f8e84cb7bedc45abbce89a50
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] binder: convert `BINDER_*` ioctl `#define`s into an `enum`
  2022-05-17 10:28 [PATCH v2] binder: convert `BINDER_*` ioctl `#define`s into an `enum` Miguel Ojeda
@ 2022-05-18 13:39 ` Miguel Ojeda
  2022-05-19 15:50   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Miguel Ojeda @ 2022-05-18 13:39 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Greg Kroah-Hartman, rust-for-linux, Arnd Bergmann,
	Masahiro Yamada, Li Li, linux-kernel, Wedson Almeida Filho

Hi Greg,

On Tue, May 17, 2022 at 12:28 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> bindgen (a tool which generates the "raw" C bindings for Rust) only
> works (so far) with "simple" C `#define`s. In order to avoid having
> to manually maintain these constants in the (potential) Rust side,
> this patch converts them into an `enum`.

Given the discussion in v1's thread [0], I think we should hold on
applying the patch (just letting you know here in v2).

[0] https://lore.kernel.org/lkml/CANiq72=_UAF5DRHCmW4qNt-Wi3yV6vPEjdLhBTijG_ZGgfpaTA@mail.gmail.com/

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] binder: convert `BINDER_*` ioctl `#define`s into an `enum`
  2022-05-18 13:39 ` Miguel Ojeda
@ 2022-05-19 15:50   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-05-19 15:50 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, rust-for-linux, Arnd Bergmann, Masahiro Yamada,
	Li Li, linux-kernel, Wedson Almeida Filho

On Wed, May 18, 2022 at 03:39:42PM +0200, Miguel Ojeda wrote:
> Hi Greg,
> 
> On Tue, May 17, 2022 at 12:28 PM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > bindgen (a tool which generates the "raw" C bindings for Rust) only
> > works (so far) with "simple" C `#define`s. In order to avoid having
> > to manually maintain these constants in the (potential) Rust side,
> > this patch converts them into an `enum`.
> 
> Given the discussion in v1's thread [0], I think we should hold on
> applying the patch (just letting you know here in v2).
> 
> [0] https://lore.kernel.org/lkml/CANiq72=_UAF5DRHCmW4qNt-Wi3yV6vPEjdLhBTijG_ZGgfpaTA@mail.gmail.com/
> 
> Cheers,
> Miguel

Yeah, I'll drop this from my queue, sorry.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-19 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-17 10:28 [PATCH v2] binder: convert `BINDER_*` ioctl `#define`s into an `enum` Miguel Ojeda
2022-05-18 13:39 ` Miguel Ojeda
2022-05-19 15:50   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox