···199199 acpi_display_output=video200200 See above.201201202202+ acpi_early_pdc_eval [HW,ACPI] Evaluate processor _PDC methods203203+ early. Needed on some platforms to properly204204+ initialize the EC.205205+202206 acpi_irq_balance [HW,ACPI]203207 ACPI will balance active IRQs204208 default in APIC mode···314310315311 aic79xx= [HW,SCSI]316312 See Documentation/scsi/aic79xx.txt.313313+314314+ alignment= [KNL,ARM]315315+ Allow the default userspace alignment fault handler316316+ behaviour to be specified. Bit 0 enables warnings,317317+ bit 1 enables fixups, and bit 2 sends a segfault.317318318319 amd_iommu= [HW,X86-84]319320 Pass parameters to the AMD IOMMU driver in the system.
···10741074 Default: 51075107510761076max_addresses - INTEGER10771077- Number of maximum addresses per interface. 0 disables limitation.10781078- It is recommended not set too large value (or 0) because it would10791079- be too easy way to crash kernel to allow to create too much of10801080- autoconfigured addresses.10771077+ Maximum number of autoconfigured addresses per interface. Setting10781078+ to zero disables the limitation. It is not recommended to set this10791079+ value too large (or to zero) because it would be an easy way to10801080+ crash the kernel by allowing too many addresses to be created.10811081 Default: 161082108210831083disable_ipv6 - BOOLEAN
+13-8
MAINTAINERS
···616616S: Maintained617617618618ARM/CORTINA SYSTEMS GEMINI ARM ARCHITECTURE619619-M: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>619619+M: Paulius Zaleckas <paulius.zaleckas@gmail.com>620620L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)621621T: git git://gitorious.org/linux-gemini/mainline.git622622-S: Maintained622622+S: Odd Fixes623623F: arch/arm/mach-gemini/624624625625ARM/EBSA110 MACHINE SUPPORT···641641F: arch/arm/mach-pxa/ezx.c642642643643ARM/FARADAY FA526 PORT644644-M: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>644644+M: Paulius Zaleckas <paulius.zaleckas@gmail.com>645645L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)646646-S: Maintained646646+S: Odd Fixes647647F: arch/arm/mm/*-fa*648648649649ARM/FOOTBRIDGE ARCHITECTURE···17331733F: net/dccp/1734173417351735DECnet NETWORK LAYER17361736-M: Christine Caulfield <christine.caulfield@googlemail.com>17371736W: http://linux-decnet.sourceforge.net17381737L: linux-decnet-user@lists.sourceforge.net17391739-S: Maintained17381738+S: Orphan17401739F: Documentation/networking/decnet.txt17411740F: net/decnet/17421741···23922393L: linuxppc-dev@ozlabs.org23932394S: Odd Fixes23942395F: drivers/char/hvc_*23962396+23972397+VIRTIO CONSOLE DRIVER23982398+M: Amit Shah <amit.shah@redhat.com>23992399+L: virtualization@lists.linux-foundation.org24002400+S: Maintained24012401+F: drivers/char/virtio_console.c2395240223962403GSPCA FINEPIX SUBDRIVER23972404M: Frank Zago <frank@zago.net>···34953490F: drivers/net/wireless/libertas/3496349134973492MARVELL MV643XX ETHERNET DRIVER34983498-M: Lennert Buytenhek <buytenh@marvell.com>34933493+M: Lennert Buytenhek <buytenh@wantstofly.org>34993494L: netdev@vger.kernel.org35003500-S: Supported34953495+S: Maintained35013496F: drivers/net/mv643xx_eth.*35023497F: include/linux/mv643xx.h35033498
···8686 unsigned int reg_both, reg_level, reg_type;87878888 reg_type = __raw_readl(base + GPIO_INT_TYPE);8989- reg_level = __raw_readl(base + GPIO_INT_BOTH_EDGE);8989+ reg_level = __raw_readl(base + GPIO_INT_LEVEL);9090 reg_both = __raw_readl(base + GPIO_INT_BOTH_EDGE);91919292 switch (type) {···117117 }118118119119 __raw_writel(reg_type, base + GPIO_INT_TYPE);120120- __raw_writel(reg_level, base + GPIO_INT_BOTH_EDGE);120120+ __raw_writel(reg_level, base + GPIO_INT_LEVEL);121121 __raw_writel(reg_both, base + GPIO_INT_BOTH_EDGE);122122123123 gpio_ack_irq(irq);
+5-7
arch/arm/mach-omap2/mux.c
···961961 while (superset->reg_offset != OMAP_MUX_TERMINATOR) {962962 struct omap_mux *entry;963963964964-#ifndef CONFIG_OMAP_MUX965965- /* Skip pins that are not muxed as GPIO by bootloader */966966- if (!OMAP_MODE_GPIO(omap_mux_read(superset->reg_offset))) {964964+#ifdef CONFIG_OMAP_MUX965965+ if (!superset->muxnames || !superset->muxnames[0]) {967966 superset++;968967 continue;969968 }970970-#endif971971-972972-#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS)973973- if (!superset->muxnames || !superset->muxnames[0]) {969969+#else970970+ /* Skip pins that are not muxed as GPIO by bootloader */971971+ if (!OMAP_MODE_GPIO(omap_mux_read(superset->reg_offset))) {974972 superset++;975973 continue;976974 }
+3
arch/arm/mm/alignment.c
···1111 * it under the terms of the GNU General Public License version 2 as1212 * published by the Free Software Foundation.1313 */1414+#include <linux/moduleparam.h>1415#include <linux/compiler.h>1516#include <linux/kernel.h>1617#include <linux/errno.h>···7776static unsigned long ai_dword;7877static unsigned long ai_multi;7978static int ai_usermode;7979+8080+core_param(alignment, ai_usermode, int, 0600);80818182#define UM_WARN (1 << 0)8283#define UM_FIXUP (1 << 1)
···4242#include <asm/sections.h>4343#include <asm/pci-bridge.h>44444545-static int __initdata dt_root_addr_cells;4646-static int __initdata dt_root_size_cells;4747-4848-typedef u32 cell_t;4949-5050-static struct boot_param_header *initial_boot_params;5151-5252-/* export that to outside world */5353-struct device_node *of_chosen;5454-5555-static inline char *find_flat_dt_string(u32 offset)4545+void __init early_init_dt_scan_chosen_arch(unsigned long node)5646{5757- return ((char *)initial_boot_params) +5858- initial_boot_params->off_dt_strings + offset;4747+ /* No Microblaze specific code here */5948}60496161-/**6262- * This function is used to scan the flattened device-tree, it is6363- * used to extract the memory informations at boot before we can6464- * unflatten the tree6565- */6666-int __init of_scan_flat_dt(int (*it)(unsigned long node,6767- const char *uname, int depth,6868- void *data),6969- void *data)5050+void __init early_init_dt_add_memory_arch(u64 base, u64 size)7051{7171- unsigned long p = ((unsigned long)initial_boot_params) +7272- initial_boot_params->off_dt_struct;7373- int rc = 0;7474- int depth = -1;7575-7676- do {7777- u32 tag = *((u32 *)p);7878- char *pathp;7979-8080- p += 4;8181- if (tag == OF_DT_END_NODE) {8282- depth--;8383- continue;8484- }8585- if (tag == OF_DT_NOP)8686- continue;8787- if (tag == OF_DT_END)8888- break;8989- if (tag == OF_DT_PROP) {9090- u32 sz = *((u32 *)p);9191- p += 8;9292- if (initial_boot_params->version < 0x10)9393- p = _ALIGN(p, sz >= 8 ? 8 : 4);9494- p += sz;9595- p = _ALIGN(p, 4);9696- continue;9797- }9898- if (tag != OF_DT_BEGIN_NODE) {9999- printk(KERN_WARNING "Invalid tag %x scanning flattened"100100- " device tree !\n", tag);101101- return -EINVAL;102102- }103103- depth++;104104- pathp = (char *)p;105105- p = _ALIGN(p + strlen(pathp) + 1, 4);106106- if ((*pathp) == '/') {107107- char *lp, *np;108108- for (lp = NULL, np = pathp; *np; np++)109109- if ((*np) == '/')110110- lp = np+1;111111- if (lp != NULL)112112- pathp = lp;113113- }114114- rc = it(p, pathp, depth, data);115115- if (rc != 0)116116- break;117117- } while (1);118118-119119- return rc;5252+ lmb_add(base, size);12053}12154122122-unsigned long __init of_get_flat_dt_root(void)5555+u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)12356{124124- unsigned long p = ((unsigned long)initial_boot_params) +125125- initial_boot_params->off_dt_struct;126126-127127- while (*((u32 *)p) == OF_DT_NOP)128128- p += 4;129129- BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);130130- p += 4;131131- return _ALIGN(p + strlen((char *)p) + 1, 4);5757+ return lmb_alloc(size, align);13258}133133-134134-/**135135- * This function can be used within scan_flattened_dt callback to get136136- * access to properties137137- */138138-void *__init of_get_flat_dt_prop(unsigned long node, const char *name,139139- unsigned long *size)140140-{141141- unsigned long p = node;142142-143143- do {144144- u32 tag = *((u32 *)p);145145- u32 sz, noff;146146- const char *nstr;147147-148148- p += 4;149149- if (tag == OF_DT_NOP)150150- continue;151151- if (tag != OF_DT_PROP)152152- return NULL;153153-154154- sz = *((u32 *)p);155155- noff = *((u32 *)(p + 4));156156- p += 8;157157- if (initial_boot_params->version < 0x10)158158- p = _ALIGN(p, sz >= 8 ? 8 : 4);159159-160160- nstr = find_flat_dt_string(noff);161161- if (nstr == NULL) {162162- printk(KERN_WARNING "Can't find property index"163163- " name !\n");164164- return NULL;165165- }166166- if (strcmp(name, nstr) == 0) {167167- if (size)168168- *size = sz;169169- return (void *)p;170170- }171171- p += sz;172172- p = _ALIGN(p, 4);173173- } while (1);174174-}175175-176176-int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)177177-{178178- const char *cp;179179- unsigned long cplen, l;180180-181181- cp = of_get_flat_dt_prop(node, "compatible", &cplen);182182- if (cp == NULL)183183- return 0;184184- while (cplen > 0) {185185- if (strncasecmp(cp, compat, strlen(compat)) == 0)186186- return 1;187187- l = strlen(cp) + 1;188188- cp += l;189189- cplen -= l;190190- }191191-192192- return 0;193193-}194194-195195-static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,196196- unsigned long align)197197-{198198- void *res;199199-200200- *mem = _ALIGN(*mem, align);201201- res = (void *)*mem;202202- *mem += size;203203-204204- return res;205205-}206206-207207-static unsigned long __init unflatten_dt_node(unsigned long mem,208208- unsigned long *p,209209- struct device_node *dad,210210- struct device_node ***allnextpp,211211- unsigned long fpsize)212212-{213213- struct device_node *np;214214- struct property *pp, **prev_pp = NULL;215215- char *pathp;216216- u32 tag;217217- unsigned int l, allocl;218218- int has_name = 0;219219- int new_format = 0;220220-221221- tag = *((u32 *)(*p));222222- if (tag != OF_DT_BEGIN_NODE) {223223- printk("Weird tag at start of node: %x\n", tag);224224- return mem;225225- }226226- *p += 4;227227- pathp = (char *)*p;228228- l = allocl = strlen(pathp) + 1;229229- *p = _ALIGN(*p + l, 4);230230-231231- /* version 0x10 has a more compact unit name here instead of the full232232- * path. we accumulate the full path size using "fpsize", we'll rebuild233233- * it later. We detect this because the first character of the name is234234- * not '/'.235235- */236236- if ((*pathp) != '/') {237237- new_format = 1;238238- if (fpsize == 0) {239239- /* root node: special case. fpsize accounts for path240240- * plus terminating zero. root node only has '/', so241241- * fpsize should be 2, but we want to avoid the first242242- * level nodes to have two '/' so we use fpsize 1 here243243- */244244- fpsize = 1;245245- allocl = 2;246246- } else {247247- /* account for '/' and path size minus terminal 0248248- * already in 'l'249249- */250250- fpsize += l;251251- allocl = fpsize;252252- }253253- }254254-255255- np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,256256- __alignof__(struct device_node));257257- if (allnextpp) {258258- memset(np, 0, sizeof(*np));259259- np->full_name = ((char *)np) + sizeof(struct device_node);260260- if (new_format) {261261- char *p2 = np->full_name;262262- /* rebuild full path for new format */263263- if (dad && dad->parent) {264264- strcpy(p2, dad->full_name);265265-#ifdef DEBUG266266- if ((strlen(p2) + l + 1) != allocl) {267267- pr_debug("%s: p: %d, l: %d, a: %d\n",268268- pathp, (int)strlen(p2),269269- l, allocl);270270- }271271-#endif272272- p2 += strlen(p2);273273- }274274- *(p2++) = '/';275275- memcpy(p2, pathp, l);276276- } else277277- memcpy(np->full_name, pathp, l);278278- prev_pp = &np->properties;279279- **allnextpp = np;280280- *allnextpp = &np->allnext;281281- if (dad != NULL) {282282- np->parent = dad;283283- /* we temporarily use the next field as `last_child'*/284284- if (dad->next == NULL)285285- dad->child = np;286286- else287287- dad->next->sibling = np;288288- dad->next = np;289289- }290290- kref_init(&np->kref);291291- }292292- while (1) {293293- u32 sz, noff;294294- char *pname;295295-296296- tag = *((u32 *)(*p));297297- if (tag == OF_DT_NOP) {298298- *p += 4;299299- continue;300300- }301301- if (tag != OF_DT_PROP)302302- break;303303- *p += 4;304304- sz = *((u32 *)(*p));305305- noff = *((u32 *)((*p) + 4));306306- *p += 8;307307- if (initial_boot_params->version < 0x10)308308- *p = _ALIGN(*p, sz >= 8 ? 8 : 4);309309-310310- pname = find_flat_dt_string(noff);311311- if (pname == NULL) {312312- printk(KERN_INFO313313- "Can't find property name in list !\n");314314- break;315315- }316316- if (strcmp(pname, "name") == 0)317317- has_name = 1;318318- l = strlen(pname) + 1;319319- pp = unflatten_dt_alloc(&mem, sizeof(struct property),320320- __alignof__(struct property));321321- if (allnextpp) {322322- if (strcmp(pname, "linux,phandle") == 0) {323323- np->node = *((u32 *)*p);324324- if (np->linux_phandle == 0)325325- np->linux_phandle = np->node;326326- }327327- if (strcmp(pname, "ibm,phandle") == 0)328328- np->linux_phandle = *((u32 *)*p);329329- pp->name = pname;330330- pp->length = sz;331331- pp->value = (void *)*p;332332- *prev_pp = pp;333333- prev_pp = &pp->next;334334- }335335- *p = _ALIGN((*p) + sz, 4);336336- }337337- /* with version 0x10 we may not have the name property, recreate338338- * it here from the unit name if absent339339- */340340- if (!has_name) {341341- char *p1 = pathp, *ps = pathp, *pa = NULL;342342- int sz;343343-344344- while (*p1) {345345- if ((*p1) == '@')346346- pa = p1;347347- if ((*p1) == '/')348348- ps = p1 + 1;349349- p1++;350350- }351351- if (pa < ps)352352- pa = p1;353353- sz = (pa - ps) + 1;354354- pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,355355- __alignof__(struct property));356356- if (allnextpp) {357357- pp->name = "name";358358- pp->length = sz;359359- pp->value = pp + 1;360360- *prev_pp = pp;361361- prev_pp = &pp->next;362362- memcpy(pp->value, ps, sz - 1);363363- ((char *)pp->value)[sz - 1] = 0;364364- pr_debug("fixed up name for %s -> %s\n", pathp,365365- (char *)pp->value);366366- }367367- }368368- if (allnextpp) {369369- *prev_pp = NULL;370370- np->name = of_get_property(np, "name", NULL);371371- np->type = of_get_property(np, "device_type", NULL);372372-373373- if (!np->name)374374- np->name = "<NULL>";375375- if (!np->type)376376- np->type = "<NULL>";377377- }378378- while (tag == OF_DT_BEGIN_NODE) {379379- mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);380380- tag = *((u32 *)(*p));381381- }382382- if (tag != OF_DT_END_NODE) {383383- printk(KERN_INFO "Weird tag at end of node: %x\n", tag);384384- return mem;385385- }386386- *p += 4;387387- return mem;388388-}389389-390390-/**391391- * unflattens the device-tree passed by the firmware, creating the392392- * tree of struct device_node. It also fills the "name" and "type"393393- * pointers of the nodes so the normal device-tree walking functions394394- * can be used (this used to be done by finish_device_tree)395395- */396396-void __init unflatten_device_tree(void)397397-{398398- unsigned long start, mem, size;399399- struct device_node **allnextp = &allnodes;400400-401401- pr_debug(" -> unflatten_device_tree()\n");402402-403403- /* First pass, scan for size */404404- start = ((unsigned long)initial_boot_params) +405405- initial_boot_params->off_dt_struct;406406- size = unflatten_dt_node(0, &start, NULL, NULL, 0);407407- size = (size | 3) + 1;408408-409409- pr_debug(" size is %lx, allocating...\n", size);410410-411411- /* Allocate memory for the expanded device tree */412412- mem = lmb_alloc(size + 4, __alignof__(struct device_node));413413- mem = (unsigned long) __va(mem);414414-415415- ((u32 *)mem)[size / 4] = 0xdeadbeef;416416-417417- pr_debug(" unflattening %lx...\n", mem);418418-419419- /* Second pass, do actual unflattening */420420- start = ((unsigned long)initial_boot_params) +421421- initial_boot_params->off_dt_struct;422422- unflatten_dt_node(mem, &start, NULL, &allnextp, 0);423423- if (*((u32 *)start) != OF_DT_END)424424- printk(KERN_WARNING "Weird tag at end of tree: %08x\n",425425- *((u32 *)start));426426- if (((u32 *)mem)[size / 4] != 0xdeadbeef)427427- printk(KERN_WARNING "End of tree marker overwritten: %08x\n",428428- ((u32 *)mem)[size / 4]);429429- *allnextp = NULL;430430-431431- /* Get pointer to OF "/chosen" node for use everywhere */432432- of_chosen = of_find_node_by_path("/chosen");433433- if (of_chosen == NULL)434434- of_chosen = of_find_node_by_path("/chosen@0");435435-436436- pr_debug(" <- unflatten_device_tree()\n");437437-}438438-439439-#define early_init_dt_scan_drconf_memory(node) 0440440-441441-static int __init early_init_dt_scan_cpus(unsigned long node,442442- const char *uname, int depth,443443- void *data)444444-{445445- static int logical_cpuid;446446- char *type = of_get_flat_dt_prop(node, "device_type", NULL);447447- const u32 *intserv;448448- int i, nthreads;449449- int found = 0;450450-451451- /* We are scanning "cpu" nodes only */452452- if (type == NULL || strcmp(type, "cpu") != 0)453453- return 0;454454-455455- /* Get physical cpuid */456456- intserv = of_get_flat_dt_prop(node, "reg", NULL);457457- nthreads = 1;458458-459459- /*460460- * Now see if any of these threads match our boot cpu.461461- * NOTE: This must match the parsing done in smp_setup_cpu_maps.462462- */463463- for (i = 0; i < nthreads; i++) {464464- /*465465- * version 2 of the kexec param format adds the phys cpuid of466466- * booted proc.467467- */468468- if (initial_boot_params && initial_boot_params->version >= 2) {469469- if (intserv[i] ==470470- initial_boot_params->boot_cpuid_phys) {471471- found = 1;472472- break;473473- }474474- } else {475475- /*476476- * Check if it's the boot-cpu, set it's hw index now,477477- * unfortunately this format did not support booting478478- * off secondary threads.479479- */480480- if (of_get_flat_dt_prop(node,481481- "linux,boot-cpu", NULL) != NULL) {482482- found = 1;483483- break;484484- }485485- }486486-487487-#ifdef CONFIG_SMP488488- /* logical cpu id is always 0 on UP kernels */489489- logical_cpuid++;490490-#endif491491- }492492-493493- if (found) {494494- pr_debug("boot cpu: logical %d physical %d\n", logical_cpuid,495495- intserv[i]);496496- boot_cpuid = logical_cpuid;497497- }498498-499499- return 0;500500-}501501-502502-#ifdef CONFIG_BLK_DEV_INITRD503503-static void __init early_init_dt_check_for_initrd(unsigned long node)504504-{505505- unsigned long l;506506- u32 *prop;507507-508508- pr_debug("Looking for initrd properties... ");509509-510510- prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);511511- if (prop) {512512- initrd_start = (unsigned long)513513- __va((u32)of_read_ulong(prop, l/4));514514-515515- prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);516516- if (prop) {517517- initrd_end = (unsigned long)518518- __va((u32)of_read_ulong(prop, 1/4));519519- initrd_below_start_ok = 1;520520- } else {521521- initrd_start = 0;522522- }523523- }524524-525525- pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n",526526- initrd_start, initrd_end);527527-}528528-#else529529-static inline void early_init_dt_check_for_initrd(unsigned long node)530530-{531531-}532532-#endif /* CONFIG_BLK_DEV_INITRD */533533-534534-static int __init early_init_dt_scan_chosen(unsigned long node,535535- const char *uname, int depth, void *data)536536-{537537- unsigned long l;538538- char *p;539539-540540- pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);541541-542542- if (depth != 1 ||543543- (strcmp(uname, "chosen") != 0 &&544544- strcmp(uname, "chosen@0") != 0))545545- return 0;546546-547547-#ifdef CONFIG_KEXEC548548- lprop = (u64 *)of_get_flat_dt_prop(node,549549- "linux,crashkernel-base", NULL);550550- if (lprop)551551- crashk_res.start = *lprop;552552-553553- lprop = (u64 *)of_get_flat_dt_prop(node,554554- "linux,crashkernel-size", NULL);555555- if (lprop)556556- crashk_res.end = crashk_res.start + *lprop - 1;557557-#endif558558-559559- early_init_dt_check_for_initrd(node);560560-561561- /* Retreive command line */562562- p = of_get_flat_dt_prop(node, "bootargs", &l);563563- if (p != NULL && l > 0)564564- strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));565565-566566-#ifdef CONFIG_CMDLINE567567-#ifndef CONFIG_CMDLINE_FORCE568568- if (p == NULL || l == 0 || (l == 1 && (*p) == 0))569569-#endif570570- strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);571571-#endif /* CONFIG_CMDLINE */572572-573573- pr_debug("Command line is: %s\n", cmd_line);574574-575575- /* break now */576576- return 1;577577-}578578-579579-static int __init early_init_dt_scan_root(unsigned long node,580580- const char *uname, int depth, void *data)581581-{582582- u32 *prop;583583-584584- if (depth != 0)585585- return 0;586586-587587- prop = of_get_flat_dt_prop(node, "#size-cells", NULL);588588- dt_root_size_cells = (prop == NULL) ? 1 : *prop;589589- pr_debug("dt_root_size_cells = %x\n", dt_root_size_cells);590590-591591- prop = of_get_flat_dt_prop(node, "#address-cells", NULL);592592- dt_root_addr_cells = (prop == NULL) ? 2 : *prop;593593- pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells);594594-595595- /* break now */596596- return 1;597597-}598598-599599-static u64 __init dt_mem_next_cell(int s, cell_t **cellp)600600-{601601- cell_t *p = *cellp;602602-603603- *cellp = p + s;604604- return of_read_number(p, s);605605-}606606-607607-static int __init early_init_dt_scan_memory(unsigned long node,608608- const char *uname, int depth, void *data)609609-{610610- char *type = of_get_flat_dt_prop(node, "device_type", NULL);611611- cell_t *reg, *endp;612612- unsigned long l;613613-614614- /* Look for the ibm,dynamic-reconfiguration-memory node */615615-/* if (depth == 1 &&616616- strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0)617617- return early_init_dt_scan_drconf_memory(node);618618-*/619619- /* We are scanning "memory" nodes only */620620- if (type == NULL) {621621- /*622622- * The longtrail doesn't have a device_type on the623623- * /memory node, so look for the node called /memory@0.624624- */625625- if (depth != 1 || strcmp(uname, "memory@0") != 0)626626- return 0;627627- } else if (strcmp(type, "memory") != 0)628628- return 0;629629-630630- reg = (cell_t *)of_get_flat_dt_prop(node, "linux,usable-memory", &l);631631- if (reg == NULL)632632- reg = (cell_t *)of_get_flat_dt_prop(node, "reg", &l);633633- if (reg == NULL)634634- return 0;635635-636636- endp = reg + (l / sizeof(cell_t));637637-638638- pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",639639- uname, l, reg[0], reg[1], reg[2], reg[3]);640640-641641- while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {642642- u64 base, size;643643-644644- base = dt_mem_next_cell(dt_root_addr_cells, ®);645645- size = dt_mem_next_cell(dt_root_size_cells, ®);646646-647647- if (size == 0)648648- continue;649649- pr_debug(" - %llx , %llx\n", (unsigned long long)base,650650- (unsigned long long)size);651651-652652- lmb_add(base, size);653653- }654654- return 0;655655-}656656-657657-#ifdef CONFIG_PHYP_DUMP658658-/**659659- * phyp_dump_calculate_reserve_size() - reserve variable boot area 5% or arg660660- *661661- * Function to find the largest size we need to reserve662662- * during early boot process.663663- *664664- * It either looks for boot param and returns that OR665665- * returns larger of 256 or 5% rounded down to multiples of 256MB.666666- *667667- */668668-static inline unsigned long phyp_dump_calculate_reserve_size(void)669669-{670670- unsigned long tmp;671671-672672- if (phyp_dump_info->reserve_bootvar)673673- return phyp_dump_info->reserve_bootvar;674674-675675- /* divide by 20 to get 5% of value */676676- tmp = lmb_end_of_DRAM();677677- do_div(tmp, 20);678678-679679- /* round it down in multiples of 256 */680680- tmp = tmp & ~0x0FFFFFFFUL;681681-682682- return (tmp > PHYP_DUMP_RMR_END ? tmp : PHYP_DUMP_RMR_END);683683-}684684-685685-/**686686- * phyp_dump_reserve_mem() - reserve all not-yet-dumped mmemory687687- *688688- * This routine may reserve memory regions in the kernel only689689- * if the system is supported and a dump was taken in last690690- * boot instance or if the hardware is supported and the691691- * scratch area needs to be setup. In other instances it returns692692- * without reserving anything. The memory in case of dump being693693- * active is freed when the dump is collected (by userland tools).694694- */695695-static void __init phyp_dump_reserve_mem(void)696696-{697697- unsigned long base, size;698698- unsigned long variable_reserve_size;699699-700700- if (!phyp_dump_info->phyp_dump_configured) {701701- printk(KERN_ERR "Phyp-dump not supported on this hardware\n");702702- return;703703- }704704-705705- if (!phyp_dump_info->phyp_dump_at_boot) {706706- printk(KERN_INFO "Phyp-dump disabled at boot time\n");707707- return;708708- }709709-710710- variable_reserve_size = phyp_dump_calculate_reserve_size();711711-712712- if (phyp_dump_info->phyp_dump_is_active) {713713- /* Reserve *everything* above RMR.Area freed by userland tools*/714714- base = variable_reserve_size;715715- size = lmb_end_of_DRAM() - base;716716-717717- /* XXX crashed_ram_end is wrong, since it may be beyond718718- * the memory_limit, it will need to be adjusted. */719719- lmb_reserve(base, size);720720-721721- phyp_dump_info->init_reserve_start = base;722722- phyp_dump_info->init_reserve_size = size;723723- } else {724724- size = phyp_dump_info->cpu_state_size +725725- phyp_dump_info->hpte_region_size +726726- variable_reserve_size;727727- base = lmb_end_of_DRAM() - size;728728- lmb_reserve(base, size);729729- phyp_dump_info->init_reserve_start = base;730730- phyp_dump_info->init_reserve_size = size;731731- }732732-}733733-#else734734-static inline void __init phyp_dump_reserve_mem(void) {}735735-#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */7365973760#ifdef CONFIG_EARLY_PRINTK73861/* MS this is Microblaze specifig function */···98775 /* Setup flat device-tree pointer */99776 initial_boot_params = params;100777101101-#ifdef CONFIG_PHYP_DUMP102102- /* scan tree to see if dump occured during last boot */103103- of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL);104104-#endif105105-106778 /* Retrieve various informations from the /chosen node of the107779 * device-tree, including the platform type, initrd location and108780 * size, TCE reserve, and more ...···117799118800 pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size());119801120120- pr_debug("Scanning CPUs ...\n");121121-122122- /* Retreive CPU related informations from the flat tree123123- * (altivec support, boot CPU ID, ...)124124- */125125- of_scan_flat_dt(early_init_dt_scan_cpus, NULL);126126-127802 pr_debug(" <- early_init_devtree()\n");128803}129804130130-/**131131- * Indicates whether the root node has a given value in its132132- * compatible property.133133- */134134-int machine_is_compatible(const char *compat)805805+#ifdef CONFIG_BLK_DEV_INITRD806806+void __init early_init_dt_setup_initrd_arch(unsigned long start,807807+ unsigned long end)135808{136136- struct device_node *root;137137- int rc = 0;138138-139139- root = of_find_node_by_path("/");140140- if (root) {141141- rc = of_device_is_compatible(root, compat);142142- of_node_put(root);143143- }144144- return rc;809809+ initrd_start = (unsigned long)__va(start);810810+ initrd_end = (unsigned long)__va(end);811811+ initrd_below_start_ok = 1;145812}146146-EXPORT_SYMBOL(machine_is_compatible);813813+#endif147814148815/*******149816 *···140837 * this isn't dealt with yet.141838 *142839 *******/143143-144144-/**145145- * of_find_node_by_phandle - Find a node given a phandle146146- * @handle: phandle of the node to find147147- *148148- * Returns a node pointer with refcount incremented, use149149- * of_node_put() on it when done.150150- */151151-struct device_node *of_find_node_by_phandle(phandle handle)152152-{153153- struct device_node *np;154154-155155- read_lock(&devtree_lock);156156- for (np = allnodes; np != NULL; np = np->allnext)157157- if (np->linux_phandle == handle)158158- break;159159- of_node_get(np);160160- read_unlock(&devtree_lock);161161- return np;162162-}163163-EXPORT_SYMBOL(of_find_node_by_phandle);164164-165165-/**166166- * of_node_get - Increment refcount of a node167167- * @node: Node to inc refcount, NULL is supported to168168- * simplify writing of callers169169- *170170- * Returns node.171171- */172172-struct device_node *of_node_get(struct device_node *node)173173-{174174- if (node)175175- kref_get(&node->kref);176176- return node;177177-}178178-EXPORT_SYMBOL(of_node_get);179179-180180-static inline struct device_node *kref_to_device_node(struct kref *kref)181181-{182182- return container_of(kref, struct device_node, kref);183183-}184184-185185-/**186186- * of_node_release - release a dynamically allocated node187187- * @kref: kref element of the node to be released188188- *189189- * In of_node_put() this function is passed to kref_put()190190- * as the destructor.191191- */192192-static void of_node_release(struct kref *kref)193193-{194194- struct device_node *node = kref_to_device_node(kref);195195- struct property *prop = node->properties;196196-197197- /* We should never be releasing nodes that haven't been detached. */198198- if (!of_node_check_flag(node, OF_DETACHED)) {199199- printk(KERN_INFO "WARNING: Bad of_node_put() on %s\n",200200- node->full_name);201201- dump_stack();202202- kref_init(&node->kref);203203- return;204204- }205205-206206- if (!of_node_check_flag(node, OF_DYNAMIC))207207- return;208208-209209- while (prop) {210210- struct property *next = prop->next;211211- kfree(prop->name);212212- kfree(prop->value);213213- kfree(prop);214214- prop = next;215215-216216- if (!prop) {217217- prop = node->deadprops;218218- node->deadprops = NULL;219219- }220220- }221221- kfree(node->full_name);222222- kfree(node->data);223223- kfree(node);224224-}225225-226226-/**227227- * of_node_put - Decrement refcount of a node228228- * @node: Node to dec refcount, NULL is supported to229229- * simplify writing of callers230230- *231231- */232232-void of_node_put(struct device_node *node)233233-{234234- if (node)235235- kref_put(&node->kref, of_node_release);236236-}237237-EXPORT_SYMBOL(of_node_put);238238-239239-/*240240- * Plug a device node into the tree and global list.241241- */242242-void of_attach_node(struct device_node *np)243243-{244244- unsigned long flags;245245-246246- write_lock_irqsave(&devtree_lock, flags);247247- np->sibling = np->parent->child;248248- np->allnext = allnodes;249249- np->parent->child = np;250250- allnodes = np;251251- write_unlock_irqrestore(&devtree_lock, flags);252252-}253253-254254-/*255255- * "Unplug" a node from the device tree. The caller must hold256256- * a reference to the node. The memory associated with the node257257- * is not freed until its refcount goes to zero.258258- */259259-void of_detach_node(struct device_node *np)260260-{261261- struct device_node *parent;262262- unsigned long flags;263263-264264- write_lock_irqsave(&devtree_lock, flags);265265-266266- parent = np->parent;267267- if (!parent)268268- goto out_unlock;269269-270270- if (allnodes == np)271271- allnodes = np->allnext;272272- else {273273- struct device_node *prev;274274- for (prev = allnodes;275275- prev->allnext != np;276276- prev = prev->allnext)277277- ;278278- prev->allnext = np->allnext;279279- }280280-281281- if (parent->child == np)282282- parent->child = np->sibling;283283- else {284284- struct device_node *prevsib;285285- for (prevsib = np->parent->child;286286- prevsib->sibling != np;287287- prevsib = prevsib->sibling)288288- ;289289- prevsib->sibling = np->sibling;290290- }291291-292292- of_node_set_flag(np, OF_DETACHED);293293-294294-out_unlock:295295- write_unlock_irqrestore(&devtree_lock, flags);296296-}297297-298298-/*299299- * Add a property to a node300300- */301301-int prom_add_property(struct device_node *np, struct property *prop)302302-{303303- struct property **next;304304- unsigned long flags;305305-306306- prop->next = NULL;307307- write_lock_irqsave(&devtree_lock, flags);308308- next = &np->properties;309309- while (*next) {310310- if (strcmp(prop->name, (*next)->name) == 0) {311311- /* duplicate ! don't insert it */312312- write_unlock_irqrestore(&devtree_lock, flags);313313- return -1;314314- }315315- next = &(*next)->next;316316- }317317- *next = prop;318318- write_unlock_irqrestore(&devtree_lock, flags);319319-320320-#ifdef CONFIG_PROC_DEVICETREE321321- /* try to add to proc as well if it was initialized */322322- if (np->pde)323323- proc_device_tree_add_prop(np->pde, prop);324324-#endif /* CONFIG_PROC_DEVICETREE */325325-326326- return 0;327327-}328328-329329-/*330330- * Remove a property from a node. Note that we don't actually331331- * remove it, since we have given out who-knows-how-many pointers332332- * to the data using get-property. Instead we just move the property333333- * to the "dead properties" list, so it won't be found any more.334334- */335335-int prom_remove_property(struct device_node *np, struct property *prop)336336-{337337- struct property **next;338338- unsigned long flags;339339- int found = 0;340340-341341- write_lock_irqsave(&devtree_lock, flags);342342- next = &np->properties;343343- while (*next) {344344- if (*next == prop) {345345- /* found the node */346346- *next = prop->next;347347- prop->next = np->deadprops;348348- np->deadprops = prop;349349- found = 1;350350- break;351351- }352352- next = &(*next)->next;353353- }354354- write_unlock_irqrestore(&devtree_lock, flags);355355-356356- if (!found)357357- return -ENODEV;358358-359359-#ifdef CONFIG_PROC_DEVICETREE360360- /* try to remove the proc node as well */361361- if (np->pde)362362- proc_device_tree_remove_prop(np->pde, prop);363363-#endif /* CONFIG_PROC_DEVICETREE */364364-365365- return 0;366366-}367367-368368-/*369369- * Update a property in a node. Note that we don't actually370370- * remove it, since we have given out who-knows-how-many pointers371371- * to the data using get-property. Instead we just move the property372372- * to the "dead properties" list, and add the new property to the373373- * property list374374- */375375-int prom_update_property(struct device_node *np,376376- struct property *newprop,377377- struct property *oldprop)378378-{379379- struct property **next;380380- unsigned long flags;381381- int found = 0;382382-383383- write_lock_irqsave(&devtree_lock, flags);384384- next = &np->properties;385385- while (*next) {386386- if (*next == oldprop) {387387- /* found the node */388388- newprop->next = oldprop->next;389389- *next = newprop;390390- oldprop->next = np->deadprops;391391- np->deadprops = oldprop;392392- found = 1;393393- break;394394- }395395- next = &(*next)->next;396396- }397397- write_unlock_irqrestore(&devtree_lock, flags);398398-399399- if (!found)400400- return -ENODEV;401401-402402-#ifdef CONFIG_PROC_DEVICETREE403403- /* try to add to proc as well if it was initialized */404404- if (np->pde)405405- proc_device_tree_update_prop(np->pde, newprop, oldprop);406406-#endif /* CONFIG_PROC_DEVICETREE */407407-408408- return 0;409409-}410840411841#if defined(CONFIG_DEBUG_FS) && defined(DEBUG)412842static struct debugfs_blob_wrapper flat_dt_blob;
+8
arch/mips/bcm47xx/prom.c
···141141 break;142142 }143143144144+ /* Ignoring the last page when ddr size is 128M. Cached145145+ * accesses to last page is causing the processor to prefetch146146+ * using address above 128M stepping out of the ddr address147147+ * space.148148+ */149149+ if (mem == 0x8000000)150150+ mem -= 0x1000;151151+144152 add_memory_region(0, mem, BOOT_MEM_RAM);145153}146154
···1818 select BUG1919 select HAVE_PERF_EVENTS2020 select GENERIC_ATOMIC64 if !64BIT2121- select HAVE_ARCH_TRACEHOOK2221 help2322 The PA-RISC microprocessor is designed by Hewlett-Packard and used2423 in many of their workstations & servers (HP9000 700 and 800 series,
+5-2
arch/parisc/kernel/pci.c
···18181919#include <asm/io.h>2020#include <asm/system.h>2121-#include <asm/cache.h> /* for L1_CACHE_BYTES */2221#include <asm/superio.h>23222423#define DEBUG_RESOURCES 0···122123 } else {123124 printk(KERN_WARNING "pci_bios != NULL but init() is!\n");124125 }126126+127127+ /* Set the CLS for PCI as early as possible. */128128+ pci_cache_line_size = pci_dfl_cache_line_size;129129+125130 return 0;126131}127132···174171 ** upper byte is PCI_LATENCY_TIMER.175172 */176173 pci_write_config_word(dev, PCI_CACHE_LINE_SIZE,177177- (0x80 << 8) | (L1_CACHE_BYTES / sizeof(u32)));174174+ (0x80 << 8) | pci_cache_line_size);178175}179176180177
···224224 * G5 machines... So when something asks for bus 0 io base225225 * (bus 0 is HT root), we return the AGP one instead.226226 */227227- if (in_bus == 0 && machine_is_compatible("MacRISC4")) {227227+ if (in_bus == 0 && of_machine_is_compatible("MacRISC4")) {228228 struct device_node *agp;229229230230 agp = of_find_compatible_node(NULL, NULL, "u3-agp");
+54-843
arch/powerpc/kernel/prom.c
···6161#define DBG(fmt...)6262#endif63636464-6565-static int __initdata dt_root_addr_cells;6666-static int __initdata dt_root_size_cells;6767-6864#ifdef CONFIG_PPC646965int __initdata iommu_is_off;7066int __initdata iommu_force_on;7167unsigned long tce_alloc_start, tce_alloc_end;7268#endif7373-7474-typedef u32 cell_t;7575-7676-#if 07777-static struct boot_param_header *initial_boot_params __initdata;7878-#else7979-struct boot_param_header *initial_boot_params;8080-#endif8181-8282-extern struct device_node *allnodes; /* temporary while merging */8383-8484-extern rwlock_t devtree_lock; /* temporary while merging */8585-8686-/* export that to outside world */8787-struct device_node *of_chosen;8888-8989-static inline char *find_flat_dt_string(u32 offset)9090-{9191- return ((char *)initial_boot_params) +9292- initial_boot_params->off_dt_strings + offset;9393-}9494-9595-/**9696- * This function is used to scan the flattened device-tree, it is9797- * used to extract the memory informations at boot before we can9898- * unflatten the tree9999- */100100-int __init of_scan_flat_dt(int (*it)(unsigned long node,101101- const char *uname, int depth,102102- void *data),103103- void *data)104104-{105105- unsigned long p = ((unsigned long)initial_boot_params) +106106- initial_boot_params->off_dt_struct;107107- int rc = 0;108108- int depth = -1;109109-110110- do {111111- u32 tag = *((u32 *)p);112112- char *pathp;113113-114114- p += 4;115115- if (tag == OF_DT_END_NODE) {116116- depth --;117117- continue;118118- }119119- if (tag == OF_DT_NOP)120120- continue;121121- if (tag == OF_DT_END)122122- break;123123- if (tag == OF_DT_PROP) {124124- u32 sz = *((u32 *)p);125125- p += 8;126126- if (initial_boot_params->version < 0x10)127127- p = _ALIGN(p, sz >= 8 ? 8 : 4);128128- p += sz;129129- p = _ALIGN(p, 4);130130- continue;131131- }132132- if (tag != OF_DT_BEGIN_NODE) {133133- printk(KERN_WARNING "Invalid tag %x scanning flattened"134134- " device tree !\n", tag);135135- return -EINVAL;136136- }137137- depth++;138138- pathp = (char *)p;139139- p = _ALIGN(p + strlen(pathp) + 1, 4);140140- if ((*pathp) == '/') {141141- char *lp, *np;142142- for (lp = NULL, np = pathp; *np; np++)143143- if ((*np) == '/')144144- lp = np+1;145145- if (lp != NULL)146146- pathp = lp;147147- }148148- rc = it(p, pathp, depth, data);149149- if (rc != 0)150150- break; 151151- } while(1);152152-153153- return rc;154154-}155155-156156-unsigned long __init of_get_flat_dt_root(void)157157-{158158- unsigned long p = ((unsigned long)initial_boot_params) +159159- initial_boot_params->off_dt_struct;160160-161161- while(*((u32 *)p) == OF_DT_NOP)162162- p += 4;163163- BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);164164- p += 4;165165- return _ALIGN(p + strlen((char *)p) + 1, 4);166166-}167167-168168-/**169169- * This function can be used within scan_flattened_dt callback to get170170- * access to properties171171- */172172-void* __init of_get_flat_dt_prop(unsigned long node, const char *name,173173- unsigned long *size)174174-{175175- unsigned long p = node;176176-177177- do {178178- u32 tag = *((u32 *)p);179179- u32 sz, noff;180180- const char *nstr;181181-182182- p += 4;183183- if (tag == OF_DT_NOP)184184- continue;185185- if (tag != OF_DT_PROP)186186- return NULL;187187-188188- sz = *((u32 *)p);189189- noff = *((u32 *)(p + 4));190190- p += 8;191191- if (initial_boot_params->version < 0x10)192192- p = _ALIGN(p, sz >= 8 ? 8 : 4);193193-194194- nstr = find_flat_dt_string(noff);195195- if (nstr == NULL) {196196- printk(KERN_WARNING "Can't find property index"197197- " name !\n");198198- return NULL;199199- }200200- if (strcmp(name, nstr) == 0) {201201- if (size)202202- *size = sz;203203- return (void *)p;204204- }205205- p += sz;206206- p = _ALIGN(p, 4);207207- } while(1);208208-}209209-210210-int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)211211-{212212- const char* cp;213213- unsigned long cplen, l;214214-215215- cp = of_get_flat_dt_prop(node, "compatible", &cplen);216216- if (cp == NULL)217217- return 0;218218- while (cplen > 0) {219219- if (strncasecmp(cp, compat, strlen(compat)) == 0)220220- return 1;221221- l = strlen(cp) + 1;222222- cp += l;223223- cplen -= l;224224- }225225-226226- return 0;227227-}228228-229229-static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,230230- unsigned long align)231231-{232232- void *res;233233-234234- *mem = _ALIGN(*mem, align);235235- res = (void *)*mem;236236- *mem += size;237237-238238- return res;239239-}240240-241241-static unsigned long __init unflatten_dt_node(unsigned long mem,242242- unsigned long *p,243243- struct device_node *dad,244244- struct device_node ***allnextpp,245245- unsigned long fpsize)246246-{247247- struct device_node *np;248248- struct property *pp, **prev_pp = NULL;249249- char *pathp;250250- u32 tag;251251- unsigned int l, allocl;252252- int has_name = 0;253253- int new_format = 0;254254-255255- tag = *((u32 *)(*p));256256- if (tag != OF_DT_BEGIN_NODE) {257257- printk("Weird tag at start of node: %x\n", tag);258258- return mem;259259- }260260- *p += 4;261261- pathp = (char *)*p;262262- l = allocl = strlen(pathp) + 1;263263- *p = _ALIGN(*p + l, 4);264264-265265- /* version 0x10 has a more compact unit name here instead of the full266266- * path. we accumulate the full path size using "fpsize", we'll rebuild267267- * it later. We detect this because the first character of the name is268268- * not '/'.269269- */270270- if ((*pathp) != '/') {271271- new_format = 1;272272- if (fpsize == 0) {273273- /* root node: special case. fpsize accounts for path274274- * plus terminating zero. root node only has '/', so275275- * fpsize should be 2, but we want to avoid the first276276- * level nodes to have two '/' so we use fpsize 1 here277277- */278278- fpsize = 1;279279- allocl = 2;280280- } else {281281- /* account for '/' and path size minus terminal 0282282- * already in 'l'283283- */284284- fpsize += l;285285- allocl = fpsize;286286- }287287- }288288-289289-290290- np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,291291- __alignof__(struct device_node));292292- if (allnextpp) {293293- memset(np, 0, sizeof(*np));294294- np->full_name = ((char*)np) + sizeof(struct device_node);295295- if (new_format) {296296- char *p = np->full_name;297297- /* rebuild full path for new format */298298- if (dad && dad->parent) {299299- strcpy(p, dad->full_name);300300-#ifdef DEBUG301301- if ((strlen(p) + l + 1) != allocl) {302302- DBG("%s: p: %d, l: %d, a: %d\n",303303- pathp, (int)strlen(p), l, allocl);304304- }305305-#endif306306- p += strlen(p);307307- }308308- *(p++) = '/';309309- memcpy(p, pathp, l);310310- } else311311- memcpy(np->full_name, pathp, l);312312- prev_pp = &np->properties;313313- **allnextpp = np;314314- *allnextpp = &np->allnext;315315- if (dad != NULL) {316316- np->parent = dad;317317- /* we temporarily use the next field as `last_child'*/318318- if (dad->next == 0)319319- dad->child = np;320320- else321321- dad->next->sibling = np;322322- dad->next = np;323323- }324324- kref_init(&np->kref);325325- }326326- while(1) {327327- u32 sz, noff;328328- char *pname;329329-330330- tag = *((u32 *)(*p));331331- if (tag == OF_DT_NOP) {332332- *p += 4;333333- continue;334334- }335335- if (tag != OF_DT_PROP)336336- break;337337- *p += 4;338338- sz = *((u32 *)(*p));339339- noff = *((u32 *)((*p) + 4));340340- *p += 8;341341- if (initial_boot_params->version < 0x10)342342- *p = _ALIGN(*p, sz >= 8 ? 8 : 4);343343-344344- pname = find_flat_dt_string(noff);345345- if (pname == NULL) {346346- printk("Can't find property name in list !\n");347347- break;348348- }349349- if (strcmp(pname, "name") == 0)350350- has_name = 1;351351- l = strlen(pname) + 1;352352- pp = unflatten_dt_alloc(&mem, sizeof(struct property),353353- __alignof__(struct property));354354- if (allnextpp) {355355- if (strcmp(pname, "linux,phandle") == 0) {356356- np->node = *((u32 *)*p);357357- if (np->linux_phandle == 0)358358- np->linux_phandle = np->node;359359- }360360- if (strcmp(pname, "ibm,phandle") == 0)361361- np->linux_phandle = *((u32 *)*p);362362- pp->name = pname;363363- pp->length = sz;364364- pp->value = (void *)*p;365365- *prev_pp = pp;366366- prev_pp = &pp->next;367367- }368368- *p = _ALIGN((*p) + sz, 4);369369- }370370- /* with version 0x10 we may not have the name property, recreate371371- * it here from the unit name if absent372372- */373373- if (!has_name) {374374- char *p = pathp, *ps = pathp, *pa = NULL;375375- int sz;376376-377377- while (*p) {378378- if ((*p) == '@')379379- pa = p;380380- if ((*p) == '/')381381- ps = p + 1;382382- p++;383383- }384384- if (pa < ps)385385- pa = p;386386- sz = (pa - ps) + 1;387387- pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,388388- __alignof__(struct property));389389- if (allnextpp) {390390- pp->name = "name";391391- pp->length = sz;392392- pp->value = pp + 1;393393- *prev_pp = pp;394394- prev_pp = &pp->next;395395- memcpy(pp->value, ps, sz - 1);396396- ((char *)pp->value)[sz - 1] = 0;397397- DBG("fixed up name for %s -> %s\n", pathp,398398- (char *)pp->value);399399- }400400- }401401- if (allnextpp) {402402- *prev_pp = NULL;403403- np->name = of_get_property(np, "name", NULL);404404- np->type = of_get_property(np, "device_type", NULL);405405-406406- if (!np->name)407407- np->name = "<NULL>";408408- if (!np->type)409409- np->type = "<NULL>";410410- }411411- while (tag == OF_DT_BEGIN_NODE) {412412- mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);413413- tag = *((u32 *)(*p));414414- }415415- if (tag != OF_DT_END_NODE) {416416- printk("Weird tag at end of node: %x\n", tag);417417- return mem;418418- }419419- *p += 4;420420- return mem;421421-}4226942370static int __init early_parse_mem(char *p)42471{···93446 DBG("-> move_device_tree\n");9444795448 start = __pa(initial_boot_params);9696- size = initial_boot_params->totalsize;449449+ size = be32_to_cpu(initial_boot_params->totalsize);9745098451 if ((memory_limit && (start + size) > memory_limit) ||99452 overlaps_crashkernel(start, size)) {···104457 }105458106459 DBG("<- move_device_tree\n");107107-}108108-109109-/**110110- * unflattens the device-tree passed by the firmware, creating the111111- * tree of struct device_node. It also fills the "name" and "type"112112- * pointers of the nodes so the normal device-tree walking functions113113- * can be used (this used to be done by finish_device_tree)114114- */115115-void __init unflatten_device_tree(void)116116-{117117- unsigned long start, mem, size;118118- struct device_node **allnextp = &allnodes;119119-120120- DBG(" -> unflatten_device_tree()\n");121121-122122- /* First pass, scan for size */123123- start = ((unsigned long)initial_boot_params) +124124- initial_boot_params->off_dt_struct;125125- size = unflatten_dt_node(0, &start, NULL, NULL, 0);126126- size = (size | 3) + 1;127127-128128- DBG(" size is %lx, allocating...\n", size);129129-130130- /* Allocate memory for the expanded device tree */131131- mem = lmb_alloc(size + 4, __alignof__(struct device_node));132132- mem = (unsigned long) __va(mem);133133-134134- ((u32 *)mem)[size / 4] = 0xdeadbeef;135135-136136- DBG(" unflattening %lx...\n", mem);137137-138138- /* Second pass, do actual unflattening */139139- start = ((unsigned long)initial_boot_params) +140140- initial_boot_params->off_dt_struct;141141- unflatten_dt_node(mem, &start, NULL, &allnextp, 0);142142- if (*((u32 *)start) != OF_DT_END)143143- printk(KERN_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start));144144- if (((u32 *)mem)[size / 4] != 0xdeadbeef)145145- printk(KERN_WARNING "End of tree marker overwritten: %08x\n",146146- ((u32 *)mem)[size / 4] );147147- *allnextp = NULL;148148-149149- /* Get pointer to OF "/chosen" node for use everywhere */150150- of_chosen = of_find_node_by_path("/chosen");151151- if (of_chosen == NULL)152152- of_chosen = of_find_node_by_path("/chosen@0");153153-154154- DBG(" <- unflatten_device_tree()\n");155460}156461157462/*···362763 return 0;363764}364765365365-#ifdef CONFIG_BLK_DEV_INITRD366366-static void __init early_init_dt_check_for_initrd(unsigned long node)367367-{368368- unsigned long l;369369- u32 *prop;370370-371371- DBG("Looking for initrd properties... ");372372-373373- prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);374374- if (prop) {375375- initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));376376-377377- prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);378378- if (prop) {379379- initrd_end = (unsigned long)380380- __va(of_read_ulong(prop, l/4));381381- initrd_below_start_ok = 1;382382- } else {383383- initrd_start = 0;384384- }385385- }386386-387387- DBG("initrd_start=0x%lx initrd_end=0x%lx\n", initrd_start, initrd_end);388388-}389389-#else390390-static inline void early_init_dt_check_for_initrd(unsigned long node)391391-{392392-}393393-#endif /* CONFIG_BLK_DEV_INITRD */394394-395395-static int __init early_init_dt_scan_chosen(unsigned long node,396396- const char *uname, int depth, void *data)766766+void __init early_init_dt_scan_chosen_arch(unsigned long node)397767{398768 unsigned long *lprop;399399- unsigned long l;400400- char *p;401401-402402- DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);403403-404404- if (depth != 1 ||405405- (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))406406- return 0;407769408770#ifdef CONFIG_PPC64409771 /* check if iommu is forced on or off */···375815#endif376816377817 /* mem=x on the command line is the preferred mechanism */378378- lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);379379- if (lprop)380380- memory_limit = *lprop;818818+ lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);819819+ if (lprop)820820+ memory_limit = *lprop;381821382822#ifdef CONFIG_PPC64383383- lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL);384384- if (lprop)385385- tce_alloc_start = *lprop;386386- lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL);387387- if (lprop)388388- tce_alloc_end = *lprop;823823+ lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL);824824+ if (lprop)825825+ tce_alloc_start = *lprop;826826+ lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL);827827+ if (lprop)828828+ tce_alloc_end = *lprop;389829#endif390830391831#ifdef CONFIG_KEXEC···397837 if (lprop)398838 crashk_res.end = crashk_res.start + *lprop - 1;399839#endif400400-401401- early_init_dt_check_for_initrd(node);402402-403403- /* Retreive command line */404404- p = of_get_flat_dt_prop(node, "bootargs", &l);405405- if (p != NULL && l > 0)406406- strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));407407-408408-#ifdef CONFIG_CMDLINE409409- if (p == NULL || l == 0 || (l == 1 && (*p) == 0))410410- strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);411411-#endif /* CONFIG_CMDLINE */412412-413413- DBG("Command line is: %s\n", cmd_line);414414-415415- /* break now */416416- return 1;417417-}418418-419419-static int __init early_init_dt_scan_root(unsigned long node,420420- const char *uname, int depth, void *data)421421-{422422- u32 *prop;423423-424424- if (depth != 0)425425- return 0;426426-427427- prop = of_get_flat_dt_prop(node, "#size-cells", NULL);428428- dt_root_size_cells = (prop == NULL) ? 1 : *prop;429429- DBG("dt_root_size_cells = %x\n", dt_root_size_cells);430430-431431- prop = of_get_flat_dt_prop(node, "#address-cells", NULL);432432- dt_root_addr_cells = (prop == NULL) ? 2 : *prop;433433- DBG("dt_root_addr_cells = %x\n", dt_root_addr_cells);434434-435435- /* break now */436436- return 1;437437-}438438-439439-static u64 __init dt_mem_next_cell(int s, cell_t **cellp)440440-{441441- cell_t *p = *cellp;442442-443443- *cellp = p + s;444444- return of_read_number(p, s);445840}446841447842#ifdef CONFIG_PPC_PSERIES···408893 */409894static int __init early_init_dt_scan_drconf_memory(unsigned long node)410895{411411- cell_t *dm, *ls, *usm;896896+ __be32 *dm, *ls, *usm;412897 unsigned long l, n, flags;413898 u64 base, size, lmb_size;414899 unsigned int is_kexec_kdump = 0, rngs;415900416901 ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l);417417- if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))902902+ if (ls == NULL || l < dt_root_size_cells * sizeof(__be32))418903 return 0;419904 lmb_size = dt_mem_next_cell(dt_root_size_cells, &ls);420905421906 dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l);422422- if (dm == NULL || l < sizeof(cell_t))907907+ if (dm == NULL || l < sizeof(__be32))423908 return 0;424909425910 n = *dm++; /* number of entries */426426- if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(cell_t))911911+ if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32))427912 return 0;428913429914 /* check if this is a kexec/kdump kernel. */···478963#define early_init_dt_scan_drconf_memory(node) 0479964#endif /* CONFIG_PPC_PSERIES */480965481481-static int __init early_init_dt_scan_memory(unsigned long node,482482- const char *uname, int depth, void *data)966966+static int __init early_init_dt_scan_memory_ppc(unsigned long node,967967+ const char *uname,968968+ int depth, void *data)483969{484484- char *type = of_get_flat_dt_prop(node, "device_type", NULL);485485- cell_t *reg, *endp;486486- unsigned long l;487487-488488- /* Look for the ibm,dynamic-reconfiguration-memory node */489970 if (depth == 1 &&490971 strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0)491972 return early_init_dt_scan_drconf_memory(node);492492-493493- /* We are scanning "memory" nodes only */494494- if (type == NULL) {495495- /*496496- * The longtrail doesn't have a device_type on the497497- * /memory node, so look for the node called /memory@0.498498- */499499- if (depth != 1 || strcmp(uname, "memory@0") != 0)500500- return 0;501501- } else if (strcmp(type, "memory") != 0)502502- return 0;503503-504504- reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);505505- if (reg == NULL)506506- reg = of_get_flat_dt_prop(node, "reg", &l);507507- if (reg == NULL)508508- return 0;509509-510510- endp = reg + (l / sizeof(cell_t));511511-512512- DBG("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",513513- uname, l, reg[0], reg[1], reg[2], reg[3]);514514-515515- while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {516516- u64 base, size;517517-518518- base = dt_mem_next_cell(dt_root_addr_cells, ®);519519- size = dt_mem_next_cell(dt_root_size_cells, ®);520520-521521- if (size == 0)522522- continue;523523- DBG(" - %llx , %llx\n", (unsigned long long)base,524524- (unsigned long long)size);525525-#ifdef CONFIG_PPC64526526- if (iommu_is_off) {527527- if (base >= 0x80000000ul)528528- continue;529529- if ((base + size) > 0x80000000ul)530530- size = 0x80000000ul - base;531531- }532532-#endif533533- lmb_add(base, size);534534-535535- memstart_addr = min((u64)memstart_addr, base);536536- }537537-538538- return 0;973973+974974+ return early_init_dt_scan_memory(node, uname, depth, data);539975}976976+977977+void __init early_init_dt_add_memory_arch(u64 base, u64 size)978978+{979979+#if defined(CONFIG_PPC64)980980+ if (iommu_is_off) {981981+ if (base >= 0x80000000ul)982982+ return;983983+ if ((base + size) > 0x80000000ul)984984+ size = 0x80000000ul - base;985985+ }986986+#endif987987+988988+ lmb_add(base, size);989989+990990+ memstart_addr = min((u64)memstart_addr, base);991991+}992992+993993+u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)994994+{995995+ return lmb_alloc(size, align);996996+}997997+998998+#ifdef CONFIG_BLK_DEV_INITRD999999+void __init early_init_dt_setup_initrd_arch(unsigned long start,10001000+ unsigned long end)10011001+{10021002+ initrd_start = (unsigned long)__va(start);10031003+ initrd_end = (unsigned long)__va(end);10041004+ initrd_below_start_ok = 1;10051005+}10061006+#endif54010075411008static void __init early_reserve_mem(void)5421009{···6831186 /* Scan memory nodes and rebuild LMBs */6841187 lmb_init();6851188 of_scan_flat_dt(early_init_dt_scan_root, NULL);686686- of_scan_flat_dt(early_init_dt_scan_memory, NULL);11891189+ of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);68711906881191 /* Save command line for /proc/cmdline and then parse parameters */6891192 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);···7311234 DBG(" <- early_init_devtree()\n");7321235}7331236734734-735735-/**736736- * Indicates whether the root node has a given value in its737737- * compatible property.738738- */739739-int machine_is_compatible(const char *compat)740740-{741741- struct device_node *root;742742- int rc = 0;743743-744744- root = of_find_node_by_path("/");745745- if (root) {746746- rc = of_device_is_compatible(root, compat);747747- of_node_put(root);748748- }749749- return rc;750750-}751751-EXPORT_SYMBOL(machine_is_compatible);752752-7531237/*******7541238 *7551239 * New implementation of the OF "find" APIs, return a refcounted···7411263 * this isn't dealt with yet.7421264 *7431265 *******/744744-745745-/**746746- * of_find_node_by_phandle - Find a node given a phandle747747- * @handle: phandle of the node to find748748- *749749- * Returns a node pointer with refcount incremented, use750750- * of_node_put() on it when done.751751- */752752-struct device_node *of_find_node_by_phandle(phandle handle)753753-{754754- struct device_node *np;755755-756756- read_lock(&devtree_lock);757757- for (np = allnodes; np != 0; np = np->allnext)758758- if (np->linux_phandle == handle)759759- break;760760- of_node_get(np);761761- read_unlock(&devtree_lock);762762- return np;763763-}764764-EXPORT_SYMBOL(of_find_node_by_phandle);76512667661267/**7671268 * of_find_next_cache_node - Find a node's subsidiary cache···7711314 return child;77213157731316 return NULL;774774-}775775-776776-/**777777- * of_node_get - Increment refcount of a node778778- * @node: Node to inc refcount, NULL is supported to779779- * simplify writing of callers780780- *781781- * Returns node.782782- */783783-struct device_node *of_node_get(struct device_node *node)784784-{785785- if (node)786786- kref_get(&node->kref);787787- return node;788788-}789789-EXPORT_SYMBOL(of_node_get);790790-791791-static inline struct device_node * kref_to_device_node(struct kref *kref)792792-{793793- return container_of(kref, struct device_node, kref);794794-}795795-796796-/**797797- * of_node_release - release a dynamically allocated node798798- * @kref: kref element of the node to be released799799- *800800- * In of_node_put() this function is passed to kref_put()801801- * as the destructor.802802- */803803-static void of_node_release(struct kref *kref)804804-{805805- struct device_node *node = kref_to_device_node(kref);806806- struct property *prop = node->properties;807807-808808- /* We should never be releasing nodes that haven't been detached. */809809- if (!of_node_check_flag(node, OF_DETACHED)) {810810- printk("WARNING: Bad of_node_put() on %s\n", node->full_name);811811- dump_stack();812812- kref_init(&node->kref);813813- return;814814- }815815-816816- if (!of_node_check_flag(node, OF_DYNAMIC))817817- return;818818-819819- while (prop) {820820- struct property *next = prop->next;821821- kfree(prop->name);822822- kfree(prop->value);823823- kfree(prop);824824- prop = next;825825-826826- if (!prop) {827827- prop = node->deadprops;828828- node->deadprops = NULL;829829- }830830- }831831- kfree(node->full_name);832832- kfree(node->data);833833- kfree(node);834834-}835835-836836-/**837837- * of_node_put - Decrement refcount of a node838838- * @node: Node to dec refcount, NULL is supported to839839- * simplify writing of callers840840- *841841- */842842-void of_node_put(struct device_node *node)843843-{844844- if (node)845845- kref_put(&node->kref, of_node_release);846846-}847847-EXPORT_SYMBOL(of_node_put);848848-849849-/*850850- * Plug a device node into the tree and global list.851851- */852852-void of_attach_node(struct device_node *np)853853-{854854- unsigned long flags;855855-856856- write_lock_irqsave(&devtree_lock, flags);857857- np->sibling = np->parent->child;858858- np->allnext = allnodes;859859- np->parent->child = np;860860- allnodes = np;861861- write_unlock_irqrestore(&devtree_lock, flags);862862-}863863-864864-/*865865- * "Unplug" a node from the device tree. The caller must hold866866- * a reference to the node. The memory associated with the node867867- * is not freed until its refcount goes to zero.868868- */869869-void of_detach_node(struct device_node *np)870870-{871871- struct device_node *parent;872872- unsigned long flags;873873-874874- write_lock_irqsave(&devtree_lock, flags);875875-876876- parent = np->parent;877877- if (!parent)878878- goto out_unlock;879879-880880- if (allnodes == np)881881- allnodes = np->allnext;882882- else {883883- struct device_node *prev;884884- for (prev = allnodes;885885- prev->allnext != np;886886- prev = prev->allnext)887887- ;888888- prev->allnext = np->allnext;889889- }890890-891891- if (parent->child == np)892892- parent->child = np->sibling;893893- else {894894- struct device_node *prevsib;895895- for (prevsib = np->parent->child;896896- prevsib->sibling != np;897897- prevsib = prevsib->sibling)898898- ;899899- prevsib->sibling = np->sibling;900900- }901901-902902- of_node_set_flag(np, OF_DETACHED);903903-904904-out_unlock:905905- write_unlock_irqrestore(&devtree_lock, flags);9061317}90713189081319#ifdef CONFIG_PPC_PSERIES···8041479 if (machine_is(powermac))8051480 return -ENODEV;8061481807807- /* fix up new node's linux_phandle field */14821482+ /* fix up new node's phandle field */8081483 if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))809809- node->linux_phandle = *ibm_phandle;14841484+ node->phandle = *ibm_phandle;81014858111486out:8121487 of_node_put(parent);···8441519}8451520__initcall(prom_reconfig_setup);8461521#endif847847-848848-/*849849- * Add a property to a node850850- */851851-int prom_add_property(struct device_node* np, struct property* prop)852852-{853853- struct property **next;854854- unsigned long flags;855855-856856- prop->next = NULL; 857857- write_lock_irqsave(&devtree_lock, flags);858858- next = &np->properties;859859- while (*next) {860860- if (strcmp(prop->name, (*next)->name) == 0) {861861- /* duplicate ! don't insert it */862862- write_unlock_irqrestore(&devtree_lock, flags);863863- return -1;864864- }865865- next = &(*next)->next;866866- }867867- *next = prop;868868- write_unlock_irqrestore(&devtree_lock, flags);869869-870870-#ifdef CONFIG_PROC_DEVICETREE871871- /* try to add to proc as well if it was initialized */872872- if (np->pde)873873- proc_device_tree_add_prop(np->pde, prop);874874-#endif /* CONFIG_PROC_DEVICETREE */875875-876876- return 0;877877-}878878-879879-/*880880- * Remove a property from a node. Note that we don't actually881881- * remove it, since we have given out who-knows-how-many pointers882882- * to the data using get-property. Instead we just move the property883883- * to the "dead properties" list, so it won't be found any more.884884- */885885-int prom_remove_property(struct device_node *np, struct property *prop)886886-{887887- struct property **next;888888- unsigned long flags;889889- int found = 0;890890-891891- write_lock_irqsave(&devtree_lock, flags);892892- next = &np->properties;893893- while (*next) {894894- if (*next == prop) {895895- /* found the node */896896- *next = prop->next;897897- prop->next = np->deadprops;898898- np->deadprops = prop;899899- found = 1;900900- break;901901- }902902- next = &(*next)->next;903903- }904904- write_unlock_irqrestore(&devtree_lock, flags);905905-906906- if (!found)907907- return -ENODEV;908908-909909-#ifdef CONFIG_PROC_DEVICETREE910910- /* try to remove the proc node as well */911911- if (np->pde)912912- proc_device_tree_remove_prop(np->pde, prop);913913-#endif /* CONFIG_PROC_DEVICETREE */914914-915915- return 0;916916-}917917-918918-/*919919- * Update a property in a node. Note that we don't actually920920- * remove it, since we have given out who-knows-how-many pointers921921- * to the data using get-property. Instead we just move the property922922- * to the "dead properties" list, and add the new property to the923923- * property list924924- */925925-int prom_update_property(struct device_node *np,926926- struct property *newprop,927927- struct property *oldprop)928928-{929929- struct property **next;930930- unsigned long flags;931931- int found = 0;932932-933933- write_lock_irqsave(&devtree_lock, flags);934934- next = &np->properties;935935- while (*next) {936936- if (*next == oldprop) {937937- /* found the node */938938- newprop->next = oldprop->next;939939- *next = newprop;940940- oldprop->next = np->deadprops;941941- np->deadprops = oldprop;942942- found = 1;943943- break;944944- }945945- next = &(*next)->next;946946- }947947- write_unlock_irqrestore(&devtree_lock, flags);948948-949949- if (!found)950950- return -ENODEV;951951-952952-#ifdef CONFIG_PROC_DEVICETREE953953- /* try to add to proc as well if it was initialized */954954- if (np->pde)955955- proc_device_tree_update_prop(np->pde, newprop, oldprop);956956-#endif /* CONFIG_PROC_DEVICETREE */957957-958958- return 0;959959-}960960-96115229621523/* Find the device node for a given logical cpu number, also returns the cpu9631524 * local thread number (index in ibm,interrupt-server#s) if relevant and
···8080 printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n");81818282 ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I;8383- if (machine_is_compatible("MPC8540") ||8484- machine_is_compatible("MPC8560"))8383+ if (of_machine_is_compatible("MPC8540") ||8484+ of_machine_is_compatible("MPC8560"))8585 /*8686 * Assume L2 SRAM is used fully for cache, so set8787 * L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).
+1-1
arch/powerpc/platforms/cell/cbe_powerbutton.c
···4848 int ret = 0;4949 struct input_dev *dev;50505151- if (!machine_is_compatible("IBM,CBPLUS-1.0")) {5151+ if (!of_machine_is_compatible("IBM,CBPLUS-1.0")) {5252 printk(KERN_ERR "%s: Not a cell blade.\n", __func__);5353 ret = -ENODEV;5454 goto out;
···457457 continue;458458 vic_handles = of_get_property(spu_dn, "vicinity", &lenp);459459 for (i=0; i < (lenp / sizeof(phandle)); i++) {460460- if (vic_handles[i] == target->linux_phandle)460460+ if (vic_handles[i] == target->phandle)461461 return spu;462462 }463463 }···499499500500 if (strcmp(name, "spe") == 0) {501501 spu = devnode_spu(cbe, vic_dn);502502- avoid_ph = last_spu_dn->linux_phandle;502502+ avoid_ph = last_spu_dn->phandle;503503 } else {504504 /*505505 * "mic-tm" and "bif0" nodes do not have···514514 last_spu->has_mem_affinity = 1;515515 spu->has_mem_affinity = 1;516516 }517517- avoid_ph = vic_dn->linux_phandle;517517+ avoid_ph = vic_dn->phandle;518518 }519519520520 list_add_tail(&spu->aff_list, &last_spu->aff_list);
+2-2
arch/powerpc/platforms/pasemi/cpufreq.c
···304304305305static int __init pas_cpufreq_init(void)306306{307307- if (!machine_is_compatible("PA6T-1682M") &&308308- !machine_is_compatible("pasemi,pwrficient"))307307+ if (!of_machine_is_compatible("PA6T-1682M") &&308308+ !of_machine_is_compatible("pasemi,pwrficient"))309309 return -ENODEV;310310311311 return cpufreq_register_driver(&pas_cpufreq_driver);
+7-7
arch/powerpc/platforms/powermac/cpufreq_32.c
···657657 cur_freq = (*value) / 1000;658658659659 /* Check for 7447A based MacRISC3 */660660- if (machine_is_compatible("MacRISC3") &&660660+ if (of_machine_is_compatible("MacRISC3") &&661661 of_get_property(cpunode, "dynamic-power-step", NULL) &&662662 PVR_VER(mfspr(SPRN_PVR)) == 0x8003) {663663 pmac_cpufreq_init_7447A(cpunode);664664 /* Check for other MacRISC3 machines */665665- } else if (machine_is_compatible("PowerBook3,4") ||666666- machine_is_compatible("PowerBook3,5") ||667667- machine_is_compatible("MacRISC3")) {665665+ } else if (of_machine_is_compatible("PowerBook3,4") ||666666+ of_machine_is_compatible("PowerBook3,5") ||667667+ of_machine_is_compatible("MacRISC3")) {668668 pmac_cpufreq_init_MacRISC3(cpunode);669669 /* Else check for iBook2 500/600 */670670- } else if (machine_is_compatible("PowerBook4,1")) {670670+ } else if (of_machine_is_compatible("PowerBook4,1")) {671671 hi_freq = cur_freq;672672 low_freq = 400000;673673 set_speed_proc = pmu_set_cpu_speed;674674 is_pmu_based = 1;675675 }676676 /* Else check for TiPb 550 */677677- else if (machine_is_compatible("PowerBook3,3") && cur_freq == 550000) {677677+ else if (of_machine_is_compatible("PowerBook3,3") && cur_freq == 550000) {678678 hi_freq = cur_freq;679679 low_freq = 500000;680680 set_speed_proc = pmu_set_cpu_speed;681681 is_pmu_based = 1;682682 }683683 /* Else check for TiPb 400 & 500 */684684- else if (machine_is_compatible("PowerBook3,2")) {684684+ else if (of_machine_is_compatible("PowerBook3,2")) {685685 /* We only know about the 400 MHz and the 500Mhz model686686 * they both have 300 MHz as low frequency687687 */
+7-7
arch/powerpc/platforms/powermac/cpufreq_64.c
···398398 int rc = -ENODEV;399399400400 /* Check supported platforms */401401- if (machine_is_compatible("PowerMac8,1") ||402402- machine_is_compatible("PowerMac8,2") ||403403- machine_is_compatible("PowerMac9,1"))401401+ if (of_machine_is_compatible("PowerMac8,1") ||402402+ of_machine_is_compatible("PowerMac8,2") ||403403+ of_machine_is_compatible("PowerMac9,1"))404404 use_volts_smu = 1;405405- else if (machine_is_compatible("PowerMac11,2"))405405+ else if (of_machine_is_compatible("PowerMac11,2"))406406 use_volts_vdnap = 1;407407 else408408 return -ENODEV;···729729 return -ENODEV;730730 }731731732732- if (machine_is_compatible("PowerMac7,2") ||733733- machine_is_compatible("PowerMac7,3") ||734734- machine_is_compatible("RackMac3,1"))732732+ if (of_machine_is_compatible("PowerMac7,2") ||733733+ of_machine_is_compatible("PowerMac7,3") ||734734+ of_machine_is_compatible("RackMac3,1"))735735 rc = g5_pm72_cpufreq_init(cpus);736736#ifdef CONFIG_PMAC_SMU737737 else
+1-1
arch/powerpc/platforms/powermac/feature.c
···24262426 }24272427 }24282428 for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) {24292429- if (machine_is_compatible(pmac_mb_defs[i].model_string)) {24292429+ if (of_machine_is_compatible(pmac_mb_defs[i].model_string)) {24302430 pmac_mb = pmac_mb_defs[i];24312431 goto found;24322432 }
+1-1
arch/powerpc/platforms/powermac/pfunc_core.c
···842842 list_for_each_entry(func, &dev->functions, link) {843843 if (name && strcmp(name, func->name))844844 continue;845845- if (func->phandle && target->node != func->phandle)845845+ if (func->phandle && target->phandle != func->phandle)846846 continue;847847 if ((func->flags & flags) == 0)848848 continue;
+6-6
arch/powerpc/platforms/powermac/smp.c
···693693#ifdef CONFIG_PPC64694694695695 /* i2c based HW sync on some G5s */696696- if (machine_is_compatible("PowerMac7,2") ||697697- machine_is_compatible("PowerMac7,3") ||698698- machine_is_compatible("RackMac3,1"))696696+ if (of_machine_is_compatible("PowerMac7,2") ||697697+ of_machine_is_compatible("PowerMac7,3") ||698698+ of_machine_is_compatible("RackMac3,1"))699699 smp_core99_setup_i2c_hwsync(ncpus);700700701701 /* pfunc based HW sync on recent G5s */···713713#else /* CONFIG_PPC64 */714714715715 /* GPIO based HW sync on ppc32 Core99 */716716- if (pmac_tb_freeze == NULL && !machine_is_compatible("MacRISC4")) {716716+ if (pmac_tb_freeze == NULL && !of_machine_is_compatible("MacRISC4")) {717717 struct device_node *cpu;718718 const u32 *tbprop = NULL;719719···750750#endif751751752752 /* 32 bits SMP can't NAP */753753- if (!machine_is_compatible("MacRISC4"))753753+ if (!of_machine_is_compatible("MacRISC4"))754754 powersave_nap = 0;755755}756756···852852 /* If we didn't start the second CPU, we must take853853 * it off the bus854854 */855855- if (machine_is_compatible("MacRISC4") &&855855+ if (of_machine_is_compatible("MacRISC4") &&856856 num_online_cpus() < 2) 857857 g5_phy_disable_cpu1();858858#endif /* CONFIG_PPC64 */
+4-4
arch/powerpc/platforms/powermac/time.c
···317317 * calibration. That's better since the VIA itself seems318318 * to be slightly off. --BenH319319 */320320- if (!machine_is_compatible("MacRISC2") &&321321- !machine_is_compatible("MacRISC3") &&322322- !machine_is_compatible("MacRISC4"))320320+ if (!of_machine_is_compatible("MacRISC2") &&321321+ !of_machine_is_compatible("MacRISC3") &&322322+ !of_machine_is_compatible("MacRISC4"))323323 if (via_calibrate_decr())324324 return;325325···328328 * probably implement calibration based on the KL timer on these329329 * machines anyway... -BenH330330 */331331- if (machine_is_compatible("PowerMac3,5"))331331+ if (of_machine_is_compatible("PowerMac3,5"))332332 if (via_calibrate_decr())333333 return;334334#endif
···59596060 cur_inst = 0;6161 for_each_node_by_type(dp, "cpu") {6262- int err = check_cpu_node(dp->node, &cur_inst,6262+ int err = check_cpu_node(dp->phandle, &cur_inst,6363 compare, compare_arg,6464 prom_node, mid);6565 if (!err) {
+4
arch/sparc/kernel/kstack.h
···1111{1212 unsigned long base = (unsigned long) tp;13131414+ /* Stack pointer must be 16-byte aligned. */1515+ if (sp & (16UL - 1))1616+ return false;1717+1418 if (sp >= (base + sizeof(struct thread_info)) &&1519 sp <= (base + THREAD_SIZE - sizeof(struct sparc_stackf)))1620 return true;
+2-2
arch/sparc/kernel/of_device_32.c
···105105106106static int of_bus_ambapp_match(struct device_node *np)107107{108108- return !strcmp(np->name, "ambapp");108108+ return !strcmp(np->type, "ambapp");109109}110110111111static void of_bus_ambapp_count_cells(struct device_node *child,···433433 if (!parent)434434 dev_set_name(&op->dev, "root");435435 else436436- dev_set_name(&op->dev, "%08x", dp->node);436436+ dev_set_name(&op->dev, "%08x", dp->phandle);437437438438 if (of_device_register(op)) {439439 printk("%s: Could not register of device.\n",
+1-1
arch/sparc/kernel/of_device_64.c
···676676 if (!parent)677677 dev_set_name(&op->dev, "root");678678 else679679- dev_set_name(&op->dev, "%08x", dp->node);679679+ dev_set_name(&op->dev, "%08x", dp->phandle);680680681681 if (of_device_register(op)) {682682 printk("%s: Could not register of device.\n",
···450450 struct perf_event *ptrace_bps[HBP_NUM];451451 /* Debug status used for traps, single steps, etc... */452452 unsigned long debugreg6;453453+ /* Keep track of the exact dr7 value set by the user */454454+ unsigned long ptrace_dr7;453455 /* Fault info: */454456 unsigned long cr2;455457 unsigned long trap_no;
···212212 return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE);213213}214214215215-/*216216- * Store a breakpoint's encoded address, length, and type.217217- */218218-static int arch_store_info(struct perf_event *bp)219219-{220220- struct arch_hw_breakpoint *info = counter_arch_bp(bp);221221- /*222222- * For kernel-addresses, either the address or symbol name can be223223- * specified.224224- */225225- if (info->name)226226- info->address = (unsigned long)227227- kallsyms_lookup_name(info->name);228228- if (info->address)229229- return 0;230230-231231- return -EINVAL;232232-}233233-234215int arch_bp_generic_fields(int x86_len, int x86_type,235216 int *gen_len, int *gen_type)236217{···343362 return ret;344363 }345364346346- ret = arch_store_info(bp);347347-348348- if (ret < 0)349349- return ret;365365+ /*366366+ * For kernel-addresses, either the address or symbol name can be367367+ * specified.368368+ */369369+ if (info->name)370370+ info->address = (unsigned long)371371+ kallsyms_lookup_name(info->name);350372 /*351373 * Check that the low-order bits of the address are appropriate352374 * for the alignment implied by len.
+5-2
arch/x86/kernel/ptrace.c
···702702 } else if (n == 6) {703703 val = thread->debugreg6;704704 } else if (n == 7) {705705- val = ptrace_get_dr7(thread->ptrace_bps);705705+ val = thread->ptrace_dr7;706706 }707707 return val;708708}···778778 return rc;779779 }780780 /* All that's left is DR7 */781781- if (n == 7)781781+ if (n == 7) {782782 rc = ptrace_write_dr7(tsk, val);783783+ if (!rc)784784+ thread->ptrace_dr7 = val;785785+ }783786784787ret_path:785788 return rc;
+2-9
block/blk-core.c
···11471147 */11481148static inline bool queue_should_plug(struct request_queue *q)11491149{11501150- return !(blk_queue_nonrot(q) && blk_queue_queuing(q));11501150+ return !(blk_queue_nonrot(q) && blk_queue_tagged(q));11511151}1152115211531153static int __make_request(struct request_queue *q, struct bio *bio)···18591859 * and to it is freed is accounted as io that is in progress at18601860 * the driver side.18611861 */18621862- if (blk_account_rq(rq)) {18621862+ if (blk_account_rq(rq))18631863 q->in_flight[rq_is_sync(rq)]++;18641864- /*18651865- * Mark this device as supporting hardware queuing, if18661866- * we have more IOs in flight than 4.18671867- */18681868- if (!blk_queue_queuing(q) && queue_in_flight(q) > 4)18691869- set_bit(QUEUE_FLAG_CQ, &q->queue_flags);18701870- }18711864}1872186518731866/**
···413413 if (result)414414 goto update_bios;415415416416- return 0;416416+ /* We need to call _PPC once when cpufreq starts */417417+ if (ignore_ppc != 1)418418+ result = acpi_processor_get_platform_limit(pr);419419+420420+ return result;417421418422 /*419423 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
+22-5
drivers/acpi/scan.c
···1336133613371337 if (child)13381338 *child = device;13391339- return 0;13391339+13401340+ if (device)13411341+ return 0;13421342+ else13431343+ return -ENODEV;13401344}13451345+13461346+/*13471347+ * acpi_bus_add and acpi_bus_start13481348+ *13491349+ * scan a given ACPI tree and (probably recently hot-plugged)13501350+ * create and add or starts found devices.13511351+ *13521352+ * If no devices were found -ENODEV is returned which does not13531353+ * mean that this is a real error, there just have been no suitable13541354+ * ACPI objects in the table trunk from which the kernel could create13551355+ * a device and add/start an appropriate driver.13561356+ */1341135713421358int13431359acpi_bus_add(struct acpi_device **child,···13641348 memset(&ops, 0, sizeof(ops));13651349 ops.acpi_op_add = 1;1366135013671367- acpi_bus_scan(handle, &ops, child);13681368- return 0;13511351+ return acpi_bus_scan(handle, &ops, child);13691352}13701353EXPORT_SYMBOL(acpi_bus_add);13711354···13721357{13731358 struct acpi_bus_ops ops;1374135913601360+ if (!device)13611361+ return -EINVAL;13621362+13751363 memset(&ops, 0, sizeof(ops));13761364 ops.acpi_op_start = 1;1377136513781378- acpi_bus_scan(device->handle, &ops, NULL);13791379- return 0;13661366+ return acpi_bus_scan(device->handle, &ops, NULL);13801367}13811368EXPORT_SYMBOL(acpi_bus_start);13821369
+2-2
drivers/acpi/tables.c
···213213 unsigned long table_end;214214 acpi_size tbl_size;215215216216- if (acpi_disabled)216216+ if (acpi_disabled && !acpi_ht)217217 return -ENODEV;218218219219 if (!handler)···280280 struct acpi_table_header *table = NULL;281281 acpi_size tbl_size;282282283283- if (acpi_disabled)283283+ if (acpi_disabled && !acpi_ht)284284 return -ENODEV;285285286286 if (!handler)
+10-2
drivers/ata/ahci.c
···30823082 ahci_save_initial_config(pdev, hpriv);3083308330843084 /* prepare host */30853085- if (hpriv->cap & HOST_CAP_NCQ)30863086- pi.flags |= ATA_FLAG_NCQ | ATA_FLAG_FPDMA_AA;30853085+ if (hpriv->cap & HOST_CAP_NCQ) {30863086+ pi.flags |= ATA_FLAG_NCQ;30873087+ /* Auto-activate optimization is supposed to be supported on30883088+ all AHCI controllers indicating NCQ support, but it seems30893089+ to be broken at least on some NVIDIA MCP79 chipsets.30903090+ Until we get info on which NVIDIA chipsets don't have this30913091+ issue, if any, disable AA on all NVIDIA AHCIs. */30923092+ if (pdev->vendor != PCI_VENDOR_ID_NVIDIA)30933093+ pi.flags |= ATA_FLAG_FPDMA_AA;30943094+ }3087309530883096 if (hpriv->cap & HOST_CAP_PMP)30893097 pi.flags |= ATA_FLAG_PMP;
+2
drivers/base/class.c
···5959 else6060 pr_debug("class '%s' does not have a release() function, "6161 "be careful\n", class->name);6262+6363+ kfree(cp);6264}63656466static struct sysfs_ops class_sysfs_ops = {
+46-15
drivers/block/virtio_blk.c
···243243static int __devinit virtblk_probe(struct virtio_device *vdev)244244{245245 struct virtio_blk *vblk;246246+ struct request_queue *q;246247 int err;247248 u64 cap;248248- u32 v;249249- u32 blk_size, sg_elems;249249+ u32 v, blk_size, sg_elems, opt_io_size;250250+ u16 min_io_size;251251+ u8 physical_block_exp, alignment_offset;250252251253 if (index_to_minor(index) >= 1 << MINORBITS)252254 return -ENOSPC;···295293 goto out_mempool;296294 }297295298298- vblk->disk->queue = blk_init_queue(do_virtblk_request, &vblk->lock);299299- if (!vblk->disk->queue) {296296+ q = vblk->disk->queue = blk_init_queue(do_virtblk_request, &vblk->lock);297297+ if (!q) {300298 err = -ENOMEM;301299 goto out_put_disk;302300 }303301304304- vblk->disk->queue->queuedata = vblk;302302+ q->queuedata = vblk;305303306304 if (index < 26) {307305 sprintf(vblk->disk->disk_name, "vd%c", 'a' + index % 26);···325323326324 /* If barriers are supported, tell block layer that queue is ordered */327325 if (virtio_has_feature(vdev, VIRTIO_BLK_F_FLUSH))328328- blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_DRAIN_FLUSH,326326+ blk_queue_ordered(q, QUEUE_ORDERED_DRAIN_FLUSH,329327 virtblk_prepare_flush);330328 else if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER))331331- blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL);329329+ blk_queue_ordered(q, QUEUE_ORDERED_TAG, NULL);332330333331 /* If disk is read-only in the host, the guest should obey */334332 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))···347345 set_capacity(vblk->disk, cap);348346349347 /* We can handle whatever the host told us to handle. */350350- blk_queue_max_phys_segments(vblk->disk->queue, vblk->sg_elems-2);351351- blk_queue_max_hw_segments(vblk->disk->queue, vblk->sg_elems-2);348348+ blk_queue_max_phys_segments(q, vblk->sg_elems-2);349349+ blk_queue_max_hw_segments(q, vblk->sg_elems-2);352350353351 /* No need to bounce any requests */354354- blk_queue_bounce_limit(vblk->disk->queue, BLK_BOUNCE_ANY);352352+ blk_queue_bounce_limit(q, BLK_BOUNCE_ANY);355353356354 /* No real sector limit. */357357- blk_queue_max_sectors(vblk->disk->queue, -1U);355355+ blk_queue_max_sectors(q, -1U);358356359357 /* Host can optionally specify maximum segment size and number of360358 * segments. */···362360 offsetof(struct virtio_blk_config, size_max),363361 &v);364362 if (!err)365365- blk_queue_max_segment_size(vblk->disk->queue, v);363363+ blk_queue_max_segment_size(q, v);366364 else367367- blk_queue_max_segment_size(vblk->disk->queue, -1U);365365+ blk_queue_max_segment_size(q, -1U);368366369367 /* Host can optionally specify the block size of the device */370368 err = virtio_config_val(vdev, VIRTIO_BLK_F_BLK_SIZE,371369 offsetof(struct virtio_blk_config, blk_size),372370 &blk_size);373371 if (!err)374374- blk_queue_logical_block_size(vblk->disk->queue, blk_size);372372+ blk_queue_logical_block_size(q, blk_size);373373+ else374374+ blk_size = queue_logical_block_size(q);375375+376376+ /* Use topology information if available */377377+ err = virtio_config_val(vdev, VIRTIO_BLK_F_TOPOLOGY,378378+ offsetof(struct virtio_blk_config, physical_block_exp),379379+ &physical_block_exp);380380+ if (!err && physical_block_exp)381381+ blk_queue_physical_block_size(q,382382+ blk_size * (1 << physical_block_exp));383383+384384+ err = virtio_config_val(vdev, VIRTIO_BLK_F_TOPOLOGY,385385+ offsetof(struct virtio_blk_config, alignment_offset),386386+ &alignment_offset);387387+ if (!err && alignment_offset)388388+ blk_queue_alignment_offset(q, blk_size * alignment_offset);389389+390390+ err = virtio_config_val(vdev, VIRTIO_BLK_F_TOPOLOGY,391391+ offsetof(struct virtio_blk_config, min_io_size),392392+ &min_io_size);393393+ if (!err && min_io_size)394394+ blk_queue_io_min(q, blk_size * min_io_size);395395+396396+ err = virtio_config_val(vdev, VIRTIO_BLK_F_TOPOLOGY,397397+ offsetof(struct virtio_blk_config, opt_io_size),398398+ &opt_io_size);399399+ if (!err && opt_io_size)400400+ blk_queue_io_opt(q, blk_size * opt_io_size);401401+375402376403 add_disk(vblk->disk);377404 return 0;···443412static unsigned int features[] = {444413 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,445414 VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,446446- VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH415415+ VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY447416};448417449418/*
+8
drivers/char/Kconfig
···666666 help667667 Virtio console for use with lguest and other hypervisors.668668669669+ Also serves as a general-purpose serial device for data670670+ transfer between the guest and host. Character devices at671671+ /dev/vportNpn will be created when corresponding ports are672672+ found, where N is the device number and n is the port number673673+ within that device. If specified by the host, a sysfs674674+ attribute called 'name' will be populated with a name for675675+ the port which can be used by udev scripts to create a676676+ symlink to the device.669677670678config HVCS671679 tristate "IBM Hypervisor Virtual Console Server support"
+1-1
drivers/char/hvc_beat.c
···9999100100static int __init hvc_beat_console_init(void)101101{102102- if (hvc_beat_useit && machine_is_compatible("Beat")) {102102+ if (hvc_beat_useit && of_machine_is_compatible("Beat")) {103103 hvc_instantiate(0, 0, &hvc_beat_get_put_ops);104104 }105105 return 0;
+1451-165
drivers/char/virtio_console.c
···11-/*D:30022- * The Guest console driver33- *44- * Writing console drivers is one of the few remaining Dark Arts in Linux.55- * Fortunately for us, the path of virtual consoles has been well-trodden by66- * the PowerPC folks, who wrote "hvc_console.c" to generically support any77- * virtual console. We use that infrastructure which only requires us to write88- * the basic put_chars and get_chars functions and call the right register99- * functions.1010- :*/1111-1212-/*M:002 The console can be flooded: while the Guest is processing input the1313- * Host can send more. Buffering in the Host could alleviate this, but it is a1414- * difficult problem in general. :*/1515-/* Copyright (C) 2006, 2007 Rusty Russell, IBM Corporation11+/*22+ * Copyright (C) 2006, 2007, 2009 Rusty Russell, IBM Corporation33+ * Copyright (C) 2009, 2010 Red Hat, Inc.164 *175 * This program is free software; you can redistribute it and/or modify186 * it under the terms of the GNU General Public License as published by···1628 * along with this program; if not, write to the Free Software1729 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1830 */3131+#include <linux/cdev.h>3232+#include <linux/debugfs.h>3333+#include <linux/device.h>1934#include <linux/err.h>3535+#include <linux/fs.h>2036#include <linux/init.h>3737+#include <linux/list.h>3838+#include <linux/poll.h>3939+#include <linux/sched.h>4040+#include <linux/spinlock.h>2141#include <linux/virtio.h>2242#include <linux/virtio_console.h>4343+#include <linux/wait.h>4444+#include <linux/workqueue.h>2345#include "hvc_console.h"24462525-/*D:340 These represent our input and output console queues, and the virtio2626- * operations for them. */2727-static struct virtqueue *in_vq, *out_vq;2828-static struct virtio_device *vdev;2929-3030-/* This is our input buffer, and how much data is left in it. */3131-static unsigned int in_len;3232-static char *in, *inbuf;3333-3434-/* The operations for our console. */3535-static struct hv_ops virtio_cons;3636-3737-/* The hvc device */3838-static struct hvc_struct *hvc;3939-4040-/*D:310 The put_chars() callback is pretty straightforward.4747+/*4848+ * This is a global struct for storing common data for all the devices4949+ * this driver handles.4150 *4242- * We turn the characters into a scatter-gather list, add it to the output4343- * queue and then kick the Host. Then we sit here waiting for it to finish:4444- * inefficient in theory, but in practice implementations will do it4545- * immediately (lguest's Launcher does). */4646-static int put_chars(u32 vtermno, const char *buf, int count)5151+ * Mainly, it has a linked list for all the consoles in one place so5252+ * that callbacks from hvc for get_chars(), put_chars() work properly5353+ * across multiple devices and multiple ports per device.5454+ */5555+struct ports_driver_data {5656+ /* Used for registering chardevs */5757+ struct class *class;5858+5959+ /* Used for exporting per-port information to debugfs */6060+ struct dentry *debugfs_dir;6161+6262+ /* Number of devices this driver is handling */6363+ unsigned int index;6464+6565+ /*6666+ * This is used to keep track of the number of hvc consoles6767+ * spawned by this driver. This number is given as the first6868+ * argument to hvc_alloc(). To correctly map an initial6969+ * console spawned via hvc_instantiate to the console being7070+ * hooked up via hvc_alloc, we need to pass the same vtermno.7171+ *7272+ * We also just assume the first console being initialised was7373+ * the first one that got used as the initial console.7474+ */7575+ unsigned int next_vtermno;7676+7777+ /* All the console devices handled by this driver */7878+ struct list_head consoles;7979+};8080+static struct ports_driver_data pdrvdata;8181+8282+DEFINE_SPINLOCK(pdrvdata_lock);8383+8484+/* This struct holds information that's relevant only for console ports */8585+struct console {8686+ /* We'll place all consoles in a list in the pdrvdata struct */8787+ struct list_head list;8888+8989+ /* The hvc device associated with this console port */9090+ struct hvc_struct *hvc;9191+9292+ /*9393+ * This number identifies the number that we used to register9494+ * with hvc in hvc_instantiate() and hvc_alloc(); this is the9595+ * number passed on by the hvc callbacks to us to9696+ * differentiate between the other console ports handled by9797+ * this driver9898+ */9999+ u32 vtermno;100100+};101101+102102+struct port_buffer {103103+ char *buf;104104+105105+ /* size of the buffer in *buf above */106106+ size_t size;107107+108108+ /* used length of the buffer */109109+ size_t len;110110+ /* offset in the buf from which to consume data */111111+ size_t offset;112112+};113113+114114+/*115115+ * This is a per-device struct that stores data common to all the116116+ * ports for that device (vdev->priv).117117+ */118118+struct ports_device {119119+ /*120120+ * Workqueue handlers where we process deferred work after121121+ * notification122122+ */123123+ struct work_struct control_work;124124+ struct work_struct config_work;125125+126126+ struct list_head ports;127127+128128+ /* To protect the list of ports */129129+ spinlock_t ports_lock;130130+131131+ /* To protect the vq operations for the control channel */132132+ spinlock_t cvq_lock;133133+134134+ /* The current config space is stored here */135135+ struct virtio_console_config config;136136+137137+ /* The virtio device we're associated with */138138+ struct virtio_device *vdev;139139+140140+ /*141141+ * A couple of virtqueues for the control channel: one for142142+ * guest->host transfers, one for host->guest transfers143143+ */144144+ struct virtqueue *c_ivq, *c_ovq;145145+146146+ /* Array of per-port IO virtqueues */147147+ struct virtqueue **in_vqs, **out_vqs;148148+149149+ /* Used for numbering devices for sysfs and debugfs */150150+ unsigned int drv_index;151151+152152+ /* Major number for this device. Ports will be created as minors. */153153+ int chr_major;154154+};155155+156156+/* This struct holds the per-port data */157157+struct port {158158+ /* Next port in the list, head is in the ports_device */159159+ struct list_head list;160160+161161+ /* Pointer to the parent virtio_console device */162162+ struct ports_device *portdev;163163+164164+ /* The current buffer from which data has to be fed to readers */165165+ struct port_buffer *inbuf;166166+167167+ /*168168+ * To protect the operations on the in_vq associated with this169169+ * port. Has to be a spinlock because it can be called from170170+ * interrupt context (get_char()).171171+ */172172+ spinlock_t inbuf_lock;173173+174174+ /* The IO vqs for this port */175175+ struct virtqueue *in_vq, *out_vq;176176+177177+ /* File in the debugfs directory that exposes this port's information */178178+ struct dentry *debugfs_file;179179+180180+ /*181181+ * The entries in this struct will be valid if this port is182182+ * hooked up to an hvc console183183+ */184184+ struct console cons;185185+186186+ /* Each port associates with a separate char device */187187+ struct cdev cdev;188188+ struct device *dev;189189+190190+ /* A waitqueue for poll() or blocking read operations */191191+ wait_queue_head_t waitqueue;192192+193193+ /* The 'name' of the port that we expose via sysfs properties */194194+ char *name;195195+196196+ /* The 'id' to identify the port with the Host */197197+ u32 id;198198+199199+ /* Is the host device open */200200+ bool host_connected;201201+202202+ /* We should allow only one process to open a port */203203+ bool guest_connected;204204+};205205+206206+/* This is the very early arch-specified put chars function. */207207+static int (*early_put_chars)(u32, const char *, int);208208+209209+static struct port *find_port_by_vtermno(u32 vtermno)47210{4848- struct scatterlist sg[1];211211+ struct port *port;212212+ struct console *cons;213213+ unsigned long flags;214214+215215+ spin_lock_irqsave(&pdrvdata_lock, flags);216216+ list_for_each_entry(cons, &pdrvdata.consoles, list) {217217+ if (cons->vtermno == vtermno) {218218+ port = container_of(cons, struct port, cons);219219+ goto out;220220+ }221221+ }222222+ port = NULL;223223+out:224224+ spin_unlock_irqrestore(&pdrvdata_lock, flags);225225+ return port;226226+}227227+228228+static struct port *find_port_by_id(struct ports_device *portdev, u32 id)229229+{230230+ struct port *port;231231+ unsigned long flags;232232+233233+ spin_lock_irqsave(&portdev->ports_lock, flags);234234+ list_for_each_entry(port, &portdev->ports, list)235235+ if (port->id == id)236236+ goto out;237237+ port = NULL;238238+out:239239+ spin_unlock_irqrestore(&portdev->ports_lock, flags);240240+241241+ return port;242242+}243243+244244+static struct port *find_port_by_vq(struct ports_device *portdev,245245+ struct virtqueue *vq)246246+{247247+ struct port *port;248248+ unsigned long flags;249249+250250+ spin_lock_irqsave(&portdev->ports_lock, flags);251251+ list_for_each_entry(port, &portdev->ports, list)252252+ if (port->in_vq == vq || port->out_vq == vq)253253+ goto out;254254+ port = NULL;255255+out:256256+ spin_unlock_irqrestore(&portdev->ports_lock, flags);257257+ return port;258258+}259259+260260+static bool is_console_port(struct port *port)261261+{262262+ if (port->cons.hvc)263263+ return true;264264+ return false;265265+}266266+267267+static inline bool use_multiport(struct ports_device *portdev)268268+{269269+ /*270270+ * This condition can be true when put_chars is called from271271+ * early_init272272+ */273273+ if (!portdev->vdev)274274+ return 0;275275+ return portdev->vdev->features[0] & (1 << VIRTIO_CONSOLE_F_MULTIPORT);276276+}277277+278278+static void free_buf(struct port_buffer *buf)279279+{280280+ kfree(buf->buf);281281+ kfree(buf);282282+}283283+284284+static struct port_buffer *alloc_buf(size_t buf_size)285285+{286286+ struct port_buffer *buf;287287+288288+ buf = kmalloc(sizeof(*buf), GFP_KERNEL);289289+ if (!buf)290290+ goto fail;291291+ buf->buf = kzalloc(buf_size, GFP_KERNEL);292292+ if (!buf->buf)293293+ goto free_buf;294294+ buf->len = 0;295295+ buf->offset = 0;296296+ buf->size = buf_size;297297+ return buf;298298+299299+free_buf:300300+ kfree(buf);301301+fail:302302+ return NULL;303303+}304304+305305+/* Callers should take appropriate locks */306306+static void *get_inbuf(struct port *port)307307+{308308+ struct port_buffer *buf;309309+ struct virtqueue *vq;49310 unsigned int len;503115151- /* This is a convenient routine to initialize a single-elem sg list */5252- sg_init_one(sg, buf, count);5353-5454- /* add_buf wants a token to identify this buffer: we hand it any5555- * non-NULL pointer, since there's only ever one buffer. */5656- if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) >= 0) {5757- /* Tell Host to go! */5858- out_vq->vq_ops->kick(out_vq);5959- /* Chill out until it's done with the buffer. */6060- while (!out_vq->vq_ops->get_buf(out_vq, &len))6161- cpu_relax();312312+ vq = port->in_vq;313313+ buf = vq->vq_ops->get_buf(vq, &len);314314+ if (buf) {315315+ buf->len = len;316316+ buf->offset = 0;62317 }6363-6464- /* We're expected to return the amount of data we wrote: all of it. */6565- return count;318318+ return buf;66319}673206868-/* Create a scatter-gather list representing our input buffer and put it in the6969- * queue. */7070-static void add_inbuf(void)321321+/*322322+ * Create a scatter-gather list representing our input buffer and put323323+ * it in the queue.324324+ *325325+ * Callers should take appropriate locks.326326+ */327327+static int add_inbuf(struct virtqueue *vq, struct port_buffer *buf)71328{72329 struct scatterlist sg[1];7373- sg_init_one(sg, inbuf, PAGE_SIZE);330330+ int ret;743317575- /* We should always be able to add one buffer to an empty queue. */7676- if (in_vq->vq_ops->add_buf(in_vq, sg, 0, 1, inbuf) < 0)7777- BUG();7878- in_vq->vq_ops->kick(in_vq);332332+ sg_init_one(sg, buf->buf, buf->size);333333+334334+ ret = vq->vq_ops->add_buf(vq, sg, 0, 1, buf);335335+ vq->vq_ops->kick(vq);336336+ return ret;79337}803388181-/*D:350 get_chars() is the callback from the hvc_console infrastructure when8282- * an interrupt is received.339339+/* Discard any unread data this port has. Callers lockers. */340340+static void discard_port_data(struct port *port)341341+{342342+ struct port_buffer *buf;343343+ struct virtqueue *vq;344344+ unsigned int len;345345+ int ret;346346+347347+ vq = port->in_vq;348348+ if (port->inbuf)349349+ buf = port->inbuf;350350+ else351351+ buf = vq->vq_ops->get_buf(vq, &len);352352+353353+ ret = 0;354354+ while (buf) {355355+ if (add_inbuf(vq, buf) < 0) {356356+ ret++;357357+ free_buf(buf);358358+ }359359+ buf = vq->vq_ops->get_buf(vq, &len);360360+ }361361+ port->inbuf = NULL;362362+ if (ret)363363+ dev_warn(port->dev, "Errors adding %d buffers back to vq\n",364364+ ret);365365+}366366+367367+static bool port_has_data(struct port *port)368368+{369369+ unsigned long flags;370370+ bool ret;371371+372372+ spin_lock_irqsave(&port->inbuf_lock, flags);373373+ if (port->inbuf) {374374+ ret = true;375375+ goto out;376376+ }377377+ port->inbuf = get_inbuf(port);378378+ if (port->inbuf) {379379+ ret = true;380380+ goto out;381381+ }382382+ ret = false;383383+out:384384+ spin_unlock_irqrestore(&port->inbuf_lock, flags);385385+ return ret;386386+}387387+388388+static ssize_t send_control_msg(struct port *port, unsigned int event,389389+ unsigned int value)390390+{391391+ struct scatterlist sg[1];392392+ struct virtio_console_control cpkt;393393+ struct virtqueue *vq;394394+ int len;395395+396396+ if (!use_multiport(port->portdev))397397+ return 0;398398+399399+ cpkt.id = port->id;400400+ cpkt.event = event;401401+ cpkt.value = value;402402+403403+ vq = port->portdev->c_ovq;404404+405405+ sg_init_one(sg, &cpkt, sizeof(cpkt));406406+ if (vq->vq_ops->add_buf(vq, sg, 1, 0, &cpkt) >= 0) {407407+ vq->vq_ops->kick(vq);408408+ while (!vq->vq_ops->get_buf(vq, &len))409409+ cpu_relax();410410+ }411411+ return 0;412412+}413413+414414+static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count)415415+{416416+ struct scatterlist sg[1];417417+ struct virtqueue *out_vq;418418+ ssize_t ret;419419+ unsigned int len;420420+421421+ out_vq = port->out_vq;422422+423423+ sg_init_one(sg, in_buf, in_count);424424+ ret = out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, in_buf);425425+426426+ /* Tell Host to go! */427427+ out_vq->vq_ops->kick(out_vq);428428+429429+ if (ret < 0) {430430+ len = 0;431431+ goto fail;432432+ }433433+434434+ /*435435+ * Wait till the host acknowledges it pushed out the data we436436+ * sent. Also ensure we return to userspace the number of437437+ * bytes that were successfully consumed by the host.438438+ */439439+ while (!out_vq->vq_ops->get_buf(out_vq, &len))440440+ cpu_relax();441441+fail:442442+ /* We're expected to return the amount of data we wrote */443443+ return len;444444+}445445+446446+/*447447+ * Give out the data that's requested from the buffer that we have448448+ * queued up.449449+ */450450+static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,451451+ bool to_user)452452+{453453+ struct port_buffer *buf;454454+ unsigned long flags;455455+456456+ if (!out_count || !port_has_data(port))457457+ return 0;458458+459459+ buf = port->inbuf;460460+ out_count = min(out_count, buf->len - buf->offset);461461+462462+ if (to_user) {463463+ ssize_t ret;464464+465465+ ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);466466+ if (ret)467467+ return -EFAULT;468468+ } else {469469+ memcpy(out_buf, buf->buf + buf->offset, out_count);470470+ }471471+472472+ buf->offset += out_count;473473+474474+ if (buf->offset == buf->len) {475475+ /*476476+ * We're done using all the data in this buffer.477477+ * Re-queue so that the Host can send us more data.478478+ */479479+ spin_lock_irqsave(&port->inbuf_lock, flags);480480+ port->inbuf = NULL;481481+482482+ if (add_inbuf(port->in_vq, buf) < 0)483483+ dev_warn(port->dev, "failed add_buf\n");484484+485485+ spin_unlock_irqrestore(&port->inbuf_lock, flags);486486+ }487487+ /* Return the number of bytes actually copied */488488+ return out_count;489489+}490490+491491+/* The condition that must be true for polling to end */492492+static bool wait_is_over(struct port *port)493493+{494494+ return port_has_data(port) || !port->host_connected;495495+}496496+497497+static ssize_t port_fops_read(struct file *filp, char __user *ubuf,498498+ size_t count, loff_t *offp)499499+{500500+ struct port *port;501501+ ssize_t ret;502502+503503+ port = filp->private_data;504504+505505+ if (!port_has_data(port)) {506506+ /*507507+ * If nothing's connected on the host just return 0 in508508+ * case of list_empty; this tells the userspace app509509+ * that there's no connection510510+ */511511+ if (!port->host_connected)512512+ return 0;513513+ if (filp->f_flags & O_NONBLOCK)514514+ return -EAGAIN;515515+516516+ ret = wait_event_interruptible(port->waitqueue,517517+ wait_is_over(port));518518+ if (ret < 0)519519+ return ret;520520+ }521521+ /*522522+ * We could've received a disconnection message while we were523523+ * waiting for more data.524524+ *525525+ * This check is not clubbed in the if() statement above as we526526+ * might receive some data as well as the host could get527527+ * disconnected after we got woken up from our wait. So we528528+ * really want to give off whatever data we have and only then529529+ * check for host_connected.530530+ */531531+ if (!port_has_data(port) && !port->host_connected)532532+ return 0;533533+534534+ return fill_readbuf(port, ubuf, count, true);535535+}536536+537537+static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,538538+ size_t count, loff_t *offp)539539+{540540+ struct port *port;541541+ char *buf;542542+ ssize_t ret;543543+544544+ port = filp->private_data;545545+546546+ count = min((size_t)(32 * 1024), count);547547+548548+ buf = kmalloc(count, GFP_KERNEL);549549+ if (!buf)550550+ return -ENOMEM;551551+552552+ ret = copy_from_user(buf, ubuf, count);553553+ if (ret) {554554+ ret = -EFAULT;555555+ goto free_buf;556556+ }557557+558558+ ret = send_buf(port, buf, count);559559+free_buf:560560+ kfree(buf);561561+ return ret;562562+}563563+564564+static unsigned int port_fops_poll(struct file *filp, poll_table *wait)565565+{566566+ struct port *port;567567+ unsigned int ret;568568+569569+ port = filp->private_data;570570+ poll_wait(filp, &port->waitqueue, wait);571571+572572+ ret = 0;573573+ if (port->inbuf)574574+ ret |= POLLIN | POLLRDNORM;575575+ if (port->host_connected)576576+ ret |= POLLOUT;577577+ if (!port->host_connected)578578+ ret |= POLLHUP;579579+580580+ return ret;581581+}582582+583583+static int port_fops_release(struct inode *inode, struct file *filp)584584+{585585+ struct port *port;586586+587587+ port = filp->private_data;588588+589589+ /* Notify host of port being closed */590590+ send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0);591591+592592+ spin_lock_irq(&port->inbuf_lock);593593+ port->guest_connected = false;594594+595595+ discard_port_data(port);596596+597597+ spin_unlock_irq(&port->inbuf_lock);598598+599599+ return 0;600600+}601601+602602+static int port_fops_open(struct inode *inode, struct file *filp)603603+{604604+ struct cdev *cdev = inode->i_cdev;605605+ struct port *port;606606+607607+ port = container_of(cdev, struct port, cdev);608608+ filp->private_data = port;609609+610610+ /*611611+ * Don't allow opening of console port devices -- that's done612612+ * via /dev/hvc613613+ */614614+ if (is_console_port(port))615615+ return -ENXIO;616616+617617+ /* Allow only one process to open a particular port at a time */618618+ spin_lock_irq(&port->inbuf_lock);619619+ if (port->guest_connected) {620620+ spin_unlock_irq(&port->inbuf_lock);621621+ return -EMFILE;622622+ }623623+624624+ port->guest_connected = true;625625+ spin_unlock_irq(&port->inbuf_lock);626626+627627+ /* Notify host of port being opened */628628+ send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);629629+630630+ return 0;631631+}632632+633633+/*634634+ * The file operations that we support: programs in the guest can open635635+ * a console device, read from it, write to it, poll for data and636636+ * close it. The devices are at637637+ * /dev/vport<device number>p<port number>638638+ */639639+static const struct file_operations port_fops = {640640+ .owner = THIS_MODULE,641641+ .open = port_fops_open,642642+ .read = port_fops_read,643643+ .write = port_fops_write,644644+ .poll = port_fops_poll,645645+ .release = port_fops_release,646646+};647647+648648+/*649649+ * The put_chars() callback is pretty straightforward.83650 *8484- * Most of the code deals with the fact that the hvc_console() infrastructure8585- * only asks us for 16 bytes at a time. We keep in_offset and in_used fields8686- * for partially-filled buffers. */651651+ * We turn the characters into a scatter-gather list, add it to the652652+ * output queue and then kick the Host. Then we sit here waiting for653653+ * it to finish: inefficient in theory, but in practice654654+ * implementations will do it immediately (lguest's Launcher does).655655+ */656656+static int put_chars(u32 vtermno, const char *buf, int count)657657+{658658+ struct port *port;659659+660660+ port = find_port_by_vtermno(vtermno);661661+ if (!port)662662+ return 0;663663+664664+ if (unlikely(early_put_chars))665665+ return early_put_chars(vtermno, buf, count);666666+667667+ return send_buf(port, (void *)buf, count);668668+}669669+670670+/*671671+ * get_chars() is the callback from the hvc_console infrastructure672672+ * when an interrupt is received.673673+ *674674+ * We call out to fill_readbuf that gets us the required data from the675675+ * buffers that are queued up.676676+ */87677static int get_chars(u32 vtermno, char *buf, int count)88678{679679+ struct port *port;680680+681681+ port = find_port_by_vtermno(vtermno);682682+ if (!port)683683+ return 0;684684+89685 /* If we don't have an input queue yet, we can't get input. */9090- BUG_ON(!in_vq);686686+ BUG_ON(!port->in_vq);916879292- /* No buffer? Try to get one. */9393- if (!in_len) {9494- in = in_vq->vq_ops->get_buf(in_vq, &in_len);9595- if (!in)9696- return 0;9797- }9898-9999- /* You want more than we have to give? Well, try wanting less! */100100- if (in_len < count)101101- count = in_len;102102-103103- /* Copy across to their buffer and increment offset. */104104- memcpy(buf, in, count);105105- in += count;106106- in_len -= count;107107-108108- /* Finished? Re-register buffer so Host will use it again. */109109- if (in_len == 0)110110- add_inbuf();111111-112112- return count;113113-}114114-/*:*/115115-116116-/*D:320 Console drivers are initialized very early so boot messages can go out,117117- * so we do things slightly differently from the generic virtio initialization118118- * of the net and block drivers.119119- *120120- * At this stage, the console is output-only. It's too early to set up a121121- * virtqueue, so we let the drivers do some boutique early-output thing. */122122-int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))123123-{124124- virtio_cons.put_chars = put_chars;125125- return hvc_instantiate(0, 0, &virtio_cons);688688+ return fill_readbuf(port, buf, count, false);126689}127690128128-/*129129- * virtio console configuration. This supports:130130- * - console resize131131- */132132-static void virtcons_apply_config(struct virtio_device *dev)691691+static void resize_console(struct port *port)133692{693693+ struct virtio_device *vdev;134694 struct winsize ws;135695136136- if (virtio_has_feature(dev, VIRTIO_CONSOLE_F_SIZE)) {137137- dev->config->get(dev,138138- offsetof(struct virtio_console_config, cols),139139- &ws.ws_col, sizeof(u16));140140- dev->config->get(dev,141141- offsetof(struct virtio_console_config, rows),142142- &ws.ws_row, sizeof(u16));143143- hvc_resize(hvc, ws);696696+ vdev = port->portdev->vdev;697697+ if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) {698698+ vdev->config->get(vdev,699699+ offsetof(struct virtio_console_config, cols),700700+ &ws.ws_col, sizeof(u16));701701+ vdev->config->get(vdev,702702+ offsetof(struct virtio_console_config, rows),703703+ &ws.ws_row, sizeof(u16));704704+ hvc_resize(port->cons.hvc, ws);144705 }145706}146707147147-/*148148- * we support only one console, the hvc struct is a global var149149- * We set the configuration at this point, since we now have a tty150150- */708708+/* We set the configuration at this point, since we now have a tty */151709static int notifier_add_vio(struct hvc_struct *hp, int data)152710{711711+ struct port *port;712712+713713+ port = find_port_by_vtermno(hp->vtermno);714714+ if (!port)715715+ return -EINVAL;716716+153717 hp->irq_requested = 1;154154- virtcons_apply_config(vdev);718718+ resize_console(port);155719156720 return 0;157721}···713173 hp->irq_requested = 0;714174}715175716716-static void hvc_handle_input(struct virtqueue *vq)176176+/* The operations for console ports. */177177+static const struct hv_ops hv_ops = {178178+ .get_chars = get_chars,179179+ .put_chars = put_chars,180180+ .notifier_add = notifier_add_vio,181181+ .notifier_del = notifier_del_vio,182182+ .notifier_hangup = notifier_del_vio,183183+};184184+185185+/*186186+ * Console drivers are initialized very early so boot messages can go187187+ * out, so we do things slightly differently from the generic virtio188188+ * initialization of the net and block drivers.189189+ *190190+ * At this stage, the console is output-only. It's too early to set191191+ * up a virtqueue, so we let the drivers do some boutique early-output192192+ * thing.193193+ */194194+int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))717195{718718- if (hvc_poll(hvc))196196+ early_put_chars = put_chars;197197+ return hvc_instantiate(0, 0, &hv_ops);198198+}199199+200200+int init_port_console(struct port *port)201201+{202202+ int ret;203203+204204+ /*205205+ * The Host's telling us this port is a console port. Hook it206206+ * up with an hvc console.207207+ *208208+ * To set up and manage our virtual console, we call209209+ * hvc_alloc().210210+ *211211+ * The first argument of hvc_alloc() is the virtual console212212+ * number. The second argument is the parameter for the213213+ * notification mechanism (like irq number). We currently214214+ * leave this as zero, virtqueues have implicit notifications.215215+ *216216+ * The third argument is a "struct hv_ops" containing the217217+ * put_chars() get_chars(), notifier_add() and notifier_del()218218+ * pointers. The final argument is the output buffer size: we219219+ * can do any size, so we put PAGE_SIZE here.220220+ */221221+ port->cons.vtermno = pdrvdata.next_vtermno;222222+223223+ port->cons.hvc = hvc_alloc(port->cons.vtermno, 0, &hv_ops, PAGE_SIZE);224224+ if (IS_ERR(port->cons.hvc)) {225225+ ret = PTR_ERR(port->cons.hvc);226226+ dev_err(port->dev,227227+ "error %d allocating hvc for port\n", ret);228228+ port->cons.hvc = NULL;229229+ return ret;230230+ }231231+ spin_lock_irq(&pdrvdata_lock);232232+ pdrvdata.next_vtermno++;233233+ list_add_tail(&port->cons.list, &pdrvdata.consoles);234234+ spin_unlock_irq(&pdrvdata_lock);235235+ port->guest_connected = true;236236+237237+ /* Notify host of port being opened */238238+ send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 1);239239+240240+ return 0;241241+}242242+243243+static ssize_t show_port_name(struct device *dev,244244+ struct device_attribute *attr, char *buffer)245245+{246246+ struct port *port;247247+248248+ port = dev_get_drvdata(dev);249249+250250+ return sprintf(buffer, "%s\n", port->name);251251+}252252+253253+static DEVICE_ATTR(name, S_IRUGO, show_port_name, NULL);254254+255255+static struct attribute *port_sysfs_entries[] = {256256+ &dev_attr_name.attr,257257+ NULL258258+};259259+260260+static struct attribute_group port_attribute_group = {261261+ .name = NULL, /* put in device directory */262262+ .attrs = port_sysfs_entries,263263+};264264+265265+static int debugfs_open(struct inode *inode, struct file *filp)266266+{267267+ filp->private_data = inode->i_private;268268+ return 0;269269+}270270+271271+static ssize_t debugfs_read(struct file *filp, char __user *ubuf,272272+ size_t count, loff_t *offp)273273+{274274+ struct port *port;275275+ char *buf;276276+ ssize_t ret, out_offset, out_count;277277+278278+ out_count = 1024;279279+ buf = kmalloc(out_count, GFP_KERNEL);280280+ if (!buf)281281+ return -ENOMEM;282282+283283+ port = filp->private_data;284284+ out_offset = 0;285285+ out_offset += snprintf(buf + out_offset, out_count,286286+ "name: %s\n", port->name ? port->name : "");287287+ out_offset += snprintf(buf + out_offset, out_count - out_offset,288288+ "guest_connected: %d\n", port->guest_connected);289289+ out_offset += snprintf(buf + out_offset, out_count - out_offset,290290+ "host_connected: %d\n", port->host_connected);291291+ out_offset += snprintf(buf + out_offset, out_count - out_offset,292292+ "is_console: %s\n",293293+ is_console_port(port) ? "yes" : "no");294294+ out_offset += snprintf(buf + out_offset, out_count - out_offset,295295+ "console_vtermno: %u\n", port->cons.vtermno);296296+297297+ ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);298298+ kfree(buf);299299+ return ret;300300+}301301+302302+static const struct file_operations port_debugfs_ops = {303303+ .owner = THIS_MODULE,304304+ .open = debugfs_open,305305+ .read = debugfs_read,306306+};307307+308308+/* Remove all port-specific data. */309309+static int remove_port(struct port *port)310310+{311311+ struct port_buffer *buf;312312+313313+ spin_lock_irq(&port->portdev->ports_lock);314314+ list_del(&port->list);315315+ spin_unlock_irq(&port->portdev->ports_lock);316316+317317+ if (is_console_port(port)) {318318+ spin_lock_irq(&pdrvdata_lock);319319+ list_del(&port->cons.list);320320+ spin_unlock_irq(&pdrvdata_lock);321321+ hvc_remove(port->cons.hvc);322322+ }323323+ if (port->guest_connected)324324+ send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0);325325+326326+ sysfs_remove_group(&port->dev->kobj, &port_attribute_group);327327+ device_destroy(pdrvdata.class, port->dev->devt);328328+ cdev_del(&port->cdev);329329+330330+ /* Remove unused data this port might have received. */331331+ discard_port_data(port);332332+333333+ /* Remove buffers we queued up for the Host to send us data in. */334334+ while ((buf = port->in_vq->vq_ops->detach_unused_buf(port->in_vq)))335335+ free_buf(buf);336336+337337+ kfree(port->name);338338+339339+ debugfs_remove(port->debugfs_file);340340+341341+ kfree(port);342342+ return 0;343343+}344344+345345+/* Any private messages that the Host and Guest want to share */346346+static void handle_control_message(struct ports_device *portdev,347347+ struct port_buffer *buf)348348+{349349+ struct virtio_console_control *cpkt;350350+ struct port *port;351351+ size_t name_size;352352+ int err;353353+354354+ cpkt = (struct virtio_console_control *)(buf->buf + buf->offset);355355+356356+ port = find_port_by_id(portdev, cpkt->id);357357+ if (!port) {358358+ /* No valid header at start of buffer. Drop it. */359359+ dev_dbg(&portdev->vdev->dev,360360+ "Invalid index %u in control packet\n", cpkt->id);361361+ return;362362+ }363363+364364+ switch (cpkt->event) {365365+ case VIRTIO_CONSOLE_CONSOLE_PORT:366366+ if (!cpkt->value)367367+ break;368368+ if (is_console_port(port))369369+ break;370370+371371+ init_port_console(port);372372+ /*373373+ * Could remove the port here in case init fails - but374374+ * have to notify the host first.375375+ */376376+ break;377377+ case VIRTIO_CONSOLE_RESIZE:378378+ if (!is_console_port(port))379379+ break;380380+ port->cons.hvc->irq_requested = 1;381381+ resize_console(port);382382+ break;383383+ case VIRTIO_CONSOLE_PORT_OPEN:384384+ port->host_connected = cpkt->value;385385+ wake_up_interruptible(&port->waitqueue);386386+ break;387387+ case VIRTIO_CONSOLE_PORT_NAME:388388+ /*389389+ * Skip the size of the header and the cpkt to get the size390390+ * of the name that was sent391391+ */392392+ name_size = buf->len - buf->offset - sizeof(*cpkt) + 1;393393+394394+ port->name = kmalloc(name_size, GFP_KERNEL);395395+ if (!port->name) {396396+ dev_err(port->dev,397397+ "Not enough space to store port name\n");398398+ break;399399+ }400400+ strncpy(port->name, buf->buf + buf->offset + sizeof(*cpkt),401401+ name_size - 1);402402+ port->name[name_size - 1] = 0;403403+404404+ /*405405+ * Since we only have one sysfs attribute, 'name',406406+ * create it only if we have a name for the port.407407+ */408408+ err = sysfs_create_group(&port->dev->kobj,409409+ &port_attribute_group);410410+ if (err)411411+ dev_err(port->dev,412412+ "Error %d creating sysfs device attributes\n",413413+ err);414414+415415+ break;416416+ case VIRTIO_CONSOLE_PORT_REMOVE:417417+ /*418418+ * Hot unplug the port. We don't decrement nr_ports419419+ * since we don't want to deal with extra complexities420420+ * of using the lowest-available port id: We can just421421+ * pick up the nr_ports number as the id and not have422422+ * userspace send it to us. This helps us in two423423+ * ways:424424+ *425425+ * - We don't need to have a 'port_id' field in the426426+ * config space when a port is hot-added. This is a427427+ * good thing as we might queue up multiple hotplug428428+ * requests issued in our workqueue.429429+ *430430+ * - Another way to deal with this would have been to431431+ * use a bitmap of the active ports and select the432432+ * lowest non-active port from that map. That433433+ * bloats the already tight config space and we434434+ * would end up artificially limiting the435435+ * max. number of ports to sizeof(bitmap). Right436436+ * now we can support 2^32 ports (as the port id is437437+ * stored in a u32 type).438438+ *439439+ */440440+ remove_port(port);441441+ break;442442+ }443443+}444444+445445+static void control_work_handler(struct work_struct *work)446446+{447447+ struct ports_device *portdev;448448+ struct virtqueue *vq;449449+ struct port_buffer *buf;450450+ unsigned int len;451451+452452+ portdev = container_of(work, struct ports_device, control_work);453453+ vq = portdev->c_ivq;454454+455455+ spin_lock(&portdev->cvq_lock);456456+ while ((buf = vq->vq_ops->get_buf(vq, &len))) {457457+ spin_unlock(&portdev->cvq_lock);458458+459459+ buf->len = len;460460+ buf->offset = 0;461461+462462+ handle_control_message(portdev, buf);463463+464464+ spin_lock(&portdev->cvq_lock);465465+ if (add_inbuf(portdev->c_ivq, buf) < 0) {466466+ dev_warn(&portdev->vdev->dev,467467+ "Error adding buffer to queue\n");468468+ free_buf(buf);469469+ }470470+ }471471+ spin_unlock(&portdev->cvq_lock);472472+}473473+474474+static void in_intr(struct virtqueue *vq)475475+{476476+ struct port *port;477477+ unsigned long flags;478478+479479+ port = find_port_by_vq(vq->vdev->priv, vq);480480+ if (!port)481481+ return;482482+483483+ spin_lock_irqsave(&port->inbuf_lock, flags);484484+ if (!port->inbuf)485485+ port->inbuf = get_inbuf(port);486486+487487+ /*488488+ * Don't queue up data when port is closed. This condition489489+ * can be reached when a console port is not yet connected (no490490+ * tty is spawned) and the host sends out data to console491491+ * ports. For generic serial ports, the host won't492492+ * (shouldn't) send data till the guest is connected.493493+ */494494+ if (!port->guest_connected)495495+ discard_port_data(port);496496+497497+ spin_unlock_irqrestore(&port->inbuf_lock, flags);498498+499499+ wake_up_interruptible(&port->waitqueue);500500+501501+ if (is_console_port(port) && hvc_poll(port->cons.hvc))719502 hvc_kick();720503}721504722722-/*D:370 Once we're further in boot, we get probed like any other virtio device.723723- * At this stage we set up the output virtqueue.724724- *725725- * To set up and manage our virtual console, we call hvc_alloc(). Since we726726- * never remove the console device we never need this pointer again.727727- *728728- * Finally we put our input buffer in the input queue, ready to receive. */729729-static int __devinit virtcons_probe(struct virtio_device *dev)505505+static void control_intr(struct virtqueue *vq)730506{731731- vq_callback_t *callbacks[] = { hvc_handle_input, NULL};732732- const char *names[] = { "input", "output" };733733- struct virtqueue *vqs[2];507507+ struct ports_device *portdev;508508+509509+ portdev = vq->vdev->priv;510510+ schedule_work(&portdev->control_work);511511+}512512+513513+static void config_intr(struct virtio_device *vdev)514514+{515515+ struct ports_device *portdev;516516+517517+ portdev = vdev->priv;518518+ if (use_multiport(portdev)) {519519+ /* Handle port hot-add */520520+ schedule_work(&portdev->config_work);521521+ }522522+ /*523523+ * We'll use this way of resizing only for legacy support.524524+ * For newer userspace (VIRTIO_CONSOLE_F_MULTPORT+), use525525+ * control messages to indicate console size changes so that526526+ * it can be done per-port527527+ */528528+ resize_console(find_port_by_id(portdev, 0));529529+}530530+531531+static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)532532+{533533+ struct port_buffer *buf;534534+ unsigned int ret;734535 int err;735536736736- vdev = dev;537537+ ret = 0;538538+ do {539539+ buf = alloc_buf(PAGE_SIZE);540540+ if (!buf)541541+ break;737542738738- /* This is the scratch page we use to receive console input */739739- inbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);740740- if (!inbuf) {543543+ spin_lock_irq(lock);544544+ err = add_inbuf(vq, buf);545545+ if (err < 0) {546546+ spin_unlock_irq(lock);547547+ free_buf(buf);548548+ break;549549+ }550550+ ret++;551551+ spin_unlock_irq(lock);552552+ } while (err > 0);553553+554554+ return ret;555555+}556556+557557+static int add_port(struct ports_device *portdev, u32 id)558558+{559559+ char debugfs_name[16];560560+ struct port *port;561561+ struct port_buffer *buf;562562+ dev_t devt;563563+ int err;564564+565565+ port = kmalloc(sizeof(*port), GFP_KERNEL);566566+ if (!port) {741567 err = -ENOMEM;742568 goto fail;743569 }744570745745- /* Find the queues. */746746- /* FIXME: This is why we want to wean off hvc: we do nothing747747- * when input comes in. */748748- err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names);749749- if (err)750750- goto free;571571+ port->portdev = portdev;572572+ port->id = id;751573752752- in_vq = vqs[0];753753- out_vq = vqs[1];574574+ port->name = NULL;575575+ port->inbuf = NULL;576576+ port->cons.hvc = NULL;754577755755- /* Start using the new console output. */756756- virtio_cons.get_chars = get_chars;757757- virtio_cons.put_chars = put_chars;758758- virtio_cons.notifier_add = notifier_add_vio;759759- virtio_cons.notifier_del = notifier_del_vio;760760- virtio_cons.notifier_hangup = notifier_del_vio;578578+ port->host_connected = port->guest_connected = false;761579762762- /* The first argument of hvc_alloc() is the virtual console number, so763763- * we use zero. The second argument is the parameter for the764764- * notification mechanism (like irq number). We currently leave this765765- * as zero, virtqueues have implicit notifications.766766- *767767- * The third argument is a "struct hv_ops" containing the put_chars()768768- * get_chars(), notifier_add() and notifier_del() pointers.769769- * The final argument is the output buffer size: we can do any size,770770- * so we put PAGE_SIZE here. */771771- hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE);772772- if (IS_ERR(hvc)) {773773- err = PTR_ERR(hvc);774774- goto free_vqs;580580+ port->in_vq = portdev->in_vqs[port->id];581581+ port->out_vq = portdev->out_vqs[port->id];582582+583583+ cdev_init(&port->cdev, &port_fops);584584+585585+ devt = MKDEV(portdev->chr_major, id);586586+ err = cdev_add(&port->cdev, devt, 1);587587+ if (err < 0) {588588+ dev_err(&port->portdev->vdev->dev,589589+ "Error %d adding cdev for port %u\n", err, id);590590+ goto free_port;591591+ }592592+ port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,593593+ devt, port, "vport%up%u",594594+ port->portdev->drv_index, id);595595+ if (IS_ERR(port->dev)) {596596+ err = PTR_ERR(port->dev);597597+ dev_err(&port->portdev->vdev->dev,598598+ "Error %d creating device for port %u\n",599599+ err, id);600600+ goto free_cdev;775601 }776602777777- /* Register the input buffer the first time. */778778- add_inbuf();603603+ spin_lock_init(&port->inbuf_lock);604604+ init_waitqueue_head(&port->waitqueue);605605+606606+ /* Fill the in_vq with buffers so the host can send us data. */607607+ err = fill_queue(port->in_vq, &port->inbuf_lock);608608+ if (!err) {609609+ dev_err(port->dev, "Error allocating inbufs\n");610610+ err = -ENOMEM;611611+ goto free_device;612612+ }613613+614614+ /*615615+ * If we're not using multiport support, this has to be a console port616616+ */617617+ if (!use_multiport(port->portdev)) {618618+ err = init_port_console(port);619619+ if (err)620620+ goto free_inbufs;621621+ }622622+623623+ spin_lock_irq(&portdev->ports_lock);624624+ list_add_tail(&port->list, &port->portdev->ports);625625+ spin_unlock_irq(&portdev->ports_lock);626626+627627+ /*628628+ * Tell the Host we're set so that it can send us various629629+ * configuration parameters for this port (eg, port name,630630+ * caching, whether this is a console port, etc.)631631+ */632632+ send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1);633633+634634+ if (pdrvdata.debugfs_dir) {635635+ /*636636+ * Finally, create the debugfs file that we can use to637637+ * inspect a port's state at any time638638+ */639639+ sprintf(debugfs_name, "vport%up%u",640640+ port->portdev->drv_index, id);641641+ port->debugfs_file = debugfs_create_file(debugfs_name, 0444,642642+ pdrvdata.debugfs_dir,643643+ port,644644+ &port_debugfs_ops);645645+ }646646+ return 0;647647+648648+free_inbufs:649649+ while ((buf = port->in_vq->vq_ops->detach_unused_buf(port->in_vq)))650650+ free_buf(buf);651651+free_device:652652+ device_destroy(pdrvdata.class, port->dev->devt);653653+free_cdev:654654+ cdev_del(&port->cdev);655655+free_port:656656+ kfree(port);657657+fail:658658+ return err;659659+}660660+661661+/*662662+ * The workhandler for config-space updates.663663+ *664664+ * This is called when ports are hot-added.665665+ */666666+static void config_work_handler(struct work_struct *work)667667+{668668+ struct virtio_console_config virtconconf;669669+ struct ports_device *portdev;670670+ struct virtio_device *vdev;671671+ int err;672672+673673+ portdev = container_of(work, struct ports_device, config_work);674674+675675+ vdev = portdev->vdev;676676+ vdev->config->get(vdev,677677+ offsetof(struct virtio_console_config, nr_ports),678678+ &virtconconf.nr_ports,679679+ sizeof(virtconconf.nr_ports));680680+681681+ if (portdev->config.nr_ports == virtconconf.nr_ports) {682682+ /*683683+ * Port 0 got hot-added. Since we already did all the684684+ * other initialisation for it, just tell the Host685685+ * that the port is ready if we find the port. In686686+ * case the port was hot-removed earlier, we call687687+ * add_port to add the port.688688+ */689689+ struct port *port;690690+691691+ port = find_port_by_id(portdev, 0);692692+ if (!port)693693+ add_port(portdev, 0);694694+ else695695+ send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1);696696+ return;697697+ }698698+ if (virtconconf.nr_ports > portdev->config.max_nr_ports) {699699+ dev_warn(&vdev->dev,700700+ "More ports specified (%u) than allowed (%u)",701701+ portdev->config.nr_ports + 1,702702+ portdev->config.max_nr_ports);703703+ return;704704+ }705705+ if (virtconconf.nr_ports < portdev->config.nr_ports)706706+ return;707707+708708+ /* Hot-add ports */709709+ while (virtconconf.nr_ports - portdev->config.nr_ports) {710710+ err = add_port(portdev, portdev->config.nr_ports);711711+ if (err)712712+ break;713713+ portdev->config.nr_ports++;714714+ }715715+}716716+717717+static int init_vqs(struct ports_device *portdev)718718+{719719+ vq_callback_t **io_callbacks;720720+ char **io_names;721721+ struct virtqueue **vqs;722722+ u32 i, j, nr_ports, nr_queues;723723+ int err;724724+725725+ nr_ports = portdev->config.max_nr_ports;726726+ nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;727727+728728+ vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);729729+ if (!vqs) {730730+ err = -ENOMEM;731731+ goto fail;732732+ }733733+ io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);734734+ if (!io_callbacks) {735735+ err = -ENOMEM;736736+ goto free_vqs;737737+ }738738+ io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);739739+ if (!io_names) {740740+ err = -ENOMEM;741741+ goto free_callbacks;742742+ }743743+ portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),744744+ GFP_KERNEL);745745+ if (!portdev->in_vqs) {746746+ err = -ENOMEM;747747+ goto free_names;748748+ }749749+ portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),750750+ GFP_KERNEL);751751+ if (!portdev->out_vqs) {752752+ err = -ENOMEM;753753+ goto free_invqs;754754+ }755755+756756+ /*757757+ * For backward compat (newer host but older guest), the host758758+ * spawns a console port first and also inits the vqs for port759759+ * 0 before others.760760+ */761761+ j = 0;762762+ io_callbacks[j] = in_intr;763763+ io_callbacks[j + 1] = NULL;764764+ io_names[j] = "input";765765+ io_names[j + 1] = "output";766766+ j += 2;767767+768768+ if (use_multiport(portdev)) {769769+ io_callbacks[j] = control_intr;770770+ io_callbacks[j + 1] = NULL;771771+ io_names[j] = "control-i";772772+ io_names[j + 1] = "control-o";773773+774774+ for (i = 1; i < nr_ports; i++) {775775+ j += 2;776776+ io_callbacks[j] = in_intr;777777+ io_callbacks[j + 1] = NULL;778778+ io_names[j] = "input";779779+ io_names[j + 1] = "output";780780+ }781781+ }782782+ /* Find the queues. */783783+ err = portdev->vdev->config->find_vqs(portdev->vdev, nr_queues, vqs,784784+ io_callbacks,785785+ (const char **)io_names);786786+ if (err)787787+ goto free_outvqs;788788+789789+ j = 0;790790+ portdev->in_vqs[0] = vqs[0];791791+ portdev->out_vqs[0] = vqs[1];792792+ j += 2;793793+ if (use_multiport(portdev)) {794794+ portdev->c_ivq = vqs[j];795795+ portdev->c_ovq = vqs[j + 1];796796+797797+ for (i = 1; i < nr_ports; i++) {798798+ j += 2;799799+ portdev->in_vqs[i] = vqs[j];800800+ portdev->out_vqs[i] = vqs[j + 1];801801+ }802802+ }803803+ kfree(io_callbacks);804804+ kfree(io_names);805805+ kfree(vqs);806806+807807+ return 0;808808+809809+free_names:810810+ kfree(io_names);811811+free_callbacks:812812+ kfree(io_callbacks);813813+free_outvqs:814814+ kfree(portdev->out_vqs);815815+free_invqs:816816+ kfree(portdev->in_vqs);817817+free_vqs:818818+ kfree(vqs);819819+fail:820820+ return err;821821+}822822+823823+static const struct file_operations portdev_fops = {824824+ .owner = THIS_MODULE,825825+};826826+827827+/*828828+ * Once we're further in boot, we get probed like any other virtio829829+ * device.830830+ *831831+ * If the host also supports multiple console ports, we check the832832+ * config space to see how many ports the host has spawned. We833833+ * initialize each port found.834834+ */835835+static int __devinit virtcons_probe(struct virtio_device *vdev)836836+{837837+ struct ports_device *portdev;838838+ u32 i;839839+ int err;840840+ bool multiport;841841+842842+ portdev = kmalloc(sizeof(*portdev), GFP_KERNEL);843843+ if (!portdev) {844844+ err = -ENOMEM;845845+ goto fail;846846+ }847847+848848+ /* Attach this portdev to this virtio_device, and vice-versa. */849849+ portdev->vdev = vdev;850850+ vdev->priv = portdev;851851+852852+ spin_lock_irq(&pdrvdata_lock);853853+ portdev->drv_index = pdrvdata.index++;854854+ spin_unlock_irq(&pdrvdata_lock);855855+856856+ portdev->chr_major = register_chrdev(0, "virtio-portsdev",857857+ &portdev_fops);858858+ if (portdev->chr_major < 0) {859859+ dev_err(&vdev->dev,860860+ "Error %d registering chrdev for device %u\n",861861+ portdev->chr_major, portdev->drv_index);862862+ err = portdev->chr_major;863863+ goto free;864864+ }865865+866866+ multiport = false;867867+ portdev->config.nr_ports = 1;868868+ portdev->config.max_nr_ports = 1;869869+ if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) {870870+ multiport = true;871871+ vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT;872872+873873+ vdev->config->get(vdev, offsetof(struct virtio_console_config,874874+ nr_ports),875875+ &portdev->config.nr_ports,876876+ sizeof(portdev->config.nr_ports));877877+ vdev->config->get(vdev, offsetof(struct virtio_console_config,878878+ max_nr_ports),879879+ &portdev->config.max_nr_ports,880880+ sizeof(portdev->config.max_nr_ports));881881+ if (portdev->config.nr_ports > portdev->config.max_nr_ports) {882882+ dev_warn(&vdev->dev,883883+ "More ports (%u) specified than allowed (%u). Will init %u ports.",884884+ portdev->config.nr_ports,885885+ portdev->config.max_nr_ports,886886+ portdev->config.max_nr_ports);887887+888888+ portdev->config.nr_ports = portdev->config.max_nr_ports;889889+ }890890+ }891891+892892+ /* Let the Host know we support multiple ports.*/893893+ vdev->config->finalize_features(vdev);894894+895895+ err = init_vqs(portdev);896896+ if (err < 0) {897897+ dev_err(&vdev->dev, "Error %d initializing vqs\n", err);898898+ goto free_chrdev;899899+ }900900+901901+ spin_lock_init(&portdev->ports_lock);902902+ INIT_LIST_HEAD(&portdev->ports);903903+904904+ if (multiport) {905905+ spin_lock_init(&portdev->cvq_lock);906906+ INIT_WORK(&portdev->control_work, &control_work_handler);907907+ INIT_WORK(&portdev->config_work, &config_work_handler);908908+909909+ err = fill_queue(portdev->c_ivq, &portdev->cvq_lock);910910+ if (!err) {911911+ dev_err(&vdev->dev,912912+ "Error allocating buffers for control queue\n");913913+ err = -ENOMEM;914914+ goto free_vqs;915915+ }916916+ }917917+918918+ for (i = 0; i < portdev->config.nr_ports; i++)919919+ add_port(portdev, i);920920+921921+ /* Start using the new console output. */922922+ early_put_chars = NULL;779923 return 0;780924781925free_vqs:782926 vdev->config->del_vqs(vdev);927927+ kfree(portdev->in_vqs);928928+ kfree(portdev->out_vqs);929929+free_chrdev:930930+ unregister_chrdev(portdev->chr_major, "virtio-portsdev");783931free:784784- kfree(inbuf);932932+ kfree(portdev);785933fail:786934 return err;935935+}936936+937937+static void virtcons_remove(struct virtio_device *vdev)938938+{939939+ struct ports_device *portdev;940940+ struct port *port, *port2;941941+ struct port_buffer *buf;942942+ unsigned int len;943943+944944+ portdev = vdev->priv;945945+946946+ cancel_work_sync(&portdev->control_work);947947+ cancel_work_sync(&portdev->config_work);948948+949949+ list_for_each_entry_safe(port, port2, &portdev->ports, list)950950+ remove_port(port);951951+952952+ unregister_chrdev(portdev->chr_major, "virtio-portsdev");953953+954954+ while ((buf = portdev->c_ivq->vq_ops->get_buf(portdev->c_ivq, &len)))955955+ free_buf(buf);956956+957957+ while ((buf = portdev->c_ivq->vq_ops->detach_unused_buf(portdev->c_ivq)))958958+ free_buf(buf);959959+960960+ vdev->config->del_vqs(vdev);961961+ kfree(portdev->in_vqs);962962+ kfree(portdev->out_vqs);963963+964964+ kfree(portdev);787965}788966789967static struct virtio_device_id id_table[] = {···15112531512254static unsigned int features[] = {1513255 VIRTIO_CONSOLE_F_SIZE,256256+ VIRTIO_CONSOLE_F_MULTIPORT,1514257};15152581516259static struct virtio_driver virtio_console = {···1521262 .driver.owner = THIS_MODULE,1522263 .id_table = id_table,1523264 .probe = virtcons_probe,15241524- .config_changed = virtcons_apply_config,265265+ .remove = virtcons_remove,266266+ .config_changed = config_intr,1525267};15262681527269static int __init init(void)1528270{271271+ int err;272272+273273+ pdrvdata.class = class_create(THIS_MODULE, "virtio-ports");274274+ if (IS_ERR(pdrvdata.class)) {275275+ err = PTR_ERR(pdrvdata.class);276276+ pr_err("Error %d creating virtio-ports class\n", err);277277+ return err;278278+ }279279+280280+ pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL);281281+ if (!pdrvdata.debugfs_dir) {282282+ pr_warning("Error %ld creating debugfs dir for virtio-ports\n",283283+ PTR_ERR(pdrvdata.debugfs_dir));284284+ }285285+ INIT_LIST_HEAD(&pdrvdata.consoles);286286+1529287 return register_virtio_driver(&virtio_console);1530288}289289+290290+static void __exit fini(void)291291+{292292+ unregister_virtio_driver(&virtio_console);293293+294294+ class_destroy(pdrvdata.class);295295+ if (pdrvdata.debugfs_dir)296296+ debugfs_remove_recursive(pdrvdata.debugfs_dir);297297+}1531298module_init(init);299299+module_exit(fini);15323001533301MODULE_DEVICE_TABLE(virtio, id_table);1534302MODULE_DESCRIPTION("Virtio console driver");
+1-1
drivers/clocksource/cs5535-clockevt.c
···21212222#define DRV_NAME "cs5535-clockevt"23232424-static int timer_irq = CONFIG_CS5535_MFGPT_DEFAULT_IRQ;2424+static int timer_irq;2525module_param_named(irq, timer_irq, int, 0644);2626MODULE_PARM_DESC(irq, "Which IRQ to use for the clock source MFGPT ticks.");2727
+45-2
drivers/gpu/drm/drm_edid.c
···598598 return mode;599599}600600601601+/*602602+ * EDID is delightfully ambiguous about how interlaced modes are to be603603+ * encoded. Our internal representation is of frame height, but some604604+ * HDTV detailed timings are encoded as field height.605605+ *606606+ * The format list here is from CEA, in frame size. Technically we607607+ * should be checking refresh rate too. Whatever.608608+ */609609+static void610610+drm_mode_do_interlace_quirk(struct drm_display_mode *mode,611611+ struct detailed_pixel_timing *pt)612612+{613613+ int i;614614+ static const struct {615615+ int w, h;616616+ } cea_interlaced[] = {617617+ { 1920, 1080 },618618+ { 720, 480 },619619+ { 1440, 480 },620620+ { 2880, 480 },621621+ { 720, 576 },622622+ { 1440, 576 },623623+ { 2880, 576 },624624+ };625625+ static const int n_sizes =626626+ sizeof(cea_interlaced)/sizeof(cea_interlaced[0]);627627+628628+ if (!(pt->misc & DRM_EDID_PT_INTERLACED))629629+ return;630630+631631+ for (i = 0; i < n_sizes; i++) {632632+ if ((mode->hdisplay == cea_interlaced[i].w) &&633633+ (mode->vdisplay == cea_interlaced[i].h / 2)) {634634+ mode->vdisplay *= 2;635635+ mode->vsync_start *= 2;636636+ mode->vsync_end *= 2;637637+ mode->vtotal *= 2;638638+ mode->vtotal |= 1;639639+ }640640+ }641641+642642+ mode->flags |= DRM_MODE_FLAG_INTERLACE;643643+}644644+601645/**602646 * drm_mode_detailed - create a new mode from an EDID detailed timing section603647 * @dev: DRM device (needed to create new mode)···724680725681 drm_mode_set_name(mode);726682727727- if (pt->misc & DRM_EDID_PT_INTERLACED)728728- mode->flags |= DRM_MODE_FLAG_INTERLACE;683683+ drm_mode_do_interlace_quirk(mode, pt);729684730685 if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {731686 pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
+9-21
drivers/gpu/drm/i915/i915_drv.c
···176176177177static int i915_drm_freeze(struct drm_device *dev)178178{179179+ struct drm_i915_private *dev_priv = dev->dev_private;180180+179181 pci_save_state(dev->pdev);180182181183 /* If KMS is active, we do the leavevt stuff here */···193191194192 i915_save_state(dev);195193196196- return 0;197197-}198198-199199-static void i915_drm_suspend(struct drm_device *dev)200200-{201201- struct drm_i915_private *dev_priv = dev->dev_private;202202-203194 intel_opregion_free(dev, 1);204195205196 /* Modeset on resume, not lid events */206197 dev_priv->modeset_on_lid = 0;198198+199199+ return 0;207200}208201209202static int i915_suspend(struct drm_device *dev, pm_message_t state)···218221 if (error)219222 return error;220223221221- i915_drm_suspend(dev);222222-223224 if (state.event == PM_EVENT_SUSPEND) {224225 /* Shut down the device */225226 pci_disable_device(dev->pdev);···231236{232237 struct drm_i915_private *dev_priv = dev->dev_private;233238 int error = 0;239239+240240+ i915_restore_state(dev);241241+242242+ intel_opregion_init(dev, 1);234243235244 /* KMS EnterVT equivalent */236245 if (drm_core_check_feature(dev, DRIVER_MODESET)) {···261262 return -EIO;262263263264 pci_set_master(dev->pdev);264264-265265- i915_restore_state(dev);266266-267267- intel_opregion_init(dev, 1);268265269266 return i915_drm_thaw(dev);270267}···418423 if (error)419424 return error;420425421421- i915_drm_suspend(drm_dev);422422-423426 pci_disable_device(pdev);424427 pci_set_power_state(pdev, PCI_D3hot);425428···457464{458465 struct pci_dev *pdev = to_pci_dev(dev);459466 struct drm_device *drm_dev = pci_get_drvdata(pdev);460460- int error;461467462462- error = i915_drm_freeze(drm_dev);463463- if (!error)464464- i915_drm_suspend(drm_dev);465465-466466- return error;468468+ return i915_drm_freeze(drm_dev);467469}468470469471const struct dev_pm_ops i915_pm_ops = {
···583583 uint64_t vm_end;584584 struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR];585585 int vm_vram_pt_nr;586586+ uint64_t vram_sys_base;586587587588 /* the mtrr covering the FB */588589 int fb_mtrr;
···9696 * symbol;9797 */9898#define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */9999+/* RADEON_IB_POOL_SIZE must be a power of 2 */99100#define RADEON_IB_POOL_SIZE 16100101#define RADEON_DEBUGFS_MAX_NUM_FILES 32101102#define RADEONFB_CONN_LIMIT 4···364363 */365364struct radeon_ib {366365 struct list_head list;367367- unsigned long idx;366366+ unsigned idx;368367 uint64_t gpu_addr;369368 struct radeon_fence *fence;370370- uint32_t *ptr;369369+ uint32_t *ptr;371370 uint32_t length_dw;371371+ bool free;372372};373373374374/*···379377struct radeon_ib_pool {380378 struct mutex mutex;381379 struct radeon_bo *robj;382382- struct list_head scheduled_ibs;383380 struct radeon_ib ibs[RADEON_IB_POOL_SIZE];384381 bool ready;385385- DECLARE_BITMAP(alloc_bm, RADEON_IB_POOL_SIZE);382382+ unsigned head_id;386383};387384388385struct radeon_cp {
+9
drivers/gpu/drm/radeon/radeon_atombios.c
···206206 *connector_type = DRM_MODE_CONNECTOR_DVID;207207 }208208209209+ /* Asrock RS600 board lists the DVI port as HDMI */210210+ if ((dev->pdev->device == 0x7941) &&211211+ (dev->pdev->subsystem_vendor == 0x1849) &&212212+ (dev->pdev->subsystem_device == 0x7941)) {213213+ if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) &&214214+ (supported_device == ATOM_DEVICE_DFP3_SUPPORT))215215+ *connector_type = DRM_MODE_CONNECTOR_DVID;216216+ }217217+209218 /* a-bit f-i90hd - ciaranm on #radeonhd - this board has no DVI */210219 if ((dev->pdev->device == 0x7941) &&211220 (dev->pdev->subsystem_vendor == 0x147b) &&
+22-22
drivers/gpu/drm/radeon/radeon_combios.c
···12791279 rdev->mode_info.connector_table = radeon_connector_table;12801280 if (rdev->mode_info.connector_table == CT_NONE) {12811281#ifdef CONFIG_PPC_PMAC12821282- if (machine_is_compatible("PowerBook3,3")) {12821282+ if (of_machine_is_compatible("PowerBook3,3")) {12831283 /* powerbook with VGA */12841284 rdev->mode_info.connector_table = CT_POWERBOOK_VGA;12851285- } else if (machine_is_compatible("PowerBook3,4") ||12861286- machine_is_compatible("PowerBook3,5")) {12851285+ } else if (of_machine_is_compatible("PowerBook3,4") ||12861286+ of_machine_is_compatible("PowerBook3,5")) {12871287 /* powerbook with internal tmds */12881288 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;12891289- } else if (machine_is_compatible("PowerBook5,1") ||12901290- machine_is_compatible("PowerBook5,2") ||12911291- machine_is_compatible("PowerBook5,3") ||12921292- machine_is_compatible("PowerBook5,4") ||12931293- machine_is_compatible("PowerBook5,5")) {12891289+ } else if (of_machine_is_compatible("PowerBook5,1") ||12901290+ of_machine_is_compatible("PowerBook5,2") ||12911291+ of_machine_is_compatible("PowerBook5,3") ||12921292+ of_machine_is_compatible("PowerBook5,4") ||12931293+ of_machine_is_compatible("PowerBook5,5")) {12941294 /* powerbook with external single link tmds (sil164) */12951295 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;12961296- } else if (machine_is_compatible("PowerBook5,6")) {12961296+ } else if (of_machine_is_compatible("PowerBook5,6")) {12971297 /* powerbook with external dual or single link tmds */12981298 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;12991299- } else if (machine_is_compatible("PowerBook5,7") ||13001300- machine_is_compatible("PowerBook5,8") ||13011301- machine_is_compatible("PowerBook5,9")) {12991299+ } else if (of_machine_is_compatible("PowerBook5,7") ||13001300+ of_machine_is_compatible("PowerBook5,8") ||13011301+ of_machine_is_compatible("PowerBook5,9")) {13021302 /* PowerBook6,2 ? */13031303 /* powerbook with external dual link tmds (sil1178?) */13041304 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;13051305- } else if (machine_is_compatible("PowerBook4,1") ||13061306- machine_is_compatible("PowerBook4,2") ||13071307- machine_is_compatible("PowerBook4,3") ||13081308- machine_is_compatible("PowerBook6,3") ||13091309- machine_is_compatible("PowerBook6,5") ||13101310- machine_is_compatible("PowerBook6,7")) {13051305+ } else if (of_machine_is_compatible("PowerBook4,1") ||13061306+ of_machine_is_compatible("PowerBook4,2") ||13071307+ of_machine_is_compatible("PowerBook4,3") ||13081308+ of_machine_is_compatible("PowerBook6,3") ||13091309+ of_machine_is_compatible("PowerBook6,5") ||13101310+ of_machine_is_compatible("PowerBook6,7")) {13111311 /* ibook */13121312 rdev->mode_info.connector_table = CT_IBOOK;13131313- } else if (machine_is_compatible("PowerMac4,4")) {13131313+ } else if (of_machine_is_compatible("PowerMac4,4")) {13141314 /* emac */13151315 rdev->mode_info.connector_table = CT_EMAC;13161316- } else if (machine_is_compatible("PowerMac10,1")) {13161316+ } else if (of_machine_is_compatible("PowerMac10,1")) {13171317 /* mini with internal tmds */13181318 rdev->mode_info.connector_table = CT_MINI_INTERNAL;13191319- } else if (machine_is_compatible("PowerMac10,2")) {13191319+ } else if (of_machine_is_compatible("PowerMac10,2")) {13201320 /* mini with external tmds */13211321 rdev->mode_info.connector_table = CT_MINI_EXTERNAL;13221322- } else if (machine_is_compatible("PowerMac12,1")) {13221322+ } else if (of_machine_is_compatible("PowerMac12,1")) {13231323 /* PowerMac8,1 ? */13241324 /* imac g5 isight */13251325 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
+2-3
drivers/gpu/drm/radeon/radeon_connectors.c
···780780 * connected and the DVI port disconnected. If the edid doesn't781781 * say HDMI, vice versa.782782 */783783- if (radeon_connector->shared_ddc && connector_status_connected) {783783+ if (radeon_connector->shared_ddc && (ret == connector_status_connected)) {784784 struct drm_device *dev = connector->dev;785785 struct drm_connector *list_connector;786786 struct radeon_connector *list_radeon_connector;···10601060 return;10611061 }10621062 if (radeon_connector->ddc_bus && i2c_bus->valid) {10631063- if (memcmp(&radeon_connector->ddc_bus->rec, i2c_bus,10641064- sizeof(struct radeon_i2c_bus_rec)) == 0) {10631063+ if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) {10651064 radeon_connector->shared_ddc = true;10661065 shared_ddc = true;10671066 }
+4-6
drivers/gpu/drm/radeon/radeon_cs.c
···8686 &p->validated);8787 }8888 }8989- return radeon_bo_list_validate(&p->validated, p->ib->fence);8989+ return radeon_bo_list_validate(&p->validated);9090}91919292int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)···189189{190190 unsigned i;191191192192- if (error && parser->ib) {193193- radeon_bo_list_unvalidate(&parser->validated,194194- parser->ib->fence);195195- } else {196196- radeon_bo_list_unreserve(&parser->validated);192192+ if (!error && parser->ib) {193193+ radeon_bo_list_fence(&parser->validated, parser->ib->fence);197194 }195195+ radeon_bo_list_unreserve(&parser->validated);198196 for (i = 0; i < parser->nrelocs; i++) {199197 if (parser->relocs[i].gobj) {200198 mutex_lock(&parser->rdev->ddev->struct_mutex);
+2-1
drivers/gpu/drm/radeon/radeon_drv.h
···106106 * 1.29- R500 3D cmd buffer support107107 * 1.30- Add support for occlusion queries108108 * 1.31- Add support for num Z pipes from GET_PARAM109109+ * 1.32- fixes for rv740 setup109110 */110111#define DRIVER_MAJOR 1111111-#define DRIVER_MINOR 31112112+#define DRIVER_MINOR 32112113#define DRIVER_PATCHLEVEL 0113114114115enum radeon_cp_microcode_version {
···961961 remaining -= 7;962962 pr_devel("client 0x%p called 'target'\n", priv);963963 /* if target is default */964964- if (!strncmp(kbuf, "default", 7))964964+ if (!strncmp(curr_pos, "default", 7))965965 pdev = pci_dev_get(vga_default_device());966966 else {967967 if (!vga_pci_str_to_vars(curr_pos, remaining,
+50-4
drivers/hid/Kconfig
···5555menu "Special HID drivers"5656 depends on HID57575858+config HID_3M_PCT5959+ tristate "3M PCT"6060+ depends on USB_HID6161+ ---help---6262+ Support for 3M PCT touch screens.6363+5864config HID_A4TECH5965 tristate "A4 tech" if EMBEDDED6066 depends on USB_HID···189183 Say Y here if you want to enable force feedback support for Logitech190184 Rumblepad 2 devices.191185186186+config LOGIG940_FF187187+ bool "Logitech Flight System G940 force feedback support"188188+ depends on HID_LOGITECH189189+ select INPUT_FF_MEMLESS190190+ help191191+ Say Y here if you want to enable force feedback support for Logitech192192+ Flight System G940 devices.193193+194194+config HID_MAGICMOUSE195195+ tristate "Apple MagicMouse multi-touch support"196196+ depends on BT_HIDP197197+ ---help---198198+ Support for the Apple Magic Mouse multi-touch.199199+200200+ Say Y here if you want support for the multi-touch features of the201201+ Apple Wireless "Magic" Mouse.202202+192203config HID_MICROSOFT193204 tristate "Microsoft" if EMBEDDED194205 depends on USB_HID195206 default !EMBEDDED196207 ---help---197208 Support for Microsoft devices that are not fully compliant with HID standard.209209+210210+config HID_MOSART211211+ tristate "MosArt"212212+ depends on USB_HID213213+ ---help---214214+ Support for MosArt dual-touch panels.198215199216config HID_MONTEREY200217 tristate "Monterey" if EMBEDDED···227198 Support for Monterey Genius KB29E.228199229200config HID_NTRIG230230- tristate "NTrig" if EMBEDDED201201+ tristate "NTrig"202202+ depends on USB_HID203203+ ---help---204204+ Support for N-Trig touch screen.205205+206206+config HID_ORTEK207207+ tristate "Ortek" if EMBEDDED231208 depends on USB_HID232209 default !EMBEDDED233210 ---help---234234- Support for N-Trig touch screen.211211+ Support for Ortek WKB-2000 wireless keyboard + mouse trackpad.235212236213config HID_PANTHERLORD237214 tristate "Pantherlord support" if EMBEDDED···262227 ---help---263228 Support for Petalynx Maxter remote control.264229230230+config HID_QUANTA231231+ tristate "Quanta Optical Touch"232232+ depends on USB_HID233233+ ---help---234234+ Support for Quanta Optical Touch dual-touch panels.235235+265236config HID_SAMSUNG266237 tristate "Samsung" if EMBEDDED267238 depends on USB_HID···281240 default !EMBEDDED282241 ---help---283242 Support for Sony PS3 controller.243243+244244+config HID_STANTUM245245+ tristate "Stantum"246246+ depends on USB_HID247247+ ---help---248248+ Support for Stantum multitouch panel.284249285250config HID_SUNPLUS286251 tristate "Sunplus" if EMBEDDED···352305 Rumble Force or Force Feedback Wheel.353306354307config HID_WACOM355355- tristate "Wacom Bluetooth devices support" if EMBEDDED308308+ tristate "Wacom Bluetooth devices support"356309 depends on BT_HIDP357357- default !EMBEDDED358310 ---help---359311 Support for Wacom Graphire Bluetooth tablet.360312
···11+/*22+ * HID driver for 3M PCT multitouch panels33+ *44+ * Copyright (c) 2009 Stephane Chatty <chatty@enac.fr>55+ *66+ */77+88+/*99+ * This program is free software; you can redistribute it and/or modify it1010+ * under the terms of the GNU General Public License as published by the Free1111+ * Software Foundation; either version 2 of the License, or (at your option)1212+ * any later version.1313+ */1414+1515+#include <linux/device.h>1616+#include <linux/hid.h>1717+#include <linux/module.h>1818+#include <linux/usb.h>1919+2020+MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");2121+MODULE_DESCRIPTION("3M PCT multitouch panels");2222+MODULE_LICENSE("GPL");2323+2424+#include "hid-ids.h"2525+2626+struct mmm_finger {2727+ __s32 x, y;2828+ __u8 rank;2929+ bool touch, valid;3030+};3131+3232+struct mmm_data {3333+ struct mmm_finger f[10];3434+ __u8 curid, num;3535+ bool touch, valid;3636+};3737+3838+static int mmm_input_mapping(struct hid_device *hdev, struct hid_input *hi,3939+ struct hid_field *field, struct hid_usage *usage,4040+ unsigned long **bit, int *max)4141+{4242+ switch (usage->hid & HID_USAGE_PAGE) {4343+4444+ case HID_UP_BUTTON:4545+ return -1;4646+4747+ case HID_UP_GENDESK:4848+ switch (usage->hid) {4949+ case HID_GD_X:5050+ hid_map_usage(hi, usage, bit, max,5151+ EV_ABS, ABS_MT_POSITION_X);5252+ /* touchscreen emulation */5353+ input_set_abs_params(hi->input, ABS_X,5454+ field->logical_minimum,5555+ field->logical_maximum, 0, 0);5656+ return 1;5757+ case HID_GD_Y:5858+ hid_map_usage(hi, usage, bit, max,5959+ EV_ABS, ABS_MT_POSITION_Y);6060+ /* touchscreen emulation */6161+ input_set_abs_params(hi->input, ABS_Y,6262+ field->logical_minimum,6363+ field->logical_maximum, 0, 0);6464+ return 1;6565+ }6666+ return 0;6767+6868+ case HID_UP_DIGITIZER:6969+ switch (usage->hid) {7070+ /* we do not want to map these: no input-oriented meaning */7171+ case 0x14:7272+ case 0x23:7373+ case HID_DG_INPUTMODE:7474+ case HID_DG_DEVICEINDEX:7575+ case HID_DG_CONTACTCOUNT:7676+ case HID_DG_CONTACTMAX:7777+ case HID_DG_INRANGE:7878+ case HID_DG_CONFIDENCE:7979+ return -1;8080+ case HID_DG_TIPSWITCH:8181+ /* touchscreen emulation */8282+ hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);8383+ return 1;8484+ case HID_DG_CONTACTID:8585+ hid_map_usage(hi, usage, bit, max,8686+ EV_ABS, ABS_MT_TRACKING_ID);8787+ return 1;8888+ }8989+ /* let hid-input decide for the others */9090+ return 0;9191+9292+ case 0xff000000:9393+ /* we do not want to map these: no input-oriented meaning */9494+ return -1;9595+ }9696+9797+ return 0;9898+}9999+100100+static int mmm_input_mapped(struct hid_device *hdev, struct hid_input *hi,101101+ struct hid_field *field, struct hid_usage *usage,102102+ unsigned long **bit, int *max)103103+{104104+ if (usage->type == EV_KEY || usage->type == EV_ABS)105105+ clear_bit(usage->code, *bit);106106+107107+ return 0;108108+}109109+110110+/*111111+ * this function is called when a whole packet has been received and processed,112112+ * so that it can decide what to send to the input layer.113113+ */114114+static void mmm_filter_event(struct mmm_data *md, struct input_dev *input)115115+{116116+ struct mmm_finger *oldest = 0;117117+ bool pressed = false, released = false;118118+ int i;119119+120120+ /*121121+ * we need to iterate on all fingers to decide if we have a press122122+ * or a release event in our touchscreen emulation.123123+ */124124+ for (i = 0; i < 10; ++i) {125125+ struct mmm_finger *f = &md->f[i];126126+ if (!f->valid) {127127+ /* this finger is just placeholder data, ignore */128128+ } else if (f->touch) {129129+ /* this finger is on the screen */130130+ input_event(input, EV_ABS, ABS_MT_TRACKING_ID, i);131131+ input_event(input, EV_ABS, ABS_MT_POSITION_X, f->x);132132+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, f->y);133133+ input_mt_sync(input);134134+ /*135135+ * touchscreen emulation: maintain the age rank136136+ * of this finger, decide if we have a press137137+ */138138+ if (f->rank == 0) {139139+ f->rank = ++(md->num);140140+ if (f->rank == 1)141141+ pressed = true;142142+ }143143+ if (f->rank == 1)144144+ oldest = f;145145+ } else {146146+ /* this finger took off the screen */147147+ /* touchscreen emulation: maintain age rank of others */148148+ int j;149149+150150+ for (j = 0; j < 10; ++j) {151151+ struct mmm_finger *g = &md->f[j];152152+ if (g->rank > f->rank) {153153+ g->rank--;154154+ if (g->rank == 1)155155+ oldest = g;156156+ }157157+ }158158+ f->rank = 0;159159+ --(md->num);160160+ if (md->num == 0)161161+ released = true;162162+ }163163+ f->valid = 0;164164+ }165165+166166+ /* touchscreen emulation */167167+ if (oldest) {168168+ if (pressed)169169+ input_event(input, EV_KEY, BTN_TOUCH, 1);170170+ input_event(input, EV_ABS, ABS_X, oldest->x);171171+ input_event(input, EV_ABS, ABS_Y, oldest->y);172172+ } else if (released) {173173+ input_event(input, EV_KEY, BTN_TOUCH, 0);174174+ }175175+}176176+177177+/*178178+ * this function is called upon all reports179179+ * so that we can accumulate contact point information,180180+ * and call input_mt_sync after each point.181181+ */182182+static int mmm_event(struct hid_device *hid, struct hid_field *field,183183+ struct hid_usage *usage, __s32 value)184184+{185185+ struct mmm_data *md = hid_get_drvdata(hid);186186+ /*187187+ * strangely, this function can be called before188188+ * field->hidinput is initialized!189189+ */190190+ if (hid->claimed & HID_CLAIMED_INPUT) {191191+ struct input_dev *input = field->hidinput->input;192192+ switch (usage->hid) {193193+ case HID_DG_TIPSWITCH:194194+ md->touch = value;195195+ break;196196+ case HID_DG_CONFIDENCE:197197+ md->valid = value;198198+ break;199199+ case HID_DG_CONTACTID:200200+ if (md->valid) {201201+ md->curid = value;202202+ md->f[value].touch = md->touch;203203+ md->f[value].valid = 1;204204+ }205205+ break;206206+ case HID_GD_X:207207+ if (md->valid)208208+ md->f[md->curid].x = value;209209+ break;210210+ case HID_GD_Y:211211+ if (md->valid)212212+ md->f[md->curid].y = value;213213+ break;214214+ case HID_DG_CONTACTCOUNT:215215+ mmm_filter_event(md, input);216216+ break;217217+ }218218+ }219219+220220+ /* we have handled the hidinput part, now remains hiddev */221221+ if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)222222+ hid->hiddev_hid_event(hid, field, usage, value);223223+224224+ return 1;225225+}226226+227227+static int mmm_probe(struct hid_device *hdev, const struct hid_device_id *id)228228+{229229+ int ret;230230+ struct mmm_data *md;231231+232232+ md = kzalloc(sizeof(struct mmm_data), GFP_KERNEL);233233+ if (!md) {234234+ dev_err(&hdev->dev, "cannot allocate 3M data\n");235235+ return -ENOMEM;236236+ }237237+ hid_set_drvdata(hdev, md);238238+239239+ ret = hid_parse(hdev);240240+ if (!ret)241241+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);242242+243243+ if (ret)244244+ kfree(md);245245+ return ret;246246+}247247+248248+static void mmm_remove(struct hid_device *hdev)249249+{250250+ hid_hw_stop(hdev);251251+ kfree(hid_get_drvdata(hdev));252252+ hid_set_drvdata(hdev, NULL);253253+}254254+255255+static const struct hid_device_id mmm_devices[] = {256256+ { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },257257+ { }258258+};259259+MODULE_DEVICE_TABLE(hid, mmm_devices);260260+261261+static const struct hid_usage_id mmm_grabbed_usages[] = {262262+ { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },263263+ { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}264264+};265265+266266+static struct hid_driver mmm_driver = {267267+ .name = "3m-pct",268268+ .id_table = mmm_devices,269269+ .probe = mmm_probe,270270+ .remove = mmm_remove,271271+ .input_mapping = mmm_input_mapping,272272+ .input_mapped = mmm_input_mapped,273273+ .usage_table = mmm_grabbed_usages,274274+ .event = mmm_event,275275+};276276+277277+static int __init mmm_init(void)278278+{279279+ return hid_register_driver(&mmm_driver);280280+}281281+282282+static void __exit mmm_exit(void)283283+{284284+ hid_unregister_driver(&mmm_driver);285285+}286286+287287+module_init(mmm_init);288288+module_exit(mmm_exit);289289+MODULE_LICENSE("GPL");290290+
+12-5
drivers/hid/hid-apple.c
···4040MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "4141 "[1] = fkeyslast, 2 = fkeysfirst)");42424343+static unsigned int iso_layout = 1;4444+module_param(iso_layout, uint, 0644);4545+MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "4646+ "(0 = disabled, [1] = enabled)");4747+4348struct apple_sc {4449 unsigned long quirks;4550 unsigned int fn_on;···204199 }205200 }206201207207- if (asc->quirks & APPLE_ISO_KEYBOARD) {208208- trans = apple_find_translation(apple_iso_keyboard, usage->code);209209- if (trans) {210210- input_event(input, usage->type, trans->to, value);211211- return 1;202202+ if (iso_layout) {203203+ if (asc->quirks & APPLE_ISO_KEYBOARD) {204204+ trans = apple_find_translation(apple_iso_keyboard, usage->code);205205+ if (trans) {206206+ input_event(input, usage->type, trans->to, value);207207+ return 1;208208+ }212209 }213210 }214211
···11+/*22+ * Force feedback support for Logitech Flight System G94033+ *44+ * Copyright (c) 2009 Gary Stein <LordCnidarian@gmail.com>55+ */66+77+/*88+ * This program is free software; you can redistribute it and/or modify99+ * it under the terms of the GNU General Public License as published by1010+ * the Free Software Foundation; either version 2 of the License, or1111+ * (at your option) any later version.1212+ *1313+ * This program is distributed in the hope that it will be useful,1414+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1515+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1616+ * GNU General Public License for more details.1717+ *1818+ * You should have received a copy of the GNU General Public License1919+ * along with this program; if not, write to the Free Software2020+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2121+ */2222+2323+2424+#include <linux/input.h>2525+#include <linux/usb.h>2626+#include <linux/hid.h>2727+2828+#include "usbhid/usbhid.h"2929+#include "hid-lg.h"3030+3131+/*3232+ * G940 Theory of Operation (from experimentation)3333+ *3434+ * There are 63 fields (only 3 of them currently used)3535+ * 0 - seems to be command field3636+ * 1 - 30 deal with the x axis3737+ * 31 -60 deal with the y axis3838+ *3939+ * Field 1 is x axis constant force4040+ * Field 31 is y axis constant force4141+ *4242+ * other interesting fields 1,2,3,4 on x axis4343+ * (same for 31,32,33,34 on y axis)4444+ *4545+ * 0 0 127 127 makes the joystick autocenter hard4646+ *4747+ * 127 0 127 127 makes the joystick loose on the right,4848+ * but stops all movemnt left4949+ *5050+ * -127 0 -127 -127 makes the joystick loose on the left,5151+ * but stops all movement right5252+ *5353+ * 0 0 -127 -127 makes the joystick rattle very hard5454+ *5555+ * I'm sure these are effects that I don't know enough about them5656+ */5757+5858+struct lg3ff_device {5959+ struct hid_report *report;6060+};6161+6262+static int hid_lg3ff_play(struct input_dev *dev, void *data,6363+ struct ff_effect *effect)6464+{6565+ struct hid_device *hid = input_get_drvdata(dev);6666+ struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;6767+ struct hid_report *report = list_entry(report_list->next, struct hid_report, list);6868+ int x, y;6969+7070+/*7171+ * Maxusage should always be 63 (maximum fields)7272+ * likely a better way to ensure this data is clean7373+ */7474+ memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);7575+7676+ switch (effect->type) {7777+ case FF_CONSTANT:7878+/*7979+ * Already clamped in ff_memless8080+ * 0 is center (different then other logitech)8181+ */8282+ x = effect->u.ramp.start_level;8383+ y = effect->u.ramp.end_level;8484+8585+ /* send command byte */8686+ report->field[0]->value[0] = 0x51;8787+8888+/*8989+ * Sign backwards from other Force3d pro9090+ * which get recast here in two's complement 8 bits9191+ */9292+ report->field[0]->value[1] = (unsigned char)(-x);9393+ report->field[0]->value[31] = (unsigned char)(-y);9494+9595+ usbhid_submit_report(hid, report, USB_DIR_OUT);9696+ break;9797+ }9898+ return 0;9999+}100100+static void hid_lg3ff_set_autocenter(struct input_dev *dev, u16 magnitude)101101+{102102+ struct hid_device *hid = input_get_drvdata(dev);103103+ struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;104104+ struct hid_report *report = list_entry(report_list->next, struct hid_report, list);105105+106106+/*107107+ * Auto Centering probed from device108108+ * NOTE: deadman's switch on G940 must be covered109109+ * for effects to work110110+ */111111+ report->field[0]->value[0] = 0x51;112112+ report->field[0]->value[1] = 0x00;113113+ report->field[0]->value[2] = 0x00;114114+ report->field[0]->value[3] = 0x7F;115115+ report->field[0]->value[4] = 0x7F;116116+ report->field[0]->value[31] = 0x00;117117+ report->field[0]->value[32] = 0x00;118118+ report->field[0]->value[33] = 0x7F;119119+ report->field[0]->value[34] = 0x7F;120120+121121+ usbhid_submit_report(hid, report, USB_DIR_OUT);122122+}123123+124124+125125+static const signed short ff3_joystick_ac[] = {126126+ FF_CONSTANT,127127+ FF_AUTOCENTER,128128+ -1129129+};130130+131131+int lg3ff_init(struct hid_device *hid)132132+{133133+ struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);134134+ struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;135135+ struct input_dev *dev = hidinput->input;136136+ struct hid_report *report;137137+ struct hid_field *field;138138+ const signed short *ff_bits = ff3_joystick_ac;139139+ int error;140140+ int i;141141+142142+ /* Find the report to use */143143+ if (list_empty(report_list)) {144144+ err_hid("No output report found");145145+ return -1;146146+ }147147+148148+ /* Check that the report looks ok */149149+ report = list_entry(report_list->next, struct hid_report, list);150150+ if (!report) {151151+ err_hid("NULL output report");152152+ return -1;153153+ }154154+155155+ field = report->field[0];156156+ if (!field) {157157+ err_hid("NULL field");158158+ return -1;159159+ }160160+161161+ /* Assume single fixed device G940 */162162+ for (i = 0; ff_bits[i] >= 0; i++)163163+ set_bit(ff_bits[i], dev->ffbit);164164+165165+ error = input_ff_create_memless(dev, NULL, hid_lg3ff_play);166166+ if (error)167167+ return error;168168+169169+ if (test_bit(FF_AUTOCENTER, dev->ffbit))170170+ dev->ff->set_autocenter = hid_lg3ff_set_autocenter;171171+172172+ dev_info(&hid->dev, "Force feedback for Logitech Flight System G940 by "173173+ "Gary Stein <LordCnidarian@gmail.com>\n");174174+ return 0;175175+}176176+
···11+/*22+ * Apple "Magic" Wireless Mouse driver33+ *44+ * Copyright (c) 2010 Michael Poole <mdpoole@troilus.org>55+ */66+77+/*88+ * This program is free software; you can redistribute it and/or modify it99+ * under the terms of the GNU General Public License as published by the Free1010+ * Software Foundation; either version 2 of the License, or (at your option)1111+ * any later version.1212+ */1313+1414+#include <linux/device.h>1515+#include <linux/hid.h>1616+#include <linux/module.h>1717+#include <linux/usb.h>1818+1919+#include "hid-ids.h"2020+2121+static bool emulate_3button = true;2222+module_param(emulate_3button, bool, 0644);2323+MODULE_PARM_DESC(emulate_3button, "Emulate a middle button");2424+2525+static int middle_button_start = -350;2626+static int middle_button_stop = +350;2727+2828+static bool emulate_scroll_wheel = true;2929+module_param(emulate_scroll_wheel, bool, 0644);3030+MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel");3131+3232+static bool report_touches = true;3333+module_param(report_touches, bool, 0644);3434+MODULE_PARM_DESC(report_touches, "Emit touch records (otherwise, only use them for emulation)");3535+3636+static bool report_undeciphered;3737+module_param(report_undeciphered, bool, 0644);3838+MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state field using a MSC_RAW event");3939+4040+#define TOUCH_REPORT_ID 0x294141+/* These definitions are not precise, but they're close enough. (Bits4242+ * 0x03 seem to indicate the aspect ratio of the touch, bits 0x70 seem4343+ * to be some kind of bit mask -- 0x20 may be a near-field reading,4444+ * and 0x40 is actual contact, and 0x10 may be a start/stop or change4545+ * indication.)4646+ */4747+#define TOUCH_STATE_MASK 0xf04848+#define TOUCH_STATE_NONE 0x004949+#define TOUCH_STATE_START 0x305050+#define TOUCH_STATE_DRAG 0x405151+5252+/**5353+ * struct magicmouse_sc - Tracks Magic Mouse-specific data.5454+ * @input: Input device through which we report events.5555+ * @quirks: Currently unused.5656+ * @last_timestamp: Timestamp from most recent (18-bit) touch report5757+ * (units of milliseconds over short windows, but seems to5858+ * increase faster when there are no touches).5959+ * @delta_time: 18-bit difference between the two most recent touch6060+ * reports from the mouse.6161+ * @ntouches: Number of touches in most recent touch report.6262+ * @scroll_accel: Number of consecutive scroll motions.6363+ * @scroll_jiffies: Time of last scroll motion.6464+ * @touches: Most recent data for a touch, indexed by tracking ID.6565+ * @tracking_ids: Mapping of current touch input data to @touches.6666+ */6767+struct magicmouse_sc {6868+ struct input_dev *input;6969+ unsigned long quirks;7070+7171+ int last_timestamp;7272+ int delta_time;7373+ int ntouches;7474+ int scroll_accel;7575+ unsigned long scroll_jiffies;7676+7777+ struct {7878+ short x;7979+ short y;8080+ short scroll_y;8181+ u8 size;8282+ } touches[16];8383+ int tracking_ids[16];8484+};8585+8686+static int magicmouse_firm_touch(struct magicmouse_sc *msc)8787+{8888+ int touch = -1;8989+ int ii;9090+9191+ /* If there is only one "firm" touch, set touch to its9292+ * tracking ID.9393+ */9494+ for (ii = 0; ii < msc->ntouches; ii++) {9595+ int idx = msc->tracking_ids[ii];9696+ if (msc->touches[idx].size < 8) {9797+ /* Ignore this touch. */9898+ } else if (touch >= 0) {9999+ touch = -1;100100+ break;101101+ } else {102102+ touch = idx;103103+ }104104+ }105105+106106+ return touch;107107+}108108+109109+static void magicmouse_emit_buttons(struct magicmouse_sc *msc, int state)110110+{111111+ int last_state = test_bit(BTN_LEFT, msc->input->key) << 0 |112112+ test_bit(BTN_RIGHT, msc->input->key) << 1 |113113+ test_bit(BTN_MIDDLE, msc->input->key) << 2;114114+115115+ if (emulate_3button) {116116+ int id;117117+118118+ /* If some button was pressed before, keep it held119119+ * down. Otherwise, if there's exactly one firm120120+ * touch, use that to override the mouse's guess.121121+ */122122+ if (state == 0) {123123+ /* The button was released. */124124+ } else if (last_state != 0) {125125+ state = last_state;126126+ } else if ((id = magicmouse_firm_touch(msc)) >= 0) {127127+ int x = msc->touches[id].x;128128+ if (x < middle_button_start)129129+ state = 1;130130+ else if (x > middle_button_stop)131131+ state = 2;132132+ else133133+ state = 4;134134+ } /* else: we keep the mouse's guess */135135+136136+ input_report_key(msc->input, BTN_MIDDLE, state & 4);137137+ }138138+139139+ input_report_key(msc->input, BTN_LEFT, state & 1);140140+ input_report_key(msc->input, BTN_RIGHT, state & 2);141141+142142+ if (state != last_state)143143+ msc->scroll_accel = 0;144144+}145145+146146+static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tdata)147147+{148148+ struct input_dev *input = msc->input;149149+ __s32 x_y = tdata[0] << 8 | tdata[1] << 16 | tdata[2] << 24;150150+ int misc = tdata[5] | tdata[6] << 8;151151+ int id = (misc >> 6) & 15;152152+ int x = x_y << 12 >> 20;153153+ int y = -(x_y >> 20);154154+155155+ /* Store tracking ID and other fields. */156156+ msc->tracking_ids[raw_id] = id;157157+ msc->touches[id].x = x;158158+ msc->touches[id].y = y;159159+ msc->touches[id].size = misc & 63;160160+161161+ /* If requested, emulate a scroll wheel by detecting small162162+ * vertical touch motions along the middle of the mouse.163163+ */164164+ if (emulate_scroll_wheel &&165165+ middle_button_start < x && x < middle_button_stop) {166166+ static const int accel_profile[] = {167167+ 256, 228, 192, 160, 128, 96, 64, 32,168168+ };169169+ unsigned long now = jiffies;170170+ int step = msc->touches[id].scroll_y - y;171171+172172+ /* Reset acceleration after half a second. */173173+ if (time_after(now, msc->scroll_jiffies + HZ / 2))174174+ msc->scroll_accel = 0;175175+176176+ /* Calculate and apply the scroll motion. */177177+ switch (tdata[7] & TOUCH_STATE_MASK) {178178+ case TOUCH_STATE_START:179179+ msc->touches[id].scroll_y = y;180180+ msc->scroll_accel = min_t(int, msc->scroll_accel + 1,181181+ ARRAY_SIZE(accel_profile) - 1);182182+ break;183183+ case TOUCH_STATE_DRAG:184184+ step = step / accel_profile[msc->scroll_accel];185185+ if (step != 0) {186186+ msc->touches[id].scroll_y = y;187187+ msc->scroll_jiffies = now;188188+ input_report_rel(input, REL_WHEEL, step);189189+ }190190+ break;191191+ }192192+ }193193+194194+ /* Generate the input events for this touch. */195195+ if (report_touches) {196196+ int orientation = (misc >> 10) - 32;197197+198198+ input_report_abs(input, ABS_MT_TRACKING_ID, id);199199+ input_report_abs(input, ABS_MT_TOUCH_MAJOR, tdata[3]);200200+ input_report_abs(input, ABS_MT_TOUCH_MINOR, tdata[4]);201201+ input_report_abs(input, ABS_MT_ORIENTATION, orientation);202202+ input_report_abs(input, ABS_MT_POSITION_X, x);203203+ input_report_abs(input, ABS_MT_POSITION_Y, y);204204+205205+ if (report_undeciphered)206206+ input_event(input, EV_MSC, MSC_RAW, tdata[7]);207207+208208+ input_mt_sync(input);209209+ }210210+}211211+212212+static int magicmouse_raw_event(struct hid_device *hdev,213213+ struct hid_report *report, u8 *data, int size)214214+{215215+ struct magicmouse_sc *msc = hid_get_drvdata(hdev);216216+ struct input_dev *input = msc->input;217217+ int x, y, ts, ii, clicks;218218+219219+ switch (data[0]) {220220+ case 0x10:221221+ if (size != 6)222222+ return 0;223223+ x = (__s16)(data[2] | data[3] << 8);224224+ y = (__s16)(data[4] | data[5] << 8);225225+ clicks = data[1];226226+ break;227227+ case TOUCH_REPORT_ID:228228+ /* Expect six bytes of prefix, and N*8 bytes of touch data. */229229+ if (size < 6 || ((size - 6) % 8) != 0)230230+ return 0;231231+ ts = data[3] >> 6 | data[4] << 2 | data[5] << 10;232232+ msc->delta_time = (ts - msc->last_timestamp) & 0x3ffff;233233+ msc->last_timestamp = ts;234234+ msc->ntouches = (size - 6) / 8;235235+ for (ii = 0; ii < msc->ntouches; ii++)236236+ magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);237237+ /* When emulating three-button mode, it is important238238+ * to have the current touch information before239239+ * generating a click event.240240+ */241241+ x = (signed char)data[1];242242+ y = (signed char)data[2];243243+ clicks = data[3];244244+ break;245245+ case 0x20: /* Theoretically battery status (0-100), but I have246246+ * never seen it -- maybe it is only upon request.247247+ */248248+ case 0x60: /* Unknown, maybe laser on/off. */249249+ case 0x61: /* Laser reflection status change.250250+ * data[1]: 0 = spotted, 1 = lost251251+ */252252+ default:253253+ return 0;254254+ }255255+256256+ magicmouse_emit_buttons(msc, clicks & 3);257257+ input_report_rel(input, REL_X, x);258258+ input_report_rel(input, REL_Y, y);259259+ input_sync(input);260260+ return 1;261261+}262262+263263+static int magicmouse_input_open(struct input_dev *dev)264264+{265265+ struct hid_device *hid = input_get_drvdata(dev);266266+267267+ return hid->ll_driver->open(hid);268268+}269269+270270+static void magicmouse_input_close(struct input_dev *dev)271271+{272272+ struct hid_device *hid = input_get_drvdata(dev);273273+274274+ hid->ll_driver->close(hid);275275+}276276+277277+static void magicmouse_setup_input(struct input_dev *input, struct hid_device *hdev)278278+{279279+ input_set_drvdata(input, hdev);280280+ input->event = hdev->ll_driver->hidinput_input_event;281281+ input->open = magicmouse_input_open;282282+ input->close = magicmouse_input_close;283283+284284+ input->name = hdev->name;285285+ input->phys = hdev->phys;286286+ input->uniq = hdev->uniq;287287+ input->id.bustype = hdev->bus;288288+ input->id.vendor = hdev->vendor;289289+ input->id.product = hdev->product;290290+ input->id.version = hdev->version;291291+ input->dev.parent = hdev->dev.parent;292292+293293+ __set_bit(EV_KEY, input->evbit);294294+ __set_bit(BTN_LEFT, input->keybit);295295+ __set_bit(BTN_RIGHT, input->keybit);296296+ if (emulate_3button)297297+ __set_bit(BTN_MIDDLE, input->keybit);298298+ __set_bit(BTN_TOOL_FINGER, input->keybit);299299+300300+ __set_bit(EV_REL, input->evbit);301301+ __set_bit(REL_X, input->relbit);302302+ __set_bit(REL_Y, input->relbit);303303+ if (emulate_scroll_wheel)304304+ __set_bit(REL_WHEEL, input->relbit);305305+306306+ if (report_touches) {307307+ __set_bit(EV_ABS, input->evbit);308308+309309+ input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, 15, 0, 0);310310+ input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 4, 0);311311+ input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255, 4, 0);312312+ input_set_abs_params(input, ABS_MT_ORIENTATION, -32, 31, 1, 0);313313+ input_set_abs_params(input, ABS_MT_POSITION_X, -1100, 1358,314314+ 4, 0);315315+ /* Note: Touch Y position from the device is inverted relative316316+ * to how pointer motion is reported (and relative to how USB317317+ * HID recommends the coordinates work). This driver keeps318318+ * the origin at the same position, and just uses the additive319319+ * inverse of the reported Y.320320+ */321321+ input_set_abs_params(input, ABS_MT_POSITION_Y, -1589, 2047,322322+ 4, 0);323323+ }324324+325325+ if (report_undeciphered) {326326+ __set_bit(EV_MSC, input->evbit);327327+ __set_bit(MSC_RAW, input->mscbit);328328+ }329329+}330330+331331+static int magicmouse_probe(struct hid_device *hdev,332332+ const struct hid_device_id *id)333333+{334334+ __u8 feature_1[] = { 0xd7, 0x01 };335335+ __u8 feature_2[] = { 0xf8, 0x01, 0x32 };336336+ struct input_dev *input;337337+ struct magicmouse_sc *msc;338338+ struct hid_report *report;339339+ int ret;340340+341341+ msc = kzalloc(sizeof(*msc), GFP_KERNEL);342342+ if (msc == NULL) {343343+ dev_err(&hdev->dev, "can't alloc magicmouse descriptor\n");344344+ return -ENOMEM;345345+ }346346+347347+ msc->quirks = id->driver_data;348348+ hid_set_drvdata(hdev, msc);349349+350350+ ret = hid_parse(hdev);351351+ if (ret) {352352+ dev_err(&hdev->dev, "magicmouse hid parse failed\n");353353+ goto err_free;354354+ }355355+356356+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);357357+ if (ret) {358358+ dev_err(&hdev->dev, "magicmouse hw start failed\n");359359+ goto err_free;360360+ }361361+362362+ report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);363363+ if (!report) {364364+ dev_err(&hdev->dev, "unable to register touch report\n");365365+ ret = -ENOMEM;366366+ goto err_stop_hw;367367+ }368368+ report->size = 6;369369+370370+ ret = hdev->hid_output_raw_report(hdev, feature_1, sizeof(feature_1),371371+ HID_FEATURE_REPORT);372372+ if (ret != sizeof(feature_1)) {373373+ dev_err(&hdev->dev, "unable to request touch data (1:%d)\n",374374+ ret);375375+ goto err_stop_hw;376376+ }377377+ ret = hdev->hid_output_raw_report(hdev, feature_2,378378+ sizeof(feature_2), HID_FEATURE_REPORT);379379+ if (ret != sizeof(feature_2)) {380380+ dev_err(&hdev->dev, "unable to request touch data (2:%d)\n",381381+ ret);382382+ goto err_stop_hw;383383+ }384384+385385+ input = input_allocate_device();386386+ if (!input) {387387+ dev_err(&hdev->dev, "can't alloc input device\n");388388+ ret = -ENOMEM;389389+ goto err_stop_hw;390390+ }391391+ magicmouse_setup_input(input, hdev);392392+393393+ ret = input_register_device(input);394394+ if (ret) {395395+ dev_err(&hdev->dev, "input device registration failed\n");396396+ goto err_input;397397+ }398398+ msc->input = input;399399+400400+ return 0;401401+err_input:402402+ input_free_device(input);403403+err_stop_hw:404404+ hid_hw_stop(hdev);405405+err_free:406406+ kfree(msc);407407+ return ret;408408+}409409+410410+static void magicmouse_remove(struct hid_device *hdev)411411+{412412+ hid_hw_stop(hdev);413413+ kfree(hid_get_drvdata(hdev));414414+}415415+416416+static const struct hid_device_id magic_mice[] = {417417+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE),418418+ .driver_data = 0 },419419+ { }420420+};421421+MODULE_DEVICE_TABLE(hid, magic_mice);422422+423423+static struct hid_driver magicmouse_driver = {424424+ .name = "magicmouse",425425+ .id_table = magic_mice,426426+ .probe = magicmouse_probe,427427+ .remove = magicmouse_remove,428428+ .raw_event = magicmouse_raw_event,429429+};430430+431431+static int __init magicmouse_init(void)432432+{433433+ int ret;434434+435435+ ret = hid_register_driver(&magicmouse_driver);436436+ if (ret)437437+ printk(KERN_ERR "can't register magicmouse driver\n");438438+439439+ return ret;440440+}441441+442442+static void __exit magicmouse_exit(void)443443+{444444+ hid_unregister_driver(&magicmouse_driver);445445+}446446+447447+module_init(magicmouse_init);448448+module_exit(magicmouse_exit);449449+MODULE_LICENSE("GPL");
+273
drivers/hid/hid-mosart.c
···11+/*22+ * HID driver for the multitouch panel on the ASUS EeePC T91MT33+ *44+ * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>55+ * Copyright (c) 2010 Teemu Tuominen <teemu.tuominen@cybercom.com>66+ *77+ */88+99+/*1010+ * This program is free software; you can redistribute it and/or modify it1111+ * under the terms of the GNU General Public License as published by the Free1212+ * Software Foundation; either version 2 of the License, or (at your option)1313+ * any later version.1414+ */1515+1616+#include <linux/device.h>1717+#include <linux/hid.h>1818+#include <linux/module.h>1919+#include <linux/usb.h>2020+#include "usbhid/usbhid.h"2121+2222+MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");2323+MODULE_DESCRIPTION("MosArt dual-touch panel");2424+MODULE_LICENSE("GPL");2525+2626+#include "hid-ids.h"2727+2828+struct mosart_data {2929+ __u16 x, y;3030+ __u8 id;3131+ bool valid; /* valid finger data, or just placeholder? */3232+ bool first; /* is this the first finger in this frame? */3333+ bool activity_now; /* at least one active finger in this frame? */3434+ bool activity; /* at least one active finger previously? */3535+};3636+3737+static int mosart_input_mapping(struct hid_device *hdev, struct hid_input *hi,3838+ struct hid_field *field, struct hid_usage *usage,3939+ unsigned long **bit, int *max)4040+{4141+ switch (usage->hid & HID_USAGE_PAGE) {4242+4343+ case HID_UP_GENDESK:4444+ switch (usage->hid) {4545+ case HID_GD_X:4646+ hid_map_usage(hi, usage, bit, max,4747+ EV_ABS, ABS_MT_POSITION_X);4848+ /* touchscreen emulation */4949+ input_set_abs_params(hi->input, ABS_X,5050+ field->logical_minimum,5151+ field->logical_maximum, 0, 0);5252+ return 1;5353+ case HID_GD_Y:5454+ hid_map_usage(hi, usage, bit, max,5555+ EV_ABS, ABS_MT_POSITION_Y);5656+ /* touchscreen emulation */5757+ input_set_abs_params(hi->input, ABS_Y,5858+ field->logical_minimum,5959+ field->logical_maximum, 0, 0);6060+ return 1;6161+ }6262+ return 0;6363+6464+ case HID_UP_DIGITIZER:6565+ switch (usage->hid) {6666+ case HID_DG_CONFIDENCE:6767+ case HID_DG_TIPSWITCH:6868+ case HID_DG_INPUTMODE:6969+ case HID_DG_DEVICEINDEX:7070+ case HID_DG_CONTACTCOUNT:7171+ case HID_DG_CONTACTMAX:7272+ case HID_DG_TIPPRESSURE:7373+ case HID_DG_WIDTH:7474+ case HID_DG_HEIGHT:7575+ return -1;7676+ case HID_DG_INRANGE:7777+ /* touchscreen emulation */7878+ hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);7979+ return 1;8080+8181+ case HID_DG_CONTACTID:8282+ hid_map_usage(hi, usage, bit, max,8383+ EV_ABS, ABS_MT_TRACKING_ID);8484+ return 1;8585+8686+ }8787+ return 0;8888+8989+ case 0xff000000:9090+ /* ignore HID features */9191+ return -1;9292+ }9393+9494+ return 0;9595+}9696+9797+static int mosart_input_mapped(struct hid_device *hdev, struct hid_input *hi,9898+ struct hid_field *field, struct hid_usage *usage,9999+ unsigned long **bit, int *max)100100+{101101+ if (usage->type == EV_KEY || usage->type == EV_ABS)102102+ clear_bit(usage->code, *bit);103103+104104+ return 0;105105+}106106+107107+/*108108+ * this function is called when a whole finger has been parsed,109109+ * so that it can decide what to send to the input layer.110110+ */111111+static void mosart_filter_event(struct mosart_data *td, struct input_dev *input)112112+{113113+ td->first = !td->first; /* touchscreen emulation */114114+115115+ if (!td->valid) {116116+ /*117117+ * touchscreen emulation: if no finger in this frame is valid118118+ * and there previously was finger activity, this is a release119119+ */ 120120+ if (!td->first && !td->activity_now && td->activity) {121121+ input_event(input, EV_KEY, BTN_TOUCH, 0);122122+ td->activity = false;123123+ }124124+ return;125125+ }126126+127127+ input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);128128+ input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);129129+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);130130+131131+ input_mt_sync(input);132132+ td->valid = false;133133+134134+ /* touchscreen emulation: if first active finger in this frame... */135135+ if (!td->activity_now) {136136+ /* if there was no previous activity, emit touch event */137137+ if (!td->activity) {138138+ input_event(input, EV_KEY, BTN_TOUCH, 1);139139+ td->activity = true;140140+ }141141+ td->activity_now = true;142142+ /* and in any case this is our preferred finger */143143+ input_event(input, EV_ABS, ABS_X, td->x);144144+ input_event(input, EV_ABS, ABS_Y, td->y);145145+ }146146+}147147+148148+149149+static int mosart_event(struct hid_device *hid, struct hid_field *field,150150+ struct hid_usage *usage, __s32 value)151151+{152152+ struct mosart_data *td = hid_get_drvdata(hid);153153+154154+ if (hid->claimed & HID_CLAIMED_INPUT) {155155+ struct input_dev *input = field->hidinput->input;156156+ switch (usage->hid) {157157+ case HID_DG_INRANGE:158158+ td->valid = !!value;159159+ break;160160+ case HID_GD_X:161161+ td->x = value;162162+ break;163163+ case HID_GD_Y:164164+ td->y = value;165165+ mosart_filter_event(td, input);166166+ break;167167+ case HID_DG_CONTACTID:168168+ td->id = value;169169+ break;170170+ case HID_DG_CONTACTCOUNT:171171+ /* touch emulation: this is the last field in a frame */172172+ td->first = false;173173+ td->activity_now = false;174174+ break;175175+ case HID_DG_CONFIDENCE:176176+ case HID_DG_TIPSWITCH:177177+ /* avoid interference from generic hidinput handling */178178+ break;179179+180180+ default:181181+ /* fallback to the generic hidinput handling */182182+ return 0;183183+ }184184+ }185185+186186+ /* we have handled the hidinput part, now remains hiddev */187187+ if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)188188+ hid->hiddev_hid_event(hid, field, usage, value);189189+190190+ return 1;191191+}192192+193193+static int mosart_probe(struct hid_device *hdev, const struct hid_device_id *id)194194+{195195+ int ret;196196+ struct mosart_data *td;197197+198198+199199+ td = kmalloc(sizeof(struct mosart_data), GFP_KERNEL);200200+ if (!td) {201201+ dev_err(&hdev->dev, "cannot allocate MosArt data\n");202202+ return -ENOMEM;203203+ }204204+ td->valid = false;205205+ td->activity = false;206206+ td->activity_now = false;207207+ td->first = false;208208+ hid_set_drvdata(hdev, td);209209+210210+ /* currently, it's better to have one evdev device only */211211+#if 0212212+ hdev->quirks |= HID_QUIRK_MULTI_INPUT;213213+#endif214214+215215+ ret = hid_parse(hdev);216216+ if (ret == 0)217217+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);218218+219219+ if (ret == 0) {220220+ struct hid_report_enum *re = hdev->report_enum221221+ + HID_FEATURE_REPORT;222222+ struct hid_report *r = re->report_id_hash[7];223223+224224+ r->field[0]->value[0] = 0x02;225225+ usbhid_submit_report(hdev, r, USB_DIR_OUT);226226+ } else 227227+ kfree(td);228228+229229+ return ret;230230+}231231+232232+static void mosart_remove(struct hid_device *hdev)233233+{234234+ hid_hw_stop(hdev);235235+ kfree(hid_get_drvdata(hdev));236236+ hid_set_drvdata(hdev, NULL);237237+}238238+239239+static const struct hid_device_id mosart_devices[] = {240240+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },241241+ { }242242+};243243+MODULE_DEVICE_TABLE(hid, mosart_devices);244244+245245+static const struct hid_usage_id mosart_grabbed_usages[] = {246246+ { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },247247+ { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}248248+};249249+250250+static struct hid_driver mosart_driver = {251251+ .name = "mosart",252252+ .id_table = mosart_devices,253253+ .probe = mosart_probe,254254+ .remove = mosart_remove,255255+ .input_mapping = mosart_input_mapping,256256+ .input_mapped = mosart_input_mapped,257257+ .usage_table = mosart_grabbed_usages,258258+ .event = mosart_event,259259+};260260+261261+static int __init mosart_init(void)262262+{263263+ return hid_register_driver(&mosart_driver);264264+}265265+266266+static void __exit mosart_exit(void)267267+{268268+ hid_unregister_driver(&mosart_driver);269269+}270270+271271+module_init(mosart_init);272272+module_exit(mosart_exit);273273+
+147-65
drivers/hid/hid-ntrig.c
···2525 EV_KEY, (c))26262727struct ntrig_data {2828- __s32 x, y, id, w, h;2929- char reading_a_point, found_contact_id;3030- char pen_active;3131- char finger_active;3232- char inverted;2828+ /* Incoming raw values for a single contact */2929+ __u16 x, y, w, h;3030+ __u16 id;3131+ __u8 confidence;3232+3333+ bool reading_mt;3434+ __u8 first_contact_confidence;3535+3636+ __u8 mt_footer[4];3737+ __u8 mt_foot_count;3338};34393540/*···4742 struct hid_field *field, struct hid_usage *usage,4843 unsigned long **bit, int *max)4944{5050- switch (usage->hid & HID_USAGE_PAGE) {4545+ /* No special mappings needed for the pen and single touch */4646+ if (field->physical)4747+ return 0;51484949+ switch (usage->hid & HID_USAGE_PAGE) {5250 case HID_UP_GENDESK:5351 switch (usage->hid) {5452 case HID_GD_X:···7466 case HID_UP_DIGITIZER:7567 switch (usage->hid) {7668 /* we do not want to map these for now */7777- case HID_DG_CONTACTID: /* value is useless */6969+ case HID_DG_CONTACTID: /* Not trustworthy, squelch for now */7870 case HID_DG_INPUTMODE:7971 case HID_DG_DEVICEINDEX:8080- case HID_DG_CONTACTCOUNT:8172 case HID_DG_CONTACTMAX:8273 return -1;8383-8484- /* original mapping by Rafi Rubin */8585- case HID_DG_CONFIDENCE:8686- nt_map_key_clear(BTN_TOOL_DOUBLETAP);8787- return 1;88748975 /* width/height mapped on TouchMajor/TouchMinor/Orientation */9076 case HID_DG_WIDTH:···106104 struct hid_field *field, struct hid_usage *usage,107105 unsigned long **bit, int *max)108106{107107+ /* No special mappings needed for the pen and single touch */108108+ if (field->physical)109109+ return 0;110110+109111 if (usage->type == EV_KEY || usage->type == EV_REL110112 || usage->type == EV_ABS)111113 clear_bit(usage->code, *bit);···129123 struct input_dev *input = field->hidinput->input;130124 struct ntrig_data *nd = hid_get_drvdata(hid);131125126126+ /* No special handling needed for the pen */127127+ if (field->application == HID_DG_PEN)128128+ return 0;129129+132130 if (hid->claimed & HID_CLAIMED_INPUT) {133131 switch (usage->hid) {134134-135135- case HID_DG_INRANGE:136136- if (field->application & 0x3)137137- nd->pen_active = (value != 0);138138- else139139- nd->finger_active = (value != 0);140140- return 0;141141-142142- case HID_DG_INVERT:143143- nd->inverted = value;144144- return 0;145145-132132+ case 0xff000001:133133+ /* Tag indicating the start of a multitouch group */134134+ nd->reading_mt = 1;135135+ nd->first_contact_confidence = 0;136136+ break;137137+ case HID_DG_CONFIDENCE:138138+ nd->confidence = value;139139+ break;146140 case HID_GD_X:147141 nd->x = value;148148- nd->reading_a_point = 1;142142+ /* Clear the contact footer */143143+ nd->mt_foot_count = 0;149144 break;150145 case HID_GD_Y:151146 nd->y = value;152147 break;153148 case HID_DG_CONTACTID:154149 nd->id = value;155155- /* we receive this only when in multitouch mode */156156- nd->found_contact_id = 1;157150 break;158151 case HID_DG_WIDTH:159152 nd->w = value;···164159 * report received in a finger event. We want165160 * to emit a normal (X, Y) position166161 */167167- if (!nd->found_contact_id) {168168- if (nd->pen_active && nd->finger_active) {169169- input_report_key(input, BTN_TOOL_DOUBLETAP, 0);170170- input_report_key(input, BTN_TOOL_DOUBLETAP, 1);171171- }162162+ if (!nd->reading_mt) {163163+ input_report_key(input, BTN_TOOL_DOUBLETAP,164164+ (nd->confidence != 0));172165 input_event(input, EV_ABS, ABS_X, nd->x);173166 input_event(input, EV_ABS, ABS_Y, nd->y);174174- }175175- break;176176- case HID_DG_TIPPRESSURE:177177- /*178178- * when in single touch mode, this is the last179179- * report received in a pen event. We want180180- * to emit a normal (X, Y) position181181- */182182- if (! nd->found_contact_id) {183183- if (nd->pen_active && nd->finger_active) {184184- input_report_key(input,185185- nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN186186- , 0);187187- input_report_key(input,188188- nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN189189- , 1);190190- }191191- input_event(input, EV_ABS, ABS_X, nd->x);192192- input_event(input, EV_ABS, ABS_Y, nd->y);193193- input_event(input, EV_ABS, ABS_PRESSURE, value);194167 }195168 break;196169 case 0xff000002:···178195 * this usage tells if the contact point is real179196 * or a placeholder180197 */181181- if (!nd->reading_a_point || value != 1)198198+199199+ /* Shouldn't get more than 4 footer packets, so skip */200200+ if (nd->mt_foot_count >= 4)182201 break;202202+203203+ nd->mt_footer[nd->mt_foot_count++] = value;204204+205205+ /* if the footer isn't complete break */206206+ if (nd->mt_foot_count != 4)207207+ break;208208+209209+ /* Pen activity signal, trigger end of touch. */210210+ if (nd->mt_footer[2]) {211211+ nd->confidence = 0;212212+ break;213213+ }214214+215215+ /* If the contact was invalid */216216+ if (!(nd->confidence && nd->mt_footer[0])217217+ || nd->w <= 250218218+ || nd->h <= 190) {219219+ nd->confidence = 0;220220+ break;221221+ }222222+183223 /* emit a normal (X, Y) for the first point only */184224 if (nd->id == 0) {225225+ nd->first_contact_confidence = nd->confidence;185226 input_event(input, EV_ABS, ABS_X, nd->x);186227 input_event(input, EV_ABS, ABS_Y, nd->y);187228 }···227220 ABS_MT_TOUCH_MINOR, nd->w);228221 }229222 input_mt_sync(field->hidinput->input);230230- nd->reading_a_point = 0;231231- nd->found_contact_id = 0;223223+ break;224224+225225+ case HID_DG_CONTACTCOUNT: /* End of a multitouch group */226226+ if (!nd->reading_mt)227227+ break;228228+229229+ nd->reading_mt = 0;230230+231231+ if (nd->first_contact_confidence) {232232+ switch (value) {233233+ case 0: /* for single touch devices */234234+ case 1:235235+ input_report_key(input,236236+ BTN_TOOL_DOUBLETAP, 1);237237+ break;238238+ case 2:239239+ input_report_key(input,240240+ BTN_TOOL_TRIPLETAP, 1);241241+ break;242242+ case 3:243243+ default:244244+ input_report_key(input,245245+ BTN_TOOL_QUADTAP, 1);246246+ }247247+ input_report_key(input, BTN_TOUCH, 1);248248+ } else {249249+ input_report_key(input,250250+ BTN_TOOL_DOUBLETAP, 0);251251+ input_report_key(input,252252+ BTN_TOOL_TRIPLETAP, 0);253253+ input_report_key(input,254254+ BTN_TOOL_QUADTAP, 0);255255+ }232256 break;233257234258 default:···269231 }270232271233 /* we have handled the hidinput part, now remains hiddev */272272- if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)273273- hid->hiddev_hid_event(hid, field, usage, value);234234+ if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event)235235+ hid->hiddev_hid_event(hid, field, usage, value);274236275237 return 1;276238}···279241{280242 int ret;281243 struct ntrig_data *nd;244244+ struct hid_input *hidinput;245245+ struct input_dev *input;246246+247247+ if (id->driver_data)248248+ hdev->quirks |= HID_QUIRK_MULTI_INPUT;282249283250 nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL);284251 if (!nd) {285252 dev_err(&hdev->dev, "cannot allocate N-Trig data\n");286253 return -ENOMEM;287254 }288288- nd->reading_a_point = 0;289289- nd->found_contact_id = 0;255255+256256+ nd->reading_mt = 0;290257 hid_set_drvdata(hdev, nd);291258292259 ret = hid_parse(hdev);293293- if (!ret)294294- ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);260260+ if (ret) {261261+ dev_err(&hdev->dev, "parse failed\n");262262+ goto err_free;263263+ }295264296296- if (ret)297297- kfree (nd);265265+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);266266+ if (ret) {267267+ dev_err(&hdev->dev, "hw start failed\n");268268+ goto err_free;269269+ }298270271271+272272+ list_for_each_entry(hidinput, &hdev->inputs, list) {273273+ input = hidinput->input;274274+ switch (hidinput->report->field[0]->application) {275275+ case HID_DG_PEN:276276+ input->name = "N-Trig Pen";277277+ break;278278+ case HID_DG_TOUCHSCREEN:279279+ __clear_bit(BTN_TOOL_PEN, input->keybit);280280+ /*281281+ * A little something special to enable282282+ * two and three finger taps.283283+ */284284+ __set_bit(BTN_TOOL_DOUBLETAP, input->keybit);285285+ __set_bit(BTN_TOOL_TRIPLETAP, input->keybit);286286+ __set_bit(BTN_TOOL_QUADTAP, input->keybit);287287+ /*288288+ * The physical touchscreen (single touch)289289+ * input has a value for physical, whereas290290+ * the multitouch only has logical input291291+ * fields.292292+ */293293+ input->name =294294+ (hidinput->report->field[0]295295+ ->physical) ?296296+ "N-Trig Touchscreen" :297297+ "N-Trig MultiTouch";298298+ break;299299+ }300300+ }301301+302302+ return 0;303303+err_free:304304+ kfree(nd);299305 return ret;300306}301307···358276359277static const struct hid_usage_id ntrig_grabbed_usages[] = {360278 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },361361- { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}279279+ { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1 }362280};363281364282static struct hid_driver ntrig_driver = {
+56
drivers/hid/hid-ortek.c
···11+/*22+ * HID driver for Ortek WKB-2000 (wireless keyboard + mouse trackpad).33+ * Fixes LogicalMaximum error in USB report description, see44+ * http://bugzilla.kernel.org/show_bug.cgi?id=1478755+ *66+ * Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>77+ */88+99+/*1010+ * This program is free software; you can redistribute it and/or modify it1111+ * under the terms of the GNU General Public License as published by the Free1212+ * Software Foundation; either version 2 of the License, or (at your option)1313+ * any later version.1414+ */1515+1616+#include <linux/device.h>1717+#include <linux/hid.h>1818+#include <linux/module.h>1919+2020+#include "hid-ids.h"2121+2222+static void ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc,2323+ unsigned int rsize)2424+{2525+ if (rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) {2626+ dev_info(&hdev->dev, "Fixing up Ortek WKB-2000 "2727+ "report descriptor.\n");2828+ rdesc[55] = 0x92;2929+ }3030+}3131+3232+static const struct hid_device_id ortek_devices[] = {3333+ { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },3434+ { }3535+};3636+MODULE_DEVICE_TABLE(hid, ortek_devices);3737+3838+static struct hid_driver ortek_driver = {3939+ .name = "ortek",4040+ .id_table = ortek_devices,4141+ .report_fixup = ortek_report_fixup4242+};4343+4444+static int __init ortek_init(void)4545+{4646+ return hid_register_driver(&ortek_driver);4747+}4848+4949+static void __exit ortek_exit(void)5050+{5151+ hid_unregister_driver(&ortek_driver);5252+}5353+5454+module_init(ortek_init);5555+module_exit(ortek_exit);5656+MODULE_LICENSE("GPL");
+260
drivers/hid/hid-quanta.c
···11+/*22+ * HID driver for Quanta Optical Touch dual-touch panels33+ *44+ * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>55+ *66+ */77+88+/*99+ * This program is free software; you can redistribute it and/or modify it1010+ * under the terms of the GNU General Public License as published by the Free1111+ * Software Foundation; either version 2 of the License, or (at your option)1212+ * any later version.1313+ */1414+1515+#include <linux/device.h>1616+#include <linux/hid.h>1717+#include <linux/module.h>1818+1919+MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");2020+MODULE_DESCRIPTION("Quanta dual-touch panel");2121+MODULE_LICENSE("GPL");2222+2323+#include "hid-ids.h"2424+2525+struct quanta_data {2626+ __u16 x, y;2727+ __u8 id;2828+ bool valid; /* valid finger data, or just placeholder? */2929+ bool first; /* is this the first finger in this frame? */3030+ bool activity_now; /* at least one active finger in this frame? */3131+ bool activity; /* at least one active finger previously? */3232+};3333+3434+static int quanta_input_mapping(struct hid_device *hdev, struct hid_input *hi,3535+ struct hid_field *field, struct hid_usage *usage,3636+ unsigned long **bit, int *max)3737+{3838+ switch (usage->hid & HID_USAGE_PAGE) {3939+4040+ case HID_UP_GENDESK:4141+ switch (usage->hid) {4242+ case HID_GD_X:4343+ hid_map_usage(hi, usage, bit, max,4444+ EV_ABS, ABS_MT_POSITION_X);4545+ /* touchscreen emulation */4646+ input_set_abs_params(hi->input, ABS_X,4747+ field->logical_minimum,4848+ field->logical_maximum, 0, 0);4949+ return 1;5050+ case HID_GD_Y:5151+ hid_map_usage(hi, usage, bit, max,5252+ EV_ABS, ABS_MT_POSITION_Y);5353+ /* touchscreen emulation */5454+ input_set_abs_params(hi->input, ABS_Y,5555+ field->logical_minimum,5656+ field->logical_maximum, 0, 0);5757+ return 1;5858+ }5959+ return 0;6060+6161+ case HID_UP_DIGITIZER:6262+ switch (usage->hid) {6363+ case HID_DG_CONFIDENCE:6464+ case HID_DG_TIPSWITCH:6565+ case HID_DG_INPUTMODE:6666+ case HID_DG_DEVICEINDEX:6767+ case HID_DG_CONTACTCOUNT:6868+ case HID_DG_CONTACTMAX:6969+ case HID_DG_TIPPRESSURE:7070+ case HID_DG_WIDTH:7171+ case HID_DG_HEIGHT:7272+ return -1;7373+ case HID_DG_INRANGE:7474+ /* touchscreen emulation */7575+ hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);7676+ return 1;7777+ case HID_DG_CONTACTID:7878+ hid_map_usage(hi, usage, bit, max,7979+ EV_ABS, ABS_MT_TRACKING_ID);8080+ return 1;8181+ }8282+ return 0;8383+8484+ case 0xff000000:8585+ /* ignore vendor-specific features */8686+ return -1;8787+ }8888+8989+ return 0;9090+}9191+9292+static int quanta_input_mapped(struct hid_device *hdev, struct hid_input *hi,9393+ struct hid_field *field, struct hid_usage *usage,9494+ unsigned long **bit, int *max)9595+{9696+ if (usage->type == EV_KEY || usage->type == EV_ABS)9797+ clear_bit(usage->code, *bit);9898+9999+ return 0;100100+}101101+102102+/*103103+ * this function is called when a whole finger has been parsed,104104+ * so that it can decide what to send to the input layer.105105+ */106106+static void quanta_filter_event(struct quanta_data *td, struct input_dev *input)107107+{108108+109109+ td->first = !td->first; /* touchscreen emulation */110110+111111+ if (!td->valid) {112112+ /*113113+ * touchscreen emulation: if no finger in this frame is valid114114+ * and there previously was finger activity, this is a release115115+ */ 116116+ if (!td->first && !td->activity_now && td->activity) {117117+ input_event(input, EV_KEY, BTN_TOUCH, 0);118118+ td->activity = false;119119+ }120120+ return;121121+ }122122+123123+ input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);124124+ input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);125125+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);126126+127127+ input_mt_sync(input);128128+ td->valid = false;129129+130130+ /* touchscreen emulation: if first active finger in this frame... */131131+ if (!td->activity_now) {132132+ /* if there was no previous activity, emit touch event */133133+ if (!td->activity) {134134+ input_event(input, EV_KEY, BTN_TOUCH, 1);135135+ td->activity = true;136136+ }137137+ td->activity_now = true;138138+ /* and in any case this is our preferred finger */139139+ input_event(input, EV_ABS, ABS_X, td->x);140140+ input_event(input, EV_ABS, ABS_Y, td->y);141141+ }142142+}143143+144144+145145+static int quanta_event(struct hid_device *hid, struct hid_field *field,146146+ struct hid_usage *usage, __s32 value)147147+{148148+ struct quanta_data *td = hid_get_drvdata(hid);149149+150150+ if (hid->claimed & HID_CLAIMED_INPUT) {151151+ struct input_dev *input = field->hidinput->input;152152+153153+ switch (usage->hid) {154154+ case HID_DG_INRANGE:155155+ td->valid = !!value;156156+ break;157157+ case HID_GD_X:158158+ td->x = value;159159+ break;160160+ case HID_GD_Y:161161+ td->y = value;162162+ quanta_filter_event(td, input);163163+ break;164164+ case HID_DG_CONTACTID:165165+ td->id = value;166166+ break;167167+ case HID_DG_CONTACTCOUNT:168168+ /* touch emulation: this is the last field in a frame */169169+ td->first = false;170170+ td->activity_now = false;171171+ break;172172+ case HID_DG_CONFIDENCE:173173+ case HID_DG_TIPSWITCH:174174+ /* avoid interference from generic hidinput handling */175175+ break;176176+177177+ default:178178+ /* fallback to the generic hidinput handling */179179+ return 0;180180+ }181181+ }182182+183183+ /* we have handled the hidinput part, now remains hiddev */184184+ if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)185185+ hid->hiddev_hid_event(hid, field, usage, value);186186+187187+ return 1;188188+}189189+190190+static int quanta_probe(struct hid_device *hdev, const struct hid_device_id *id)191191+{192192+ int ret;193193+ struct quanta_data *td;194194+195195+ td = kmalloc(sizeof(struct quanta_data), GFP_KERNEL);196196+ if (!td) {197197+ dev_err(&hdev->dev, "cannot allocate Quanta Touch data\n");198198+ return -ENOMEM;199199+ }200200+ td->valid = false;201201+ td->activity = false;202202+ td->activity_now = false;203203+ td->first = false;204204+ hid_set_drvdata(hdev, td);205205+206206+ ret = hid_parse(hdev);207207+ if (!ret)208208+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);209209+210210+ if (ret)211211+ kfree(td);212212+213213+ return ret;214214+}215215+216216+static void quanta_remove(struct hid_device *hdev)217217+{218218+ hid_hw_stop(hdev);219219+ kfree(hid_get_drvdata(hdev));220220+ hid_set_drvdata(hdev, NULL);221221+}222222+223223+static const struct hid_device_id quanta_devices[] = {224224+ { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,225225+ USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },226226+ { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,227227+ USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },228228+ { }229229+};230230+MODULE_DEVICE_TABLE(hid, quanta_devices);231231+232232+static const struct hid_usage_id quanta_grabbed_usages[] = {233233+ { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },234234+ { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}235235+};236236+237237+static struct hid_driver quanta_driver = {238238+ .name = "quanta-touch",239239+ .id_table = quanta_devices,240240+ .probe = quanta_probe,241241+ .remove = quanta_remove,242242+ .input_mapping = quanta_input_mapping,243243+ .input_mapped = quanta_input_mapped,244244+ .usage_table = quanta_grabbed_usages,245245+ .event = quanta_event,246246+};247247+248248+static int __init quanta_init(void)249249+{250250+ return hid_register_driver(&quanta_driver);251251+}252252+253253+static void __exit quanta_exit(void)254254+{255255+ hid_unregister_driver(&quanta_driver);256256+}257257+258258+module_init(quanta_init);259259+module_exit(quanta_exit);260260+
+20-3
drivers/hid/hid-sony.c
···4848 * to "operational". Without this, the ps3 controller will not report any4949 * events.5050 */5151-static int sony_set_operational(struct hid_device *hdev)5151+static int sony_set_operational_usb(struct hid_device *hdev)5252{5353 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);5454 struct usb_device *dev = interface_to_usbdev(intf);···7373 return ret;7474}75757676+static int sony_set_operational_bt(struct hid_device *hdev)7777+{7878+ unsigned char buf[] = { 0x53, 0xf4, 0x42, 0x03, 0x00, 0x00 };7979+ return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);8080+}8181+7682static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)7783{7884 int ret;···87818882 sc = kzalloc(sizeof(*sc), GFP_KERNEL);8983 if (sc == NULL) {9090- dev_err(&hdev->dev, "can't alloc apple descriptor\n");8484+ dev_err(&hdev->dev, "can't alloc sony descriptor\n");9185 return -ENOMEM;9286 }9387···107101 goto err_free;108102 }109103110110- ret = sony_set_operational(hdev);104104+ switch (hdev->bus) {105105+ case BUS_USB:106106+ ret = sony_set_operational_usb(hdev);107107+ break;108108+ case BUS_BLUETOOTH:109109+ ret = sony_set_operational_bt(hdev);110110+ break;111111+ default:112112+ ret = 0;113113+ }114114+111115 if (ret < 0)112116 goto err_stop;113117···137121138122static const struct hid_device_id sony_devices[] = {139123 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },124124+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },140125 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),141126 .driver_data = VAIO_RDESC_CONSTANT },142127 { }
+283
drivers/hid/hid-stantum.c
···11+/*22+ * HID driver for Stantum multitouch panels33+ *44+ * Copyright (c) 2009 Stephane Chatty <chatty@enac.fr>55+ *66+ */77+88+/*99+ * This program is free software; you can redistribute it and/or modify it1010+ * under the terms of the GNU General Public License as published by the Free1111+ * Software Foundation; either version 2 of the License, or (at your option)1212+ * any later version.1313+ */1414+1515+#include <linux/device.h>1616+#include <linux/hid.h>1717+#include <linux/module.h>1818+1919+MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");2020+MODULE_DESCRIPTION("Stantum HID multitouch panels");2121+MODULE_LICENSE("GPL");2222+2323+#include "hid-ids.h"2424+2525+struct stantum_data {2626+ __s32 x, y, z, w, h; /* x, y, pressure, width, height */2727+ __u16 id; /* touch id */2828+ bool valid; /* valid finger data, or just placeholder? */2929+ bool first; /* first finger in the HID packet? */3030+ bool activity; /* at least one active finger so far? */3131+};3232+3333+static int stantum_input_mapping(struct hid_device *hdev, struct hid_input *hi,3434+ struct hid_field *field, struct hid_usage *usage,3535+ unsigned long **bit, int *max)3636+{3737+ switch (usage->hid & HID_USAGE_PAGE) {3838+3939+ case HID_UP_GENDESK:4040+ switch (usage->hid) {4141+ case HID_GD_X:4242+ hid_map_usage(hi, usage, bit, max,4343+ EV_ABS, ABS_MT_POSITION_X);4444+ /* touchscreen emulation */4545+ input_set_abs_params(hi->input, ABS_X,4646+ field->logical_minimum,4747+ field->logical_maximum, 0, 0);4848+ return 1;4949+ case HID_GD_Y:5050+ hid_map_usage(hi, usage, bit, max,5151+ EV_ABS, ABS_MT_POSITION_Y);5252+ /* touchscreen emulation */5353+ input_set_abs_params(hi->input, ABS_Y,5454+ field->logical_minimum,5555+ field->logical_maximum, 0, 0);5656+ return 1;5757+ }5858+ return 0;5959+6060+ case HID_UP_DIGITIZER:6161+ switch (usage->hid) {6262+ case HID_DG_INRANGE:6363+ case HID_DG_CONFIDENCE:6464+ case HID_DG_INPUTMODE:6565+ case HID_DG_DEVICEINDEX:6666+ case HID_DG_CONTACTCOUNT:6767+ case HID_DG_CONTACTMAX:6868+ return -1;6969+7070+ case HID_DG_TIPSWITCH:7171+ /* touchscreen emulation */7272+ hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);7373+ return 1;7474+7575+ case HID_DG_WIDTH:7676+ hid_map_usage(hi, usage, bit, max,7777+ EV_ABS, ABS_MT_TOUCH_MAJOR);7878+ return 1;7979+ case HID_DG_HEIGHT:8080+ hid_map_usage(hi, usage, bit, max,8181+ EV_ABS, ABS_MT_TOUCH_MINOR);8282+ input_set_abs_params(hi->input, ABS_MT_ORIENTATION,8383+ 1, 1, 0, 0);8484+ return 1;8585+ case HID_DG_TIPPRESSURE:8686+ hid_map_usage(hi, usage, bit, max,8787+ EV_ABS, ABS_MT_PRESSURE);8888+ return 1;8989+9090+ case HID_DG_CONTACTID:9191+ hid_map_usage(hi, usage, bit, max,9292+ EV_ABS, ABS_MT_TRACKING_ID);9393+ return 1;9494+9595+ }9696+ return 0;9797+9898+ case 0xff000000:9999+ /* no input-oriented meaning */100100+ return -1;101101+ }102102+103103+ return 0;104104+}105105+106106+static int stantum_input_mapped(struct hid_device *hdev, struct hid_input *hi,107107+ struct hid_field *field, struct hid_usage *usage,108108+ unsigned long **bit, int *max)109109+{110110+ if (usage->type == EV_KEY || usage->type == EV_ABS)111111+ clear_bit(usage->code, *bit);112112+113113+ return 0;114114+}115115+116116+/*117117+ * this function is called when a whole finger has been parsed,118118+ * so that it can decide what to send to the input layer.119119+ */120120+static void stantum_filter_event(struct stantum_data *sd,121121+ struct input_dev *input)122122+{123123+ bool wide;124124+125125+ if (!sd->valid) {126126+ /*127127+ * touchscreen emulation: if the first finger is not valid and128128+ * there previously was finger activity, this is a release129129+ */130130+ if (sd->first && sd->activity) {131131+ input_event(input, EV_KEY, BTN_TOUCH, 0);132132+ sd->activity = false;133133+ }134134+ return;135135+ }136136+137137+ input_event(input, EV_ABS, ABS_MT_TRACKING_ID, sd->id);138138+ input_event(input, EV_ABS, ABS_MT_POSITION_X, sd->x);139139+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, sd->y);140140+141141+ wide = (sd->w > sd->h);142142+ input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);143143+ input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, wide ? sd->w : sd->h);144144+ input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, wide ? sd->h : sd->w);145145+146146+ input_event(input, EV_ABS, ABS_MT_PRESSURE, sd->z);147147+148148+ input_mt_sync(input);149149+ sd->valid = false;150150+151151+ /* touchscreen emulation */152152+ if (sd->first) {153153+ if (!sd->activity) {154154+ input_event(input, EV_KEY, BTN_TOUCH, 1);155155+ sd->activity = true;156156+ }157157+ input_event(input, EV_ABS, ABS_X, sd->x);158158+ input_event(input, EV_ABS, ABS_Y, sd->y);159159+ }160160+ sd->first = false;161161+}162162+163163+164164+static int stantum_event(struct hid_device *hid, struct hid_field *field,165165+ struct hid_usage *usage, __s32 value)166166+{167167+ struct stantum_data *sd = hid_get_drvdata(hid);168168+169169+ if (hid->claimed & HID_CLAIMED_INPUT) {170170+ struct input_dev *input = field->hidinput->input;171171+172172+ switch (usage->hid) {173173+ case HID_DG_INRANGE:174174+ /* this is the last field in a finger */175175+ stantum_filter_event(sd, input);176176+ break;177177+ case HID_DG_WIDTH:178178+ sd->w = value;179179+ break;180180+ case HID_DG_HEIGHT:181181+ sd->h = value;182182+ break;183183+ case HID_GD_X:184184+ sd->x = value;185185+ break;186186+ case HID_GD_Y:187187+ sd->y = value;188188+ break;189189+ case HID_DG_TIPPRESSURE:190190+ sd->z = value;191191+ break;192192+ case HID_DG_CONTACTID:193193+ sd->id = value;194194+ break;195195+ case HID_DG_CONFIDENCE:196196+ sd->valid = !!value;197197+ break;198198+ case 0xff000002:199199+ /* this comes only before the first finger */200200+ sd->first = true;201201+ break;202202+203203+ default:204204+ /* ignore the others */205205+ return 1;206206+ }207207+ }208208+209209+ /* we have handled the hidinput part, now remains hiddev */210210+ if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)211211+ hid->hiddev_hid_event(hid, field, usage, value);212212+213213+ return 1;214214+}215215+216216+static int stantum_probe(struct hid_device *hdev,217217+ const struct hid_device_id *id)218218+{219219+ int ret;220220+ struct stantum_data *sd;221221+222222+ sd = kmalloc(sizeof(struct stantum_data), GFP_KERNEL);223223+ if (!sd) {224224+ dev_err(&hdev->dev, "cannot allocate Stantum data\n");225225+ return -ENOMEM;226226+ }227227+ sd->valid = false;228228+ sd->first = false;229229+ sd->activity = false;230230+ hid_set_drvdata(hdev, sd);231231+232232+ ret = hid_parse(hdev);233233+ if (!ret)234234+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);235235+236236+ if (ret)237237+ kfree(sd);238238+239239+ return ret;240240+}241241+242242+static void stantum_remove(struct hid_device *hdev)243243+{244244+ hid_hw_stop(hdev);245245+ kfree(hid_get_drvdata(hdev));246246+ hid_set_drvdata(hdev, NULL);247247+}248248+249249+static const struct hid_device_id stantum_devices[] = {250250+ { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },251251+ { }252252+};253253+MODULE_DEVICE_TABLE(hid, stantum_devices);254254+255255+static const struct hid_usage_id stantum_grabbed_usages[] = {256256+ { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },257257+ { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}258258+};259259+260260+static struct hid_driver stantum_driver = {261261+ .name = "stantum",262262+ .id_table = stantum_devices,263263+ .probe = stantum_probe,264264+ .remove = stantum_remove,265265+ .input_mapping = stantum_input_mapping,266266+ .input_mapped = stantum_input_mapped,267267+ .usage_table = stantum_grabbed_usages,268268+ .event = stantum_event,269269+};270270+271271+static int __init stantum_init(void)272272+{273273+ return hid_register_driver(&stantum_driver);274274+}275275+276276+static void __exit stantum_exit(void)277277+{278278+ hid_unregister_driver(&stantum_driver);279279+}280280+281281+module_init(stantum_init);282282+module_exit(stantum_exit);283283+
+28
drivers/hid/hid-wacom.c
···156156 struct hid_input *hidinput;157157 struct input_dev *input;158158 struct wacom_data *wdata;159159+ char rep_data[2];159160 int ret;161161+ int limit;160162161163 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);162164 if (wdata == NULL) {···168166169167 hid_set_drvdata(hdev, wdata);170168169169+ /* Parse the HID report now */171170 ret = hid_parse(hdev);172171 if (ret) {173172 dev_err(&hdev->dev, "parse failed\n");···180177 dev_err(&hdev->dev, "hw start failed\n");181178 goto err_free;182179 }180180+181181+ /*182182+ * Note that if the raw queries fail, it's not a hard failure and it183183+ * is safe to continue184184+ */185185+186186+ /* Set Wacom mode2 */187187+ rep_data[0] = 0x03; rep_data[1] = 0x00;188188+ limit = 3;189189+ do {190190+ ret = hdev->hid_output_raw_report(hdev, rep_data, 2,191191+ HID_FEATURE_REPORT);192192+ } while (ret < 0 && limit-- > 0);193193+ if (ret < 0)194194+ dev_warn(&hdev->dev, "failed to poke device #1, %d\n", ret);195195+196196+ /* 0x06 - high reporting speed, 0x05 - low speed */197197+ rep_data[0] = 0x06; rep_data[1] = 0x00;198198+ limit = 3;199199+ do {200200+ ret = hdev->hid_output_raw_report(hdev, rep_data, 2,201201+ HID_FEATURE_REPORT);202202+ } while (ret < 0 && limit-- > 0);203203+ if (ret < 0)204204+ dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret);183205184206 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);185207 input = hidinput->input;
+1-1
drivers/hid/hidraw.c
···134134 goto out;135135 }136136137137- ret = dev->hid_output_raw_report(dev, buf, count);137137+ ret = dev->hid_output_raw_report(dev, buf, count, HID_OUTPUT_REPORT);138138out:139139 kfree(buf);140140 return ret;
+33-9
drivers/hid/usbhid/hid-core.c
···55 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>66 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc77 * Copyright (c) 2007-2008 Oliver Neukum88- * Copyright (c) 2006-2009 Jiri Kosina88+ * Copyright (c) 2006-2010 Jiri Kosina99 */10101111/*···316316 err_hid("usb_submit_urb(out) failed");317317 return -1;318318 }319319+ usbhid->last_out = jiffies;319320 } else {320321 /*321322 * queue work to wake up the device.···378377 err_hid("usb_submit_urb(ctrl) failed");379378 return -1;380379 }380380+ usbhid->last_ctrl = jiffies;381381 } else {382382 /*383383 * queue work to wake up the device.···514512 usbhid->out[usbhid->outhead].report = report;515513 usbhid->outhead = head;516514517517- if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl))515515+ if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) {518516 if (hid_submit_out(hid))519517 clear_bit(HID_OUT_RUNNING, &usbhid->iofl);518518+ } else {519519+ /*520520+ * the queue is known to run521521+ * but an earlier request may be stuck522522+ * we may need to time out523523+ * no race because this is called under524524+ * spinlock525525+ */526526+ if (time_after(jiffies, usbhid->last_out + HZ * 5))527527+ usb_unlink_urb(usbhid->urbout);528528+ }520529 return;521530 }522531···548535 usbhid->ctrl[usbhid->ctrlhead].dir = dir;549536 usbhid->ctrlhead = head;550537551551- if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl))538538+ if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) {552539 if (hid_submit_ctrl(hid))553540 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);541541+ } else {542542+ /*543543+ * the queue is known to run544544+ * but an earlier request may be stuck545545+ * we may need to time out546546+ * no race because this is called under547547+ * spinlock548548+ */549549+ if (time_after(jiffies, usbhid->last_ctrl + HZ * 5))550550+ usb_unlink_urb(usbhid->urbctrl);551551+ }554552}555553556554void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)···798774 return 0;799775}800776801801-static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count)777777+static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count,778778+ unsigned char report_type)802779{803780 struct usbhid_device *usbhid = hid->driver_data;804781 struct usb_device *dev = hid_to_usb_dev(hid);···810785 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),811786 HID_REQ_SET_REPORT,812787 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,813813- ((HID_OUTPUT_REPORT + 1) << 8) | *buf,788788+ ((report_type + 1) << 8) | *buf,814789 interface->desc.bInterfaceNumber, buf + 1, count - 1,815790 USB_CTRL_SET_TIMEOUT);816791···10069811007982 spin_lock_init(&usbhid->lock);100898310091009- usbhid->intf = intf;10101010- usbhid->ifnum = interface->desc.bInterfaceNumber;10111011-1012984 usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);1013985 if (!usbhid->urbctrl) {1014986 ret = -ENOMEM;···1176115411771155 hid->driver_data = usbhid;11781156 usbhid->hid = hid;11571157+ usbhid->intf = intf;11581158+ usbhid->ifnum = interface->desc.bInterfaceNumber;1179115911801160 ret = hid_add_device(hid);11811161 if (ret) {···1366134213671343#endif /* CONFIG_PM */1368134413691369-static struct usb_device_id hid_usb_ids [] = {13451345+static const struct usb_device_id hid_usb_ids[] = {13701346 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,13711347 .bInterfaceClass = USB_INTERFACE_CLASS_HID },13721348 { } /* Terminating entry */
···8080 unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */8181 char *ctrlbuf; /* Control buffer */8282 dma_addr_t ctrlbuf_dma; /* Control buffer dma */8383+ unsigned long last_ctrl; /* record of last output for timeouts */83848485 struct urb *urbout; /* Output URB */8586 struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */8687 unsigned char outhead, outtail; /* Output pipe fifo head & tail */8788 char *outbuf; /* Output buffer */8889 dma_addr_t outbuf_dma; /* Output buffer dma */9090+ unsigned long last_out; /* record of last output for timeouts */89919092 spinlock_t lock; /* fifo spinlock */9193 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
+6
drivers/input/input-polldev.c
···100100 struct input_polled_dev *dev = input_get_drvdata(input);101101102102 cancel_delayed_work_sync(&dev->work);103103+ /*104104+ * Clean up work struct to remove references to the workqueue.105105+ * It may be destroyed by the next call. This causes problems106106+ * at next device open-close in case of poll_interval == 0.107107+ */108108+ INIT_DELAYED_WORK(&dev->work, dev->work.work.func);103109 input_polldev_stop_workqueue();104110105111 if (dev->close)
···150150151151 /* Special case for the old PowerBook since I can't test on it */152152 autosave =153153- machine_is_compatible("AAPL,3400/2400") ||154154- machine_is_compatible("AAPL,3500");153153+ of_machine_is_compatible("AAPL,3400/2400") ||154154+ of_machine_is_compatible("AAPL,3500");155155156156 if (!autosave &&157157 !pmac_has_backlight_type("pmu") &&158158- !machine_is_compatible("AAPL,PowerBook1998") &&159159- !machine_is_compatible("PowerBook1,1"))158158+ !of_machine_is_compatible("AAPL,PowerBook1998") &&159159+ !of_machine_is_compatible("PowerBook1,1"))160160 return;161161162162 snprintf(name, sizeof(name), "pmubl");
···468468 DBG("wf: core loaded\n");469469470470 /* Don't register on old machines that use therm_pm72 for now */471471- if (machine_is_compatible("PowerMac7,2") ||472472- machine_is_compatible("PowerMac7,3") ||473473- machine_is_compatible("RackMac3,1"))471471+ if (of_machine_is_compatible("PowerMac7,2") ||472472+ of_machine_is_compatible("PowerMac7,3") ||473473+ of_machine_is_compatible("RackMac3,1"))474474 return -ENODEV;475475 platform_device_register(&wf_platform_device);476476 return 0;
+3-3
drivers/macintosh/windfarm_cpufreq_clamp.c
···7676 struct wf_control *clamp;77777878 /* Don't register on old machines that use therm_pm72 for now */7979- if (machine_is_compatible("PowerMac7,2") ||8080- machine_is_compatible("PowerMac7,3") ||8181- machine_is_compatible("RackMac3,1"))7979+ if (of_machine_is_compatible("PowerMac7,2") ||8080+ of_machine_is_compatible("PowerMac7,3") ||8181+ of_machine_is_compatible("RackMac3,1"))8282 return -ENODEV;83838484 clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
+3-3
drivers/macintosh/windfarm_lm75_sensor.c
···239239static int __init wf_lm75_sensor_init(void)240240{241241 /* Don't register on old machines that use therm_pm72 for now */242242- if (machine_is_compatible("PowerMac7,2") ||243243- machine_is_compatible("PowerMac7,3") ||244244- machine_is_compatible("RackMac3,1"))242242+ if (of_machine_is_compatible("PowerMac7,2") ||243243+ of_machine_is_compatible("PowerMac7,3") ||244244+ of_machine_is_compatible("RackMac3,1"))245245 return -ENODEV;246246 return i2c_add_driver(&wf_lm75_driver);247247}
+3-3
drivers/macintosh/windfarm_max6690_sensor.c
···188188static int __init wf_max6690_sensor_init(void)189189{190190 /* Don't register on old machines that use therm_pm72 for now */191191- if (machine_is_compatible("PowerMac7,2") ||192192- machine_is_compatible("PowerMac7,3") ||193193- machine_is_compatible("RackMac3,1"))191191+ if (of_machine_is_compatible("PowerMac7,2") ||192192+ of_machine_is_compatible("PowerMac7,3") ||193193+ of_machine_is_compatible("RackMac3,1"))194194 return -ENODEV;195195 return i2c_add_driver(&wf_max6690_driver);196196}
+1-1
drivers/macintosh/windfarm_pm112.c
···676676{677677 struct device_node *cpu;678678679679- if (!machine_is_compatible("PowerMac11,2"))679679+ if (!of_machine_is_compatible("PowerMac11,2"))680680 return -ENODEV;681681682682 /* Count the number of CPU cores */
···779779{780780 int rc = -ENODEV;781781782782- if (machine_is_compatible("PowerMac8,1") ||783783- machine_is_compatible("PowerMac8,2"))782782+ if (of_machine_is_compatible("PowerMac8,1") ||783783+ of_machine_is_compatible("PowerMac8,2"))784784 rc = wf_init_pm();785785786786 if (rc == 0) {
+1-1
drivers/macintosh/windfarm_pm91.c
···711711{712712 int rc = -ENODEV;713713714714- if (machine_is_compatible("PowerMac9,1"))714714+ if (of_machine_is_compatible("PowerMac9,1"))715715 rc = wf_init_pm();716716717717 if (rc == 0) {
+3-3
drivers/macintosh/windfarm_smu_sensors.c
···363363 * I yet have to figure out what's up with 8,2 and will have to364364 * adjust for later, unless we can 100% trust the SDB partition...365365 */366366- if ((machine_is_compatible("PowerMac8,1") ||367367- machine_is_compatible("PowerMac8,2") ||368368- machine_is_compatible("PowerMac9,1")) &&366366+ if ((of_machine_is_compatible("PowerMac8,1") ||367367+ of_machine_is_compatible("PowerMac8,2") ||368368+ of_machine_is_compatible("PowerMac9,1")) &&369369 cpuvcp_version >= 2) {370370 pow->quadratic = 1;371371 DBG("windfarm: CPU Power using quadratic transform\n");
+3-1
drivers/media/dvb/dvb-usb/Kconfig
···112112 select DVB_MT352 if !DVB_FE_CUSTOMISE113113 select DVB_ZL10353 if !DVB_FE_CUSTOMISE114114 select DVB_DIB7000P if !DVB_FE_CUSTOMISE115115- select DVB_LGS8GL5 if !DVB_FE_CUSTOMISE116115 select DVB_TUNER_DIB0070 if !DVB_FE_CUSTOMISE116116+ select DVB_ATBM8830 if !DVB_FE_CUSTOMISE117117+ select DVB_LGS8GXX if !DVB_FE_CUSTOMISE117118 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMISE118119 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE119120 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE121121+ select MEDIA_TUNER_MAX2165 if !MEDIA_TUNER_CUSTOMISE120122 help121123 Say Y here to support the Conexant USB2.0 hybrid reference design.122124 Currently, only DVB and ATSC modes are supported, analog mode
···388388 if (0 == btv->i2c_rc && i2c_scan)389389 do_i2c_scan(btv->c.v4l2_dev.name, &btv->i2c_client);390390391391- /* Instantiate the IR receiver device, if present */391391+ return btv->i2c_rc;392392+}393393+394394+/* Instantiate the I2C IR receiver device, if present */395395+void __devinit init_bttv_i2c_ir(struct bttv *btv)396396+{392397 if (0 == btv->i2c_rc) {393398 struct i2c_board_info info;394399 /* The external IR receiver is at i2c address 0x34 (0x35 for···413408 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);414409 i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list);415410 }416416- return btv->i2c_rc;417411}418412419413int __devexit fini_bttv_i2c(struct bttv *btv)
+1
drivers/media/video/bt8xx/bttvp.h
···279279extern unsigned int bttv_gpio;280280extern void bttv_gpio_tracking(struct bttv *btv, char *comment);281281extern int init_bttv_i2c(struct bttv *btv);282282+extern void init_bttv_i2c_ir(struct bttv *btv);282283extern int fini_bttv_i2c(struct bttv *btv);283284284285#define bttv_printk if (bttv_verbose) printk
+1-1
drivers/media/video/mt9t112.c
···514514 /* poll to verify out of standby. Must Poll this bit */515515 for (i = 0; i < 100; i++) {516516 mt9t112_reg_read(data, client, 0x0018);517517- if (0x4000 & data)517517+ if (!(0x4000 & data))518518 break;519519520520 mdelay(10);
+1-1
drivers/media/video/pwc/pwc-ctrl.c
···753753 buf[0] = 0xff; /* fixed */754754755755 ret = send_control_msg(pdev,756756- SET_LUM_CTL, SHUTTER_MODE_FORMATTER, &buf, sizeof(buf));756756+ SET_LUM_CTL, SHUTTER_MODE_FORMATTER, &buf, 1);757757758758 if (!mode && ret >= 0) {759759 if (value < 0)
···40064006 }40074007 }4008400840094009- if (!buffer_info->dma)40094009+ if (!buffer_info->dma) {40104010 buffer_info->dma = pci_map_page(pdev,40114011 buffer_info->page, 0,40124012 buffer_info->length,40134013 PCI_DMA_FROMDEVICE);40144014+ if (pci_dma_mapping_error(pdev, buffer_info->dma)) {40154015+ put_page(buffer_info->page);40164016+ dev_kfree_skb(skb);40174017+ buffer_info->page = NULL;40184018+ buffer_info->skb = NULL;40194019+ buffer_info->dma = 0;40204020+ adapter->alloc_rx_buff_failed++;40214021+ break; /* while !buffer_info->skb */40224022+ }40234023+ }4014402440154025 rx_desc = E1000_RX_DESC(*rx_ring, i);40164026 rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);···41114101 skb->data,41124102 buffer_info->length,41134103 PCI_DMA_FROMDEVICE);41044104+ if (pci_dma_mapping_error(pdev, buffer_info->dma)) {41054105+ dev_kfree_skb(skb);41064106+ buffer_info->skb = NULL;41074107+ buffer_info->dma = 0;41084108+ adapter->alloc_rx_buff_failed++;41094109+ break; /* while !buffer_info->skb */41104110+ }4114411141154112 /*41164113 * XXX if it was allocated cleanly it will never map to a
+22
drivers/net/ixgbe/ixgbe_82598.c
···357357 u32 fctrl_reg;358358 u32 rmcs_reg;359359 u32 reg;360360+ u32 link_speed = 0;361361+ bool link_up;360362361363#ifdef CONFIG_DCB362364 if (hw->fc.requested_mode == ixgbe_fc_pfc)363365 goto out;364366365367#endif /* CONFIG_DCB */368368+ /*369369+ * On 82598 having Rx FC on causes resets while doing 1G370370+ * so if it's on turn it off once we know link_speed. For371371+ * more details see 82598 Specification update.372372+ */373373+ hw->mac.ops.check_link(hw, &link_speed, &link_up, false);374374+ if (link_up && link_speed == IXGBE_LINK_SPEED_1GB_FULL) {375375+ switch (hw->fc.requested_mode) {376376+ case ixgbe_fc_full:377377+ hw->fc.requested_mode = ixgbe_fc_tx_pause;378378+ break;379379+ case ixgbe_fc_rx_pause:380380+ hw->fc.requested_mode = ixgbe_fc_none;381381+ break;382382+ default:383383+ /* no change */384384+ break;385385+ }386386+ }387387+366388 /* Negotiate the fc mode to use */367389 ret_val = ixgbe_fc_autoneg(hw);368390 if (ret_val)
+4
drivers/net/ixgbe/ixgbe_main.c
···57635763 if (err)57645764 goto err_sw_init;5765576557665766+ /* Make it possible the adapter to be woken up via WOL */57675767+ if (adapter->hw.mac.type == ixgbe_mac_82599EB)57685768+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0);57695769+57665770 /*57675771 * If there is a fan on this device and it has failed log the57685772 * failure.
+1-1
drivers/net/mace.c
···206206 mp->port_aaui = port_aaui;207207 else {208208 /* Apple Network Server uses the AAUI port */209209- if (machine_is_compatible("AAPL,ShinerESB"))209209+ if (of_machine_is_compatible("AAPL,ShinerESB"))210210 mp->port_aaui = 1;211211 else {212212#ifdef CONFIG_MACE_AAUI_PORT
···127127 efx_dword_t reg;128128129129 /* Check for a reboot atomically with respect to efx_mcdi_copyout() */130130- rc = efx_mcdi_poll_reboot(efx);130130+ rc = -efx_mcdi_poll_reboot(efx);131131 if (rc)132132 goto out;133133
···18771877/**18781878 * tx_srv - transmit interrupt service18791879 * @vptr; Velocity18801880- * @status:18811880 *18821881 * Scan the queues looking for transmitted packets that18831882 * we can complete and clean up. Update any statistics as18841883 * necessary/18851884 */18861886-static int velocity_tx_srv(struct velocity_info *vptr, u32 status)18851885+static int velocity_tx_srv(struct velocity_info *vptr)18871886{18881887 struct tx_desc *td;18891888 int qnum;···20892090/**20902091 * velocity_rx_srv - service RX interrupt20912092 * @vptr: velocity20922092- * @status: adapter status (unused)20932093 *20942094 * Walk the receive ring of the velocity adapter and remove20952095 * any received packets from the receive queue. Hand the ring20962096 * slots back to the adapter for reuse.20972097 */20982098-static int velocity_rx_srv(struct velocity_info *vptr, int status,20992099- int budget_left)20982098+static int velocity_rx_srv(struct velocity_info *vptr, int budget_left)21002099{21012100 struct net_device_stats *stats = &vptr->dev->stats;21022101 int rd_curr = vptr->rx.curr;···21482151 struct velocity_info *vptr = container_of(napi,21492152 struct velocity_info, napi);21502153 unsigned int rx_done;21512151- u32 isr_status;21542154+ unsigned long flags;2152215521532153- spin_lock(&vptr->lock);21542154- isr_status = mac_read_isr(vptr->mac_regs);21552155-21562156- /* Ack the interrupt */21572157- mac_write_isr(vptr->mac_regs, isr_status);21582158- if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI)))21592159- velocity_error(vptr, isr_status);21602160-21562156+ spin_lock_irqsave(&vptr->lock, flags);21612157 /*21622158 * Do rx and tx twice for performance (taken from the VIA21632159 * out-of-tree driver).21642160 */21652165- rx_done = velocity_rx_srv(vptr, isr_status, budget / 2);21662166- velocity_tx_srv(vptr, isr_status);21672167- rx_done += velocity_rx_srv(vptr, isr_status, budget - rx_done);21682168- velocity_tx_srv(vptr, isr_status);21692169-21702170- spin_unlock(&vptr->lock);21612161+ rx_done = velocity_rx_srv(vptr, budget / 2);21622162+ velocity_tx_srv(vptr);21632163+ rx_done += velocity_rx_srv(vptr, budget - rx_done);21642164+ velocity_tx_srv(vptr);2171216521722166 /* If budget not fully consumed, exit the polling mode */21732167 if (rx_done < budget) {21742168 napi_complete(napi);21752169 mac_enable_int(vptr->mac_regs);21762170 }21712171+ spin_unlock_irqrestore(&vptr->lock, flags);2177217221782173 return rx_done;21792174}···21952206 return IRQ_NONE;21962207 }2197220822092209+ /* Ack the interrupt */22102210+ mac_write_isr(vptr->mac_regs, isr_status);22112211+21982212 if (likely(napi_schedule_prep(&vptr->napi))) {21992213 mac_disable_int(vptr->mac_regs);22002214 __napi_schedule(&vptr->napi);22012215 }22162216+22172217+ if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI)))22182218+ velocity_error(vptr, isr_status);22192219+22022220 spin_unlock(&vptr->lock);2203222122042222 return IRQ_HANDLED;···30963100 velocity_init_registers(vptr, VELOCITY_INIT_WOL);30973101 mac_disable_int(vptr->mac_regs);3098310230993099- velocity_tx_srv(vptr, 0);31033103+ velocity_tx_srv(vptr);3100310431013105 for (i = 0; i < vptr->tx.numq; i++) {31023106 if (vptr->tx.used[i])···33403344{33413345 struct velocity_info *vptr = netdev_priv(dev);33423346 int max_us = 0x3f * 64;33473347+ unsigned long flags;3343334833443349 /* 6 bits of */33453350 if (ecmd->tx_coalesce_usecs > max_us)···33623365 ecmd->tx_coalesce_usecs);3363336633643367 /* Setup the interrupt suppression and queue timers */33683368+ spin_lock_irqsave(&vptr->lock, flags);33653369 mac_disable_int(vptr->mac_regs);33663370 setup_adaptive_interrupts(vptr);33673371 setup_queue_timers(vptr);···33703372 mac_write_int_mask(vptr->int_mask, vptr->mac_regs);33713373 mac_clear_isr(vptr->mac_regs);33723374 mac_enable_int(vptr->mac_regs);33753375+ spin_unlock_irqrestore(&vptr->lock, flags);3373337633743377 return 0;33753378}
+2-2
drivers/net/wireless/ath/ath9k/xmit.c
···16151615 bf->bf_frmlen -= padsize;16161616 }1617161716181618- if (conf_is_ht(&hw->conf) && !is_pae(skb))16181618+ if (conf_is_ht(&hw->conf))16191619 bf->bf_state.bf_type |= BUF_HT;1620162016211621 bf->bf_flags = setup_tx_flags(sc, skb, txctl->txq);···17011701 goto tx_done;17021702 }1703170317041704- if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {17041704+ if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && !is_pae(skb)) {17051705 /*17061706 * Try aggregation if it's a unicast data frame17071707 * and the destination is HT capable.
+1
drivers/net/wireless/b43/b43.h
···115115#define B43_MMIO_TSF_2 0x636 /* core rev < 3 only */116116#define B43_MMIO_TSF_3 0x638 /* core rev < 3 only */117117#define B43_MMIO_RNG 0x65A118118+#define B43_MMIO_IFSSLOT 0x684 /* Interframe slot time */118119#define B43_MMIO_IFSCTL 0x688 /* Interframe space control */119120#define B43_MMIO_IFSCTL_USE_EDCF 0x0004120121#define B43_MMIO_POWERUP_DELAY 0x6A8
+10-3
drivers/net/wireless/b43/main.c
···628628static void b43_set_slot_time(struct b43_wldev *dev, u16 slot_time)629629{630630 /* slot_time is in usec. */631631- if (dev->phy.type != B43_PHYTYPE_G)631631+ /* This test used to exit for all but a G PHY. */632632+ if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ)632633 return;633633- b43_write16(dev, 0x684, 510 + slot_time);634634- b43_shm_write16(dev, B43_SHM_SHARED, 0x0010, slot_time);634634+ b43_write16(dev, B43_MMIO_IFSSLOT, 510 + slot_time);635635+ /* Shared memory location 0x0010 is the slot time and should be636636+ * set to slot_time; however, this register is initially 0 and changing637637+ * the value adversely affects the transmit rate for BCM4311638638+ * devices. Until this behavior is unterstood, delete this step639639+ *640640+ * b43_shm_write16(dev, B43_SHM_SHARED, 0x0010, slot_time);641641+ */635642}636643637644static void b43_short_slot_timing_enable(struct b43_wldev *dev)
···2020#include <linux/module.h>2121#include <linux/of.h>2222#include <linux/spinlock.h>2323+#include <linux/proc_fs.h>23242425struct device_node *allnodes;2626+struct device_node *of_chosen;25272628/* use when traversing tree through the allnext, child, sibling,2729 * or parent members of struct device_node.···3937 np = np->parent;4038 ip = of_get_property(np, "#address-cells", NULL);4139 if (ip)4242- return *ip;4040+ return be32_to_cpup(ip);4341 } while (np->parent);4442 /* No #address-cells property for the root node */4543 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;···5553 np = np->parent;5654 ip = of_get_property(np, "#size-cells", NULL);5755 if (ip)5858- return *ip;5656+ return be32_to_cpup(ip);5957 } while (np->parent);6058 /* No #size-cells property for the root node */6159 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;6260}6361EXPORT_SYMBOL(of_n_size_cells);6262+6363+#if !defined(CONFIG_SPARC) /* SPARC doesn't do ref counting (yet) */6464+/**6565+ * of_node_get - Increment refcount of a node6666+ * @node: Node to inc refcount, NULL is supported to6767+ * simplify writing of callers6868+ *6969+ * Returns node.7070+ */7171+struct device_node *of_node_get(struct device_node *node)7272+{7373+ if (node)7474+ kref_get(&node->kref);7575+ return node;7676+}7777+EXPORT_SYMBOL(of_node_get);7878+7979+static inline struct device_node *kref_to_device_node(struct kref *kref)8080+{8181+ return container_of(kref, struct device_node, kref);8282+}8383+8484+/**8585+ * of_node_release - release a dynamically allocated node8686+ * @kref: kref element of the node to be released8787+ *8888+ * In of_node_put() this function is passed to kref_put()8989+ * as the destructor.9090+ */9191+static void of_node_release(struct kref *kref)9292+{9393+ struct device_node *node = kref_to_device_node(kref);9494+ struct property *prop = node->properties;9595+9696+ /* We should never be releasing nodes that haven't been detached. */9797+ if (!of_node_check_flag(node, OF_DETACHED)) {9898+ pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name);9999+ dump_stack();100100+ kref_init(&node->kref);101101+ return;102102+ }103103+104104+ if (!of_node_check_flag(node, OF_DYNAMIC))105105+ return;106106+107107+ while (prop) {108108+ struct property *next = prop->next;109109+ kfree(prop->name);110110+ kfree(prop->value);111111+ kfree(prop);112112+ prop = next;113113+114114+ if (!prop) {115115+ prop = node->deadprops;116116+ node->deadprops = NULL;117117+ }118118+ }119119+ kfree(node->full_name);120120+ kfree(node->data);121121+ kfree(node);122122+}123123+124124+/**125125+ * of_node_put - Decrement refcount of a node126126+ * @node: Node to dec refcount, NULL is supported to127127+ * simplify writing of callers128128+ *129129+ */130130+void of_node_put(struct device_node *node)131131+{132132+ if (node)133133+ kref_put(&node->kref, of_node_release);134134+}135135+EXPORT_SYMBOL(of_node_put);136136+#endif /* !CONFIG_SPARC */6413765138struct property *of_find_property(const struct device_node *np,66139 const char *name,···219142 return 0;220143}221144EXPORT_SYMBOL(of_device_is_compatible);145145+146146+/**147147+ * of_machine_is_compatible - Test root of device tree for a given compatible value148148+ * @compat: compatible string to look for in root node's compatible property.149149+ *150150+ * Returns true if the root node has the given value in its151151+ * compatible property.152152+ */153153+int of_machine_is_compatible(const char *compat)154154+{155155+ struct device_node *root;156156+ int rc = 0;157157+158158+ root = of_find_node_by_path("/");159159+ if (root) {160160+ rc = of_device_is_compatible(root, compat);161161+ of_node_put(root);162162+ }163163+ return rc;164164+}165165+EXPORT_SYMBOL(of_machine_is_compatible);222166223167/**224168 * of_device_is_available - check if a device is available for use···617519EXPORT_SYMBOL_GPL(of_modalias_node);618520619521/**522522+ * of_find_node_by_phandle - Find a node given a phandle523523+ * @handle: phandle of the node to find524524+ *525525+ * Returns a node pointer with refcount incremented, use526526+ * of_node_put() on it when done.527527+ */528528+struct device_node *of_find_node_by_phandle(phandle handle)529529+{530530+ struct device_node *np;531531+532532+ read_lock(&devtree_lock);533533+ for (np = allnodes; np; np = np->allnext)534534+ if (np->phandle == handle)535535+ break;536536+ of_node_get(np);537537+ read_unlock(&devtree_lock);538538+ return np;539539+}540540+EXPORT_SYMBOL(of_find_node_by_phandle);541541+542542+/**620543 * of_parse_phandle - Resolve a phandle property to a device_node pointer621544 * @np: Pointer to device node holding phandle property622545 * @phandle_name: Name of property holding a phandle value···697578 const void **out_args)698579{699580 int ret = -EINVAL;700700- const u32 *list;701701- const u32 *list_end;581581+ const __be32 *list;582582+ const __be32 *list_end;702583 int size;703584 int cur_index = 0;704585 struct device_node *node = NULL;···712593 list_end = list + size / sizeof(*list);713594714595 while (list < list_end) {715715- const u32 *cells;596596+ const __be32 *cells;716597 const phandle *phandle;717598718599 phandle = list++;···736617 goto err1;737618 }738619739739- list += *cells;620620+ list += be32_to_cpup(cells);740621 if (list > list_end) {741622 pr_debug("%s: insufficient arguments length\n",742623 np->full_name);···777658 return ret;778659}779660EXPORT_SYMBOL(of_parse_phandles_with_args);661661+662662+/**663663+ * prom_add_property - Add a property to a node664664+ */665665+int prom_add_property(struct device_node *np, struct property *prop)666666+{667667+ struct property **next;668668+ unsigned long flags;669669+670670+ prop->next = NULL;671671+ write_lock_irqsave(&devtree_lock, flags);672672+ next = &np->properties;673673+ while (*next) {674674+ if (strcmp(prop->name, (*next)->name) == 0) {675675+ /* duplicate ! don't insert it */676676+ write_unlock_irqrestore(&devtree_lock, flags);677677+ return -1;678678+ }679679+ next = &(*next)->next;680680+ }681681+ *next = prop;682682+ write_unlock_irqrestore(&devtree_lock, flags);683683+684684+#ifdef CONFIG_PROC_DEVICETREE685685+ /* try to add to proc as well if it was initialized */686686+ if (np->pde)687687+ proc_device_tree_add_prop(np->pde, prop);688688+#endif /* CONFIG_PROC_DEVICETREE */689689+690690+ return 0;691691+}692692+693693+/**694694+ * prom_remove_property - Remove a property from a node.695695+ *696696+ * Note that we don't actually remove it, since we have given out697697+ * who-knows-how-many pointers to the data using get-property.698698+ * Instead we just move the property to the "dead properties"699699+ * list, so it won't be found any more.700700+ */701701+int prom_remove_property(struct device_node *np, struct property *prop)702702+{703703+ struct property **next;704704+ unsigned long flags;705705+ int found = 0;706706+707707+ write_lock_irqsave(&devtree_lock, flags);708708+ next = &np->properties;709709+ while (*next) {710710+ if (*next == prop) {711711+ /* found the node */712712+ *next = prop->next;713713+ prop->next = np->deadprops;714714+ np->deadprops = prop;715715+ found = 1;716716+ break;717717+ }718718+ next = &(*next)->next;719719+ }720720+ write_unlock_irqrestore(&devtree_lock, flags);721721+722722+ if (!found)723723+ return -ENODEV;724724+725725+#ifdef CONFIG_PROC_DEVICETREE726726+ /* try to remove the proc node as well */727727+ if (np->pde)728728+ proc_device_tree_remove_prop(np->pde, prop);729729+#endif /* CONFIG_PROC_DEVICETREE */730730+731731+ return 0;732732+}733733+734734+/*735735+ * prom_update_property - Update a property in a node.736736+ *737737+ * Note that we don't actually remove it, since we have given out738738+ * who-knows-how-many pointers to the data using get-property.739739+ * Instead we just move the property to the "dead properties" list,740740+ * and add the new property to the property list741741+ */742742+int prom_update_property(struct device_node *np,743743+ struct property *newprop,744744+ struct property *oldprop)745745+{746746+ struct property **next;747747+ unsigned long flags;748748+ int found = 0;749749+750750+ write_lock_irqsave(&devtree_lock, flags);751751+ next = &np->properties;752752+ while (*next) {753753+ if (*next == oldprop) {754754+ /* found the node */755755+ newprop->next = oldprop->next;756756+ *next = newprop;757757+ oldprop->next = np->deadprops;758758+ np->deadprops = oldprop;759759+ found = 1;760760+ break;761761+ }762762+ next = &(*next)->next;763763+ }764764+ write_unlock_irqrestore(&devtree_lock, flags);765765+766766+ if (!found)767767+ return -ENODEV;768768+769769+#ifdef CONFIG_PROC_DEVICETREE770770+ /* try to add to proc as well if it was initialized */771771+ if (np->pde)772772+ proc_device_tree_update_prop(np->pde, newprop, oldprop);773773+#endif /* CONFIG_PROC_DEVICETREE */774774+775775+ return 0;776776+}777777+778778+#if defined(CONFIG_OF_DYNAMIC)779779+/*780780+ * Support for dynamic device trees.781781+ *782782+ * On some platforms, the device tree can be manipulated at runtime.783783+ * The routines in this section support adding, removing and changing784784+ * device tree nodes.785785+ */786786+787787+/**788788+ * of_attach_node - Plug a device node into the tree and global list.789789+ */790790+void of_attach_node(struct device_node *np)791791+{792792+ unsigned long flags;793793+794794+ write_lock_irqsave(&devtree_lock, flags);795795+ np->sibling = np->parent->child;796796+ np->allnext = allnodes;797797+ np->parent->child = np;798798+ allnodes = np;799799+ write_unlock_irqrestore(&devtree_lock, flags);800800+}801801+802802+/**803803+ * of_detach_node - "Unplug" a node from the device tree.804804+ *805805+ * The caller must hold a reference to the node. The memory associated with806806+ * the node is not freed until its refcount goes to zero.807807+ */808808+void of_detach_node(struct device_node *np)809809+{810810+ struct device_node *parent;811811+ unsigned long flags;812812+813813+ write_lock_irqsave(&devtree_lock, flags);814814+815815+ parent = np->parent;816816+ if (!parent)817817+ goto out_unlock;818818+819819+ if (allnodes == np)820820+ allnodes = np->allnext;821821+ else {822822+ struct device_node *prev;823823+ for (prev = allnodes;824824+ prev->allnext != np;825825+ prev = prev->allnext)826826+ ;827827+ prev->allnext = np->allnext;828828+ }829829+830830+ if (parent->child == np)831831+ parent->child = np->sibling;832832+ else {833833+ struct device_node *prevsib;834834+ for (prevsib = np->parent->child;835835+ prevsib->sibling != np;836836+ prevsib = prevsib->sibling)837837+ ;838838+ prevsib->sibling = np->sibling;839839+ }840840+841841+ of_node_set_flag(np, OF_DETACHED);842842+843843+out_unlock:844844+ write_unlock_irqrestore(&devtree_lock, flags);845845+}846846+#endif /* defined(CONFIG_OF_DYNAMIC) */847847+
+590
drivers/of/fdt.c
···11+/*22+ * Functions for working with the Flattened Device Tree data format33+ *44+ * Copyright 2009 Benjamin Herrenschmidt, IBM Corp55+ * benh@kernel.crashing.org66+ *77+ * This program is free software; you can redistribute it and/or88+ * modify it under the terms of the GNU General Public License99+ * version 2 as published by the Free Software Foundation.1010+ */1111+1212+#include <linux/kernel.h>1313+#include <linux/initrd.h>1414+#include <linux/of.h>1515+#include <linux/of_fdt.h>1616+#include <linux/string.h>1717+#include <linux/errno.h>1818+1919+#ifdef CONFIG_PPC2020+#include <asm/machdep.h>2121+#endif /* CONFIG_PPC */2222+2323+#include <asm/page.h>2424+2525+int __initdata dt_root_addr_cells;2626+int __initdata dt_root_size_cells;2727+2828+struct boot_param_header *initial_boot_params;2929+3030+char *find_flat_dt_string(u32 offset)3131+{3232+ return ((char *)initial_boot_params) +3333+ be32_to_cpu(initial_boot_params->off_dt_strings) + offset;3434+}3535+3636+/**3737+ * of_scan_flat_dt - scan flattened tree blob and call callback on each.3838+ * @it: callback function3939+ * @data: context data pointer4040+ *4141+ * This function is used to scan the flattened device-tree, it is4242+ * used to extract the memory information at boot before we can4343+ * unflatten the tree4444+ */4545+int __init of_scan_flat_dt(int (*it)(unsigned long node,4646+ const char *uname, int depth,4747+ void *data),4848+ void *data)4949+{5050+ unsigned long p = ((unsigned long)initial_boot_params) +5151+ be32_to_cpu(initial_boot_params->off_dt_struct);5252+ int rc = 0;5353+ int depth = -1;5454+5555+ do {5656+ u32 tag = be32_to_cpup((__be32 *)p);5757+ char *pathp;5858+5959+ p += 4;6060+ if (tag == OF_DT_END_NODE) {6161+ depth--;6262+ continue;6363+ }6464+ if (tag == OF_DT_NOP)6565+ continue;6666+ if (tag == OF_DT_END)6767+ break;6868+ if (tag == OF_DT_PROP) {6969+ u32 sz = be32_to_cpup((__be32 *)p);7070+ p += 8;7171+ if (be32_to_cpu(initial_boot_params->version) < 0x10)7272+ p = _ALIGN(p, sz >= 8 ? 8 : 4);7373+ p += sz;7474+ p = _ALIGN(p, 4);7575+ continue;7676+ }7777+ if (tag != OF_DT_BEGIN_NODE) {7878+ pr_err("Invalid tag %x in flat device tree!\n", tag);7979+ return -EINVAL;8080+ }8181+ depth++;8282+ pathp = (char *)p;8383+ p = _ALIGN(p + strlen(pathp) + 1, 4);8484+ if ((*pathp) == '/') {8585+ char *lp, *np;8686+ for (lp = NULL, np = pathp; *np; np++)8787+ if ((*np) == '/')8888+ lp = np+1;8989+ if (lp != NULL)9090+ pathp = lp;9191+ }9292+ rc = it(p, pathp, depth, data);9393+ if (rc != 0)9494+ break;9595+ } while (1);9696+9797+ return rc;9898+}9999+100100+/**101101+ * of_get_flat_dt_root - find the root node in the flat blob102102+ */103103+unsigned long __init of_get_flat_dt_root(void)104104+{105105+ unsigned long p = ((unsigned long)initial_boot_params) +106106+ be32_to_cpu(initial_boot_params->off_dt_struct);107107+108108+ while (be32_to_cpup((__be32 *)p) == OF_DT_NOP)109109+ p += 4;110110+ BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);111111+ p += 4;112112+ return _ALIGN(p + strlen((char *)p) + 1, 4);113113+}114114+115115+/**116116+ * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr117117+ *118118+ * This function can be used within scan_flattened_dt callback to get119119+ * access to properties120120+ */121121+void *__init of_get_flat_dt_prop(unsigned long node, const char *name,122122+ unsigned long *size)123123+{124124+ unsigned long p = node;125125+126126+ do {127127+ u32 tag = be32_to_cpup((__be32 *)p);128128+ u32 sz, noff;129129+ const char *nstr;130130+131131+ p += 4;132132+ if (tag == OF_DT_NOP)133133+ continue;134134+ if (tag != OF_DT_PROP)135135+ return NULL;136136+137137+ sz = be32_to_cpup((__be32 *)p);138138+ noff = be32_to_cpup((__be32 *)(p + 4));139139+ p += 8;140140+ if (be32_to_cpu(initial_boot_params->version) < 0x10)141141+ p = _ALIGN(p, sz >= 8 ? 8 : 4);142142+143143+ nstr = find_flat_dt_string(noff);144144+ if (nstr == NULL) {145145+ pr_warning("Can't find property index name !\n");146146+ return NULL;147147+ }148148+ if (strcmp(name, nstr) == 0) {149149+ if (size)150150+ *size = sz;151151+ return (void *)p;152152+ }153153+ p += sz;154154+ p = _ALIGN(p, 4);155155+ } while (1);156156+}157157+158158+/**159159+ * of_flat_dt_is_compatible - Return true if given node has compat in compatible list160160+ * @node: node to test161161+ * @compat: compatible string to compare with compatible list.162162+ */163163+int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)164164+{165165+ const char *cp;166166+ unsigned long cplen, l;167167+168168+ cp = of_get_flat_dt_prop(node, "compatible", &cplen);169169+ if (cp == NULL)170170+ return 0;171171+ while (cplen > 0) {172172+ if (strncasecmp(cp, compat, strlen(compat)) == 0)173173+ return 1;174174+ l = strlen(cp) + 1;175175+ cp += l;176176+ cplen -= l;177177+ }178178+179179+ return 0;180180+}181181+182182+static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,183183+ unsigned long align)184184+{185185+ void *res;186186+187187+ *mem = _ALIGN(*mem, align);188188+ res = (void *)*mem;189189+ *mem += size;190190+191191+ return res;192192+}193193+194194+/**195195+ * unflatten_dt_node - Alloc and populate a device_node from the flat tree196196+ * @p: pointer to node in flat tree197197+ * @dad: Parent struct device_node198198+ * @allnextpp: pointer to ->allnext from last allocated device_node199199+ * @fpsize: Size of the node path up at the current depth.200200+ */201201+unsigned long __init unflatten_dt_node(unsigned long mem,202202+ unsigned long *p,203203+ struct device_node *dad,204204+ struct device_node ***allnextpp,205205+ unsigned long fpsize)206206+{207207+ struct device_node *np;208208+ struct property *pp, **prev_pp = NULL;209209+ char *pathp;210210+ u32 tag;211211+ unsigned int l, allocl;212212+ int has_name = 0;213213+ int new_format = 0;214214+215215+ tag = be32_to_cpup((__be32 *)(*p));216216+ if (tag != OF_DT_BEGIN_NODE) {217217+ pr_err("Weird tag at start of node: %x\n", tag);218218+ return mem;219219+ }220220+ *p += 4;221221+ pathp = (char *)*p;222222+ l = allocl = strlen(pathp) + 1;223223+ *p = _ALIGN(*p + l, 4);224224+225225+ /* version 0x10 has a more compact unit name here instead of the full226226+ * path. we accumulate the full path size using "fpsize", we'll rebuild227227+ * it later. We detect this because the first character of the name is228228+ * not '/'.229229+ */230230+ if ((*pathp) != '/') {231231+ new_format = 1;232232+ if (fpsize == 0) {233233+ /* root node: special case. fpsize accounts for path234234+ * plus terminating zero. root node only has '/', so235235+ * fpsize should be 2, but we want to avoid the first236236+ * level nodes to have two '/' so we use fpsize 1 here237237+ */238238+ fpsize = 1;239239+ allocl = 2;240240+ } else {241241+ /* account for '/' and path size minus terminal 0242242+ * already in 'l'243243+ */244244+ fpsize += l;245245+ allocl = fpsize;246246+ }247247+ }248248+249249+ np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,250250+ __alignof__(struct device_node));251251+ if (allnextpp) {252252+ memset(np, 0, sizeof(*np));253253+ np->full_name = ((char *)np) + sizeof(struct device_node);254254+ if (new_format) {255255+ char *fn = np->full_name;256256+ /* rebuild full path for new format */257257+ if (dad && dad->parent) {258258+ strcpy(fn, dad->full_name);259259+#ifdef DEBUG260260+ if ((strlen(fn) + l + 1) != allocl) {261261+ pr_debug("%s: p: %d, l: %d, a: %d\n",262262+ pathp, (int)strlen(fn),263263+ l, allocl);264264+ }265265+#endif266266+ fn += strlen(fn);267267+ }268268+ *(fn++) = '/';269269+ memcpy(fn, pathp, l);270270+ } else271271+ memcpy(np->full_name, pathp, l);272272+ prev_pp = &np->properties;273273+ **allnextpp = np;274274+ *allnextpp = &np->allnext;275275+ if (dad != NULL) {276276+ np->parent = dad;277277+ /* we temporarily use the next field as `last_child'*/278278+ if (dad->next == NULL)279279+ dad->child = np;280280+ else281281+ dad->next->sibling = np;282282+ dad->next = np;283283+ }284284+ kref_init(&np->kref);285285+ }286286+ while (1) {287287+ u32 sz, noff;288288+ char *pname;289289+290290+ tag = be32_to_cpup((__be32 *)(*p));291291+ if (tag == OF_DT_NOP) {292292+ *p += 4;293293+ continue;294294+ }295295+ if (tag != OF_DT_PROP)296296+ break;297297+ *p += 4;298298+ sz = be32_to_cpup((__be32 *)(*p));299299+ noff = be32_to_cpup((__be32 *)((*p) + 4));300300+ *p += 8;301301+ if (be32_to_cpu(initial_boot_params->version) < 0x10)302302+ *p = _ALIGN(*p, sz >= 8 ? 8 : 4);303303+304304+ pname = find_flat_dt_string(noff);305305+ if (pname == NULL) {306306+ pr_info("Can't find property name in list !\n");307307+ break;308308+ }309309+ if (strcmp(pname, "name") == 0)310310+ has_name = 1;311311+ l = strlen(pname) + 1;312312+ pp = unflatten_dt_alloc(&mem, sizeof(struct property),313313+ __alignof__(struct property));314314+ if (allnextpp) {315315+ /* We accept flattened tree phandles either in316316+ * ePAPR-style "phandle" properties, or the317317+ * legacy "linux,phandle" properties. If both318318+ * appear and have different values, things319319+ * will get weird. Don't do that. */320320+ if ((strcmp(pname, "phandle") == 0) ||321321+ (strcmp(pname, "linux,phandle") == 0)) {322322+ if (np->phandle == 0)323323+ np->phandle = *((u32 *)*p);324324+ }325325+ /* And we process the "ibm,phandle" property326326+ * used in pSeries dynamic device tree327327+ * stuff */328328+ if (strcmp(pname, "ibm,phandle") == 0)329329+ np->phandle = *((u32 *)*p);330330+ pp->name = pname;331331+ pp->length = sz;332332+ pp->value = (void *)*p;333333+ *prev_pp = pp;334334+ prev_pp = &pp->next;335335+ }336336+ *p = _ALIGN((*p) + sz, 4);337337+ }338338+ /* with version 0x10 we may not have the name property, recreate339339+ * it here from the unit name if absent340340+ */341341+ if (!has_name) {342342+ char *p1 = pathp, *ps = pathp, *pa = NULL;343343+ int sz;344344+345345+ while (*p1) {346346+ if ((*p1) == '@')347347+ pa = p1;348348+ if ((*p1) == '/')349349+ ps = p1 + 1;350350+ p1++;351351+ }352352+ if (pa < ps)353353+ pa = p1;354354+ sz = (pa - ps) + 1;355355+ pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,356356+ __alignof__(struct property));357357+ if (allnextpp) {358358+ pp->name = "name";359359+ pp->length = sz;360360+ pp->value = pp + 1;361361+ *prev_pp = pp;362362+ prev_pp = &pp->next;363363+ memcpy(pp->value, ps, sz - 1);364364+ ((char *)pp->value)[sz - 1] = 0;365365+ pr_debug("fixed up name for %s -> %s\n", pathp,366366+ (char *)pp->value);367367+ }368368+ }369369+ if (allnextpp) {370370+ *prev_pp = NULL;371371+ np->name = of_get_property(np, "name", NULL);372372+ np->type = of_get_property(np, "device_type", NULL);373373+374374+ if (!np->name)375375+ np->name = "<NULL>";376376+ if (!np->type)377377+ np->type = "<NULL>";378378+ }379379+ while (tag == OF_DT_BEGIN_NODE) {380380+ mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);381381+ tag = be32_to_cpup((__be32 *)(*p));382382+ }383383+ if (tag != OF_DT_END_NODE) {384384+ pr_err("Weird tag at end of node: %x\n", tag);385385+ return mem;386386+ }387387+ *p += 4;388388+ return mem;389389+}390390+391391+#ifdef CONFIG_BLK_DEV_INITRD392392+/**393393+ * early_init_dt_check_for_initrd - Decode initrd location from flat tree394394+ * @node: reference to node containing initrd location ('chosen')395395+ */396396+void __init early_init_dt_check_for_initrd(unsigned long node)397397+{398398+ unsigned long start, end, len;399399+ __be32 *prop;400400+401401+ pr_debug("Looking for initrd properties... ");402402+403403+ prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len);404404+ if (!prop)405405+ return;406406+ start = of_read_ulong(prop, len/4);407407+408408+ prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len);409409+ if (!prop)410410+ return;411411+ end = of_read_ulong(prop, len/4);412412+413413+ early_init_dt_setup_initrd_arch(start, end);414414+ pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n", start, end);415415+}416416+#else417417+inline void early_init_dt_check_for_initrd(unsigned long node)418418+{419419+}420420+#endif /* CONFIG_BLK_DEV_INITRD */421421+422422+/**423423+ * early_init_dt_scan_root - fetch the top level address and size cells424424+ */425425+int __init early_init_dt_scan_root(unsigned long node, const char *uname,426426+ int depth, void *data)427427+{428428+ __be32 *prop;429429+430430+ if (depth != 0)431431+ return 0;432432+433433+ dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;434434+ dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;435435+436436+ prop = of_get_flat_dt_prop(node, "#size-cells", NULL);437437+ if (prop)438438+ dt_root_size_cells = be32_to_cpup(prop);439439+ pr_debug("dt_root_size_cells = %x\n", dt_root_size_cells);440440+441441+ prop = of_get_flat_dt_prop(node, "#address-cells", NULL);442442+ if (prop)443443+ dt_root_addr_cells = be32_to_cpup(prop);444444+ pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells);445445+446446+ /* break now */447447+ return 1;448448+}449449+450450+u64 __init dt_mem_next_cell(int s, __be32 **cellp)451451+{452452+ __be32 *p = *cellp;453453+454454+ *cellp = p + s;455455+ return of_read_number(p, s);456456+}457457+458458+/**459459+ * early_init_dt_scan_memory - Look for an parse memory nodes460460+ */461461+int __init early_init_dt_scan_memory(unsigned long node, const char *uname,462462+ int depth, void *data)463463+{464464+ char *type = of_get_flat_dt_prop(node, "device_type", NULL);465465+ __be32 *reg, *endp;466466+ unsigned long l;467467+468468+ /* We are scanning "memory" nodes only */469469+ if (type == NULL) {470470+ /*471471+ * The longtrail doesn't have a device_type on the472472+ * /memory node, so look for the node called /memory@0.473473+ */474474+ if (depth != 1 || strcmp(uname, "memory@0") != 0)475475+ return 0;476476+ } else if (strcmp(type, "memory") != 0)477477+ return 0;478478+479479+ reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);480480+ if (reg == NULL)481481+ reg = of_get_flat_dt_prop(node, "reg", &l);482482+ if (reg == NULL)483483+ return 0;484484+485485+ endp = reg + (l / sizeof(__be32));486486+487487+ pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",488488+ uname, l, reg[0], reg[1], reg[2], reg[3]);489489+490490+ while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {491491+ u64 base, size;492492+493493+ base = dt_mem_next_cell(dt_root_addr_cells, ®);494494+ size = dt_mem_next_cell(dt_root_size_cells, ®);495495+496496+ if (size == 0)497497+ continue;498498+ pr_debug(" - %llx , %llx\n", (unsigned long long)base,499499+ (unsigned long long)size);500500+501501+ early_init_dt_add_memory_arch(base, size);502502+ }503503+504504+ return 0;505505+}506506+507507+int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,508508+ int depth, void *data)509509+{510510+ unsigned long l;511511+ char *p;512512+513513+ pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);514514+515515+ if (depth != 1 ||516516+ (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))517517+ return 0;518518+519519+ early_init_dt_check_for_initrd(node);520520+521521+ /* Retreive command line */522522+ p = of_get_flat_dt_prop(node, "bootargs", &l);523523+ if (p != NULL && l > 0)524524+ strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));525525+526526+#ifdef CONFIG_CMDLINE527527+#ifndef CONFIG_CMDLINE_FORCE528528+ if (p == NULL || l == 0 || (l == 1 && (*p) == 0))529529+#endif530530+ strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);531531+#endif /* CONFIG_CMDLINE */532532+533533+ early_init_dt_scan_chosen_arch(node);534534+535535+ pr_debug("Command line is: %s\n", cmd_line);536536+537537+ /* break now */538538+ return 1;539539+}540540+541541+/**542542+ * unflatten_device_tree - create tree of device_nodes from flat blob543543+ *544544+ * unflattens the device-tree passed by the firmware, creating the545545+ * tree of struct device_node. It also fills the "name" and "type"546546+ * pointers of the nodes so the normal device-tree walking functions547547+ * can be used.548548+ */549549+void __init unflatten_device_tree(void)550550+{551551+ unsigned long start, mem, size;552552+ struct device_node **allnextp = &allnodes;553553+554554+ pr_debug(" -> unflatten_device_tree()\n");555555+556556+ /* First pass, scan for size */557557+ start = ((unsigned long)initial_boot_params) +558558+ be32_to_cpu(initial_boot_params->off_dt_struct);559559+ size = unflatten_dt_node(0, &start, NULL, NULL, 0);560560+ size = (size | 3) + 1;561561+562562+ pr_debug(" size is %lx, allocating...\n", size);563563+564564+ /* Allocate memory for the expanded device tree */565565+ mem = early_init_dt_alloc_memory_arch(size + 4,566566+ __alignof__(struct device_node));567567+ mem = (unsigned long) __va(mem);568568+569569+ ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);570570+571571+ pr_debug(" unflattening %lx...\n", mem);572572+573573+ /* Second pass, do actual unflattening */574574+ start = ((unsigned long)initial_boot_params) +575575+ be32_to_cpu(initial_boot_params->off_dt_struct);576576+ unflatten_dt_node(mem, &start, NULL, &allnextp, 0);577577+ if (be32_to_cpup((__be32 *)start) != OF_DT_END)578578+ pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));579579+ if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef)580580+ pr_warning("End of tree marker overwritten: %08x\n",581581+ be32_to_cpu(((__be32 *)mem)[size / 4]));582582+ *allnextp = NULL;583583+584584+ /* Get pointer to OF "/chosen" node for use everywhere */585585+ of_chosen = of_find_node_by_path("/chosen");586586+ if (of_chosen == NULL)587587+ of_chosen = of_find_node_by_path("/chosen@0");588588+589589+ pr_debug(" <- unflatten_device_tree()\n");590590+}
+7-6
drivers/of/gpio.c
···3636 struct of_gpio_chip *of_gc = NULL;3737 int size;3838 const void *gpio_spec;3939- const u32 *gpio_cells;3939+ const __be32 *gpio_cells;40404141 ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index,4242 &gc, &gpio_spec);···55555656 gpio_cells = of_get_property(gc, "#gpio-cells", &size);5757 if (!gpio_cells || size != sizeof(*gpio_cells) ||5858- *gpio_cells != of_gc->gpio_cells) {5858+ be32_to_cpup(gpio_cells) != of_gc->gpio_cells) {5959 pr_debug("%s: wrong #gpio-cells for %s\n",6060 np->full_name, gc->full_name);6161 ret = -EINVAL;···127127int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,128128 const void *gpio_spec, enum of_gpio_flags *flags)129129{130130- const u32 *gpio = gpio_spec;130130+ const __be32 *gpio = gpio_spec;131131+ const u32 n = be32_to_cpup(gpio);131132132133 /*133134 * We're discouraging gpio_cells < 2, since that way you'll have to···141140 return -EINVAL;142141 }143142144144- if (*gpio > of_gc->gc.ngpio)143143+ if (n > of_gc->gc.ngpio)145144 return -EINVAL;146145147146 if (flags)148148- *flags = gpio[1];147147+ *flags = be32_to_cpu(gpio[1]);149148150150- return *gpio;149149+ return n;151150}152151EXPORT_SYMBOL(of_gpio_simple_xlate);153152
···720720 -ret_val);721721 goto acpiphp_bus_add_out;722722 }723723- /*724724- * try to start anyway. We could have failed to add725725- * simply because this bus had previously been added726726- * on another add. Don't bother with the return value727727- * we just keep going.728728- */729723 ret_val = acpi_bus_start(device);730724731725acpiphp_bus_add_out:
···57715771 case TPACPI_THERMAL_ACPI_TMP07:57725772 case TPACPI_THERMAL_ACPI_UPDT:57735773 sysfs_remove_group(&tpacpi_sensors_pdev->dev.kobj,57745774- &thermal_temp_input16_group);57745774+ &thermal_temp_input8_group);57755775 break;57765776 case TPACPI_THERMAL_NONE:57775777 default:
···37813781 compat_alloc_user_space(sizeof(struct megasas_iocpacket));37823782 int i;37833783 int error = 0;37843784+ compat_uptr_t ptr;3784378537853786 if (clear_user(ioc, sizeof(*ioc)))37863787 return -EFAULT;···37943793 copy_in_user(&ioc->sge_count, &cioc->sge_count, sizeof(u32)))37953794 return -EFAULT;3796379537973797- for (i = 0; i < MAX_IOCTL_SGE; i++) {37983798- compat_uptr_t ptr;37963796+ /*37973797+ * The sense_ptr is used in megasas_mgmt_fw_ioctl only when37983798+ * sense_len is not null, so prepare the 64bit value under37993799+ * the same condition.38003800+ */38013801+ if (ioc->sense_len) {38023802+ void __user **sense_ioc_ptr =38033803+ (void __user **)(ioc->frame.raw + ioc->sense_off);38043804+ compat_uptr_t *sense_cioc_ptr =38053805+ (compat_uptr_t *)(cioc->frame.raw + cioc->sense_off);38063806+ if (get_user(ptr, sense_cioc_ptr) ||38073807+ put_user(compat_ptr(ptr), sense_ioc_ptr))38083808+ return -EFAULT;38093809+ }3799381038113811+ for (i = 0; i < MAX_IOCTL_SGE; i++) {38003812 if (get_user(ptr, &cioc->sgl[i].iov_base) ||38013813 put_user(compat_ptr(ptr), &ioc->sgl[i].iov_base) ||38023814 copy_in_user(&ioc->sgl[i].iov_len,
+4-3
drivers/serial/8250.c
···83838484#define PASS_LIMIT 25685858686+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)8787+8888+8689/*8790 * We default to IRQ0 for the "no irq" hack. Some8891 * machine types want others as well - they're free···17951792 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;17961793 spin_unlock_irqrestore(&up->port.lock, flags);1797179417981798- return lsr & UART_LSR_TEMT ? TIOCSER_TEMT : 0;17951795+ return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0;17991796}1800179718011798static unsigned int serial8250_get_mctrl(struct uart_port *port)···18521849 serial_out(up, UART_LCR, up->lcr);18531850 spin_unlock_irqrestore(&up->port.lock, flags);18541851}18551855-18561856-#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)1857185218581853/*18591854 * Wait for transmitter & holding register to empty
+3-3
drivers/serial/pmac_zilog.c
···20312031 /*20322032 * XServe's default to 57600 bps20332033 */20342034- if (machine_is_compatible("RackMac1,1")20352035- || machine_is_compatible("RackMac1,2")20362036- || machine_is_compatible("MacRISC4"))20342034+ if (of_machine_is_compatible("RackMac1,1")20352035+ || of_machine_is_compatible("RackMac1,2")20362036+ || of_machine_is_compatible("MacRISC4"))20372037 baud = 57600;2038203820392039 /*
+22-1
drivers/spi/Kconfig
···100100 inexpensive battery powered microcontroller evaluation board.101101 This same cable can be used to flash new firmware.102102103103+config SPI_COLDFIRE_QSPI104104+ tristate "Freescale Coldfire QSPI controller"105105+ depends on (M520x || M523x || M5249 || M527x || M528x || M532x)106106+ help107107+ This enables support for the Coldfire QSPI controller in master108108+ mode.109109+110110+ This driver can also be built as a module. If so, the module111111+ will be called coldfire_qspi.112112+113113+config SPI_DAVINCI114114+ tristate "SPI controller driver for DaVinci/DA8xx SoC's"115115+ depends on SPI_MASTER && ARCH_DAVINCI116116+ select SPI_BITBANG117117+ help118118+ SPI master controller for DaVinci and DA8xx SPI modules.119119+103120config SPI_GPIO104121 tristate "GPIO-based bitbanging SPI Master"105122 depends on GENERIC_GPIO···325308#326309327310config SPI_DESIGNWARE328328- bool "DesignWare SPI controller core support"311311+ tristate "DesignWare SPI controller core support"329312 depends on SPI_MASTER330313 help331314 general driver for SPI controller core from DesignWare···333316config SPI_DW_PCI334317 tristate "PCI interface driver for DW SPI core"335318 depends on SPI_DESIGNWARE && PCI319319+320320+config SPI_DW_MMIO321321+ tristate "Memory-mapped io interface driver for DW SPI core"322322+ depends on SPI_DESIGNWARE && HAVE_CLK336323337324#338325# There are lots of SPI device types, with sensors and memory
···4444config USB_ULPI4545 bool "Generic ULPI Transceiver Driver"4646 depends on ARM4747+ select USB_OTG_UTILS4748 help4849 Enable this to support ULPI connected USB OTG transceivers which4950 are likely found on embedded boards.
···19311931 * PowerMac2,2 summer 2000 iMacs19321932 * PowerMac4,1 january 2001 iMacs "flower power"19331933 */19341934- if (machine_is_compatible("PowerMac2,1") ||19351935- machine_is_compatible("PowerMac2,2") ||19361936- machine_is_compatible("PowerMac4,1"))19341934+ if (of_machine_is_compatible("PowerMac2,1") ||19351935+ of_machine_is_compatible("PowerMac2,2") ||19361936+ of_machine_is_compatible("PowerMac4,1"))19371937 default_vmode = VMODE_1024_768_75;1938193819391939 /* iBook SE */19401940- if (machine_is_compatible("PowerBook2,2"))19401940+ if (of_machine_is_compatible("PowerBook2,2"))19411941 default_vmode = VMODE_800_600_60;1942194219431943 /* PowerBook Firewire (Pismo), iBook Dual USB */19441944- if (machine_is_compatible("PowerBook3,1") ||19451945- machine_is_compatible("PowerBook4,1"))19441944+ if (of_machine_is_compatible("PowerBook3,1") ||19451945+ of_machine_is_compatible("PowerBook4,1"))19461946 default_vmode = VMODE_1024_768_60;1947194719481948 /* PowerBook Titanium */19491949- if (machine_is_compatible("PowerBook3,2"))19491949+ if (of_machine_is_compatible("PowerBook3,2"))19501950 default_vmode = VMODE_1152_768_60;1951195119521952 if (default_cmode > 16)
+5-5
drivers/video/aty/atyfb_base.c
···24392439 * The Apple iBook1 uses non-standard memory frequencies.24402440 * We detect it and set the frequency manually.24412441 */24422442- if (machine_is_compatible("PowerBook2,1")) {24422442+ if (of_machine_is_compatible("PowerBook2,1")) {24432443 par->pll_limits.mclk = 70;24442444 par->pll_limits.xclk = 53;24452445 }···26592659 FBINFO_HWACCEL_YPAN;2660266026612661#ifdef CONFIG_PMAC_BACKLIGHT26622662- if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) {26622662+ if (M64_HAS(G3_PB_1_1) && of_machine_is_compatible("PowerBook1,1")) {26632663 /*26642664 * these bits let the 101 powerbook26652665 * wake up from sleep -- paulus···26902690 if (M64_HAS(G3_PB_1024x768))26912691 /* G3 PowerBook with 1024x768 LCD */26922692 default_vmode = VMODE_1024_768_60;26932693- else if (machine_is_compatible("iMac"))26932693+ else if (of_machine_is_compatible("iMac"))26942694 default_vmode = VMODE_1024_768_75;26952695- else if (machine_is_compatible("PowerBook2,1"))26952695+ else if (of_machine_is_compatible("PowerBook2,1"))26962696 /* iBook with 800x600 LCD */26972697 default_vmode = VMODE_800_600_60;26982698 else···31043104 }3105310531063106 dp = pci_device_to_OF_node(pdev);31073107- if (node == dp->node) {31073107+ if (node == dp->phandle) {31083108 struct fb_var_screeninfo *var = &default_var;31093109 unsigned int N, P, Q, M, T, R;31103110 u32 v_total, h_total;
···2121#include <linux/virtio_config.h>2222#include <linux/device.h>23232424+/* virtio guest is communicating with a virtual "device" that actually runs on2525+ * a host processor. Memory barriers are used to control SMP effects. */2626+#ifdef CONFIG_SMP2727+/* Where possible, use SMP barriers which are more lightweight than mandatory2828+ * barriers, because mandatory barriers control MMIO effects on accesses2929+ * through relaxed memory I/O windows (which virtio does not use). */3030+#define virtio_mb() smp_mb()3131+#define virtio_rmb() smp_rmb()3232+#define virtio_wmb() smp_wmb()3333+#else3434+/* We must force memory ordering even if guest is UP since host could be3535+ * running on another CPU, but SMP barriers are defined to barrier() in that3636+ * configuration. So fall back to mandatory barriers instead. */3737+#define virtio_mb() mb()3838+#define virtio_rmb() rmb()3939+#define virtio_wmb() wmb()4040+#endif4141+2442#ifdef DEBUG2543/* For development, we want to crash whenever the ring is screwed. */2644#define BAD_RING(_vq, fmt, args...) \···5436 panic("%s:in_use = %i\n", \5537 (_vq)->vq.name, (_vq)->in_use); \5638 (_vq)->in_use = __LINE__; \5757- mb(); \5839 } while (0)5940#define END_USE(_vq) \6060- do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0)4141+ do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; } while(0)6142#else6243#define BAD_RING(_vq, fmt, args...) \6344 do { \···238221 START_USE(vq);239222 /* Descriptors and available array need to be set before we expose the240223 * new available array entries. */241241- wmb();224224+ virtio_wmb();242225243226 vq->vring.avail->idx += vq->num_added;244227 vq->num_added = 0;245228246229 /* Need to update avail index before checking if we should notify */247247- mb();230230+ virtio_mb();248231249232 if (!(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY))250233 /* Prod other side to tell it about changes. */···303286 }304287305288 /* Only get used array entries after they have been exposed by host. */306306- rmb();289289+ virtio_rmb();307290308291 i = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].id;309292 *len = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].len;···341324 /* We optimistically turn back on interrupts, then check if there was342325 * more to do. */343326 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;344344- mb();327327+ virtio_mb();345328 if (unlikely(more_used(vq))) {346329 END_USE(vq);347330 return false;···349332350333 END_USE(vq);351334 return true;335335+}336336+337337+static void *vring_detach_unused_buf(struct virtqueue *_vq)338338+{339339+ struct vring_virtqueue *vq = to_vvq(_vq);340340+ unsigned int i;341341+ void *buf;342342+343343+ START_USE(vq);344344+345345+ for (i = 0; i < vq->vring.num; i++) {346346+ if (!vq->data[i])347347+ continue;348348+ /* detach_buf clears data, so grab it now. */349349+ buf = vq->data[i];350350+ detach_buf(vq, i);351351+ END_USE(vq);352352+ return buf;353353+ }354354+ /* That should have freed everything. */355355+ BUG_ON(vq->num_free != vq->vring.num);356356+357357+ END_USE(vq);358358+ return NULL;352359}353360354361irqreturn_t vring_interrupt(int irq, void *_vq)···401360 .kick = vring_kick,402361 .disable_cb = vring_disable_cb,403362 .enable_cb = vring_enable_cb,363363+ .detach_unused_buf = vring_detach_unused_buf,404364};405365406366struct virtqueue *vring_new_virtqueue(unsigned int num,···448406 /* Put everything in free lists. */449407 vq->num_free = num;450408 vq->free_head = 0;451451- for (i = 0; i < num-1; i++)409409+ for (i = 0; i < num-1; i++) {452410 vq->vring.desc[i].next = i+1;411411+ vq->data[i] = NULL;412412+ }413413+ vq->data[i] = NULL;453414454415 return &vq->vq;455416}
+7-6
drivers/watchdog/bfin_wdt.c
···11/*22 * Blackfin On-Chip Watchdog Driver33- * Supports BF53[123]/BF53[467]/BF54[2489]/BF56143 *54 * Originally based on softdog.c66- * Copyright 2006-2007 Analog Devices Inc.55+ * Copyright 2006-2010 Analog Devices Inc.76 * Copyright 2006-2007 Michele d'Amico87 * Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>98 *···136137 */137138static int bfin_wdt_set_timeout(unsigned long t)138139{139139- u32 cnt;140140+ u32 cnt, max_t, sclk;140141 unsigned long flags;141142142142- stampit();143143+ sclk = get_sclk();144144+ max_t = -1 / sclk;145145+ cnt = t * sclk;146146+ stamp("maxtimeout=%us newtimeout=%lus (cnt=%#x)", max_t, t, cnt);143147144144- cnt = t * get_sclk();145145- if (cnt < get_sclk()) {148148+ if (t > max_t) {146149 printk(KERN_WARNING PFX "timeout value is too large\n");147150 return -EINVAL;148151 }
+11-1
fs/cachefiles/namei.c
···348348 dir = dget_parent(object->dentry);349349350350 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);351351- ret = cachefiles_bury_object(cache, dir, object->dentry);351351+352352+ /* we need to check that our parent is _still_ our parent - it may have353353+ * been renamed */354354+ if (dir == object->dentry->d_parent) {355355+ ret = cachefiles_bury_object(cache, dir, object->dentry);356356+ } else {357357+ /* it got moved, presumably by cachefilesd culling it, so it's358358+ * no longer in the key path and we can ignore it */359359+ mutex_unlock(&dir->d_inode->i_mutex);360360+ ret = 0;361361+ }352362353363 dput(dir);354364 _leave(" = %d", ret);
-1
fs/exec.c
···637637 * will align it up.638638 */639639 rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;640640- rlim_stack = min(rlim_stack, stack_size);641640#ifdef CONFIG_STACK_GROWSUP642641 if (stack_size + stack_expand > rlim_stack)643642 stack_base = vma->vm_start + rlim_stack;
+12-2
fs/namei.c
···823823}824824825825/*826826+ * This is a temporary kludge to deal with "automount" symlinks; proper827827+ * solution is to trigger them on follow_mount(), so that do_lookup()828828+ * would DTRT. To be killed before 2.6.34-final.829829+ */830830+static inline int follow_on_final(struct inode *inode, unsigned lookup_flags)831831+{832832+ return inode && unlikely(inode->i_op->follow_link) &&833833+ ((lookup_flags & LOOKUP_FOLLOW) || S_ISDIR(inode->i_mode));834834+}835835+836836+/*826837 * Name resolution.827838 * This is the basic name resolution function, turning a pathname into828839 * the final dentry. We expect 'base' to be positive and a directory.···953942 if (err)954943 break;955944 inode = next.dentry->d_inode;956956- if ((lookup_flags & LOOKUP_FOLLOW)957957- && inode && inode->i_op->follow_link) {945945+ if (follow_on_final(inode, lookup_flags)) {958946 err = do_follow_link(&next, nd);959947 if (err)960948 goto return_err;
···8181 if (!sd_attrs)8282 return -ENOMEM;8383 sd->s_iattr = sd_attrs;8484- } else {8585- /* attributes were changed at least once in past */8686- iattrs = &sd_attrs->ia_iattr;8484+ }8585+ /* attributes were changed at least once in past */8686+ iattrs = &sd_attrs->ia_iattr;87878888- if (ia_valid & ATTR_UID)8989- iattrs->ia_uid = iattr->ia_uid;9090- if (ia_valid & ATTR_GID)9191- iattrs->ia_gid = iattr->ia_gid;9292- if (ia_valid & ATTR_ATIME)9393- iattrs->ia_atime = iattr->ia_atime;9494- if (ia_valid & ATTR_MTIME)9595- iattrs->ia_mtime = iattr->ia_mtime;9696- if (ia_valid & ATTR_CTIME)9797- iattrs->ia_ctime = iattr->ia_ctime;9898- if (ia_valid & ATTR_MODE) {9999- umode_t mode = iattr->ia_mode;100100- iattrs->ia_mode = sd->s_mode = mode;101101- }8888+ if (ia_valid & ATTR_UID)8989+ iattrs->ia_uid = iattr->ia_uid;9090+ if (ia_valid & ATTR_GID)9191+ iattrs->ia_gid = iattr->ia_gid;9292+ if (ia_valid & ATTR_ATIME)9393+ iattrs->ia_atime = iattr->ia_atime;9494+ if (ia_valid & ATTR_MTIME)9595+ iattrs->ia_mtime = iattr->ia_mtime;9696+ if (ia_valid & ATTR_CTIME)9797+ iattrs->ia_ctime = iattr->ia_ctime;9898+ if (ia_valid & ATTR_MODE) {9999+ umode_t mode = iattr->ia_mode;100100+ iattrs->ia_mode = sd->s_mode = mode;102101 }103102 return 0;104103}
+5-1
include/linux/amba/bus.h
···11/*22- * linux/include/asm-arm/hardware/amba.h22+ * linux/include/amba/bus.h33+ *44+ * This device type deals with ARM PrimeCells and anything else that55+ * presents a proper CID (0xB105F00D) at the end of the I/O register66+ * region or that is derived from a PrimeCell.37 *48 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.59 *
···1919#include <linux/bitops.h>2020#include <linux/kref.h>2121#include <linux/mod_devicetable.h>2222+#include <linux/spinlock.h>2323+2424+#include <asm/byteorder.h>2525+2626+#ifdef CONFIG_OF22272328typedef u32 phandle;2429typedef u32 ihandle;···4439struct device_node {4540 const char *name;4641 const char *type;4747- phandle node;4848-#if !defined(CONFIG_SPARC)4949- phandle linux_phandle;5050-#endif4242+ phandle phandle;5143 char *full_name;52445345 struct property *properties;···6563#endif6664};67656666+/* Pointer for first entry in chain of all nodes. */6767+extern struct device_node *allnodes;6868+extern struct device_node *of_chosen;6969+extern rwlock_t devtree_lock;7070+6871static inline int of_node_check_flag(struct device_node *n, unsigned long flag)6972{7073 return test_bit(flag, &n->_flags);···7871static inline void of_node_set_flag(struct device_node *n, unsigned long flag)7972{8073 set_bit(flag, &n->_flags);8181-}8282-8383-static inline void8484-set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)8585-{8686- dn->pde = de;8774}88758976extern struct device_node *of_find_all_nodes(struct device_node *prev);···102101 */103102104103/* Helper to read a big number; size is in cells (not bytes) */105105-static inline u64 of_read_number(const u32 *cell, int size)104104+static inline u64 of_read_number(const __be32 *cell, int size)106105{107106 u64 r = 0;108107 while (size--)109109- r = (r << 32) | *(cell++);108108+ r = (r << 32) | be32_to_cpu(*(cell++));110109 return r;111110}112111113112/* Like of_read_number, but we want an unsigned long result */114114-#ifdef CONFIG_PPC32115115-static inline unsigned long of_read_ulong(const u32 *cell, int size)113113+static inline unsigned long of_read_ulong(const __be32 *cell, int size)116114{117117- return cell[size-1];115115+ /* toss away upper bits if unsigned long is smaller than u64 */116116+ return of_read_number(cell, size);118117}119119-#else120120-#define of_read_ulong(cell, size) of_read_number(cell, size)121121-#endif122118123119#include <asm/prom.h>120120+121121+/* Default #address and #size cells. Allow arch asm/prom.h to override */122122+#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT)123123+#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1124124+#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1125125+#endif126126+127127+/* Default string compare functions, Allow arch asm/prom.h to override */128128+#if !defined(of_compat_cmp)129129+#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))130130+#define of_prop_cmp(s1, s2) strcmp((s1), (s2))131131+#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))132132+#endif124133125134/* flag descriptions */126135#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */···198187 const char *list_name, const char *cells_name, int index,199188 struct device_node **out_node, const void **out_args);200189190190+extern int of_machine_is_compatible(const char *compat);191191+192192+extern int prom_add_property(struct device_node* np, struct property* prop);193193+extern int prom_remove_property(struct device_node *np, struct property *prop);194194+extern int prom_update_property(struct device_node *np,195195+ struct property *newprop,196196+ struct property *oldprop);197197+198198+#if defined(CONFIG_OF_DYNAMIC)199199+/* For updating the device tree at runtime */200200+extern void of_attach_node(struct device_node *);201201+extern void of_detach_node(struct device_node *);202202+#endif203203+204204+#endif /* CONFIG_OF */201205#endif /* _LINUX_OF_H */
+46-29
include/linux/of_fdt.h
···4242 * ends when size is 04343 */4444struct boot_param_header {4545- u32 magic; /* magic word OF_DT_HEADER */4646- u32 totalsize; /* total size of DT block */4747- u32 off_dt_struct; /* offset to structure */4848- u32 off_dt_strings; /* offset to strings */4949- u32 off_mem_rsvmap; /* offset to memory reserve map */5050- u32 version; /* format version */5151- u32 last_comp_version; /* last compatible version */4545+ __be32 magic; /* magic word OF_DT_HEADER */4646+ __be32 totalsize; /* total size of DT block */4747+ __be32 off_dt_struct; /* offset to structure */4848+ __be32 off_dt_strings; /* offset to strings */4949+ __be32 off_mem_rsvmap; /* offset to memory reserve map */5050+ __be32 version; /* format version */5151+ __be32 last_comp_version; /* last compatible version */5252 /* version 2 fields below */5353- u32 boot_cpuid_phys; /* Physical CPU id we're booting on */5353+ __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */5454 /* version 3 fields below */5555- u32 dt_strings_size; /* size of the DT strings block */5555+ __be32 dt_strings_size; /* size of the DT strings block */5656 /* version 17 fields below */5757- u32 dt_struct_size; /* size of the DT structure block */5757+ __be32 dt_struct_size; /* size of the DT structure block */5858};59596060+/* TBD: Temporary export of fdt globals - remove when code fully merged */6161+extern int __initdata dt_root_addr_cells;6262+extern int __initdata dt_root_size_cells;6363+extern struct boot_param_header *initial_boot_params;6464+6065/* For scanning the flat device-tree at boot time */6161-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,6262- const char *uname, int depth,6363- void *data),6464- void *data);6565-extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name,6666- unsigned long *size);6767-extern int __init of_flat_dt_is_compatible(unsigned long node,6868- const char *name);6969-extern unsigned long __init of_get_flat_dt_root(void);6666+extern char *find_flat_dt_string(u32 offset);6767+extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,6868+ int depth, void *data),6969+ void *data);7070+extern void *of_get_flat_dt_prop(unsigned long node, const char *name,7171+ unsigned long *size);7272+extern int of_flat_dt_is_compatible(unsigned long node, const char *name);7373+extern unsigned long of_get_flat_dt_root(void);7474+extern void early_init_dt_scan_chosen_arch(unsigned long node);7575+extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,7676+ int depth, void *data);7777+extern void early_init_dt_check_for_initrd(unsigned long node);7878+extern int early_init_dt_scan_memory(unsigned long node, const char *uname,7979+ int depth, void *data);8080+extern void early_init_dt_add_memory_arch(u64 base, u64 size);8181+extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align);8282+extern u64 dt_mem_next_cell(int s, __be32 **cellp);8383+8484+/*8585+ * If BLK_DEV_INITRD, the fdt early init code will call this function,8686+ * to be provided by the arch code. start and end are specified as8787+ * physical addresses.8888+ */8989+#ifdef CONFIG_BLK_DEV_INITRD9090+extern void early_init_dt_setup_initrd_arch(unsigned long start,9191+ unsigned long end);9292+#endif9393+9494+/* Early flat tree scan hooks */9595+extern int early_init_dt_scan_root(unsigned long node, const char *uname,9696+ int depth, void *data);70977198/* Other Prototypes */7272-extern void finish_device_tree(void);7399extern void unflatten_device_tree(void);74100extern void early_init_devtree(void *);7575-extern int machine_is_compatible(const char *compat);7676-extern void print_properties(struct device_node *node);7777-extern int prom_n_intr_cells(struct device_node* np);7878-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);7979-extern int prom_add_property(struct device_node* np, struct property* prop);8080-extern int prom_remove_property(struct device_node *np, struct property *prop);8181-extern int prom_update_property(struct device_node *np,8282- struct property *newprop,8383- struct property *oldprop);8410185102#endif /* __ASSEMBLY__ */86103#endif /* _LINUX_OF_FDT_H */
+5
include/linux/spi/dw_spi.h
···9090 unsigned long paddr;9191 u32 iolen;9292 int irq;9393+ u32 fifo_len; /* depth of the FIFO buffer */9394 u32 max_freq; /* max bus freq supported */94959596 u16 bus_num;···172171{173172 if (cs > dws->num_cs)174173 return;174174+175175+ if (dws->cs_control)176176+ dws->cs_control(1);177177+175178 dw_writel(dws, ser, 1 << cs);176179}177180
+4
include/linux/virtio.h
···5151 * This re-enables callbacks; it returns "false" if there are pending5252 * buffers in the queue, to detect a possible race between the driver5353 * checking for more work, and enabling callbacks.5454+ * @detach_unused_buf: detach first unused buffer5555+ * vq: the struct virtqueue we're talking about.5656+ * Returns NULL or the "data" token handed to add_buf5457 *5558 * Locking rules are straightforward: the driver is responsible for5659 * locking. No two operations may be invoked simultaneously, with the exception···74717572 void (*disable_cb)(struct virtqueue *vq);7673 bool (*enable_cb)(struct virtqueue *vq);7474+ void *(*detach_unused_buf)(struct virtqueue *vq);7775};78767977/**
+15
include/linux/virtio_balloon.h
···7788/* The feature bitmap for virtio balloon */99#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */1010+#define VIRTIO_BALLOON_F_STATS_VQ 1 /* Memory Stats virtqueue */10111112/* Size of a PFN in the balloon interface. */1213#define VIRTIO_BALLOON_PFN_SHIFT 12···1918 /* Number of pages we've actually got in balloon. */2019 __le32 actual;2120};2121+2222+#define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */2323+#define VIRTIO_BALLOON_S_SWAP_OUT 1 /* Amount of memory swapped out */2424+#define VIRTIO_BALLOON_S_MAJFLT 2 /* Number of major faults */2525+#define VIRTIO_BALLOON_S_MINFLT 3 /* Number of minor faults */2626+#define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */2727+#define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */2828+#define VIRTIO_BALLOON_S_NR 62929+3030+struct virtio_balloon_stat {3131+ u16 tag;3232+ u64 val;3333+} __attribute__((packed));3434+2235#endif /* _LINUX_VIRTIO_BALLOON_H */
+13
include/linux/virtio_blk.h
···1515#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/1616#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */1717#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */1818+#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */18191920struct virtio_blk_config {2021 /* The capacity (in 512-byte sectors). */···3029 __u8 heads;3130 __u8 sectors;3231 } geometry;3232+3333 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */3434 __u32 blk_size;3535+3636+ /* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */3737+ /* exponent for physical block per logical block. */3838+ __u8 physical_block_exp;3939+ /* alignment offset in logical blocks. */4040+ __u8 alignment_offset;4141+ /* minimum I/O size without performance penalty in logical blocks. */4242+ __u16 min_io_size;4343+ /* optimal sustained I/O size in logical blocks. */4444+ __u32 opt_io_size;4545+3546} __attribute__((packed));36473748/*
+28-2
include/linux/virtio_console.h
···33#include <linux/types.h>44#include <linux/virtio_ids.h>55#include <linux/virtio_config.h>66-/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so77- * anyone can use the definitions to implement compatible drivers/servers. */66+/*77+ * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so88+ * anyone can use the definitions to implement compatible drivers/servers.99+ *1010+ * Copyright (C) Red Hat, Inc., 2009, 20101111+ */812913/* Feature bits */1014#define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */1515+#define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */11161217struct virtio_console_config {1318 /* colums of the screens */1419 __u16 cols;1520 /* rows of the screens */1621 __u16 rows;2222+ /* max. number of ports this device can hold */2323+ __u32 max_nr_ports;2424+ /* number of ports added so far */2525+ __u32 nr_ports;1726} __attribute__((packed));18272828+/*2929+ * A message that's passed between the Host and the Guest for a3030+ * particular port.3131+ */3232+struct virtio_console_control {3333+ __u32 id; /* Port number */3434+ __u16 event; /* The kind of control event (see below) */3535+ __u16 value; /* Extra information for the key */3636+};3737+3838+/* Some events for control messages */3939+#define VIRTIO_CONSOLE_PORT_READY 04040+#define VIRTIO_CONSOLE_CONSOLE_PORT 14141+#define VIRTIO_CONSOLE_RESIZE 24242+#define VIRTIO_CONSOLE_PORT_OPEN 34343+#define VIRTIO_CONSOLE_PORT_NAME 44444+#define VIRTIO_CONSOLE_PORT_REMOVE 519452046#ifdef __KERNEL__2147int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int));
···32593259 task_event->event_id.tid = perf_event_tid(event, task);32603260 task_event->event_id.ptid = perf_event_tid(event, current);3261326132623262- task_event->event_id.time = perf_clock();32633263-32643262 perf_output_put(&handle, task_event->event_id);3265326332663264 perf_output_end(&handle);···3266326832673269static int perf_event_task_match(struct perf_event *event)32683270{32693269- if (event->state != PERF_EVENT_STATE_ACTIVE)32713271+ if (event->state < PERF_EVENT_STATE_INACTIVE)32703272 return 0;3271327332723274 if (event->cpu != -1 && event->cpu != smp_processor_id())···32983300 cpuctx = &get_cpu_var(perf_cpu_context);32993301 perf_event_task_ctx(&cpuctx->ctx, task_event);33003302 if (!ctx)33013301- ctx = rcu_dereference(task_event->task->perf_event_ctxp);33033303+ ctx = rcu_dereference(current->perf_event_ctxp);33023304 if (ctx)33033305 perf_event_task_ctx(ctx, task_event);33043306 put_cpu_var(perf_cpu_context);···33293331 /* .ppid */33303332 /* .tid */33313333 /* .ptid */33343334+ .time = perf_clock(),33323335 },33333336 };33343337···3379338033803381static int perf_event_comm_match(struct perf_event *event)33813382{33823382- if (event->state != PERF_EVENT_STATE_ACTIVE)33833383+ if (event->state < PERF_EVENT_STATE_INACTIVE)33833384 return 0;3384338533853386 if (event->cpu != -1 && event->cpu != smp_processor_id())···34993500static int perf_event_mmap_match(struct perf_event *event,35003501 struct perf_mmap_event *mmap_event)35013502{35023502- if (event->state != PERF_EVENT_STATE_ACTIVE)35033503+ if (event->state < PERF_EVENT_STATE_INACTIVE)35033504 return 0;3504350535053506 if (event->cpu != -1 && event->cpu != smp_processor_id())
+2
kernel/sys.c
···222222 if (which > PRIO_USER || which < PRIO_PROCESS)223223 return -EINVAL;224224225225+ rcu_read_lock();225226 read_lock(&tasklist_lock);226227 switch (which) {227228 case PRIO_PROCESS:···268267 }269268out_unlock:270269 read_unlock(&tasklist_lock);270270+ rcu_read_unlock();271271272272 return retval;273273}
+3-1
lib/idr.c
···156156 id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;157157158158 /* if already at the top layer, we need to grow */159159- if (!(p = pa[l])) {159159+ if (id >= 1 << (idp->layers * IDR_BITS)) {160160 *starting_id = id;161161 return IDR_NEED_TO_GROW;162162 }163163+ p = pa[l];164164+ BUG_ON(!p);163165164166 /* If we need to go up one layer, continue the165167 * loop; otherwise, restart from the top.
+15-21
mm/migrate.c
···10021002#define DO_PAGES_STAT_CHUNK_NR 1610031003 const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];10041004 int chunk_status[DO_PAGES_STAT_CHUNK_NR];10051005- unsigned long i, chunk_nr = DO_PAGES_STAT_CHUNK_NR;10061006- int err;1007100510081008- for (i = 0; i < nr_pages; i += chunk_nr) {10091009- if (chunk_nr > nr_pages - i)10101010- chunk_nr = nr_pages - i;10061006+ while (nr_pages) {10071007+ unsigned long chunk_nr;1011100810121012- err = copy_from_user(chunk_pages, &pages[i],10131013- chunk_nr * sizeof(*chunk_pages));10141014- if (err) {10151015- err = -EFAULT;10161016- goto out;10171017- }10091009+ chunk_nr = nr_pages;10101010+ if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)10111011+ chunk_nr = DO_PAGES_STAT_CHUNK_NR;10121012+10131013+ if (copy_from_user(chunk_pages, pages, chunk_nr * sizeof(*chunk_pages)))10141014+ break;1018101510191016 do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status);1020101710211021- err = copy_to_user(&status[i], chunk_status,10221022- chunk_nr * sizeof(*chunk_status));10231023- if (err) {10241024- err = -EFAULT;10251025- goto out;10261026- }10271027- }10281028- err = 0;10181018+ if (copy_to_user(status, chunk_status, chunk_nr * sizeof(*status)))10191019+ break;1029102010301030-out:10311031- return err;10211021+ pages += chunk_nr;10221022+ status += chunk_nr;10231023+ nr_pages -= chunk_nr;10241024+ }10251025+ return nr_pages ? -EFAULT : 0;10321026}1033102710341028/*
+2
mm/oom_kill.c
···459459 list_for_each_entry(c, &p->children, sibling) {460460 if (c->mm == p->mm)461461 continue;462462+ if (mem && !task_in_mem_cgroup(c, mem))463463+ continue;462464 if (!oom_kill_task(c))463465 return 0;464466 }
···27612761 switch (ret) {27622762 case GRO_NORMAL:27632763 case GRO_HELD:27642764- skb->protocol = eth_type_trans(skb, napi->dev);27642764+ skb->protocol = eth_type_trans(skb, skb->dev);2765276527662766 if (ret == GRO_HELD)27672767 skb_gro_pull(skb, -ETH_HLEN);
+1
net/core/ethtool.c
···927927 case ETHTOOL_GPERMADDR:928928 case ETHTOOL_GUFO:929929 case ETHTOOL_GGSO:930930+ case ETHTOOL_GGRO:930931 case ETHTOOL_GFLAGS:931932 case ETHTOOL_GPFLAGS:932933 case ETHTOOL_GRXFH:
+2-1
net/core/net-sysfs.c
···410410 const struct iw_statistics *iw;411411 ssize_t ret = -EINVAL;412412413413- rtnl_lock();413413+ if (!rtnl_trylock())414414+ return restart_syscall();414415 if (dev_isalive(dev)) {415416 iw = get_wireless_stats(dev);416417 if (iw)
+6-1
net/ipv4/devinet.c
···13171317{13181318 int *valp = ctl->data;13191319 int val = *valp;13201320+ loff_t pos = *ppos;13201321 int ret = proc_dointvec(ctl, write, buffer, lenp, ppos);1321132213221323 if (write && *valp != val) {13231324 struct net *net = ctl->extra2;1324132513251326 if (valp != &IPV4_DEVCONF_DFLT(net, FORWARDING)) {13261326- if (!rtnl_trylock())13271327+ if (!rtnl_trylock()) {13281328+ /* Restore the original values before restarting */13291329+ *valp = val;13301330+ *ppos = pos;13271331 return restart_syscall();13321332+ }13281333 if (valp == &IPV4_DEVCONF_ALL(net, FORWARDING)) {13291334 inet_forward_change(net);13301335 } else if (*valp) {
+1-1
net/ipv4/igmp.c
···946946 break;947947 case IGMP_HOST_MEMBERSHIP_REPORT:948948 case IGMPV2_HOST_MEMBERSHIP_REPORT:949949- case IGMPV3_HOST_MEMBERSHIP_REPORT:950949 /* Is it our report looped back? */951950 if (skb_rtable(skb)->fl.iif == 0)952951 break;···959960 in_dev_put(in_dev);960961 return pim_rcv_v1(skb);961962#endif963963+ case IGMPV3_HOST_MEMBERSHIP_REPORT:962964 case IGMP_DVMRP:963965 case IGMP_TRACE:964966 case IGMP_HOST_LEAVE_MESSAGE:
···5783578357845784 /* tcp_ack considers this ACK as duplicate57855785 * and does not calculate rtt.57865786- * Fix it at least with timestamps.57865786+ * Force it here.57875787 */57885788- if (tp->rx_opt.saw_tstamp &&57895789- tp->rx_opt.rcv_tsecr && !tp->srtt)57905790- tcp_ack_saw_tstamp(sk, 0);57885788+ tcp_ack_update_rtt(sk, 0, 0);5791578957925790 if (tp->rx_opt.tstamp_ok)57935791 tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;
+14-2
net/ipv6/addrconf.c
···502502 if (p == &net->ipv6.devconf_dflt->forwarding)503503 return 0;504504505505- if (!rtnl_trylock())505505+ if (!rtnl_trylock()) {506506+ /* Restore the original values before restarting */507507+ *p = old;506508 return restart_syscall();509509+ }507510508511 if (p == &net->ipv6.devconf_all->forwarding) {509512 __s32 newf = net->ipv6.devconf_all->forwarding;···40314028{40324029 int *valp = ctl->data;40334030 int val = *valp;40314031+ loff_t pos = *ppos;40344032 int ret;4035403340364034 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);4037403540384036 if (write)40394037 ret = addrconf_fixup_forwarding(ctl, valp, val);40384038+ if (ret)40394039+ *ppos = pos;40404040 return ret;40414041}40424042···40814075 if (p == &net->ipv6.devconf_dflt->disable_ipv6)40824076 return 0;4083407740844084- if (!rtnl_trylock())40784078+ if (!rtnl_trylock()) {40794079+ /* Restore the original values before restarting */40804080+ *p = old;40854081 return restart_syscall();40824082+ }4086408340874084 if (p == &net->ipv6.devconf_all->disable_ipv6) {40884085 __s32 newf = net->ipv6.devconf_all->disable_ipv6;···41044095{41054096 int *valp = ctl->data;41064097 int val = *valp;40984098+ loff_t pos = *ppos;41074099 int ret;4108410041094101 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);4110410241114103 if (write)41124104 ret = addrconf_disable_ipv6(ctl, valp, val);41054105+ if (ret)41064106+ *ppos = pos;41134107 return ret;41144108}41154109
···11-/***************************************************************************22- * binoffset.c33- * (C) 2002 Randy Dunlap <rdunlap@xenotime.net>44-55-# This program is free software; you can redistribute it and/or modify66-# it under the terms of the GNU General Public License as published by77-# the Free Software Foundation; either version 2 of the License, or88-# (at your option) any later version.99-#1010-# This program is distributed in the hope that it will be useful,1111-# but WITHOUT ANY WARRANTY; without even the implied warranty of1212-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313-# GNU General Public License for more details.1414-#1515-# You should have received a copy of the GNU General Public License1616-# along with this program; if not, write to the Free Software1717-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1818-1919-# binoffset.c:2020-# - searches a (binary) file for a specified (binary) pattern2121-# - returns the offset of the located pattern or ~0 if not found2222-# - exits with exit status 0 normally or non-0 if pattern is not found2323-# or any other error occurs.2424-2525-****************************************************************/2626-2727-#include <stdio.h>2828-#include <stdlib.h>2929-#include <string.h>3030-#include <errno.h>3131-#include <unistd.h>3232-#include <fcntl.h>3333-#include <sys/types.h>3434-#include <sys/stat.h>3535-#include <sys/mman.h>3636-3737-#define VERSION "0.1"3838-#define BUF_SIZE (16 * 1024)3939-#define PAT_SIZE 1004040-4141-char *progname;4242-char *inputname;4343-int inputfd;4444-unsigned int bix; /* buf index */4545-unsigned char patterns [PAT_SIZE] = {0}; /* byte-sized pattern array */4646-int pat_len; /* actual number of pattern bytes */4747-unsigned char *madr; /* mmap address */4848-size_t filesize;4949-int num_matches = 0;5050-off_t firstloc = 0;5151-5252-void usage (void)5353-{5454- fprintf (stderr, "%s ver. %s\n", progname, VERSION);5555- fprintf (stderr, "usage: %s filename pattern_bytes\n",5656- progname);5757- fprintf (stderr, " [prints location of pattern_bytes in file]\n");5858- exit (1);5959-}6060-6161-void get_pattern (int pat_count, char *pats [])6262-{6363- int ix, err, tmp;6464-6565-#ifdef DEBUG6666- fprintf (stderr,"get_pattern: count = %d\n", pat_count);6767- for (ix = 0; ix < pat_count; ix++)6868- fprintf (stderr, " pat # %d: [%s]\n", ix, pats[ix]);6969-#endif7070-7171- for (ix = 0; ix < pat_count; ix++) {7272- tmp = 0;7373- err = sscanf (pats[ix], "%5i", &tmp);7474- if (err != 1 || tmp > 0xff) {7575- fprintf (stderr, "pattern or value error in pattern # %d [%s]\n",7676- ix, pats[ix]);7777- usage ();7878- }7979- patterns [ix] = tmp;8080- }8181- pat_len = pat_count;8282-}8383-8484-void search_pattern (void)8585-{8686- for (bix = 0; bix < filesize; bix++) {8787- if (madr[bix] == patterns[0]) {8888- if (memcmp (&madr[bix], patterns, pat_len) == 0) {8989- if (num_matches == 0)9090- firstloc = bix;9191- num_matches++;9292- }9393- }9494- }9595-}9696-9797-#ifdef NOTDEF9898-size_t get_filesize (int fd)9999-{100100- off_t end_off = lseek (fd, 0, SEEK_END);101101- lseek (fd, 0, SEEK_SET);102102- return (size_t) end_off;103103-}104104-#endif105105-106106-size_t get_filesize (int fd)107107-{108108- int err;109109- struct stat stat;110110-111111- err = fstat (fd, &stat);112112- fprintf (stderr, "filesize: %ld\n", err < 0 ? (long)err : stat.st_size);113113- if (err < 0)114114- return err;115115- return (size_t) stat.st_size;116116-}117117-118118-int main (int argc, char *argv [])119119-{120120- progname = argv[0];121121-122122- if (argc < 3)123123- usage ();124124-125125- get_pattern (argc - 2, argv + 2);126126-127127- inputname = argv[1];128128-129129- inputfd = open (inputname, O_RDONLY);130130- if (inputfd == -1) {131131- fprintf (stderr, "%s: cannot open '%s'\n",132132- progname, inputname);133133- exit (3);134134- }135135-136136- filesize = get_filesize (inputfd);137137-138138- madr = mmap (0, filesize, PROT_READ, MAP_PRIVATE, inputfd, 0);139139- if (madr == MAP_FAILED) {140140- fprintf (stderr, "mmap error = %d\n", errno);141141- close (inputfd);142142- exit (4);143143- }144144-145145- search_pattern ();146146-147147- if (munmap (madr, filesize))148148- fprintf (stderr, "munmap error = %d\n", errno);149149-150150- if (close (inputfd))151151- fprintf (stderr, "%s: error %d closing '%s'\n",152152- progname, errno, inputname);153153-154154- fprintf (stderr, "number of pattern matches = %d\n", num_matches);155155- if (num_matches == 0)156156- firstloc = ~0;157157- printf ("%ld\n", firstloc);158158- fprintf (stderr, "%ld\n", firstloc);159159-160160- exit (num_matches ? 0 : 2);161161-}162162-163163-/* end binoffset.c */
+40-79
scripts/extract-ikconfig
···11#!/bin/sh22-# extracts .config info from a [b]zImage file33-# uses: binoffset (new), dd, zcat, strings, grep44-# $arg1 is [b]zImage filename22+# ----------------------------------------------------------------------33+# extract-ikconfig - Extract the .config file from a kernel image44+#55+# This will only work when the kernel was compiled with CONFIG_IKCONFIG.66+#77+# The obscure use of the "tr" filter is to work around older versions of88+# "grep" that report the byte offset of the line instead of the pattern.99+#1010+# (c) 2009, Dick Streefland <dick@streefland.net>1111+# Licensed under the terms of the GNU General Public License.1212+# ----------------------------------------------------------------------51366-binoffset="./scripts/binoffset"77-test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 11414+gz1='\037\213\010'1515+gz2='01'1616+cf1='IKCFG_ST\037\213\010'1717+cf2='0123456789'81899-IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"1010-IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"1111-dump_config() {1212- file="$1"1313-1414- start=`$binoffset $file $IKCFG_ST 2>/dev/null`1515- [ "$?" != "0" ] && start="-1"1616- if [ "$start" -eq "-1" ]; then1717- return1818- fi1919- end=`$binoffset $file $IKCFG_ED 2>/dev/null`2020- [ "$?" != "0" ] && end="-1"2121- if [ "$end" -eq "-1" ]; then2222- return2323- fi2424-2525- start=`expr $start + 8`2626- size=`expr $end - $start`2727-2828- dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat2929-3030- clean_up3131- exit 03232-}3333-3434-3535-usage()1919+dump_config()3620{3737- echo " usage: extract-ikconfig [b]zImage_filename"3838-}3939-4040-clean_up()4141-{4242- if [ "$TMPFILE" != "" ]; then4343- rm -f $TMPFILE2121+ if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`2222+ then2323+ pos=${pos%%:*}2424+ tail -c+$(($pos+8)) "$1" | zcat -q2525+ exit 04426 fi4527}46284747-if [ $# -lt 1 ]2929+# Check invocation:3030+me=${0##*/}3131+img=$13232+if [ $# -ne 1 -o ! -s "$img" ]4833then4949- usage5050- exit 13434+ echo "Usage: $me <kernel-image>" >&23535+ exit 25136fi52375353-TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 15454-image="$1"3838+# Initial attempt for uncompressed images or objects:3939+dump_config "$img"55405656-# vmlinux: Attempt to dump the configuration from the file directly5757-dump_config "$image"4141+# That didn't work, so decompress and try again:4242+tmp=/tmp/ikconfig$$4343+trap "rm -f $tmp" 04444+for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"`4545+do4646+ pos=${pos%%:*}4747+ tail -c+$pos "$img" | zcat 2> /dev/null > $tmp4848+ dump_config $tmp4949+done58505959-GZHDR1="0x1f 0x8b 0x08 0x00"6060-GZHDR2="0x1f 0x8b 0x08 0x08"6161-6262-ELFHDR="0x7f 0x45 0x4c 0x46"6363-6464-# vmlinux.gz: Check for a compressed images6565-off=`$binoffset "$image" $GZHDR1 2>/dev/null`6666-[ "$?" != "0" ] && off="-1"6767-if [ "$off" -eq "-1" ]; then6868- off=`$binoffset "$image" $GZHDR2 2>/dev/null`6969- [ "$?" != "0" ] && off="-1"7070-fi7171-if [ "$off" -eq "0" ]; then7272- zcat <"$image" >"$TMPFILE"7373- dump_config "$TMPFILE"7474-elif [ "$off" -ne "-1" ]; then7575- (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \7676- zcat >"$TMPFILE"7777- dump_config "$TMPFILE"7878-7979-# check if this is simply an ELF file8080-else8181- off=`$binoffset "$image" $ELFHDR 2>/dev/null`8282- [ "$?" != "0" ] && off="-1"8383- if [ "$off" -eq "0" ]; then8484- dump_config "$image"8585- fi8686-fi8787-8888-echo "ERROR: Unable to extract kernel configuration information."8989-echo " This kernel image may not have the config info."9090-9191-clean_up5151+# Bail out:5252+echo "$me: Cannot find kernel config." >&29253exit 1
···582582static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify)583583{584584 if (chip->auto_mute) {585585- int imac = machine_is_compatible("iMac");585585+ int imac = of_machine_is_compatible("iMac");586586 int reg, oreg;587587 reg = oreg = snd_pmac_burgundy_rcb(chip,588588 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES);···620620 */621621int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip)622622{623623- int imac = machine_is_compatible("iMac");623623+ int imac = of_machine_is_compatible("iMac");624624 int i, err;625625626626 /* Checks to see the chip is alive and kicking */
+9-9
sound/ppc/pmac.c
···922922 }923923924924 /* it seems the Pismo & iBook can't byte-swap in hardware. */925925- if (machine_is_compatible("PowerBook3,1") ||926926- machine_is_compatible("PowerBook2,1"))925925+ if (of_machine_is_compatible("PowerBook3,1") ||926926+ of_machine_is_compatible("PowerBook2,1"))927927 chip->can_byte_swap = 0 ;928928929929- if (machine_is_compatible("PowerBook2,1"))929929+ if (of_machine_is_compatible("PowerBook2,1"))930930 chip->can_duplex = 0;931931}932932···959959 chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */960960961961 /* check machine type */962962- if (machine_is_compatible("AAPL,3400/2400")963963- || machine_is_compatible("AAPL,3500"))962962+ if (of_machine_is_compatible("AAPL,3400/2400")963963+ || of_machine_is_compatible("AAPL,3500"))964964 chip->is_pbook_3400 = 1;965965- else if (machine_is_compatible("PowerBook1,1")966966- || machine_is_compatible("AAPL,PowerBook1998"))965965+ else if (of_machine_is_compatible("PowerBook1,1")966966+ || of_machine_is_compatible("AAPL,PowerBook1998"))967967 chip->is_pbook_G3 = 1;968968 chip->node = of_find_node_by_name(NULL, "awacs");969969 sound = of_node_get(chip->node);···10331033 }10341034 if (of_device_is_compatible(sound, "tumbler")) {10351035 chip->model = PMAC_TUMBLER;10361036- chip->can_capture = machine_is_compatible("PowerMac4,2")10371037- || machine_is_compatible("PowerBook4,1");10361036+ chip->can_capture = of_machine_is_compatible("PowerMac4,2")10371037+ || of_machine_is_compatible("PowerBook4,1");10381038 chip->can_duplex = 0;10391039 // chip->can_byte_swap = 0; /* FIXME: check this */10401040 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
+1-1
sound/soc/fsl/efika-audio-fabric.c
···5555 struct platform_device *pdev;5656 int rc;57575858- if (!machine_is_compatible("bplan,efika"))5858+ if (!of_machine_is_compatible("bplan,efika"))5959 return -ENODEV;60606161 card.platform = &mpc5200_audio_dma_platform;
+1-1
sound/soc/fsl/pcm030-audio-fabric.c
···5555 struct platform_device *pdev;5656 int rc;57575858- if (!machine_is_compatible("phytec,pcm030"))5858+ if (!of_machine_is_compatible("phytec,pcm030"))5959 return -ENODEV;60606161 card.platform = &mpc5200_audio_dma_platform;
+3
tools/perf/util/probe-event.c
···272272 int ret;273273274274 pp->probes[0] = buf = zalloc(MAX_CMDLEN);275275+ pp->found = 1;275276 if (!buf)276277 die("Failed to allocate memory by zalloc.");277278 if (pp->offset) {···295294error:296295 free(pp->probes[0]);297296 pp->probes[0] = NULL;297297+ pp->found = 0;298298 }299299 return ret;300300}···457455 struct strlist *rawlist;458456 struct str_node *ent;459457458458+ memset(&pp, 0, sizeof(pp));460459 fd = open_kprobe_events(O_RDONLY, 0);461460 rawlist = get_trace_kprobe_event_rawlist(fd);462461 close(fd);