History log of /linux-master/drivers/staging/greybus/spilib.c
Revision Date Author Comments
# ee3c668d 07-Feb-2024 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

staging: greybus: spi: Follow renaming of SPI "master" to "controller"

In commit 8caab75fd2c2 ("spi: Generalize SPI "master" to "controller"")
some functions and struct members were renamed. To not break all drivers
compatibility macros were provided.

To be able to remove these compatibility macros push the renaming into
this driver.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/f6f0568df29f9a51358e86326b917d81af8aba74.1707324794.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# caa9d347 10-Mar-2023 Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>

staging: Replace all spi->chip_select and spi->cs_gpiod references with function call

Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod
members of struct spi_device to be an array. But changing the type of these
members to array would break the spi driver functionality. To make the
transition smoother introduced four new APIs to get/set the
spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and
spi->cs_gpiod references with get or set API calls.
While adding multi-cs support in further patches the chip_select & cs_gpiod
members of the spi_device structure would be converted to arrays & the
"idx" parameter of the APIs would be used as array index i.e.,
spi->chip_select[idx] & spi->cs_gpiod[idx] respectively.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20230310173217.3429788-6-amit.kumar-mahapatra@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 62d7ecaf 19-May-2021 Philippe Dixon <philippesdixon@gmail.com>

staging: greybus: spi: add blank line after variable declaration

This patch fixes the following checkpatch.pl warning:

WARNING: Missing a blank line after declarations

Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Philippe Dixon <philippesdixon@gmail.com>
Link: https://lore.kernel.org/r/20210519193938.GA7131@ubuntu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 33a23423 08-Mar-2021 Alexandru Ardelean <aardelean@deviqon.com>

staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay

The intent is the removal of the 'delay_usecs' field from the
spi_transfer struct, as there is a 'delay' field that does the same
thing.

The spi_delay_to_ns() can be used to get the transfer delay. It works by
using the 'delay_usecs' field first (if it is non-zero), and finally
uses the 'delay' field.

Since the 'delay_usecs' field is going away, this change makes use of the
spi_delay_to_ns() function. This also means dividing the return value of
the function by 1000, to convert it to microseconds.
To prevent any potential faults when converting to microseconds and since
the result of spi_delay_to_ns() is int, the delay is being computed in 32
bits and then clamped between 0 & U16_MAX.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20210308145502.1075689-7-aardelean@deviqon.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a6611144 31-Jan-2021 Kumar Kartikeya Dwivedi <memxor@gmail.com>

staging: greybus: Switch from strlcpy to strscpy

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20210131172838.146706-3-memxor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ec0ad868 24-Aug-2019 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: move core include files to include/linux/greybus/

With the goal of moving the core of the greybus code out of staging, the
include files need to be moved to include/linux/greybus.h and
include/linux/greybus/

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 863dbc52 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: Remove redundant license text

Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner. So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb50fd3a 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: add SPDX identifiers to all greybus driver files

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself. The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 770b03c2 29-Oct-2017 Johan Hovold <johan@kernel.org>

staging: greybus: spilib: fix use-after-free after deregistration

Remove erroneous spi_master_put() after controller deregistration which
would access the already freed spi controller.

Note that spi_unregister_master() drops our only controller reference.

Fixes: ba3e67001b42 ("greybus: SPI: convert to a gpbridge driver")
Cc: stable <stable@vger.kernel.org> # 4.9
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 148e0b8f 08-Sep-2016 Greg Kroah-Hartman <gregkh@google.com>

staging: greybus: spi: remove KERNEL_VERSION checks

No need to support older kernel versions in the Greybus SPI and spilib
driver, so remove the checks as needed, we can now rely on all of the
correct SPI core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 92bcadde 21-Jul-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: spilib: make spilib independent of gbphy

spilib is used by multiple users currently (spi.c and fw-core.c) but
commit aa52b62a0556 broke that hierarchy and introduced gbphy dependent
code in spilib.

This may have unreliable consequences as we are doing following
operation unconditionally now:

gbphy_dev = to_gbphy_dev(spi->parent);
gbphy_runtime_get_sync(gbphy_dev);

which may not go well when the parent is of type &bundle->dev
(fw-core.c).

This patch introduces spilib_ops and lets the users of the core register
them. This shall have no functional change for the spi.c usecase and
shall fix the unreliable results for the fw-core.c usecase.

Tested by writing to mtd0 dev and verifying (with print messages) that
the below routines are getting called for a gpbridge-test module.

Fixes: aa52b62a0556 ("spi: Add runtime_pm support")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4c615dcc 14-Jul-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: spi: Add runtime_pm support

Add runtime operations to the spi driver so that the
module is woken up when an spi transfer is started
and put back to sleep when the transfer is done.

Testing Done: Let the module enter standby and initiate
an spi operation. The operation wakes up the module
and succeeds.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Alex Elder <elder@linaro.org>


# 60fb3405 10-Jun-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Remove extra blank lines

This patch removes few blank lines across the repository at places where
two blank lines were present together or when a blank line is present at
the start or end of a routine.

Note that this doesn't remove most of them from greybus_protocols.h as
they were added on purpose.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 3a238fc7 16-May-2016 Rui Miguel Silva <rui.silva@linaro.org>

greybus: spi: add inprogress bit to xfer_flags

When a SPI transfer needs to be split by more than one greybus spi
transfer operation, we need to indicate it so the controller can handle
the chip select lines correctly.

Add a new bit to indicate it, GB_SPI_XFER_INPROGRESS, and create an
helper function to calculate when the transfer is done. As we need this
information also in other places.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 22e26a3a 16-May-2016 Rui Miguel Silva <rui.silva@linaro.org>

greybus: spi: rename rdwr field to xfer_flags

As more bits will be added to the field, let's make the field more
generic and name it accordingly. So, rename it from rdwr to xfer_flags.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 8888b963 14-May-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: spi: Separate out spilib from spi bridged PHY bundle driver

spilib can be used by multiple bridge drivers implementing different
bundle classes. Separate out bridged PHY bundle drivers parts.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4c412921 14-May-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: spi: Restructure spi.c to share it with other bundle drivers

This patch restructures spi.c as spilib core, so that the same logic can
be reused for SPI connections implemented as part of different bundle
types. This is required for Firmware Management Bundle.

Note that the 'struct gb_protocol' and its callback aren't moved to
a separate file in this commit to make its reviews easier. That will be
done by a following patch.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>