From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net,
qemu-devel@nongnu.org
Subject: Re: [PATCH 08/10] esp: convert ESPState pdma_cb from a function pointer to an integer
Date: Tue, 1 Mar 2022 00:10:24 +0100 [thread overview]
Message-ID: <f4927d00-f37a-3970-37ba-40e672154c0d@gmail.com> (raw)
In-Reply-To: <20220228222527.8234-9-mark.cave-ayland@ilande.co.uk>
On 28/2/22 23:25, Mark Cave-Ayland wrote:
> This prepares for the inclusion of the current PDMA callback in the migration
> stream since the callback is referenced by an integer instead of a function
> pointer.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
> hw/scsi/esp.c | 47 ++++++++++++++++++++++++++++++-------------
> include/hw/scsi/esp.h | 11 +++++++++-
> 2 files changed, 43 insertions(+), 15 deletions(-)
>
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index 035fb0d1f6..e8b6f25dbb 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -195,14 +195,10 @@ static void esp_pdma_write(ESPState *s, uint8_t val)
> esp_set_tc(s, dmalen);
> }
>
> -static void esp_set_pdma_cb(ESPState *s, void (*cb)(ESPState *))
> +static void esp_set_pdma_cb(ESPState *s, int pdma_cb)
Why signed?
> {
> - s->pdma_cb = cb;
> -}
> -
> -static void esp_pdma_cb(ESPState *s)
> -{
> - s->pdma_cb(s);
> + assert(pdma_cb >= 0 && pdma_cb < PDMA_NUM_CBS);
No need to check >=0 if using unsigned.
> + s->pdma_cb = pdma_cb;
> }
> +static void esp_pdma_cb(ESPState *s)
> +{
> + switch (s->pdma_cb) {
> + case PDMA_SATN_PDMA_CB:
> + satn_pdma_cb(s);
> + break;
> + case PDMA_S_WITHOUT_SATN_PDMA_CB:
> + s_without_satn_pdma_cb(s);
> + break;
> + case PDMA_SATN_STOP_PDMA_CB:
> + satn_stop_pdma_cb(s);
> + break;
> + case PDMA_WRITE_RESPONSE_PDMA_CB:
> + write_response_pdma_cb(s);
> + break;
> + case PDMA_DO_DMA_PDMA_CB:
> + do_dma_pdma_cb(s);
> + break;
> + default:
> + g_assert_not_reached();
> + }
> +}
> +
> index b1ec27612f..885ccf4660 100644
> --- a/include/hw/scsi/esp.h
> +++ b/include/hw/scsi/esp.h
> @@ -51,7 +51,7 @@ struct ESPState {
> ESPDMAMemoryReadWriteFunc dma_memory_write;
> void *dma_opaque;
> void (*dma_cb)(ESPState *s);
> - void (*pdma_cb)(ESPState *s);
> + uint8_t pdma_cb;
And here you use unsigned :)
> uint8_t mig_version_id;
>
> @@ -150,6 +150,15 @@ struct SysBusESPState {
> #define TCHI_FAS100A 0x4
> #define TCHI_AM53C974 0x12
>
> +/* PDMA callbacks */
> +#define PDMA_SATN_PDMA_CB 0
> +#define PDMA_S_WITHOUT_SATN_PDMA_CB 1
> +#define PDMA_SATN_STOP_PDMA_CB 2
> +#define PDMA_WRITE_RESPONSE_PDMA_CB 3
> +#define PDMA_DO_DMA_PDMA_CB 4
I'd rather use an enum (and in esp_pdma_cb's switch).
> +#define PDMA_NUM_CBS 5
> +
> void esp_dma_enable(ESPState *s, int irq, int level);
> void esp_request_cancelled(SCSIRequest *req);
> void esp_command_complete(SCSIRequest *req, size_t resid);
Preferrably using unsigned:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
next prev parent reply other threads:[~2022-02-28 23:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 22:25 [PATCH 00/10] q800: migration fixes Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 01/10] macfb: add VMStateDescription for MacfbNubusState and MacfbSysBusState Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 02/10] macfb: don't use special irq_state and irq_mask variables in MacfbState Mark Cave-Ayland
2022-02-28 23:11 ` Philippe Mathieu-Daudé
2022-02-28 22:25 ` [PATCH 03/10] macfb: increase number of registers saved " Mark Cave-Ayland
2022-03-02 9:11 ` Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 04/10] macfb: add VMStateDescription fields for display type and VBL timer Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 05/10] macfb: set initial value of mode control registers in macfb_common_realize() Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 06/10] esp: introduce esp_set_pdma_cb() function Mark Cave-Ayland
2022-02-28 23:06 ` Philippe Mathieu-Daudé
2022-02-28 22:25 ` [PATCH 07/10] esp: introduce esp_pdma_cb() function Mark Cave-Ayland
2022-02-28 23:06 ` Philippe Mathieu-Daudé
2022-02-28 22:25 ` [PATCH 08/10] esp: convert ESPState pdma_cb from a function pointer to an integer Mark Cave-Ayland
2022-02-28 23:10 ` Philippe Mathieu-Daudé [this message]
2022-03-02 9:17 ` Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 09/10] esp: include the current PDMA callback in the migration stream Mark Cave-Ayland
2022-02-28 22:25 ` [PATCH 10/10] esp: recreate ESPState current_req after migration Mark Cave-Ayland
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=f4927d00-f37a-3970-37ba-40e672154c0d@gmail.com \
--to=philippe.mathieu.daude@gmail.com \
--cc=fam@euphon.net \
--cc=laurent@vivier.eu \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).