From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Chris Healy <cphealy@gmail.com>,
Lucas Stach <l.stach@pengutronix.de>,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
Lee Jones <lee.jones@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Pavel Machek <pavel@ucw.cz>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Guenter Roeck <linux@roeck-us.net>, Rob Herring <robh@kernel.org>,
Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Subject: Re: [PATCH v10 3/5] mfd: Add driver for RAVE Supervisory Processor
Date: Sun, 5 Nov 2017 14:02:00 -0800 [thread overview]
Message-ID: <CAHQ1cqHJWWSRuWnp84u1jba5yzXuuX2cY=zyNwnUrdCE22zd=w@mail.gmail.com> (raw)
In-Reply-To: <20171105153838.GB13118@localhost>
On Sun, Nov 5, 2017 at 7:38 AM, Johan Hovold <johan@kernel.org> wrote:
> On Tue, Oct 31, 2017 at 09:36:54AM -0700, Andrey Smirnov wrote:
>> Add a driver for RAVE Supervisory Processor, an MCU implementing
>> various bits of housekeeping functionality (watchdoging, backlight
>> control, LED control, etc) on RAVE family of products by Zodiac
>> Inflight Innovations.
>>
>> This driver implementes core MFD/serdev device as well as
>> communication subroutines necessary for commanding the device.
>>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: cphealy@gmail.com
>> Cc: Lucas Stach <l.stach@pengutronix.de>
>> Cc: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Pavel Machek <pavel@ucw.cz>
>> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
>> Cc: Guenter Roeck <linux@roeck-us.net>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: Johan Hovold <johan@kernel.org>
>> Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
>> Tested-by: Chris Healy <cphealy@gmail.com>
>> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>
>> +int rave_sp_exec(struct rave_sp *sp,
>> + void *__data, size_t data_size,
>> + void *reply_data, size_t reply_data_size)
>> +{
>> + struct rave_sp_reply reply = {
>> + .data = reply_data,
>> + .length = reply_data_size,
>> + .received = COMPLETION_INITIALIZER_ONSTACK(reply.received),
>> + };
>> + unsigned char *data = __data;
>> + int command, ret = 0;
>> + u8 ackid;
>> +
>> + command = sp->variant->cmd.translate(data[0]);
>> + if (command < 0)
>> + return command;
>> +
>> + ackid = atomic_inc_return(&sp->ackid);
>> + reply.ackid = ackid;
>> + reply.code = rave_sp_reply_code((u8)command),
>> +
>> + mutex_lock(&sp->bus_lock);
>> +
>> + mutex_lock(&sp->reply_lock);
>> + sp->reply = &reply;
>> + mutex_unlock(&sp->reply_lock);
>> +
>> + data[0] = command;
>> + data[1] = ackid;
>> +
>> + rave_sp_write(sp, data, data_size);
>> +
>> + if (!wait_for_completion_timeout(&reply.received, HZ)) {
>> + dev_err(&sp->serdev->dev, "Command timeout\n");
>> + ret = -ETIMEDOUT;
>> +
>> + mutex_lock(&sp->reply_lock);
>> + sp->reply = NULL;
>> + mutex_unlock(&sp->reply_lock);
>> + }
>> +
>> + mutex_unlock(&sp->bus_lock);
>> + return ret;
>> +}
>> +EXPORT_SYMBOL(rave_sp_exec);
>
> EXPORT_SYMBOL_GPL?
>
Yep, will change in v11.
>> +static int rave_sp_receive_buf(struct serdev_device *serdev,
>> + const unsigned char *buf, size_t size)
>> +{
>> + struct device *dev = &serdev->dev;
>> + struct rave_sp *sp = dev_get_drvdata(dev);
>> + struct rave_sp_deframer *deframer = &sp->deframer;
>> + const unsigned char *src = buf;
>> + const unsigned char *end = buf + size;
>> + bool reset_framer = false;
>> +
>> + while (src < end) {
>> + const unsigned char byte = *src++;
>> +
>> + switch (deframer->state) {
>> + case RAVE_SP_EXPECT_SOF:
>> + if (byte == RAVE_SP_STX)
>> + deframer->state = RAVE_SP_EXPECT_DATA;
>> + continue;
>> +
>> + case RAVE_SP_EXPECT_DATA:
>> + switch (byte) {
>> + case RAVE_SP_ETX:
>> + rave_sp_receive_frame(sp,
>> + deframer->data,
>> + deframer->length);
>> + reset_framer = true;
>> + break;
>> + case RAVE_SP_STX:
>> + dev_warn(dev, "Bad frame: STX before ETX\n");
>> + reset_framer = true;
>> + break;
>> + case RAVE_SP_DLE:
>> + deframer->state = RAVE_SP_EXPECT_ESCAPED_DATA;
>> + continue;
>> + }
>> +
>> + case RAVE_SP_EXPECT_ESCAPED_DATA: /* FALLTHROUGH */
>
> The fallthrough comment should precede the case statement (or you will
> soon receive a patch from the people working enabling
> -Wimplicit-fallthrough).
>
Sure, will change in v11.
>> + deframer->data[deframer->length++] = byte;
>> +
>> + if (deframer->length == sizeof(deframer->data)) {
>> + dev_warn(dev, "Bad frame: Too long\n");
>> + reset_framer = true;
>> + break;
>> + }
>> +
>> + deframer->state = RAVE_SP_EXPECT_DATA;
>> + break;
>> + }
>> + }
>> +
>> + if (reset_framer) {
>> + deframer->state = RAVE_SP_EXPECT_SOF;
>> + deframer->length = 0;
>> + }
>> +
>> + return src - buf;
>> +}
>
>> +MODULE_LICENSE("GPL v2");
>
> This doesn't match the license text (GPL-2.0+).
>
Will update in v11.
>> +MODULE_AUTHOR("Andrey Vostrikov <andrey.vostrikov@cogentembedded.com>");
>> +MODULE_AUTHOR("Nikita Yushchenko <nikita.yoush@cogentembedded.com>");
>> +MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>");
>> +MODULE_DESCRIPTION("RAVE SP core driver");
>> diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
>> index c11db8bceea1..989d38b587bf 100644
>> --- a/drivers/platform/Kconfig
>> +++ b/drivers/platform/Kconfig
>> @@ -8,3 +8,4 @@ endif
>> source "drivers/platform/goldfish/Kconfig"
>>
>> source "drivers/platform/chrome/Kconfig"
>> +
>
> This chunk should not be here.
>
Missed this one. Will remove in v11.
>> diff --git a/include/linux/rave-sp.h b/include/linux/rave-sp.h
>> new file mode 100644
>> index 000000000000..811929afc1a9
>> --- /dev/null
>> +++ b/include/linux/rave-sp.h
>
> I think this one should live in include/linux/mfd/
My bad, forgot to move that file. Will do in v11.
Thanks,
Andrey Smirnov
next prev parent reply other threads:[~2017-11-05 22:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 16:36 [PATCH v10 0/5] ZII RAVE platform driver Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 1/5] serdev: Make .remove in struct serdev_device_driver optional Andrey Smirnov
2017-11-01 23:48 ` Rob Herring
2017-11-04 11:24 ` Greg Kroah-Hartman
2017-11-04 17:05 ` Sebastian Reichel
2017-10-31 16:36 ` [PATCH v10 2/5] serdev: Introduce devm_serdev_device_open() Andrey Smirnov
2017-11-01 23:48 ` Rob Herring
2017-11-05 15:38 ` Johan Hovold
2017-11-05 22:19 ` Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 3/5] mfd: Add driver for RAVE Supervisory Processor Andrey Smirnov
2017-11-05 15:38 ` Johan Hovold
2017-11-05 22:02 ` Andrey Smirnov [this message]
2017-10-31 16:36 ` [PATCH v10 4/5] watchdog: Add RAVE SP watchdog driver Andrey Smirnov
2017-10-31 17:21 ` Guenter Roeck
2017-11-04 11:24 ` Greg Kroah-Hartman
2017-11-05 15:55 ` Guenter Roeck
2017-11-05 15:47 ` Johan Hovold
2017-11-05 18:34 ` Guenter Roeck
2017-11-05 21:59 ` Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 5/5] dt-bindings: watchdog: Add bindings for " Andrey Smirnov
2017-10-31 17:22 ` Guenter Roeck
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='CAHQ1cqHJWWSRuWnp84u1jba5yzXuuX2cY=zyNwnUrdCE22zd=w@mail.gmail.com' \
--to=andrew.smirnov@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=cphealy@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=l.stach@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nikita.yoush@cogentembedded.com \
--cc=pavel@ucw.cz \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.co.uk \
/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).