netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Peter Hilber <quic_philber@quicinc.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Trilok Soni" <quic_tsoni@quicinc.com>,
	"Srivatsa Vaddagiri" <quic_svaddagi@quicinc.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Richard Cochran" <richardcochran@gmail.com>,
	linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
	netdev@vger.kernel.org, "David Woodhouse" <dwmw2@infradead.org>,
	"Ridoux, Julien" <ridouxj@amazon.com>,
	"Marc Zyngier" <maz@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Daniel Lezcano" <daniel.lezcano@linaro.org>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Parav Pandit" <parav@nvidia.com>,
	"Matias Ezequiel Vara Larsen" <mvaralar@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	virtio-dev@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH v5 1/4] virtio_rtc: Add module and driver core
Date: Mon, 24 Feb 2025 17:55:27 +0000	[thread overview]
Message-ID: <20250224175527.GF1615191@kernel.org> (raw)
In-Reply-To: <20250219193306.1045-2-quic_philber@quicinc.com>

On Wed, Feb 19, 2025 at 08:32:56PM +0100, Peter Hilber wrote:

...

> +/**
> + * VIORTC_MSG() - extract message from message handle
> + * @hdl: message handle
> + *
> + * Return: struct viortc_msg
> + */
> +#define VIORTC_MSG(hdl) ((hdl).msg)
> +
> +/**
> + * VIORTC_MSG_INIT() - initialize message handle
> + * @hdl: message handle
> + * @viortc: device data (struct viortc_dev *)
> + *
> + * Context: Process context.
> + * Return: 0 on success, -ENOMEM otherwise.
> + */
> +#define VIORTC_MSG_INIT(hdl, viortc)                                         \
> +	({                                                                   \
> +		typeof(hdl) *_hdl = &(hdl);                                  \
> +									     \
> +		_hdl->msg = viortc_msg_init((viortc), _hdl->msg_type,        \
> +					    _hdl->req_size, _hdl->resp_cap); \
> +		if (_hdl->msg) {                                             \
> +			_hdl->req = _hdl->msg->req;                          \
> +			_hdl->resp = _hdl->msg->resp;                        \
> +		}                                                            \
> +		_hdl->msg ? 0 : -ENOMEM;                                     \
> +	})
> +
> +/**
> + * VIORTC_MSG_WRITE() - write a request message field
> + * @hdl: message handle
> + * @dest_member: request message field name
> + * @src_ptr: pointer to data of compatible type
> + *
> + * Writes the field in little-endian format.
> + */
> +#define VIORTC_MSG_WRITE(hdl, dest_member, src_ptr)                         \
> +	do {                                                                \
> +		typeof(hdl) _hdl = (hdl);                                   \
> +		typeof(src_ptr) _src_ptr = (src_ptr);                       \
> +									    \
> +		/* Sanity check: must match the member's type */            \
> +		typecheck(typeof(_hdl.req->dest_member), *_src_ptr);        \

Hi Peter,

FWIIW, this trips up sparse because from it's perspective
there is an endianness mismatch between the two types.

> +									    \
> +		_hdl.req->dest_member =                                     \
> +			virtio_cpu_to_le(*_src_ptr, _hdl.req->dest_member); \
> +	} while (0)
> +
> +/**
> + * VIORTC_MSG_READ() - read from a response message field
> + * @hdl: message handle
> + * @src_member: response message field name
> + * @dest_ptr: pointer to data of compatible type
> + *
> + * Converts from little-endian format and writes to dest_ptr.
> + */
> +#define VIORTC_MSG_READ(hdl, src_member, dest_ptr)                     \
> +	do {                                                           \
> +		typeof(dest_ptr) _dest_ptr = (dest_ptr);               \
> +								       \
> +		/* Sanity check: must match the member's type */       \
> +		typecheck(typeof((hdl).resp->src_member), *_dest_ptr); \

Ditto.

> +								       \
> +		*_dest_ptr = virtio_le_to_cpu((hdl).resp->src_member); \
> +	} while (0)
> +
> +/*
> + * read requests
> + */

...

  reply	other threads:[~2025-02-24 17:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 19:32 [PATCH v5 0/4] Add virtio_rtc module Peter Hilber
2025-02-19 19:32 ` [PATCH v5 1/4] virtio_rtc: Add module and driver core Peter Hilber
2025-02-24 17:55   ` Simon Horman [this message]
2025-02-25 12:25     ` Peter Hilber
2025-02-19 19:32 ` [PATCH v5 2/4] virtio_rtc: Add PTP clocks Peter Hilber
2025-02-24 17:56   ` Simon Horman
2025-02-25 11:28     ` Peter Hilber
2025-02-25 14:12       ` Simon Horman
2025-02-25 14:21         ` Michael S. Tsirkin
2025-02-19 19:32 ` [PATCH v5 3/4] virtio_rtc: Add Arm Generic Timer cross-timestamping Peter Hilber
2025-02-25 12:18 ` [PATCH v5 0/4] Add virtio_rtc module Michael S. Tsirkin
2025-02-25 12:34   ` Peter Hilber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250224175527.GF1615191@kernel.org \
    --to=horms@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=cohuck@redhat.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=dwmw2@infradead.org \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mst@redhat.com \
    --cc=mvaralar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=parav@nvidia.com \
    --cc=quic_philber@quicinc.com \
    --cc=quic_svaddagi@quicinc.com \
    --cc=quic_tsoni@quicinc.com \
    --cc=richardcochran@gmail.com \
    --cc=ridouxj@amazon.com \
    --cc=virtio-dev@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).