License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-05-17 04:54:10 +00:00
|
|
|
/*
|
2009-03-29 10:46:58 +00:00
|
|
|
* Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
|
2005-05-17 04:54:10 +00:00
|
|
|
* flexcop-i2c.c - flexcop internal 2Wire bus (I2C) and dvb i2c initialization
|
2009-03-29 10:46:58 +00:00
|
|
|
* see flexcop.c for copyright information
|
2005-05-17 04:54:10 +00:00
|
|
|
*/
|
|
|
|
#include "flexcop.h"
|
|
|
|
|
|
|
|
#define FC_MAX_I2C_RETRIES 100000
|
|
|
|
|
2009-03-29 10:46:58 +00:00
|
|
|
static int flexcop_i2c_operation(struct flexcop_device *fc,
|
|
|
|
flexcop_ibi_value *r100)
|
2005-05-17 04:54:10 +00:00
|
|
|
{
|
2005-05-17 04:54:18 +00:00
|
|
|
int i;
|
2005-05-17 04:54:10 +00:00
|
|
|
flexcop_ibi_value r;
|
|
|
|
|
|
|
|
r100->tw_sm_c_100.working_start = 1;
|
|
|
|
deb_i2c("r100 before: %08x\n",r100->raw);
|
|
|
|
|
|
|
|
fc->write_ibi_reg(fc, tw_sm_c_100, ibi_zero);
|
|
|
|
fc->write_ibi_reg(fc, tw_sm_c_100, *r100); /* initiating i2c operation */
|
|
|
|
|
|
|
|
for (i = 0; i < FC_MAX_I2C_RETRIES; i++) {
|
|
|
|
r = fc->read_ibi_reg(fc, tw_sm_c_100);
|
|
|
|
|
|
|
|
if (!r.tw_sm_c_100.no_base_addr_ack_error) {
|
2009-03-29 10:46:58 +00:00
|
|
|
if (r.tw_sm_c_100.st_done) {
|
2005-05-17 04:54:10 +00:00
|
|
|
*r100 = r;
|
|
|
|
deb_i2c("i2c success\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
deb_i2c("suffering from an i2c ack_error\n");
|
2005-05-17 04:54:18 +00:00
|
|
|
return -EREMOTEIO;
|
2005-05-17 04:54:10 +00:00
|
|
|
}
|
|
|
|
}
|
[media] b2c2: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-18 19:44:00 +00:00
|
|
|
deb_i2c("tried %d times i2c operation, never finished or too many ack errors.\n",
|
|
|
|
i);
|
2005-05-17 04:54:10 +00:00
|
|
|
return -EREMOTEIO;
|
|
|
|
}
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c,
|
2009-03-29 10:46:58 +00:00
|
|
|
flexcop_ibi_value r100, u8 *buf)
|
2005-05-17 04:54:10 +00:00
|
|
|
{
|
|
|
|
flexcop_ibi_value r104;
|
2009-03-29 10:46:58 +00:00
|
|
|
int len = r100.tw_sm_c_100.total_bytes,
|
|
|
|
/* remember total_bytes is buflen-1 */
|
2005-05-17 04:54:10 +00:00
|
|
|
ret;
|
|
|
|
|
2009-02-28 13:19:30 +00:00
|
|
|
/* work-around to have CableStar2 and SkyStar2 rev 2.7 work
|
|
|
|
* correctly:
|
|
|
|
*
|
|
|
|
* the ITD1000 is behind an i2c-gate which closes automatically
|
|
|
|
* after an i2c-transaction the STV0297 needs 2 consecutive reads
|
|
|
|
* one with no_base_addr = 0 and one with 1
|
|
|
|
*
|
|
|
|
* those two work-arounds are conflictin: we check for the card
|
|
|
|
* type, it is set when probing the ITD1000 */
|
|
|
|
if (i2c->fc->dev_type == FC_SKY_REV27)
|
|
|
|
r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr;
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
ret = flexcop_i2c_operation(i2c->fc, &r100);
|
2008-12-01 09:59:37 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
deb_i2c("Retrying operation\n");
|
|
|
|
r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr;
|
|
|
|
ret = flexcop_i2c_operation(i2c->fc, &r100);
|
|
|
|
}
|
2008-03-29 23:49:57 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
deb_i2c("read failed. %d\n", ret);
|
|
|
|
return ret;
|
2005-05-17 04:54:18 +00:00
|
|
|
}
|
2005-05-17 04:54:10 +00:00
|
|
|
|
|
|
|
buf[0] = r100.tw_sm_c_100.data1_reg;
|
|
|
|
|
2005-05-17 04:54:18 +00:00
|
|
|
if (len > 0) {
|
2008-03-29 23:49:57 +00:00
|
|
|
r104 = i2c->fc->read_ibi_reg(i2c->fc, tw_sm_c_104);
|
|
|
|
deb_i2c("read: r100: %08x, r104: %08x\n", r100.raw, r104.raw);
|
2005-05-17 04:54:18 +00:00
|
|
|
|
|
|
|
/* there is at least one more byte, otherwise we wouldn't be here */
|
|
|
|
buf[1] = r104.tw_sm_c_104.data2_reg;
|
|
|
|
if (len > 1) buf[2] = r104.tw_sm_c_104.data3_reg;
|
|
|
|
if (len > 2) buf[3] = r104.tw_sm_c_104.data4_reg;
|
|
|
|
}
|
2005-05-17 04:54:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-29 10:46:58 +00:00
|
|
|
static int flexcop_i2c_write4(struct flexcop_device *fc,
|
|
|
|
flexcop_ibi_value r100, u8 *buf)
|
2005-05-17 04:54:10 +00:00
|
|
|
{
|
|
|
|
flexcop_ibi_value r104;
|
|
|
|
int len = r100.tw_sm_c_100.total_bytes; /* remember total_bytes is buflen-1 */
|
|
|
|
r104.raw = 0;
|
|
|
|
|
|
|
|
/* there is at least one byte, otherwise we wouldn't be here */
|
|
|
|
r100.tw_sm_c_100.data1_reg = buf[0];
|
|
|
|
r104.tw_sm_c_104.data2_reg = len > 0 ? buf[1] : 0;
|
|
|
|
r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0;
|
|
|
|
r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0;
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
deb_i2c("write: r100: %08x, r104: %08x\n", r100.raw, r104.raw);
|
2005-05-17 04:54:10 +00:00
|
|
|
|
|
|
|
/* write the additional i2c data before doing the actual i2c operation */
|
2008-03-29 23:49:57 +00:00
|
|
|
fc->write_ibi_reg(fc, tw_sm_c_104, r104);
|
|
|
|
return flexcop_i2c_operation(fc, &r100);
|
2005-05-17 04:54:18 +00:00
|
|
|
}
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
flexcop_access_op_t op, u8 chipaddr,
|
|
|
|
u8 start_addr, u8 *buf, u16 size)
|
2005-05-17 04:54:18 +00:00
|
|
|
{
|
|
|
|
int ret;
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
int len = size;
|
|
|
|
u8 *p;
|
|
|
|
u8 addr = start_addr;
|
2008-03-29 23:49:57 +00:00
|
|
|
|
2005-05-17 04:54:18 +00:00
|
|
|
u16 bytes_to_transfer;
|
|
|
|
flexcop_ibi_value r100;
|
|
|
|
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
deb_i2c("port %d %s(%02x): register %02x, size: %d\n",
|
|
|
|
i2c->port,
|
|
|
|
op == FC_READ ? "rd" : "wr",
|
|
|
|
chipaddr, start_addr, size);
|
2005-05-17 04:54:18 +00:00
|
|
|
r100.raw = 0;
|
|
|
|
r100.tw_sm_c_100.chipaddr = chipaddr;
|
|
|
|
r100.tw_sm_c_100.twoWS_rw = op;
|
2008-03-29 23:49:57 +00:00
|
|
|
r100.tw_sm_c_100.twoWS_port_reg = i2c->port;
|
|
|
|
|
|
|
|
/* in that case addr is the only value ->
|
|
|
|
* we write it twice as baseaddr and val0
|
|
|
|
* BBTI is doing it like that for ISL6421 at least */
|
|
|
|
if (i2c->no_base_addr && len == 0 && op == FC_WRITE) {
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
buf = &start_addr;
|
2008-03-29 23:49:57 +00:00
|
|
|
len = 1;
|
|
|
|
}
|
2005-05-17 04:54:18 +00:00
|
|
|
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
p = buf;
|
|
|
|
|
2005-05-17 04:54:18 +00:00
|
|
|
while (len != 0) {
|
|
|
|
bytes_to_transfer = len > 4 ? 4 : len;
|
2005-05-17 04:54:10 +00:00
|
|
|
|
2005-05-17 04:54:18 +00:00
|
|
|
r100.tw_sm_c_100.total_bytes = bytes_to_transfer - 1;
|
|
|
|
r100.tw_sm_c_100.baseaddr = addr;
|
|
|
|
|
|
|
|
if (op == FC_READ)
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
ret = flexcop_i2c_read4(i2c, r100, p);
|
2005-05-17 04:54:18 +00:00
|
|
|
else
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
ret = flexcop_i2c_write4(i2c->fc, r100, p);
|
2005-05-17 04:54:18 +00:00
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
p += bytes_to_transfer;
|
2005-05-17 04:54:18 +00:00
|
|
|
addr += bytes_to_transfer;
|
|
|
|
len -= bytes_to_transfer;
|
2008-03-29 23:49:57 +00:00
|
|
|
}
|
media: flexcop-i2c: get rid of KERN_CONT
Coverity complains about werid stuff at the debug logic:
CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.
Instead of directly addressing the issue there, let's rework at
the logic there.
On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).
So, the way it is is too buggy.
There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.
Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.
Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-23 12:29:09 +00:00
|
|
|
deb_i2c_dump("port %d %s(%02x): register %02x: %*ph\n",
|
|
|
|
i2c->port,
|
|
|
|
op == FC_READ ? "rd" : "wr",
|
|
|
|
chipaddr, start_addr, size, buf);
|
2005-05-17 04:54:18 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-05-17 04:54:10 +00:00
|
|
|
}
|
2005-05-17 04:54:18 +00:00
|
|
|
/* exported for PCI i2c */
|
|
|
|
EXPORT_SYMBOL(flexcop_i2c_request);
|
2005-05-17 04:54:10 +00:00
|
|
|
|
|
|
|
/* master xfer callback for demodulator */
|
2009-03-29 10:46:58 +00:00
|
|
|
static int flexcop_master_xfer(struct i2c_adapter *i2c_adap,
|
|
|
|
struct i2c_msg msgs[], int num)
|
2005-05-17 04:54:10 +00:00
|
|
|
{
|
2008-03-29 23:49:57 +00:00
|
|
|
struct flexcop_i2c_adapter *i2c = i2c_get_adapdata(i2c_adap);
|
2005-05-17 04:54:10 +00:00
|
|
|
int i, ret = 0;
|
|
|
|
|
V4L/DVB (6042): b2c2-flexcop: fix Airstar HD5000 tuning regression
Git changeset 6bdcc6e6dbab8daffd05e5026486f34ba41a6c72 dropped the
stand-alone lgh06xf module, whose functionality was absorbed into the
dvb-pll module. However, there was a minor difference between the code
in lgh06xf and dvb-pll, which caused a regression in b2c2-flexcop
devices using the LG-H06xF NIM.
dvb-pll will probe for the presence of an i2c pll chip by performing a
single byte read, the lgh06xf driver did not do this. Unfortunately, the
code in flexcop-i2c.c does not currently support 1 byte or 0 byte reads
as a probe. Such probes with the current code will always fail.
In order to work around this problem, and restore proper functionality
of the Airstar HD5000 device, this hack was created to make the probe
appear to succeed. The single byte read in dvb_pll_attach is the only
place where such a probe would ever occur, so this change is safe, and
will not affect any other devices.
Of course, if one knew how to actually perform the read operation, it
would be better to go that route. In the meantime, however, we must
apply this workaround, in order to prevent the regression that causes
tuning to fail on the Airstar HD5000 ATSC device.
Thanks to Jarod Wilson, who had originally reported this regression, and
to Geoffrey Hausheer, whose original workaround patch led us to find the
actual cause of the problem.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Cc: Geoffrey Hausheer <inli3epy93n@phracturedblue.com>
Acked-by: Jarod Wilson <jwilson@redhat.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-08-19 08:05:54 +00:00
|
|
|
/* Some drivers use 1 byte or 0 byte reads as probes, which this
|
|
|
|
* driver doesn't support. These probes will always fail, so this
|
|
|
|
* hack makes them always succeed. If one knew how, it would of
|
|
|
|
* course be better to actually do the read. */
|
|
|
|
if (num == 1 && msgs[0].flags == I2C_M_RD && msgs[0].len <= 1)
|
|
|
|
return 1;
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
if (mutex_lock_interruptible(&i2c->fc->i2c_mutex))
|
2005-05-17 04:54:10 +00:00
|
|
|
return -ERESTARTSYS;
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
/* reading */
|
|
|
|
if (i+1 < num && (msgs[i+1].flags == I2C_M_RD)) {
|
|
|
|
ret = i2c->fc->i2c_request(i2c, FC_READ, msgs[i].addr,
|
2009-03-29 10:46:58 +00:00
|
|
|
msgs[i].buf[0], msgs[i+1].buf,
|
|
|
|
msgs[i+1].len);
|
2008-03-29 23:49:57 +00:00
|
|
|
i++; /* skip the following message */
|
|
|
|
} else /* writing */
|
|
|
|
ret = i2c->fc->i2c_request(i2c, FC_WRITE, msgs[i].addr,
|
2009-03-29 10:46:58 +00:00
|
|
|
msgs[i].buf[0], &msgs[i].buf[1],
|
|
|
|
msgs[i].len - 1);
|
2008-03-29 23:49:57 +00:00
|
|
|
if (ret < 0) {
|
2009-05-20 07:57:10 +00:00
|
|
|
deb_i2c("i2c master_xfer failed");
|
2005-05-17 04:54:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
mutex_unlock(&i2c->fc->i2c_mutex);
|
2005-05-17 04:54:10 +00:00
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
if (ret == 0)
|
|
|
|
ret = num;
|
2005-05-17 04:54:10 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
|
|
|
|
{
|
|
|
|
return I2C_FUNC_I2C;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct i2c_algorithm flexcop_algo = {
|
|
|
|
.master_xfer = flexcop_master_xfer,
|
|
|
|
.functionality = flexcop_i2c_func,
|
|
|
|
};
|
|
|
|
|
|
|
|
int flexcop_i2c_init(struct flexcop_device *fc)
|
|
|
|
{
|
|
|
|
int ret;
|
2006-02-07 08:49:14 +00:00
|
|
|
mutex_init(&fc->i2c_mutex);
|
2005-05-17 04:54:10 +00:00
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
fc->fc_i2c_adap[0].fc = fc;
|
|
|
|
fc->fc_i2c_adap[1].fc = fc;
|
|
|
|
fc->fc_i2c_adap[2].fc = fc;
|
|
|
|
fc->fc_i2c_adap[0].port = FC_I2C_PORT_DEMOD;
|
|
|
|
fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM;
|
|
|
|
fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER;
|
|
|
|
|
2018-09-10 12:19:14 +00:00
|
|
|
strscpy(fc->fc_i2c_adap[0].i2c_adap.name, "B2C2 FlexCop I2C to demod",
|
|
|
|
sizeof(fc->fc_i2c_adap[0].i2c_adap.name));
|
|
|
|
strscpy(fc->fc_i2c_adap[1].i2c_adap.name, "B2C2 FlexCop I2C to eeprom",
|
|
|
|
sizeof(fc->fc_i2c_adap[1].i2c_adap.name));
|
|
|
|
strscpy(fc->fc_i2c_adap[2].i2c_adap.name, "B2C2 FlexCop I2C to tuner",
|
|
|
|
sizeof(fc->fc_i2c_adap[2].i2c_adap.name));
|
2008-03-29 23:49:57 +00:00
|
|
|
|
|
|
|
i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]);
|
|
|
|
i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]);
|
|
|
|
i2c_set_adapdata(&fc->fc_i2c_adap[2].i2c_adap, &fc->fc_i2c_adap[2]);
|
|
|
|
|
|
|
|
fc->fc_i2c_adap[0].i2c_adap.algo =
|
|
|
|
fc->fc_i2c_adap[1].i2c_adap.algo =
|
|
|
|
fc->fc_i2c_adap[2].i2c_adap.algo = &flexcop_algo;
|
|
|
|
fc->fc_i2c_adap[0].i2c_adap.algo_data =
|
|
|
|
fc->fc_i2c_adap[1].i2c_adap.algo_data =
|
|
|
|
fc->fc_i2c_adap[2].i2c_adap.algo_data = NULL;
|
|
|
|
fc->fc_i2c_adap[0].i2c_adap.dev.parent =
|
|
|
|
fc->fc_i2c_adap[1].i2c_adap.dev.parent =
|
|
|
|
fc->fc_i2c_adap[2].i2c_adap.dev.parent = fc->dev;
|
|
|
|
|
|
|
|
ret = i2c_add_adapter(&fc->fc_i2c_adap[0].i2c_adap);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-05-17 04:54:10 +00:00
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
ret = i2c_add_adapter(&fc->fc_i2c_adap[1].i2c_adap);
|
|
|
|
if (ret < 0)
|
|
|
|
goto adap_1_failed;
|
2005-05-17 04:54:10 +00:00
|
|
|
|
2008-03-29 23:49:57 +00:00
|
|
|
ret = i2c_add_adapter(&fc->fc_i2c_adap[2].i2c_adap);
|
|
|
|
if (ret < 0)
|
|
|
|
goto adap_2_failed;
|
2005-05-17 04:54:10 +00:00
|
|
|
|
|
|
|
fc->init_state |= FC_STATE_I2C_INIT;
|
|
|
|
return 0;
|
2008-03-29 23:49:57 +00:00
|
|
|
|
|
|
|
adap_2_failed:
|
|
|
|
i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap);
|
|
|
|
adap_1_failed:
|
|
|
|
i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap);
|
|
|
|
return ret;
|
2005-05-17 04:54:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flexcop_i2c_exit(struct flexcop_device *fc)
|
|
|
|
{
|
2008-03-29 23:49:57 +00:00
|
|
|
if (fc->init_state & FC_STATE_I2C_INIT) {
|
|
|
|
i2c_del_adapter(&fc->fc_i2c_adap[2].i2c_adap);
|
|
|
|
i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap);
|
|
|
|
i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap);
|
|
|
|
}
|
2005-05-17 04:54:10 +00:00
|
|
|
fc->init_state &= ~FC_STATE_I2C_INIT;
|
|
|
|
}
|