History log of /linux-master/drivers/media/common/siano/smscoreapi.h
Revision Date Author Comments
# 13dfead4 10-Mar-2021 Gustavo A. R. Silva <gustavoars@kernel.org>

media: siano: Fix out-of-bounds warnings in smscore_load_firmware_family2()

Rename struct sms_msg_data4 to sms_msg_data5 and increase the size of
its msg_data array from 4 to 5 elements. Notice that at some point
the 5th element of msg_data is being accessed in function
smscore_load_firmware_family2():

1006 trigger_msg->msg_data[4] = 4; /* Task ID */

Also, there is no need for the object _trigger_msg_ of type struct
sms_msg_data *, when _msg_ can be used, directly. Notice that msg_data
in struct sms_msg_data is a one-element array, which causes multiple
out-of-bounds warnings when accessing beyond its first element
in function smscore_load_firmware_family2():

992 struct sms_msg_data *trigger_msg =
993 (struct sms_msg_data *) msg;
994
995 pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
996 SMS_INIT_MSG(&msg->x_msg_header,
997 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
998 sizeof(struct sms_msg_hdr) +
999 sizeof(u32) * 5);
1000
1001 trigger_msg->msg_data[0] = firmware->start_address;
1002 /* Entry point */
1003 trigger_msg->msg_data[1] = 6; /* Priority */
1004 trigger_msg->msg_data[2] = 0x200; /* Stack size */
1005 trigger_msg->msg_data[3] = 0; /* Parameter */
1006 trigger_msg->msg_data[4] = 4; /* Task ID */

even when enough dynamic memory is allocated for _msg_:

929 /* PAGE_SIZE buffer shall be enough and dma aligned */
930 msg = kmalloc(PAGE_SIZE, GFP_KERNEL | coredev->gfp_buf_flags);

but as _msg_ is casted to (struct sms_msg_data *):

992 struct sms_msg_data *trigger_msg =
993 (struct sms_msg_data *) msg;

the out-of-bounds warnings are actually valid and should be addressed.

Fix this by declaring object _msg_ of type struct sms_msg_data5 *,
which contains a 5-elements array, instead of just 4. And use
_msg_ directly, instead of creating object trigger_msg.

This helps with the ongoing efforts to enable -Warray-bounds by fixing
the following warnings:

CC [M] drivers/media/common/siano/smscoreapi.o
drivers/media/common/siano/smscoreapi.c: In function ‘smscore_load_firmware_family2’:
drivers/media/common/siano/smscoreapi.c:1003:24: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1003 | trigger_msg->msg_data[1] = 6; /* Priority */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~
drivers/media/common/siano/smscoreapi.c:1004:24: warning: array subscript 2 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1004 | trigger_msg->msg_data[2] = 0x200; /* Stack size */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~
drivers/media/common/siano/smscoreapi.c:1005:24: warning: array subscript 3 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1005 | trigger_msg->msg_data[3] = 0; /* Parameter */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~
drivers/media/common/siano/smscoreapi.c:1006:24: warning: array subscript 4 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1006 | trigger_msg->msg_data[4] = 4; /* Task ID */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~

Fixes: 018b0c6f8acb ("[media] siano: make load firmware logic to work with newer firmwares")
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>


# 73605de0 01-Nov-2020 Davidlohr Bueso <dave@stgolabs.net>

media: media/siano: kill pointless kmutex definitions

Use the mutex api instead of renaming the calls for this
driver.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 13183724 03-Nov-2019 Colin Ian King <colin.king@canonical.com>

media: siano: fix spelling mistake "ENBALE" -> "ENABLE"

Macros MSG_SMS_ENBALE_TS_INTERFACE_REQ and MSG_SMS_ENBALE_TS_INTERFACE_RES
contain a spelling mistake. Fix these by replacing ENBALE with ENABLE.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 1ccea77e 19-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details you
should have received a copy of the gnu general public license along
with this program if not see http www gnu org licenses

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details [based]
[from] [clk] [highbank] [c] you should have received a copy of the
gnu general public license along with this program if not see http
www gnu org licenses

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 355 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4b129dc9 18-Feb-2019 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

media: common: fix several typos

Use codespell to fix lots of typos over frontends.

Manually verified to avoid false-positives.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 782b9d20 06-May-2018 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

