linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dominique Martinet <dominique.martinet@atmark-techno.com>
To: Adam Ford <aford173@gmail.com>
Cc: linux-phy@lists.infradead.org, linux-imx@nxp.com,
	festevam@gmail.com, frieder.schrempf@kontron.de,
	aford@beaconembedded.com, "Vinod Koul" <vkoul@kernel.org>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Marco Felsch" <m.felsch@pengutronix.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lucas Stach" <l.stach@pengutronix.de>,
	linux-kernel@vger.kernel.org,
	"Makoto Sato" <makoto.sato@atmark-techno.com>
Subject: Re: [RFC V3 3/3] phy: freescale: fsl-samsung-hdmi: Support dynamic integer
Date: Tue, 3 Sep 2024 09:47:06 +0900	[thread overview]
Message-ID: <ZtZcit7HVzzedgdk@atmark-techno.com> (raw)
In-Reply-To: <CAHCN7xJL-aS+kFp2YwtSSUUMoTBqZCsXb0qvCpYQGpJVM_qJYg@mail.gmail.com>

Adam Ford wrote on Mon, Sep 02, 2024 at 04:20:11PM -0500:
> > -       const struct phy_config *cur_cfg;
> > +       struct phy_config cur_cfg;
> 
> Wouldn't converting this from a pointer require me to do a memcpy
> later?  It seems like that's more work than just pointing it to an
> address.
> 
> > -       phy->cur_cfg = &phy_pll_cfg[i];
> > +       phy->cur_cfg = phy_pll_cfg[i];
> 
> I think this is would have to be a memcpy instead of just an equal
> statement since phy->cur_cfg  would no longer be a pointer.

C allows copying structs like this, it's fine to write it as just an
equal.
It's not 100% equivalent, iiuc simple assignment is undefined behaviour
if the elements aren't aligned but memcpy will work even in that case,
but for us this is not a proble mand the generated code should be
identical... Also note I'm only suggesting that because the struct is
tiny (1*u32+7*u8 is less than two u64), but this code isn't meant to run
very often anyway so we should prioritize readability -- if you think
it's harder to understand than an extra pointer somewhere I have no
strong opinion; as said in the previous mail if parallel uses are
possible it'd be better kept on the stack anyway...

-- 
Dominique



-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2024-09-03  0:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30  3:24 [RFC V3 1/3] phy: freescale: fsl-samsung-hdmi: Replace register defines with macro Adam Ford
2024-08-30  3:24 ` [RFC V3 2/3] phy: freescale: fsl-samsung-hdmi: Simplify REG21_PMS_S_MASK lookup Adam Ford
2024-08-30  3:24 ` [RFC V3 3/3] phy: freescale: fsl-samsung-hdmi: Support dynamic integer Adam Ford
2024-08-30  5:56   ` Dominique Martinet
2024-08-30 15:04     ` Adam Ford
2024-09-01 21:46       ` Dominique Martinet
2024-09-02 21:20     ` Adam Ford
2024-09-03  0:47       ` Dominique Martinet [this message]
2024-09-03  1:20         ` Adam Ford

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=ZtZcit7HVzzedgdk@atmark-techno.com \
    --to=dominique.martinet@atmark-techno.com \
    --cc=aford173@gmail.com \
    --cc=aford@beaconembedded.com \
    --cc=festevam@gmail.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=kishon@kernel.org \
    --cc=l.stach@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    --cc=makoto.sato@atmark-techno.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vkoul@kernel.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).