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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-06-24 13:02:35 +08:00
|
|
|
/* dvb-usb-firmware.c is part of the DVB USB library.
|
|
|
|
*
|
2016-01-24 22:56:58 +08:00
|
|
|
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
|
2005-06-24 13:02:35 +08:00
|
|
|
* see dvb-usb-init.c for copyright information.
|
|
|
|
*
|
|
|
|
* This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices.
|
|
|
|
*
|
|
|
|
* FIXME: This part does actually not belong to dvb-usb, but to the usb-subsystem.
|
|
|
|
*/
|
|
|
|
#include "dvb-usb-common.h"
|
|
|
|
|
|
|
|
#include <linux/usb.h>
|
|
|
|
|
|
|
|
struct usb_cypress_controller {
|
|
|
|
int id;
|
|
|
|
const char *name; /* name of the usb controller */
|
|
|
|
u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct usb_cypress_controller cypress[] = {
|
2006-01-10 01:25:04 +08:00
|
|
|
{ .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 },
|
|
|
|
{ .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 },
|
|
|
|
{ .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 },
|
|
|
|
{ .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 },
|
2005-06-24 13:02:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* load a firmware packet to the device
|
|
|
|
*/
|
|
|
|
static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len)
|
|
|
|
{
|
|
|
|
return usb_control_msg(udev, usb_sndctrlpipe(udev,0),
|
2006-01-10 01:25:22 +08:00
|
|
|
0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000);
|
2005-06-24 13:02:35 +08:00
|
|
|
}
|
|
|
|
|
2006-01-10 04:21:38 +08:00
|
|
|
int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
|
2005-06-24 13:02:35 +08:00
|
|
|
{
|
2017-01-24 18:13:11 +08:00
|
|
|
struct hexline *hx;
|
2017-02-12 23:02:13 +08:00
|
|
|
u8 *buf;
|
|
|
|
int ret, pos = 0;
|
|
|
|
u16 cpu_cs_register = cypress[type].cpu_cs_register;
|
2005-06-24 13:02:35 +08:00
|
|
|
|
2017-02-12 23:02:13 +08:00
|
|
|
buf = kmalloc(sizeof(*hx), GFP_KERNEL);
|
|
|
|
if (!buf)
|
2017-01-24 18:13:11 +08:00
|
|
|
return -ENOMEM;
|
2017-02-12 23:02:13 +08:00
|
|
|
hx = (struct hexline *)buf;
|
2017-01-24 18:13:11 +08:00
|
|
|
|
2006-01-10 01:25:04 +08:00
|
|
|
/* stop the CPU */
|
2017-02-12 23:02:13 +08:00
|
|
|
buf[0] = 1;
|
|
|
|
if (usb_cypress_writemem(udev, cpu_cs_register, buf, 1) != 1)
|
2006-01-10 01:25:04 +08:00
|
|
|
err("could not stop the USB controller CPU.");
|
|
|
|
|
2017-01-24 18:13:11 +08:00
|
|
|
while ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) {
|
|
|
|
deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n", hx->addr, hx->len, hx->chk);
|
|
|
|
ret = usb_cypress_writemem(udev, hx->addr, hx->data, hx->len);
|
2006-01-10 01:25:04 +08:00
|
|
|
|
2017-01-24 18:13:11 +08:00
|
|
|
if (ret != hx->len) {
|
[media] dvb-usb: 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-19 03:44:15 +08:00
|
|
|
err("error while transferring firmware (transferred size: %d, block size: %d)",
|
2017-01-24 18:13:11 +08:00
|
|
|
ret, hx->len);
|
2006-01-10 01:25:04 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret < 0) {
|
|
|
|
err("firmware download failed at %d with %d",pos,ret);
|
2017-02-12 23:02:13 +08:00
|
|
|
kfree(buf);
|
2005-06-24 13:02:35 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-10 01:25:04 +08:00
|
|
|
if (ret == 0) {
|
2005-06-24 13:02:35 +08:00
|
|
|
/* restart the CPU */
|
2017-02-12 23:02:13 +08:00
|
|
|
buf[0] = 0;
|
|
|
|
if (usb_cypress_writemem(udev, cpu_cs_register, buf, 1) != 1) {
|
2005-06-24 13:02:35 +08:00
|
|
|
err("could not restart the USB controller CPU.");
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
2006-01-10 01:25:04 +08:00
|
|
|
} else
|
|
|
|
ret = -EIO;
|
2005-06-24 13:02:35 +08:00
|
|
|
|
2017-02-12 23:02:13 +08:00
|
|
|
kfree(buf);
|
2017-01-24 18:13:11 +08:00
|
|
|
|
2006-01-10 01:25:04 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2006-01-10 04:21:38 +08:00
|
|
|
EXPORT_SYMBOL(usb_cypress_load_firmware);
|
2006-01-10 04:21:28 +08:00
|
|
|
|
2006-09-30 17:53:48 +08:00
|
|
|
int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_properties *props)
|
2006-01-10 01:25:04 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
const struct firmware *fw = NULL;
|
|
|
|
|
|
|
|
if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) {
|
2018-05-09 05:10:05 +08:00
|
|
|
err("did not find the firmware file '%s' (status %d). You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware",
|
2006-01-10 01:25:04 +08:00
|
|
|
props->firmware,ret);
|
|
|
|
return ret;
|
2005-06-24 13:02:35 +08:00
|
|
|
}
|
|
|
|
|
2006-01-10 01:25:04 +08:00
|
|
|
info("downloading firmware from file '%s'",props->firmware);
|
|
|
|
|
|
|
|
switch (props->usb_ctrl) {
|
|
|
|
case CYPRESS_AN2135:
|
|
|
|
case CYPRESS_AN2235:
|
|
|
|
case CYPRESS_FX2:
|
|
|
|
ret = usb_cypress_load_firmware(udev, fw, props->usb_ctrl);
|
|
|
|
break;
|
|
|
|
case DEVICE_SPECIFIC:
|
|
|
|
if (props->download_firmware)
|
|
|
|
ret = props->download_firmware(udev,fw);
|
|
|
|
else {
|
|
|
|
err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one.");
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
release_firmware(fw);
|
2005-06-24 13:02:35 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2006-01-10 01:25:04 +08:00
|
|
|
|
2006-09-19 23:51:33 +08:00
|
|
|
int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
|
2006-01-23 19:58:17 +08:00
|
|
|
int *pos)
|
2006-01-10 01:25:04 +08:00
|
|
|
{
|
|
|
|
u8 *b = (u8 *) &fw->data[*pos];
|
|
|
|
int data_offs = 4;
|
|
|
|
if (*pos >= fw->size)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
memset(hx,0,sizeof(struct hexline));
|
|
|
|
|
|
|
|
hx->len = b[0];
|
|
|
|
|
|
|
|
if ((*pos + hx->len + 4) >= fw->size)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2008-05-21 11:33:01 +08:00
|
|
|
hx->addr = b[1] | (b[2] << 8);
|
2006-01-10 01:25:04 +08:00
|
|
|
hx->type = b[3];
|
|
|
|
|
|
|
|
if (hx->type == 0x04) {
|
|
|
|
/* b[4] and b[5] are the Extended linear address record data field */
|
|
|
|
hx->addr |= (b[4] << 24) | (b[5] << 16);
|
|
|
|
/* hx->len -= 2;
|
|
|
|
data_offs += 2; */
|
|
|
|
}
|
|
|
|
memcpy(hx->data,&b[data_offs],hx->len);
|
|
|
|
hx->chk = b[hx->len + data_offs];
|
|
|
|
|
|
|
|
*pos += hx->len + 5;
|
|
|
|
|
|
|
|
return *pos;
|
|
|
|
}
|
2006-09-19 23:51:33 +08:00
|
|
|
EXPORT_SYMBOL(dvb_usb_get_hexline);
|