Linux Sound subsystem development
 help / color / mirror / Atom feed
From: "Shuming [范書銘]" <shumingf@realtek.com>
To: Mark Brown <broonie@kernel.org>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-sound@vger.kernel.org" <linux-sound@vger.kernel.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"Flove(HsinFu)" <flove@realtek.com>,
	"Oder Chiou" <oder_chiou@realtek.com>,
	"Jack Yu" <jack.yu@realtek.com>,
	"Derek [方德義]" <derek.fang@realtek.com>,
	"oliva@gnu.org" <oliva@gnu.org>
Subject: RE: [PATCH] ASoC: rt1320: reads patch code from firmware file
Date: Sat, 14 Sep 2024 09:02:13 +0000	[thread overview]
Message-ID: <daf1b32a8c53434794608b0c241c2da8@realtek.com> (raw)
In-Reply-To: <2aa00670-d820-43cb-b479-c9aca7d0c243@sirena.org.uk>

> > + * The 'patch code' is written to the patch code area.
> > + * The patch code area is used for SDCA register expansion flexibility.
> > + */
> > +static void rt1320_load_mcu_patch(struct rt1320_sdw_priv *rt1320) {
> > +	struct sdw_slave *slave = rt1320->sdw_slave;
> > +	const struct firmware *patch;
> > +	char filename[128];
> > +	unsigned int addr, val;
> > +	const unsigned int *ptr;
> > +	int ret, i;
> > +
> > +	if (rt1320->version_id <= RT1320_VB)
> > +		strscpy(filename, RT1320_VAB_MCU_PATCH, sizeof(filename));
> > +	else
> > +		strscpy(filename, RT1320_VC_MCU_PATCH, sizeof(filename));
> > +
> > +	/* load the patch code here */
> > +	ret = request_firmware(&patch, filename, &slave->dev);
> 
> Why not just
> 
> 	const char *filename;
> 
> 	if (rt1320->version_id <= RT1320_VB)
> 		filename = RT1320_VAB_MCU_PATCH;
> 	else
> 		filename = RT1320_VC_MCU_PATCH;
> 
> 	ret = request_firmware(&patch, filename, &slave->dev);
> 
> (ie, what does the copy into the buffer do?)

Will fix

> > +	} else {
> > +		ptr = (const unsigned int *)patch->data;
> > +		for (i = 0; i < (patch->size / sizeof(unsigned int)); i += 2) {
> > +			addr = ptr[i];
> > +			val = ptr[i + 1];
> > +			regmap_write(rt1320->regmap, addr, val);
> > +		}
> 
> Shouldn't this be using a specifically sized type in case we build on some
> architecture where int is a different size?  We should also validate that the file
> is an even number of register/value combinations to make sure it's not corrupt,
> checking the value of regmap_write() to make sure the register numbers are
> OK would probably be good.

Thanks for reviewing. Will update the v2 patch.

      reply	other threads:[~2024-09-14  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-13  8:27 [PATCH] ASoC: rt1320: reads patch code from firmware file shumingf
2024-09-13 15:52 ` Mark Brown
2024-09-14  9:02   ` Shuming [范書銘] [this message]

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=daf1b32a8c53434794608b0c241c2da8@realtek.com \
    --to=shumingf@realtek.com \
    --cc=broonie@kernel.org \
    --cc=derek.fang@realtek.com \
    --cc=flove@realtek.com \
    --cc=jack.yu@realtek.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=oliva@gnu.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