linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Jay Fang <f.fangjian@huawei.com>
Cc: linux-spi@vger.kernel.org, broonie@kernel.org, huangdaode@huawei.com
Subject: Re: [PATCH] spi: Add HiSilicon SPI controller driver support
Date: Mon, 8 Mar 2021 09:06:28 +0100	[thread overview]
Message-ID: <20210308080628.GA16403@wunner.de> (raw)
In-Reply-To: <331fa0f5-7052-0dac-e375-df25789c56b6@huawei.com>

On Mon, Mar 08, 2021 at 11:57:17AM +0800, Jay Fang wrote:
> On 2021/3/7 22:36, Lukas Wunner wrote:
> > On Mon, Mar 01, 2021 at 07:56:11PM +0800, Jay Fang wrote:
> > > +static int hisi_spi_setup(struct spi_device *spi)
> > > +{
> > > +	struct hisi_spi *hs = spi_controller_get_devdata(spi->controller);
> > > +	struct hisi_chip_data *chip;
> > > +
> > > +	/* Only alloc on first setup */
> > > +	chip = spi_get_ctldata(spi);
> > > +	if (!chip) {
> > > +		chip = kzalloc(sizeof(*chip), GFP_KERNEL);
> > > +		if (!chip)
> > > +			return -ENOMEM;
> > > +		spi_set_ctldata(spi, chip);
> > > +	}
> > [...]
> > > +	master = devm_spi_alloc_master(dev, 0);
> > 
> > It would seem simpler to just pass "sizeof struct hisi_chip_data"
> > to devm_spi_alloc_master(), thus obviating the need to allocate
> > it on first invocation of the ->setup hook.
> 
> Thanks for your review. "struct hisi_chip_data" is the private data
> of per-spi device, not the spi controller. So I think this method
> is not suitable here. Maybe we can allocate "struct hisi_spi" in
> this way.

Ah, I was mistaken then.  Yes, allocating struct hisi_spi with
devm_spi_alloc_master() would probably make sense.

Thanks,

Lukas

      reply	other threads:[~2021-03-08  8:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 11:56 [PATCH] spi: Add HiSilicon SPI controller driver support Jay Fang
2021-03-01 13:54 ` Mark Brown
2021-03-04  6:54   ` Fangjian (Jay)
     [not found]   ` <79a0bb79-654b-8afc-f34a-c3a08bae275c@huawei.com>
2021-03-04 12:34     ` Mark Brown
2021-03-08 11:24       ` Jay Fang
2021-03-07 14:43   ` Lukas Wunner
2021-03-08 14:11     ` Mark Brown
2021-03-08 18:18       ` Lukas Wunner
2021-03-08 18:28         ` Mark Brown
2021-03-09  9:13     ` Jay Fang
2021-03-07 14:36 ` Lukas Wunner
2021-03-08  3:57   ` Jay Fang
2021-03-08  8:06     ` Lukas Wunner [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=20210308080628.GA16403@wunner.de \
    --to=lukas@wunner.de \
    --cc=broonie@kernel.org \
    --cc=f.fangjian@huawei.com \
    --cc=huangdaode@huawei.com \
    --cc=linux-spi@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).