mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 09:31:50 +00:00
b24413180f
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>
286 lines
6.5 KiB
C
286 lines
6.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Driver for the ADB controller in the Mac I/O (Hydra) chip.
|
|
*/
|
|
#include <stdarg.h>
|
|
#include <linux/types.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/interrupt.h>
|
|
#include <asm/prom.h>
|
|
#include <linux/adb.h>
|
|
#include <asm/io.h>
|
|
#include <asm/pgtable.h>
|
|
#include <asm/hydra.h>
|
|
#include <asm/irq.h>
|
|
#include <linux/init.h>
|
|
#include <linux/ioport.h>
|
|
|
|
struct preg {
|
|
unsigned char r;
|
|
char pad[15];
|
|
};
|
|
|
|
struct adb_regs {
|
|
struct preg intr;
|
|
struct preg data[9];
|
|
struct preg intr_enb;
|
|
struct preg dcount;
|
|
struct preg error;
|
|
struct preg ctrl;
|
|
struct preg autopoll;
|
|
struct preg active_hi;
|
|
struct preg active_lo;
|
|
struct preg test;
|
|
};
|
|
|
|
/* Bits in intr and intr_enb registers */
|
|
#define DFB 1 /* data from bus */
|
|
#define TAG 2 /* transfer access grant */
|
|
|
|
/* Bits in dcount register */
|
|
#define HMB 0x0f /* how many bytes */
|
|
#define APD 0x10 /* auto-poll data */
|
|
|
|
/* Bits in error register */
|
|
#define NRE 1 /* no response error */
|
|
#define DLE 2 /* data lost error */
|
|
|
|
/* Bits in ctrl register */
|
|
#define TAR 1 /* transfer access request */
|
|
#define DTB 2 /* data to bus */
|
|
#define CRE 4 /* command response expected */
|
|
#define ADB_RST 8 /* ADB reset */
|
|
|
|
/* Bits in autopoll register */
|
|
#define APE 1 /* autopoll enable */
|
|
|
|
static volatile struct adb_regs __iomem *adb;
|
|
static struct adb_request *current_req, *last_req;
|
|
static DEFINE_SPINLOCK(macio_lock);
|
|
|
|
static int macio_probe(void);
|
|
static int macio_init(void);
|
|
static irqreturn_t macio_adb_interrupt(int irq, void *arg);
|
|
static int macio_send_request(struct adb_request *req, int sync);
|
|
static int macio_adb_autopoll(int devs);
|
|
static void macio_adb_poll(void);
|
|
static int macio_adb_reset_bus(void);
|
|
|
|
struct adb_driver macio_adb_driver = {
|
|
"MACIO",
|
|
macio_probe,
|
|
macio_init,
|
|
macio_send_request,
|
|
/*macio_write,*/
|
|
macio_adb_autopoll,
|
|
macio_adb_poll,
|
|
macio_adb_reset_bus
|
|
};
|
|
|
|
int macio_probe(void)
|
|
{
|
|
struct device_node *np;
|
|
|
|
np = of_find_compatible_node(NULL, "adb", "chrp,adb0");
|
|
if (np) {
|
|
of_node_put(np);
|
|
return 0;
|
|
}
|
|
return -ENODEV;
|
|
}
|
|
|
|
int macio_init(void)
|
|
{
|
|
struct device_node *adbs;
|
|
struct resource r;
|
|
unsigned int irq;
|
|
|
|
adbs = of_find_compatible_node(NULL, "adb", "chrp,adb0");
|
|
if (adbs == 0)
|
|
return -ENXIO;
|
|
|
|
if (of_address_to_resource(adbs, 0, &r)) {
|
|
of_node_put(adbs);
|
|
return -ENXIO;
|
|
}
|
|
adb = ioremap(r.start, sizeof(struct adb_regs));
|
|
|
|
out_8(&adb->ctrl.r, 0);
|
|
out_8(&adb->intr.r, 0);
|
|
out_8(&adb->error.r, 0);
|
|
out_8(&adb->active_hi.r, 0xff); /* for now, set all devices active */
|
|
out_8(&adb->active_lo.r, 0xff);
|
|
out_8(&adb->autopoll.r, APE);
|
|
|
|
irq = irq_of_parse_and_map(adbs, 0);
|
|
of_node_put(adbs);
|
|
if (request_irq(irq, macio_adb_interrupt, 0, "ADB", (void *)0)) {
|
|
printk(KERN_ERR "ADB: can't get irq %d\n", irq);
|
|
return -EAGAIN;
|
|
}
|
|
out_8(&adb->intr_enb.r, DFB | TAG);
|
|
|
|
printk("adb: mac-io driver 1.0 for unified ADB\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int macio_adb_autopoll(int devs)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&macio_lock, flags);
|
|
out_8(&adb->active_hi.r, devs >> 8);
|
|
out_8(&adb->active_lo.r, devs);
|
|
out_8(&adb->autopoll.r, devs? APE: 0);
|
|
spin_unlock_irqrestore(&macio_lock, flags);
|
|
return 0;
|
|
}
|
|
|
|
static int macio_adb_reset_bus(void)
|
|
{
|
|
unsigned long flags;
|
|
int timeout = 1000000;
|
|
|
|
/* Hrm... we may want to not lock interrupts for so
|
|
* long ... oh well, who uses that chip anyway ? :)
|
|
* That function will be seldom used during boot
|
|
* on rare machines, so...
|
|
*/
|
|
spin_lock_irqsave(&macio_lock, flags);
|
|
out_8(&adb->ctrl.r, in_8(&adb->ctrl.r) | ADB_RST);
|
|
while ((in_8(&adb->ctrl.r) & ADB_RST) != 0) {
|
|
if (--timeout == 0) {
|
|
out_8(&adb->ctrl.r, in_8(&adb->ctrl.r) & ~ADB_RST);
|
|
spin_unlock_irqrestore(&macio_lock, flags);
|
|
return -1;
|
|
}
|
|
}
|
|
spin_unlock_irqrestore(&macio_lock, flags);
|
|
return 0;
|
|
}
|
|
|
|
/* Send an ADB command */
|
|
static int macio_send_request(struct adb_request *req, int sync)
|
|
{
|
|
unsigned long flags;
|
|
int i;
|
|
|
|
if (req->data[0] != ADB_PACKET)
|
|
return -EINVAL;
|
|
|
|
for (i = 0; i < req->nbytes - 1; ++i)
|
|
req->data[i] = req->data[i+1];
|
|
--req->nbytes;
|
|
|
|
req->next = NULL;
|
|
req->sent = 0;
|
|
req->complete = 0;
|
|
req->reply_len = 0;
|
|
|
|
spin_lock_irqsave(&macio_lock, flags);
|
|
if (current_req != 0) {
|
|
last_req->next = req;
|
|
last_req = req;
|
|
} else {
|
|
current_req = last_req = req;
|
|
out_8(&adb->ctrl.r, in_8(&adb->ctrl.r) | TAR);
|
|
}
|
|
spin_unlock_irqrestore(&macio_lock, flags);
|
|
|
|
if (sync) {
|
|
while (!req->complete)
|
|
macio_adb_poll();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static irqreturn_t macio_adb_interrupt(int irq, void *arg)
|
|
{
|
|
int i, n, err;
|
|
struct adb_request *req = NULL;
|
|
unsigned char ibuf[16];
|
|
int ibuf_len = 0;
|
|
int complete = 0;
|
|
int autopoll = 0;
|
|
int handled = 0;
|
|
|
|
spin_lock(&macio_lock);
|
|
if (in_8(&adb->intr.r) & TAG) {
|
|
handled = 1;
|
|
if ((req = current_req) != 0) {
|
|
/* put the current request in */
|
|
for (i = 0; i < req->nbytes; ++i)
|
|
out_8(&adb->data[i].r, req->data[i]);
|
|
out_8(&adb->dcount.r, req->nbytes & HMB);
|
|
req->sent = 1;
|
|
if (req->reply_expected) {
|
|
out_8(&adb->ctrl.r, DTB + CRE);
|
|
} else {
|
|
out_8(&adb->ctrl.r, DTB);
|
|
current_req = req->next;
|
|
complete = 1;
|
|
if (current_req)
|
|
out_8(&adb->ctrl.r, in_8(&adb->ctrl.r) | TAR);
|
|
}
|
|
}
|
|
out_8(&adb->intr.r, 0);
|
|
}
|
|
|
|
if (in_8(&adb->intr.r) & DFB) {
|
|
handled = 1;
|
|
err = in_8(&adb->error.r);
|
|
if (current_req && current_req->sent) {
|
|
/* this is the response to a command */
|
|
req = current_req;
|
|
if (err == 0) {
|
|
req->reply_len = in_8(&adb->dcount.r) & HMB;
|
|
for (i = 0; i < req->reply_len; ++i)
|
|
req->reply[i] = in_8(&adb->data[i].r);
|
|
}
|
|
current_req = req->next;
|
|
complete = 1;
|
|
if (current_req)
|
|
out_8(&adb->ctrl.r, in_8(&adb->ctrl.r) | TAR);
|
|
} else if (err == 0) {
|
|
/* autopoll data */
|
|
n = in_8(&adb->dcount.r) & HMB;
|
|
for (i = 0; i < n; ++i)
|
|
ibuf[i] = in_8(&adb->data[i].r);
|
|
ibuf_len = n;
|
|
autopoll = (in_8(&adb->dcount.r) & APD) != 0;
|
|
}
|
|
out_8(&adb->error.r, 0);
|
|
out_8(&adb->intr.r, 0);
|
|
}
|
|
spin_unlock(&macio_lock);
|
|
if (complete && req) {
|
|
void (*done)(struct adb_request *) = req->done;
|
|
mb();
|
|
req->complete = 1;
|
|
/* Here, we assume that if the request has a done member, the
|
|
* struct request will survive to setting req->complete to 1
|
|
*/
|
|
if (done)
|
|
(*done)(req);
|
|
}
|
|
if (ibuf_len)
|
|
adb_input(ibuf, ibuf_len, autopoll);
|
|
|
|
return IRQ_RETVAL(handled);
|
|
}
|
|
|
|
static void macio_adb_poll(void)
|
|
{
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
if (in_8(&adb->intr.r) != 0)
|
|
macio_adb_interrupt(0, NULL);
|
|
local_irq_restore(flags);
|
|
}
|