media: siano: use GFP_DMA only for smssdio

Right now, the Siano's core uses GFP_DMA for both USB and
SDIO variants of the driver. There's no reason to use it
for USB. So, pass GFP_DMA as a parameter during sms core
register.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 564246fd 03-Mar-2018 Tomoki Sekiyama <tomoki.sekiyama@gmail.com>

media: siano: Fix coherent memory allocation failure on arm64

On some architectures such as arm64, siano chip based TV-tuner
USB devices are not recognized correctly due to coherent memory
allocation failure with the following error:

[ 663.556135] usbcore: deregistering interface driver smsusb
[ 683.624809] smsusb:smsusb_probe: board id=18, interface number 0
[ 683.633530] smsusb:smsusb_init_device: smscore_register_device(...) failed, rc -12
[ 683.641501] smsusb:smsusb_probe: Device initialized with return code -12
[ 683.652978] smsusb: probe of 1-1:1.0 failed with error -12

This is caused by dma_alloc_coherent(NULL, ...) returning NULL in
smscoreapi.c.

To fix this error, allocate the buffer memory for the USB devices
via kmalloc() and let the USB core do the DMA mapping and free.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# f5d39078 02-May-2015 Fabian Frederick <fabf@skynet.be>

[media] siano: define SRVM_MAX_PID_FILTERS only once

SRVM_MAX_PID_FILTERS was defined in 2 sms_tx_stats structures

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 4b208f8b 21-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: register media controller earlier

We need to initialize the media controller earlier, as the core
will call the smsdvb hotplug during register time. Ok, this is
an async operation, so, when the module is not loaded, the media
controller works.

However, if the module is already loaded, nothing will be
registered at the media controller, as it will load too late.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 0dd5f20c 22-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: get rid of sms_info()

On most cases, sms_info() should actually be pr_debug(), but,
on other places, it should be pr_info().

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 69083688 22-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: replace sms_debug() by pr_debug()

There's no reason to use a macro here. Just replace everything,
and let those debug messages to be activated via dynamic printk.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 9b283e67 22-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: replace sms_log() by pr_debug()

Despite its name, those functions are acutally debug
prints for the IR part of the driver. So, properly
map them using pr_debug()

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 5ed0a2c7 22-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: replace sms_err by pr_err

Originally, sms_err() would be also displaying the line where
the error occurs, but the messages are clear enough. Also,
the function is always printed. So, no need for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 535bd1e9 22-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: replace sms_warn() by pr_warn()

There's no reason for a sms' own sms_warn macro. Just replace
it by the standard pr_warn().

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 5e022d1a 22-Feb-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: use pr_* print functions

Instead of defining its own set of printk functions, let's
use the common Kernel debug logic provided by pr_foo functions.

As a first step, let's just define the existing macros as the
Kernel ones.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 46b1e21f 07-Jan-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: add support for the media controller at USB driver

Adding support for the media controller for a pure DVB device
is simple: just create a struct media_device and add it to the
dvb adapter. After creating all DVB devices, we need to call
the DVB core, for it to create the media graph.

More work is needed for pure DVB tuners, but this is hidden
at the Siano driver, just like several others non-hybrid
devices. So, this is streight forward.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# f58c91ce 20-Oct-2013 Jonathan McCrohan <jmccrohan@gmail.com>

[media] media_tree: Fix spelling errors

Fix various spelling errors in strings and comments throughout the media
tree. The majority of these were found using Lucas De Marchi's codespell
tool.

[m.chehab@samsung.com: discard hunks with conflicts]

Signed-off-by: Jonathan McCrohan <jmccrohan@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 39c1cb2b 20-Oct-2013 Jonathan McCrohan <jmccrohan@gmail.com>

[media] media_tree: Fix spelling errors

Fix various spelling errors in strings and comments throughout the media
tree. The majority of these were found using Lucas De Marchi's codespell
tool.

[m.chehab@samsung.com: discard hunks with conflicts]

Signed-off-by: Jonathan McCrohan <jmccrohan@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 05ad412a 21-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: Fix the remaining checkpatch.pl compliants

Fix all other remaining checkpatch.pl compliants on the Siano driver,
except for the 80-cols (soft) limit. Those are harder to fix, and
probably not worth to do right now.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 28a59df4 21-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: remove the remaining CamelCase compliants

