mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Daniel Danzberger <dd@embedd.com>
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
	f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: Re: [PATCH net-next 1/2] net: dsa: microchip: properly support platform_data probing
Date: Wed, 6 Dec 2023 16:42:52 +0100	[thread overview]
Message-ID: <9d2bc0a2-1ef9-4e42-82ac-e5c1b2af90c9@lunn.ch> (raw)
In-Reply-To: <20231205164231.1863020-1-dd@embedd.com>

On Tue, Dec 05, 2023 at 05:42:30PM +0100, Daniel Danzberger wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> The ksz driver has bits and pieces of platform_data probing support, but
> it doesn't work.
> 
> The conventional thing to do is to have an encapsulating structure for
> struct dsa_chip_data that gets put into dev->platform_data. This driver
> expects a struct ksz_platform_data, but that doesn't contain a struct
> dsa_chip_data as first element, which will obviously not work with
> dsa_switch_probe() -> dsa_switch_parse().
> 
> Pointing dev->platform_data to a struct dsa_chip_data directly is in
> principle possible, but that doesn't work either. The driver has
> ksz_switch_detect() to read the device ID from hardware, followed by
> ksz_check_device_id() to compare it against a predetermined expected
> value. This protects against early errors in the SPI/I2C communication.
> With platform_data, the mechanism in ksz_check_device_id() doesn't work
> and even leads to NULL pointer dereferences, since of_device_get_match_data()
> doesn't work in that probe path.
> 
> So obviously, the platform_data support is actually missing, and the
> existing handling of struct ksz_platform_data is bogus. Complete the
> support by adding a struct dsa_chip_data as first element, and fixing up
> ksz_check_device_id() to pick up the platform_data instead of the
> unavailable of_device_get_match_data().
> 
> The early dev->chip_id assignment from ksz_switch_register() is also
> bogus, because ksz_switch_detect() sets it to an initial value. So
> remove it.
> 
> Also, ksz_platform_data :: enabled_ports isn't used anywhere, delete it.
> 
> Link: https://lore.kernel.org/netdev/20231204154315.3906267-1-dd@embedd.com/
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Daniel Danzberger <dd@embedd.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

  parent reply	other threads:[~2023-12-06 15:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 16:42 Daniel Danzberger
2023-12-05 16:42 ` [PATCH net-next 2/2] net: dsa: microchip: move ksz_chip_id enum to platform include Daniel Danzberger
2023-12-06 15:42   ` Andrew Lunn
2023-12-06 15:42 ` Andrew Lunn [this message]
2023-12-07 12:10 ` [PATCH net-next 1/2] net: dsa: microchip: properly support platform_data probing patchwork-bot+netdevbpf

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=9d2bc0a2-1ef9-4e42-82ac-e5c1b2af90c9@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=dd@embedd.com \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=woojung.huh@microchip.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

all inboxes | Powered by JetHome®