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 07:07:57 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2013-09-26 05:38:16 -07:00
|
|
|
#ifndef USB_STORAGE_COMMON_H
|
|
|
|
#define USB_STORAGE_COMMON_H
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/usb/storage.h>
|
|
|
|
#include <scsi/scsi.h>
|
2024-10-01 12:35:57 -07:00
|
|
|
#include <linux/unaligned.h>
|
2013-09-26 05:38:16 -07:00
|
|
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
#undef VERBOSE_DEBUG
|
|
|
|
#undef DUMP_MSGS
|
|
|
|
#endif /* !DEBUG */
|
|
|
|
|
|
|
|
#ifdef VERBOSE_DEBUG
|
|
|
|
#define VLDBG LDBG
|
|
|
|
#else
|
|
|
|
#define VLDBG(lun, fmt, args...) do { } while (0)
|
|
|
|
#endif /* VERBOSE_DEBUG */
|
|
|
|
|
2013-10-09 01:05:53 -07:00
|
|
|
#define _LMSG(func, lun, fmt, args...) \
|
|
|
|
do { \
|
|
|
|
if ((lun)->name_pfx && *(lun)->name_pfx) \
|
|
|
|
func("%s/%s: " fmt, *(lun)->name_pfx, \
|
|
|
|
(lun)->name, ## args); \
|
|
|
|
else \
|
|
|
|
func("%s: " fmt, (lun)->name, ## args); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define LDBG(lun, fmt, args...) _LMSG(pr_debug, lun, fmt, ## args)
|
|
|
|
#define LERROR(lun, fmt, args...) _LMSG(pr_err, lun, fmt, ## args)
|
|
|
|
#define LWARN(lun, fmt, args...) _LMSG(pr_warn, lun, fmt, ## args)
|
|
|
|
#define LINFO(lun, fmt, args...) _LMSG(pr_info, lun, fmt, ## args)
|
|
|
|
|
2013-09-26 05:38:16 -07:00
|
|
|
|
|
|
|
#ifdef DUMP_MSGS
|
|
|
|
|
|
|
|
# define dump_msg(fsg, /* const char * */ label, \
|
|
|
|
/* const u8 * */ buf, /* unsigned */ length) \
|
|
|
|
do { \
|
|
|
|
if (length < 512) { \
|
|
|
|
DBG(fsg, "%s, length %u:\n", label, length); \
|
|
|
|
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, \
|
|
|
|
16, 1, buf, length, 0); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
# define dump_cdb(fsg) do { } while (0)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
# define dump_msg(fsg, /* const char * */ label, \
|
|
|
|
/* const u8 * */ buf, /* unsigned */ length) do { } while (0)
|
|
|
|
|
|
|
|
# ifdef VERBOSE_DEBUG
|
|
|
|
|
|
|
|
# define dump_cdb(fsg) \
|
|
|
|
print_hex_dump(KERN_DEBUG, "SCSI CDB: ", DUMP_PREFIX_NONE, \
|
|
|
|
16, 1, (fsg)->cmnd, (fsg)->cmnd_size, 0) \
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
# define dump_cdb(fsg) do { } while (0)
|
|
|
|
|
|
|
|
# endif /* VERBOSE_DEBUG */
|
|
|
|
|
|
|
|
#endif /* DUMP_MSGS */
|
|
|
|
|
|
|
|
/* Length of a SCSI Command Data Block */
|
|
|
|
#define MAX_COMMAND_SIZE 16
|
|
|
|
|
|
|
|
/* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
|
|
|
|
#define SS_NO_SENSE 0
|
|
|
|
#define SS_COMMUNICATION_FAILURE 0x040800
|
|
|
|
#define SS_INVALID_COMMAND 0x052000
|
|
|
|
#define SS_INVALID_FIELD_IN_CDB 0x052400
|
|
|
|
#define SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x052100
|
|
|
|
#define SS_LOGICAL_UNIT_NOT_SUPPORTED 0x052500
|
|
|
|
#define SS_MEDIUM_NOT_PRESENT 0x023a00
|
|
|
|
#define SS_MEDIUM_REMOVAL_PREVENTED 0x055302
|
|
|
|
#define SS_NOT_READY_TO_READY_TRANSITION 0x062800
|
|
|
|
#define SS_RESET_OCCURRED 0x062900
|
|
|
|
#define SS_SAVING_PARAMETERS_NOT_SUPPORTED 0x053900
|
|
|
|
#define SS_UNRECOVERED_READ_ERROR 0x031100
|
|
|
|
#define SS_WRITE_ERROR 0x030c02
|
|
|
|
#define SS_WRITE_PROTECTED 0x072700
|
|
|
|
|
|
|
|
#define SK(x) ((u8) ((x) >> 16)) /* Sense Key byte, etc. */
|
|
|
|
#define ASC(x) ((u8) ((x) >> 8))
|
|
|
|
#define ASCQ(x) ((u8) (x))
|
|
|
|
|
2016-08-01 08:04:19 -07:00
|
|
|
/*
|
|
|
|
* Vendor (8 chars), product (16 chars), release (4 hexadecimal digits) and NUL
|
|
|
|
* byte
|
|
|
|
*/
|
|
|
|
#define INQUIRY_STRING_LEN ((size_t) (8 + 16 + 4 + 1))
|
|
|
|
|
2013-09-26 05:38:16 -07:00
|
|
|
struct fsg_lun {
|
|
|
|
struct file *filp;
|
|
|
|
loff_t file_length;
|
|
|
|
loff_t num_sectors;
|
|
|
|
|
|
|
|
unsigned int initially_ro:1;
|
|
|
|
unsigned int ro:1;
|
|
|
|
unsigned int removable:1;
|
|
|
|
unsigned int cdrom:1;
|
|
|
|
unsigned int prevent_medium_removal:1;
|
|
|
|
unsigned int registered:1;
|
|
|
|
unsigned int info_valid:1;
|
|
|
|
unsigned int nofua:1;
|
|
|
|
|
|
|
|
u32 sense_data;
|
|
|
|
u32 sense_data_info;
|
|
|
|
u32 unit_attention_data;
|
|
|
|
|
|
|
|
unsigned int blkbits; /* Bits of logical block size
|
|
|
|
of bound block device */
|
|
|
|
unsigned int blksize; /* logical block size of bound block device */
|
|
|
|
struct device dev;
|
2013-10-09 01:05:53 -07:00
|
|
|
const char *name; /* "lun.name" */
|
|
|
|
const char **name_pfx; /* "function.name" */
|
2016-08-01 08:04:19 -07:00
|
|
|
char inquiry_string[INQUIRY_STRING_LEN];
|
2013-09-26 05:38:16 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
|
|
|
|
{
|
|
|
|
return curlun->filp != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Default size of buffer length. */
|
|
|
|
#define FSG_BUFLEN ((u32)16384)
|
|
|
|
|
|
|
|
/* Maximal number of LUNs supported in mass storage function */
|
2015-07-20 11:15:19 -07:00
|
|
|
#define FSG_MAX_LUNS 16
|
2013-09-26 05:38:16 -07:00
|
|
|
|
|
|
|
enum fsg_buffer_state {
|
2017-04-13 13:37:01 -07:00
|
|
|
BUF_STATE_SENDING = -2,
|
|
|
|
BUF_STATE_RECEIVING,
|
2013-09-26 05:38:16 -07:00
|
|
|
BUF_STATE_EMPTY = 0,
|
2017-04-13 13:37:01 -07:00
|
|
|
BUF_STATE_FULL
|
2013-09-26 05:38:16 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fsg_buffhd {
|
|
|
|
void *buf;
|
|
|
|
enum fsg_buffer_state state;
|
|
|
|
struct fsg_buffhd *next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The NetChip 2280 is faster, and handles some protocol faults
|
|
|
|
* better, if we don't submit any short bulk-out read requests.
|
|
|
|
* So we will record the intended request length here.
|
|
|
|
*/
|
|
|
|
unsigned int bulk_out_intended_length;
|
|
|
|
|
|
|
|
struct usb_request *inreq;
|
|
|
|
struct usb_request *outreq;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum fsg_state {
|
2017-04-13 13:36:50 -07:00
|
|
|
FSG_STATE_NORMAL,
|
2013-09-26 05:38:16 -07:00
|
|
|
FSG_STATE_ABORT_BULK_OUT,
|
2017-04-13 13:36:50 -07:00
|
|
|
FSG_STATE_PROTOCOL_RESET,
|
2013-09-26 05:38:16 -07:00
|
|
|
FSG_STATE_CONFIG_CHANGE,
|
|
|
|
FSG_STATE_EXIT,
|
|
|
|
FSG_STATE_TERMINATED
|
|
|
|
};
|
|
|
|
|
|
|
|
enum data_direction {
|
|
|
|
DATA_DIR_UNKNOWN = 0,
|
|
|
|
DATA_DIR_FROM_HOST,
|
|
|
|
DATA_DIR_TO_HOST,
|
|
|
|
DATA_DIR_NONE
|
|
|
|
};
|
|
|
|
|
2013-10-09 01:06:03 -07:00
|
|
|
static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev)
|
|
|
|
{
|
|
|
|
return container_of(dev, struct fsg_lun, dev);
|
|
|
|
}
|
|
|
|
|
2013-09-26 05:38:16 -07:00
|
|
|
enum {
|
|
|
|
FSG_STRING_INTERFACE
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct usb_interface_descriptor fsg_intf_desc;
|
|
|
|
|
|
|
|
extern struct usb_endpoint_descriptor fsg_fs_bulk_in_desc;
|
|
|
|
extern struct usb_endpoint_descriptor fsg_fs_bulk_out_desc;
|
|
|
|
extern struct usb_descriptor_header *fsg_fs_function[];
|
|
|
|
|
|
|
|
extern struct usb_endpoint_descriptor fsg_hs_bulk_in_desc;
|
|
|
|
extern struct usb_endpoint_descriptor fsg_hs_bulk_out_desc;
|
|
|
|
extern struct usb_descriptor_header *fsg_hs_function[];
|
|
|
|
|
|
|
|
extern struct usb_endpoint_descriptor fsg_ss_bulk_in_desc;
|
|
|
|
extern struct usb_ss_ep_comp_descriptor fsg_ss_bulk_in_comp_desc;
|
|
|
|
extern struct usb_endpoint_descriptor fsg_ss_bulk_out_desc;
|
|
|
|
extern struct usb_ss_ep_comp_descriptor fsg_ss_bulk_out_comp_desc;
|
|
|
|
extern struct usb_descriptor_header *fsg_ss_function[];
|
|
|
|
|
|
|
|
void fsg_lun_close(struct fsg_lun *curlun);
|
|
|
|
int fsg_lun_open(struct fsg_lun *curlun, const char *filename);
|
|
|
|
int fsg_lun_fsync_sub(struct fsg_lun *curlun);
|
|
|
|
void store_cdrom_address(u8 *dest, int msf, u32 addr);
|
2013-10-09 01:06:03 -07:00
|
|
|
ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf);
|
|
|
|
ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf);
|
|
|
|
ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
|
2013-09-26 05:38:16 -07:00
|
|
|
char *buf);
|
2016-08-01 08:04:19 -07:00
|
|
|
ssize_t fsg_show_inquiry_string(struct fsg_lun *curlun, char *buf);
|
2013-10-09 01:06:04 -07:00
|
|
|
ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf);
|
|
|
|
ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf);
|
2013-10-09 01:06:03 -07:00
|
|
|
ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem,
|
2013-09-26 05:38:16 -07:00
|
|
|
const char *buf, size_t count);
|
2013-10-09 01:06:03 -07:00
|
|
|
ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count);
|
|
|
|
ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
|
2013-09-26 05:38:16 -07:00
|
|
|
const char *buf, size_t count);
|
2013-10-14 23:33:13 -07:00
|
|
|
ssize_t fsg_store_cdrom(struct fsg_lun *curlun, struct rw_semaphore *filesem,
|
|
|
|
const char *buf, size_t count);
|
2013-10-09 01:06:04 -07:00
|
|
|
ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf,
|
|
|
|
size_t count);
|
2016-08-01 08:04:19 -07:00
|
|
|
ssize_t fsg_store_inquiry_string(struct fsg_lun *curlun, const char *buf,
|
|
|
|
size_t count);
|
2022-07-11 03:29:57 -07:00
|
|
|
ssize_t fsg_store_forced_eject(struct fsg_lun *curlun, struct rw_semaphore *filesem,
|
|
|
|
const char *buf, size_t count);
|
2013-09-26 05:38:16 -07:00
|
|
|
|
|
|
|
#endif /* USB_STORAGE_COMMON_H */
|