Am 09.08.2018 um 23:06 schrieb Ben Whitten:
> On Thu, 9 Aug 2018 at 21:43, Andreas Färber <afaer...@suse.de> wrote:
>> Am 09.08.2018 um 14:33 schrieb Ben Whitten:
>>> @@ -654,22 +646,35 @@ static int sx1301_probe(struct spi_device *spi)
>>>       priv->rst_gpio = rst;
>>>       priv->cur_page = 0xff;
>>>
>>> -     spi_set_drvdata(spi, netdev);
>>> +     spi_set_drvdata(spi, priv);
>>
>> This change seems unnecessary and counter-productive for unregistration.
>>
>> Otherwise applying.
> 
> This is actually pretty critical, as it stands with the two spi masters we use
> spi_get_drvdata on the parent device of the controller to recover the priv
> struct for regmap.
> 
> We may have to include the netdev in the priv data, or do a container_of
> dance to recover netdev in unregistration.
> That said if we wrap things in devm then really our remove function could
> be empty, as we have done with the allocation.

Thanks for quickly noticing. This should compensate:

diff --git a/drivers/net/lora/sx1301.c b/drivers/net/lora/sx1301.c
index 0ba841f8e7cd..43cd2308e41c 100644
--- a/drivers/net/lora/sx1301.c
+++ b/drivers/net/lora/sx1301.c
@@ -164,7 +164,8 @@ static int sx1301_soft_reset(struct sx1301_priv *priv)
 static int sx1301_radio_set_cs(struct spi_controller *ctrl, bool enable)
 {
        struct spi_sx1301 *ssx = spi_controller_get_devdata(ctrl);
-       struct sx1301_priv *priv = spi_get_drvdata(ssx->parent);
+       struct net_device *netdev = spi_get_drvdata(ssx->parent);
+       struct sx1301_priv *priv = netdev_priv(netdev);
        u8 cs;
        int ret;

@@ -204,7 +205,8 @@ static int sx1301_radio_spi_transfer_one(struct
spi_controller *ctrl,
        struct spi_device *spi, struct spi_transfer *xfr)
 {
        struct spi_sx1301 *ssx = spi_controller_get_devdata(ctrl);
-       struct sx1301_priv *priv = spi_get_drvdata(ssx->parent);
+       struct net_device *netdev = spi_get_drvdata(ssx->parent);
+       struct sx1301_priv *priv = netdev_priv(netdev);
        const u8 *tx_buf = xfr->tx_buf;
        u8 *rx_buf = xfr->rx_buf;
        int ret;

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

Reply via email to