···33 *44 * Copyright (c) 2005 IBM Corporation55 * Heiko J Schick <schickhj@de.ibm.com>66- * 66+ *77 * All rights reserved.88 *99- * This source code is distributed under a dual license of GPL v2.0 and OpenIB 1010- * BSD. 99+ * This source code is distributed under a dual license of GPL v2.0 and OpenIB1010+ * BSD.1111 *1212 * OpenIB BSD License1313 *1414- * Redistribution and use in source and binary forms, with or without 1515- * modification, are permitted provided that the following conditions are met: 1414+ * Redistribution and use in source and binary forms, with or without1515+ * modification, are permitted provided that the following conditions are met:1616 *1717- * Redistributions of source code must retain the above copyright notice, this 1818- * list of conditions and the following disclaimer. 1717+ * Redistributions of source code must retain the above copyright notice, this1818+ * list of conditions and the following disclaimer.1919 *2020- * Redistributions in binary form must reproduce the above copyright notice, 2121- * this list of conditions and the following disclaimer in the documentation 2020+ * Redistributions in binary form must reproduce the above copyright notice,2121+ * this list of conditions and the following disclaimer in the documentation2222 * and/or other materials2323- * provided with the distribution. 2323+ * provided with the distribution.2424 *2525- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2626- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2727- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2828- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2929- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3030- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2525+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"2626+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE2727+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2828+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE2929+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR3030+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF3131 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR3232 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER3333- * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3434- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3333+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)3434+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE3535 * POSSIBILITY OF SUCH DAMAGE.3636 */3737···5555 gfp_t flag)5656{5757 void *mem;5858-5858+5959 mem = kmalloc(size, flag);6060 *dma_handle = (dma_addr_t)mem;6161···6363}64646565static void ibmebus_free_coherent(struct device *dev,6666- size_t size, void *vaddr, 6666+ size_t size, void *vaddr,6767 dma_addr_t dma_handle)6868{6969 kfree(vaddr);···79798080static void ibmebus_unmap_single(struct device *dev,8181 dma_addr_t dma_addr,8282- size_t size, 8282+ size_t size,8383 enum dma_data_direction direction)8484{8585 return;···9090 int nents, enum dma_data_direction direction)9191{9292 int i;9393-9393+9494 for (i = 0; i < nents; i++) {9595- sg[i].dma_address = (dma_addr_t)page_address(sg[i].page) 9595+ sg[i].dma_address = (dma_addr_t)page_address(sg[i].page)9696 + sg[i].offset;9797 sg[i].dma_length = sg[i].length;9898 }9999-9999+100100 return nents;101101}102102···128128 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver);129129 const struct of_device_id *id;130130 int error = -ENODEV;131131-131131+132132 if (!ibmebusdrv->probe)133133 return error;134134-134134+135135 id = of_match_device(ibmebusdrv->id_table, &ibmebusdev->ofdev);136136 if (id) {137137 error = ibmebusdrv->probe(ibmebusdev, id);138138 }139139-139139+140140 return error;141141}142142···144144{145145 struct ibmebus_dev *ibmebusdev = to_ibmebus_dev(dev);146146 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver);147147-147147+148148 if (ibmebusdrv->remove) {149149 return ibmebusdrv->remove(ibmebusdev);150150 }151151-151151+152152 return 0;153153}154154···158158 kfree(to_ibmebus_dev(dev));159159}160160161161-static ssize_t ibmebusdev_show_name(struct device *dev, 161161+static ssize_t ibmebusdev_show_name(struct device *dev,162162 struct device_attribute *attr, char *buf)163163{164164 return sprintf(buf, "%s\n", to_ibmebus_dev(dev)->name);165165}166166-static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, ibmebusdev_show_name, 166166+static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, ibmebusdev_show_name,167167 NULL);168168169169static struct ibmebus_dev* __devinit ibmebus_register_device_common(···181181 dev->ofdev.dev.archdata.numa_node = of_node_to_nid(dev->ofdev.node);182182183183 /* An ibmebusdev is based on a of_device. We have to change the184184- * bus type to use our own DMA mapping operations. 185185- */ 184184+ * bus type to use our own DMA mapping operations.185185+ */186186 if ((err = of_device_register(&dev->ofdev)) != 0) {187187 printk(KERN_ERR "%s: failed to register device (%d).\n",188188 __FUNCTION__, err);189189 return NULL;190190 }191191-191191+192192 device_create_file(&dev->ofdev.dev, &dev_attr_name);193193-193193+194194 return dev;195195}196196···207207 __FUNCTION__, dn->name ? dn->name : "<unknown>");208208 return NULL;209209 }210210-210210+211211 if (strlen(loc_code) == 0) {212212 printk(KERN_WARNING "%s: 'ibm,loc-code' is invalid\n",213213 __FUNCTION__);···220220 }221221222222 dev->ofdev.node = of_node_get(dn);223223-223223+224224 length = strlen(loc_code);225225- memcpy(dev->ofdev.dev.bus_id, loc_code 226226- + (length - min(length, BUS_ID_SIZE - 1)), 225225+ memcpy(dev->ofdev.dev.bus_id, loc_code226226+ + (length - min(length, BUS_ID_SIZE - 1)),227227 min(length, BUS_ID_SIZE - 1));228228229229 /* Register with generic device framework. */···238238static void ibmebus_probe_of_nodes(char* name)239239{240240 struct device_node *dn = NULL;241241-241241+242242 while ((dn = of_find_node_by_name(dn, name))) {243243 if (ibmebus_register_device_node(dn) == NULL) {244244 of_node_put(dn);245245-245245+246246 return;247247 }248248 }249249-249249+250250 of_node_put(dn);251251-251251+252252 return;253253}254254···266266{267267 if (strcmp((char*)data, to_ibmebus_dev(dev)->name) == 0)268268 return 1;269269-269269+270270 return 0;271271}272272···281281static void ibmebus_remove_devices_by_id(struct of_device_id *idt)282282{283283 struct device *dev;284284-284284+285285 while (strlen(idt->name) > 0) {286286- while ((dev = bus_find_device(&ibmebus_bus_type, NULL, 286286+ while ((dev = bus_find_device(&ibmebus_bus_type, NULL,287287 (void*)idt->name,288288 ibmebus_match_helper))) {289289 ibmebus_unregister_device(dev);290290 }291291 idt++;292292-292292+293293 }294294-294294+295295 return;296296}297297···308308 return err;309309310310 ibmebus_add_devices_by_id(drv->id_table);311311-311311+312312 return 0;313313}314314EXPORT_SYMBOL(ibmebus_register_driver);315315316316void ibmebus_unregister_driver(struct ibmebus_driver *drv)317317-{ 317317+{318318 driver_unregister(&drv->driver);319319 ibmebus_remove_devices_by_id(drv->id_table);320320}321321EXPORT_SYMBOL(ibmebus_unregister_driver);322322323323int ibmebus_request_irq(struct ibmebus_dev *dev,324324- u32 ist, 324324+ u32 ist,325325 irq_handler_t handler,326326 unsigned long irq_flags, const char * devname,327327 void *dev_id)328328{329329 unsigned int irq = irq_create_mapping(NULL, ist);330330-330330+331331 if (irq == NO_IRQ)332332 return -EINVAL;333333-333333+334334 return request_irq(irq, handler,335335 irq_flags, devname, dev_id);336336}···339339void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id)340340{341341 unsigned int irq = irq_find_mapping(NULL, ist);342342-342342+343343 free_irq(irq, dev_id);344344}345345EXPORT_SYMBOL(ibmebus_free_irq);346346347347static int ibmebus_bus_match(struct device *dev, struct device_driver *drv)348348-{ 348348+{349349 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);350350 struct ibmebus_driver *ebus_drv = to_ibmebus_driver(drv);351351 const struct of_device_id *ids = ebus_drv->id_table;352352 const struct of_device_id *found_id;353353-353353+354354 if (!ids)355355 return 0;356356-356356+357357 found_id = of_match_device(ids, &ebus_dev->ofdev);358358 if (found_id)359359 return 1;360360-360360+361361 return 0;362362}363363···370370static int __init ibmebus_bus_init(void)371371{372372 int err;373373-373373+374374 printk(KERN_INFO "IBM eBus Device Driver\n");375375-375375+376376 err = bus_register(&ibmebus_bus_type);377377 if (err) {378378 printk(KERN_ERR ":%s: failed to register IBM eBus.\n",379379 __FUNCTION__);380380 return err;381381 }382382-382382+383383 err = device_register(&ibmebus_bus_device.ofdev.dev);384384 if (err) {385385- printk(KERN_WARNING "%s: device_register returned %i\n", 385385+ printk(KERN_WARNING "%s: device_register returned %i\n",386386 __FUNCTION__, err);387387 bus_unregister(&ibmebus_bus_type);388388389389 return err;390390 }391391-391391+392392 return 0;393393}394394__initcall(ibmebus_bus_init);
+21-21
include/asm-powerpc/ibmebus.h
···33 *44 * Copyright (c) 2005 IBM Corporation55 * Heiko J Schick <schickhj@de.ibm.com>66- * 66+ *77 * All rights reserved.88 *99- * This source code is distributed under a dual license of GPL v2.0 and OpenIB 1010- * BSD. 99+ * This source code is distributed under a dual license of GPL v2.0 and OpenIB1010+ * BSD.1111 *1212 * OpenIB BSD License1313 *1414- * Redistribution and use in source and binary forms, with or without 1515- * modification, are permitted provided that the following conditions are met: 1414+ * Redistribution and use in source and binary forms, with or without1515+ * modification, are permitted provided that the following conditions are met:1616 *1717- * Redistributions of source code must retain the above copyright notice, this 1818- * list of conditions and the following disclaimer. 1717+ * Redistributions of source code must retain the above copyright notice, this1818+ * list of conditions and the following disclaimer.1919 *2020- * Redistributions in binary form must reproduce the above copyright notice, 2121- * this list of conditions and the following disclaimer in the documentation 2020+ * Redistributions in binary form must reproduce the above copyright notice,2121+ * this list of conditions and the following disclaimer in the documentation2222 * and/or other materials2323- * provided with the distribution. 2323+ * provided with the distribution.2424 *2525- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2626- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2727- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2828- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2929- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3030- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2525+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"2626+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE2727+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2828+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE2929+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR3030+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF3131 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR3232 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER3333- * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3434- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3333+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)3434+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE3535 * POSSIBILITY OF SUCH DAMAGE.3636 */3737···46464747extern struct bus_type ibmebus_bus_type;48484949-struct ibmebus_dev { 4949+struct ibmebus_dev {5050 const char *name;5151 struct of_device ofdev;5252};53535454-struct ibmebus_driver { 5454+struct ibmebus_driver {5555 char *name;5656 struct of_device_id *id_table;5757 int (*probe) (struct ibmebus_dev *dev, const struct of_device_id *id);···6363void ibmebus_unregister_driver(struct ibmebus_driver *drv);64646565int ibmebus_request_irq(struct ibmebus_dev *dev,6666- u32 ist, 6666+ u32 ist,6767 irq_handler_t handler,6868 unsigned long irq_flags, const char * devname,6969 void *dev_id);