Re: git: 682b069c5c56 - main - iicbus: add compat32 support for I2C ioctls

From: Jessica Clarke <jrtc27_at_freebsd.org>
Date: Fri, 01 Dec 2023 02:01:12 UTC
On 1 Dec 2023, at 01:33, Stephen J. Kiernan <stevek@FreeBSD.org> wrote:
> 
> The branch main has been updated by stevek:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=682b069c5c5643d26199cc1b65717f99c98bce9d
> 
> commit 682b069c5c5643d26199cc1b65717f99c98bce9d
> Author:     Stephen J. Kiernan <stevek@FreeBSD.org>
> AuthorDate: 2023-11-29 19:20:45 +0000
> Commit:     Stephen J. Kiernan <stevek@FreeBSD.org>
> CommitDate: 2023-12-01 01:33:46 +0000
> 
>    iicbus: add compat32 support for I2C ioctls
> 
>    Some of the I2C ioctl request structures contain pointers and need to
>    handle requests from 32-bit applications on 64-bit kernels.
> 
>    Obtained from:  Juniper Networks, Inc.
>    Differential Revision:  https://reviews.freebsd.org/D42836
> ---
> sys/dev/iicbus/iic.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 108 insertions(+), 3 deletions(-)
> 
> diff --git a/sys/dev/iicbus/iic.c b/sys/dev/iicbus/iic.c
> index baaa7a096a14..8c9dbb6bc145 100644
> --- a/sys/dev/iicbus/iic.c
> +++ b/sys/dev/iicbus/iic.c
> @@ -2,6 +2,7 @@
>  * SPDX-License-Identifier: BSD-2-Clause
>  *
>  * Copyright (c) 1998, 2001 Nicolas Souchu
> + * Copyright (c) 2023 Juniper Networks, Inc.
>  * All rights reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
> @@ -27,6 +28,7 @@
>  *
>  */
> #include <sys/param.h>
> +#include <sys/abi_compat.h>
> #include <sys/bus.h>
> #include <sys/conf.h>
> #include <sys/fcntl.h>
> @@ -57,6 +59,30 @@ struct iic_cdevpriv {
> uint8_t addr;
> };
> 
> +#ifdef COMPAT_FREEBSD32
> +struct iic_msg32 {
> + uint16_t slave;
> + uint16_t flags;
> + uint16_t len;
> + uint32_t buf;
> +};
> +
> +struct iiccmd32 {
> + u_char slave;
> + uint32_t count;
> + uint32_t last;
> + uint32_t buf;
> +};
> +
> +struct iic_rdwr_data32 {
> + uint32_t msgs;
> + uint32_t nmsgs;
> +};
> +
> +#define I2CWRITE32 _IOW('i', 4, struct iiccmd32)
> +#define I2CREAD32 _IOW('i', 5, struct iiccmd32)
> +#define I2CRDWR32 _IOW('i', 6, struct iic_rdwr_data32)
> +#endif

Like I said for smbus, please use _IOC_NEWTYPE.

Jess