netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Whitten <benwhitten@gmail.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: 潘建宏 <starnight@g.ncu.edu.tw>,
	hasnain.virk@arm.com, netdev@vger.kernel.org,
	"Xue Liu" <liuxuenetmail@gmail.com>,
	shess@hessware.de, "Ben Whitten" <ben.whitten@lairdtech.com>
Subject: Re: [PATCH lora-next v2 3/8] net: lora: sx1301: convert to passing priv data throughout
Date: Thu, 9 Aug 2018 22:06:19 +0100	[thread overview]
Message-ID: <CAF3==is4CLr5faEyzB2ADbsDXWD8A4eca73+CHZvPTkY81yqDQ@mail.gmail.com> (raw)
In-Reply-To: <3884a134-c916-7b30-1db3-1e2c8f0d9d5b@suse.de>

On Thu, 9 Aug 2018 at 21:43, Andreas Färber <afaerber@suse.de> wrote:
>
> Am 09.08.2018 um 14:33 schrieb Ben Whitten:
> > Instead of passing around the spi device we instead pass around our
> > driver data directly.
> >
> > Signed-off-by: Ben Whitten <ben.whitten@lairdtech.com>
> > ---
> >  drivers/net/lora/sx1301.c | 305 +++++++++++++++++++++++-----------------------
> >  1 file changed, 155 insertions(+), 150 deletions(-)
> >
> > diff --git a/drivers/net/lora/sx1301.c b/drivers/net/lora/sx1301.c
> > index 3c09f5a..7324001 100644
> > --- a/drivers/net/lora/sx1301.c
> > +++ b/drivers/net/lora/sx1301.c
> > @@ -73,24 +73,26 @@ struct spi_sx1301 {
> >  };
> >
> >  struct sx1301_priv {
> > +     struct device           *dev;
> > +     struct spi_device       *spi;
>
> Obviously this is not a long-term solution, but as interim step it'll
> have to do.
>
> >       struct lora_priv lora;
> >       struct gpio_desc *rst_gpio;
> >       u8 cur_page;
> >       struct spi_controller *radio_a_ctrl, *radio_b_ctrl;
> >  };
> >
> > -static int sx1301_read_burst(struct spi_device *spi, u8 reg, u8 *val, size_t len)
> > +static int sx1301_read_burst(struct sx1301_priv *priv, u8 reg, u8 *val, size_t len)
> >  {
> >       u8 addr = reg & 0x7f;
> > -     return spi_write_then_read(spi, &addr, 1, val, len);
> > +     return spi_write_then_read(priv->spi, &addr, 1, val, len);
> >  }
> >
> > -static int sx1301_read(struct spi_device *spi, u8 reg, u8 *val)
> > +static int sx1301_read(struct sx1301_priv *priv, u8 reg, u8 *val)
> >  {
> > -     return sx1301_read_burst(spi, reg, val, 1);
> > +     return sx1301_read_burst(priv, reg, val, 1);
> >  }
> >
> > -static int sx1301_write_burst(struct spi_device *spi, u8 reg, const u8 *val, size_t len)
> > +static int sx1301_write_burst(struct sx1301_priv *priv, u8 reg, const u8 *val, size_t len)
> >  {
> >       u8 addr = reg | BIT(7);
> >       struct spi_transfer xfr[2] = {
>
> This hunk did not apply for some reason, I've manually re-applied it.
>
> [...]
> > @@ -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.

Regards,
Ben

  reply	other threads:[~2018-08-09 23:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 12:33 [PATCH lora-next v2 1/8] net: lora: add methods for devm registration Ben Whitten
2018-08-09 12:33 ` [PATCH lora-next v2 2/8] net: lora: sx1301: convert to devm registration of netdev Ben Whitten
2018-08-09 19:27   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 3/8] net: lora: sx1301: convert to passing priv data throughout Ben Whitten
2018-08-09 20:43   ` Andreas Färber
2018-08-09 21:06     ` Ben Whitten [this message]
2018-08-09 21:21       ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 4/8] net: lora: sx1301: convert load_firmware to take firmware directly Ben Whitten
2018-08-09 20:48   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 5/8] net: lora: sx1301: remove duplicate firmware size checks Ben Whitten
2018-08-09 20:58   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 6/8] net: lora: sx1301: replace version and size magic numbers with defines Ben Whitten
2018-08-09 21:11   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 7/8] net: lora: sx1301: add initial registration for regmap Ben Whitten
2018-08-09 21:58   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 8/8] net: lora: sx1301: convert driver over to regmap reads and writes Ben Whitten
2018-08-09 22:34   ` Andreas Färber
2018-08-09 22:47     ` Ben Whitten
2018-08-10  0:17       ` Andreas Färber
2018-08-09 19:18 ` [PATCH lora-next v2 1/8] net: lora: add methods for devm registration Andreas Färber

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='CAF3==is4CLr5faEyzB2ADbsDXWD8A4eca73+CHZvPTkY81yqDQ@mail.gmail.com' \
    --to=benwhitten@gmail.com \
    --cc=afaerber@suse.de \
    --cc=ben.whitten@lairdtech.com \
    --cc=hasnain.virk@arm.com \
    --cc=liuxuenetmail@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shess@hessware.de \
    --cc=starnight@g.ncu.edu.tw \
    /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;
as well as URLs for NNTP newsgroup(s).