mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Baolin Wang <baolin.wang@spreadtrum.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 2/2] mfd: Add Spreadtrum SC27xx series PMICs driver
Date: Tue, 24 Oct 2017 11:37:18 +0100	[thread overview]
Message-ID: <20171024103718.jz2mvikg6klzs7un@dell> (raw)
In-Reply-To: <CAMz4kuJ1SV0yv-mAbWiGZN15OoYxXap3-CEvVoDCkZwr7MJK9w@mail.gmail.com>

On Tue, 24 Oct 2017, Baolin Wang wrote:

> Hi Lee,
> 
> On 24 October 2017 at 17:26, Lee Jones <lee.jones@linaro.org> wrote:
> > On Mon, 16 Oct 2017, Baolin Wang wrote:
> >
> >> This patch adds support for Spreadtrum SC27xx series PMIC MFD core, and It
> >> provides communication through the SPI interfaces. The SC27xx series PMICs
> >> contains the following 6 major components:
> >> - DCDCs
> >> - LDOs
> >> - Battery management system
> >> - Audio codec
> >> - User interface function, such as indicator, flash LED
> >> - IC level function, such as power on/off, type-c
> >>
> >> Signed-off-by: Baolin Wang <baolin.wang@spreadtrum.com>
> >> ---
> >> Changes since v1:
> >>  - Re-order the including head files.
> >>  - Add one condition to check register size and value size when reading.
> >>  - Fix some coding style issues.
> >> ---
> >>  drivers/mfd/Kconfig           |   10 ++
> >>  drivers/mfd/Makefile          |    1 +
> >>  drivers/mfd/sprd-sc27xx-spi.c |  264 +++++++++++++++++++++++++++++++++++++++++
> >>  3 files changed, 275 insertions(+)
> >>  create mode 100644 drivers/mfd/sprd-sc27xx-spi.c

[...]

> >> +static int sprd_pmic_spi_read(void *context,
> >> +                           const void *reg, size_t reg_size,
> >> +                           void *val, size_t val_size)
> >> +{
> >> +     struct device *dev = context;
> >> +     struct spi_device *spi = to_spi_device(dev);
> >> +     u32 rx_buf[2] = { 0 };
> >> +     int ret;
> >> +
> >> +     /* Now we only support one PMIC register to read every time. */
> >> +     if (reg_size != sizeof(u32) || val_size != sizeof(u32))
> >> +             return -EINVAL;
> >> +
> >> +     rx_buf[0] = *(u32 *)reg;
> >
> > This looks dodgy.  You should not be doing raw memory manipulation.
> >
> > You need to be passing __iomem and using one of the predefined APIs
> > (i.e. readl) on it.
> 
> Sorry, I did not get you here. The 'reg' parameter is just one PMIC
> register offset which want to be read. We do not need to pass __iomem
> to SPI master driver, we just pass one register offset address to our
> SPI master driver then the SPI master driver will handle to read
> values from our PMIC.

You should not be referencing the value at 'reg' manually:

rx_buf[0] = readl(reg);

[...]

> >> +static struct spi_driver sprd_pmic_driver = {
> >> +     .driver = {
> >> +             .name = "sc27xx-pmic",
> >> +             .bus = &spi_bus_type,
> >> +             .of_match_table = sprd_pmic_match,
> >
> > of_match_ptr()?
> 
> The of_match_ptr() did nothing, so I think it is not necessary.

What do you mean?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2017-10-24 10:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 12:03 [PATCH v2 1/2] dt-bindings: mfd: Add Spreadtrum SC27xx PMIC documentation Baolin Wang
2017-10-16 12:03 ` [PATCH v2 2/2] mfd: Add Spreadtrum SC27xx series PMICs driver Baolin Wang
2017-10-24  9:26   ` Lee Jones
2017-10-24  9:59     ` Baolin Wang
2017-10-24 10:37       ` Lee Jones [this message]
2017-10-25  2:17         ` Baolin Wang
2017-10-23 14:21 ` [PATCH v2 1/2] dt-bindings: mfd: Add Spreadtrum SC27xx PMIC documentation Lee Jones
2017-10-23 22:41 ` Rob Herring
2017-10-24  1:35   ` Baolin Wang

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=20171024103718.jz2mvikg6klzs7un@dell \
    --to=lee.jones@linaro.org \
    --cc=baolin.wang@linaro.org \
    --cc=baolin.wang@spreadtrum.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@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

all inboxes | Powered by JetHome®