summaryrefslogtreecommitdiff
path: root/drivers/bus/moxtet.c
AgeCommit message (Collapse)Author
2020-02-15bus: moxtet: fix potential stack buffer overflowMarek Behún
The input_read function declares the size of the hex array relative to sizeof(buf), but buf is a pointer argument of the function. The hex array is meant to contain hexadecimal representation of the bin array. Link: https://lore.kernel.org/r/20200215142130.22743-1-marek.behun@nic.cz Fixes: 5bc7f990cd98 ("bus: Add support for Moxtet bus") Signed-off-by: Marek Behún <marek.behun@nic.cz> Reported-by: sohu0106 <sohu0106@126.com> Signed-off-by: Olof Johansson <olof@lixom.net>
2020-01-08bus: moxtet: declare moxtet_bus_type as staticMarek Behún
This symbol is not meant to be used from elsewhere. Cc: Ben Dooks <ben.dooks@codethink.co.uk> Cc: Christoph Hellwig <hch@infradead.org> Cc: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Marek Behún <marek.behun@nic.cz> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
2019-09-04bus: moxtet: fix unsigned comparison to less than zeroColin Ian King
Currently the size_t variable res is being checked for an error failure however the unsigned variable is never less than zero so this test is always false. Fix this by making variable res ssize_t Link: https://lore.kernel.org/r/20190822010351.15660-2-marek.behun@nic.cz Addresses-Coverity: ("Unsigned compared against 0") Fixes: 5bc7f990cd98 ("bus: Add support for Moxtet bus") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Marek Behún <marek.behun@nic.cz> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-09-04bus: moxtet: remove set but not used variable 'dummy'Jason Yan
Fixes gcc '-Wunused-but-set-variable' warning: drivers/bus/moxtet.c: In function moxtet_remove: drivers/bus/moxtet.c:822:6: warning: variable dummy set but not used [-Wunused-but-set-variable] Link: https://lore.kernel.org/r/20190822010351.15660-3-marek.behun@nic.cz Signed-off-by: Jason Yan <yanaijie@huawei.com> Signed-off-by: Marek Behún <marek.behun@nic.cz> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-08-14bus: Add support for Moxtet busMarek Behún
On the Turris Mox router different modules can be connected to the main CPU board: currently a module with a SFP cage, a module with MiniPCIe connector, a PCIe pass-through MiniPCIe connector module, a 4-port switch module, an 8-port switch module, and a 4-port USB3 module. For example: [CPU]-[PCIe-pass-through]-[PCIe]-[8-port switch]-[8-port switch]-[SFP] Each of this modules has an input and output shift register, and these are connected via SPI to the CPU board. Via SPI we are able to discover which modules are connected, in which order, and we can also read some information about the modules (eg. their interrupt status), and configure them. From each module 8 bits can be read (of which low 4 bits identify the module) and 8 bits can be written. For example from the module with a SFP cage we can read the LOS, TX-FAULT and MOD-DEF0 signals, while we can write TX-DISABLE and RATE-SELECT signals. This driver creates a new bus type, called "moxtet". For each Mox module it finds via SPI, it creates a new device on the moxtet bus so that drivers can be written for them. It also implements a virtual interrupt controller for the modules which send their interrupt status over the SPI shift register. These modules do this in addition to sending their interrupt status via the shared interrupt line. When the shared interrupt is triggered, we read from the shift register and handle IRQs for all devices which are in interrupt. The topology of how Mox modules are connected can then be read by listing /sys/bus/moxtet/devices. Link: https://lore.kernel.org/r/20190812161118.21476-2-marek.behun@nic.cz Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>