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 17:07:57 +03:00
// SPDX-License-Identifier: GPL-2.0
2015-12-08 13:38:05 +03:00
/*
* Marvell Dove PMU Core PLL divider driver
*
* Cleaned up by substantially rewriting , and converted to DT by
* Russell King . Origin is not known .
*/
# include <linux/clk-provider.h>
# include <linux/delay.h>
# include <linux/io.h>
# include <linux/kernel.h>
# include <linux/of.h>
# include <linux/of_address.h>
# include "dove-divider.h"
struct dove_clk {
const char * name ;
struct clk_hw hw ;
void __iomem * base ;
spinlock_t * lock ;
u8 div_bit_start ;
u8 div_bit_end ;
u8 div_bit_load ;
u8 div_bit_size ;
u32 * divider_table ;
} ;
enum {
DIV_CTRL0 = 0 ,
DIV_CTRL1 = 4 ,
DIV_CTRL1_N_RESET_MASK = BIT ( 10 ) ,
} ;
# define to_dove_clk(hw) container_of(hw, struct dove_clk, hw)
static void dove_load_divider ( void __iomem * base , u32 val , u32 mask , u32 load )
{
u32 v ;
v = readl_relaxed ( base + DIV_CTRL1 ) | DIV_CTRL1_N_RESET_MASK ;
writel_relaxed ( v , base + DIV_CTRL1 ) ;
v = ( readl_relaxed ( base + DIV_CTRL0 ) & ~ ( mask | load ) ) | val ;
writel_relaxed ( v , base + DIV_CTRL0 ) ;
writel_relaxed ( v | load , base + DIV_CTRL0 ) ;
ndelay ( 250 ) ;
writel_relaxed ( v , base + DIV_CTRL0 ) ;
}
static unsigned int dove_get_divider ( struct dove_clk * dc )
{
unsigned int divider ;
u32 val ;
val = readl_relaxed ( dc - > base + DIV_CTRL0 ) ;
val > > = dc - > div_bit_start ;
divider = val & ~ ( ~ 0 < < dc - > div_bit_size ) ;
if ( dc - > divider_table )
divider = dc - > divider_table [ divider ] ;
return divider ;
}
static int dove_calc_divider ( const struct dove_clk * dc , unsigned long rate ,
unsigned long parent_rate , bool set )
{
unsigned int divider , max ;
divider = DIV_ROUND_CLOSEST ( parent_rate , rate ) ;
if ( dc - > divider_table ) {
unsigned int i ;
for ( i = 0 ; dc - > divider_table [ i ] ; i + + )
if ( divider = = dc - > divider_table [ i ] ) {
divider = i ;
break ;
}
if ( ! dc - > divider_table [ i ] )
return - EINVAL ;
} else {
max = 1 < < dc - > div_bit_size ;
if ( set & & ( divider = = 0 | | divider > = max ) )
return - EINVAL ;
if ( divider > = max )
divider = max - 1 ;
else if ( divider = = 0 )
divider = 1 ;
}
return divider ;
}
static unsigned long dove_recalc_rate ( struct clk_hw * hw , unsigned long parent )
{
struct dove_clk * dc = to_dove_clk ( hw ) ;
unsigned int divider = dove_get_divider ( dc ) ;
unsigned long rate = DIV_ROUND_CLOSEST ( parent , divider ) ;
pr_debug ( " %s(): %s divider=%u parent=%lu rate=%lu \n " ,
__func__ , dc - > name , divider , parent , rate ) ;
return rate ;
}
static long dove_round_rate ( struct clk_hw * hw , unsigned long rate ,
unsigned long * parent )
{
struct dove_clk * dc = to_dove_clk ( hw ) ;
unsigned long parent_rate = * parent ;
int divider ;
divider = dove_calc_divider ( dc , rate , parent_rate , false ) ;
if ( divider < 0 )
return divider ;
rate = DIV_ROUND_CLOSEST ( parent_rate , divider ) ;
pr_debug ( " %s(): %s divider=%u parent=%lu rate=%lu \n " ,
__func__ , dc - > name , divider , parent_rate , rate ) ;
return rate ;
}
static int dove_set_clock ( struct clk_hw * hw , unsigned long rate ,
unsigned long parent_rate )
{
struct dove_clk * dc = to_dove_clk ( hw ) ;
u32 mask , load , div ;
int divider ;
divider = dove_calc_divider ( dc , rate , parent_rate , true ) ;
if ( divider < 0 )
return divider ;
pr_debug ( " %s(): %s divider=%u parent=%lu rate=%lu \n " ,
__func__ , dc - > name , divider , parent_rate , rate ) ;
div = ( u32 ) divider < < dc - > div_bit_start ;
mask = ~ ( ~ 0 < < dc - > div_bit_size ) < < dc - > div_bit_start ;
load = BIT ( dc - > div_bit_load ) ;
spin_lock ( dc - > lock ) ;
dove_load_divider ( dc - > base , div , mask , load ) ;
spin_unlock ( dc - > lock ) ;
return 0 ;
}
static const struct clk_ops dove_divider_ops = {
. set_rate = dove_set_clock ,
. round_rate = dove_round_rate ,
. recalc_rate = dove_recalc_rate ,
} ;
static struct clk * clk_register_dove_divider ( struct device * dev ,
struct dove_clk * dc , const char * * parent_names , size_t num_parents ,
void __iomem * base )
{
char name [ 32 ] ;
struct clk_init_data init = {
. name = name ,
. ops = & dove_divider_ops ,
. parent_names = parent_names ,
. num_parents = num_parents ,
} ;
2022-08-19 00:00:00 +03:00
strscpy ( name , dc - > name , sizeof ( name ) ) ;
2015-12-08 13:38:05 +03:00
dc - > hw . init = & init ;
dc - > base = base ;
dc - > div_bit_size = dc - > div_bit_end - dc - > div_bit_start + 1 ;
return clk_register ( dev , & dc - > hw ) ;
}
static DEFINE_SPINLOCK ( dove_divider_lock ) ;
static u32 axi_divider [ ] = { - 1 , 2 , 1 , 3 , 4 , 6 , 5 , 7 , 8 , 10 , 9 , 0 } ;
static struct dove_clk dove_hw_clocks [ 4 ] = {
{
. name = " axi " ,
. lock = & dove_divider_lock ,
. div_bit_start = 1 ,
. div_bit_end = 6 ,
. div_bit_load = 7 ,
. divider_table = axi_divider ,
} , {
. name = " gpu " ,
. lock = & dove_divider_lock ,
. div_bit_start = 8 ,
. div_bit_end = 13 ,
. div_bit_load = 14 ,
} , {
. name = " vmeta " ,
. lock = & dove_divider_lock ,
. div_bit_start = 15 ,
. div_bit_end = 20 ,
. div_bit_load = 21 ,
} , {
. name = " lcd " ,
. lock = & dove_divider_lock ,
. div_bit_start = 22 ,
. div_bit_end = 27 ,
. div_bit_load = 28 ,
} ,
} ;
static const char * core_pll [ ] = {
" core-pll " ,
} ;
static int dove_divider_init ( struct device * dev , void __iomem * base ,
struct clk * * clks )
{
struct clk * clk ;
int i ;
/*
* Create the core PLL clock . We treat this as a fixed rate
* clock as we don ' t know any better , and documentation is sparse .
*/
2016-03-01 21:59:53 +03:00
clk = clk_register_fixed_rate ( dev , core_pll [ 0 ] , NULL , 0 , 2000000000UL ) ;
2015-12-08 13:38:05 +03:00
if ( IS_ERR ( clk ) )
return PTR_ERR ( clk ) ;
for ( i = 0 ; i < ARRAY_SIZE ( dove_hw_clocks ) ; i + + )
clks [ i ] = clk_register_dove_divider ( dev , & dove_hw_clocks [ i ] ,
core_pll ,
ARRAY_SIZE ( core_pll ) , base ) ;
return 0 ;
}
static struct clk * dove_divider_clocks [ 4 ] ;
static struct clk_onecell_data dove_divider_data = {
. clks = dove_divider_clocks ,
. clk_num = ARRAY_SIZE ( dove_divider_clocks ) ,
} ;
void __init dove_divider_clk_init ( struct device_node * np )
{
2016-01-08 20:35:58 +03:00
void __iomem * base ;
2015-12-08 13:38:05 +03:00
base = of_iomap ( np , 0 ) ;
if ( WARN_ON ( ! base ) )
return ;
if ( WARN_ON ( dove_divider_init ( NULL , base , dove_divider_clocks ) ) ) {
iounmap ( base ) ;
return ;
}
of_clk_add_provider ( np , of_clk_src_onecell_get , & dove_divider_data ) ;
}