Thread (12 messages) 12 messages, 5 authors, 2020-03-30

Re: [PATCH v3 2/2] net: phy: add marvell usb to mdio controller

From: "Tobias Waldekranz" <tobias@waldekranz.com>
Date: 2020-03-22 09:09:34
Also in: linux-usb

On Sun Mar 22, 2020 at 8:40 AM, Greg KH wrote:
From a USB point of view, it looks sane, only one question:
Great, thanks for the review.
quoted
+static int mvusb_mdio_probe(struct usb_interface *interface,
+			    const struct usb_device_id *id)
+{
+	struct device *dev = &interface->dev;
+	struct mvusb_mdio *mvusb;
+	struct mii_bus *mdio;
+
+	mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb));

You allocate a bigger buffer here than the original pointer thinks it is
pointing to?
Yes. I've seen this pattern in a couple of places in the kernel,
e.g. alloc_netdev also does this. The object is extended with the
requested size, and the offset is stored somewhere for later use by
the driver.
quoted
+	if (!mdio)
+		return -ENOMEM;
+
+	mvusb = mdio->priv;

And then you set this pointer here?
...in this case in the priv member.

https://code.woboq.org/linux/linux/drivers/net/phy/mdio_bus.c.html#143

Thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help