Remove the remaining CamelCase checkpatch.pl compliants.
There are still a few left, but those are due to USB and
DVB APIs.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 90414248 21-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: fix checkpatch.pl compliants on smscoreapi.h

Fix the remaining checkpatch.pl compliants at smscoreapi.h,
except by the "line over 80 characters" on comments. Fixing those
would require more time, as the better is to convert them into the
struct descriptions used inside the kernel, as described at:
Documentation/kernel-doc-nano-HOWTO.txt

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# cf0e9cfc 21-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: convert structure names to lowercase

There are several structures defined in uppercase. Convert them
to lowercase, and simplify their names, when possible.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# dfef84fc 21-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: get rid of CammelCase from smscoreapi.h

It is almost impossible to see a compliant with checkpatch.pl
on those Siano drivers, as there are simply too much violations
on it. So, now that a big change was done, the better is to
cleanup the checkpatch compliants.

Let's first replace all CammelCase symbols found at smscoreapi.h
using camel_case namespace. That removed 144 checkpatch.pl
compliants on this file. Of course, the other files need to be
fixed accordingly.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# c8b8fdb3 19-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: add MODULE_FIRMWARE() macros

This driver can use several firmwares. Provide such info at
module firmware metadata.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 11ad03a5 19-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: use defines for firmware names

There are too many firmwares there. As we need to add
MODULE_FIMWARE() macros, the better is to define their names
on just one place and use the macros for both cards/device type
tables and MODULE_FIRMWARE().

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 503efe5c 10-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: split debugfs code into a separate file

To avoid mixing two different things at the same place, move the
debugfs code into a separate file.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# b4059095 07-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: use the newer stats message for recent firmwares

The old statistics request don't work with newer firmwares.
Add a logic to use the newer stats if firmware major is 8.
Note that I have only 2 devices here, one with firmware 2.1
(Hauppauge model 55009 Rev B1F7) and another one with
firmware 8.1. We may need to adjust the firmware minimal
version for the *_EX message variants, as we start finding
firmware versions between 2.x and 8.x.
This patch was based on Doron Cohen patch:
http://patchwork.linuxtv.org/patch/7886/

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# e5d218ee 07-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: cleanups at smscoreapi.c

Some cleanups at smscoreapi. Most are just CodingStyle.
Also, use kzalloc when allocating a new buffer, as it initializes
the allocated space with zero.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 018b0c6f 05-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: make load firmware logic to work with newer firmwares

There are new firmwares for sms2xxx devices. Change the firmware
load logic to handle those newer firmwares and devices.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 73338395 09-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: store firmware version

As there are some changes that seem to be firmware-dependent,
we need to store the firmware version, as we don't want to break
support for existing cards that use a legacy (and sometimes
custom) firmware.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# ab2b599e 06-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: add the remaining new defines from new driver

Add the remaining new defines/enums from Doron Cohen's patch:
http://patchwork.linuxtv.org/patch/7882/

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 4c3bdb5e 09-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: better debug send/receive messages

Instead of printing a message for some random messages, print
it for all sent/received ones. That helps a lot to debug
what's going on.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# f251001c 06-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: update message macros

Convert from #define into an enum and add the newer message
macros as found on this patch from Doron Cohen:
http://patchwork.linuxtv.org/patch/7882/
No messages got supressed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# c31b9fb2 06-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: remove a duplicated structure definition

The same GPIO config struct was declared twice at the
driver, with different names and different macros:
struct smscore_config_gpio
struct smscore_config_gpio
Remove the one that uses CamelCase and fix the references to
its attributes/macros.
No functional changes.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 739a8c91 06-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: Add the new voltage definitions for GPIO

Those new definitions came from this patch, from Doron Cohen:
http://patchwork.linuxtv.org/patch/7882/

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# f82757d9 06-Mar-2013 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: Change GPIO voltage setting names

Siano changed the namespace on more recent API, and re-used some
of the old names. In order to be able to update the API to support
newer chips, the better is to follow this change.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 0013ca8c 14-Jun-2012 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] siano: break it into common, mmc and usb

siano is, in fact, 2 drivers: one for MMC and one for USB, plus
a common bus-independent code. Break it accordingly.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>