From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net: designware: rockchip: future-proof driver for more SoCs
Date: Fri, 17 Jun 2022 09:31:29 +0200 [thread overview]
Message-ID: <20220617073129.GI1615@pengutronix.de> (raw)
In-Reply-To: <20220615080305.954879-1-a.fatoum@pengutronix.de>
On Wed, Jun 15, 2022 at 10:03:05AM +0200, Ahmad Fatoum wrote:
> Linux driver has a struct rk_gmac_ops::regs_valid member to mark
> whether regs is populated or not. Population happens via a GCC
> extension that allows static initialization of flexible array
> members. Replace that with a pointer that is checked, so future
> SoC support just initializes it to NULL by default and avoid
> the OOB access.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/net/designware_rockchip.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/net/designware_rockchip.c b/drivers/net/designware_rockchip.c
> index dcf65c9ad4cc..a3859dce0c62 100644
> --- a/drivers/net/designware_rockchip.c
> +++ b/drivers/net/designware_rockchip.c
> @@ -21,7 +21,7 @@ struct rk_gmac_ops {
> void (*set_rmii_speed)(struct eqos *eqos, int speed);
> void (*set_rgmii_speed)(struct eqos *eqos, int speed);
> void (*integrated_phy_powerup)(struct eqos *eqos);
> - u32 regs[];
> + const u32 *regs;
> };
>
> struct eqos_rk_gmac {
> @@ -175,7 +175,7 @@ static const struct rk_gmac_ops rk3568_ops = {
> .set_to_rmii = rk3568_set_to_rmii,
> .set_rmii_speed = rk3568_set_gmac_speed,
> .set_rgmii_speed = rk3568_set_gmac_speed,
> - .regs = {
> + .regs = (u32 []) {
> 0xfe2a0000, /* gmac0 */
> 0xfe010000, /* gmac1 */
> 0x0, /* sentinel */
> @@ -253,7 +253,7 @@ static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
>
> priv->ops = device_get_match_data(dev);
>
> - if (dev->num_resources > 0) {
> + if (dev->num_resources > 0 && priv->ops->regs) {
> while (priv->ops->regs[i]) {
> if (priv->ops->regs[i] == dev->resource[0].start) {
> priv->bus_id = i;
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2022-06-17 7:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 8:03 Ahmad Fatoum
2022-06-17 7:31 ` Sascha Hauer [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=20220617073129.GI1615@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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