diff --git a/[refs] b/[refs] index 130902c9d358..3d721473f634 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c4f9e64456ae3ed6f6c8df07cc903a292c755991 +refs/heads/master: 8e3829c61b489933e58f671ac111a2f1980563d4 diff --git a/trunk/drivers/staging/asus_oled/asus_oled.c b/trunk/drivers/staging/asus_oled/asus_oled.c index 42a5e7ab5122..f63c1d3aeb64 100644 --- a/trunk/drivers/staging/asus_oled/asus_oled.c +++ b/trunk/drivers/staging/asus_oled/asus_oled.c @@ -42,6 +42,8 @@ #define ASUS_OLED_NAME "asus-oled" #define ASUS_OLED_UNDERSCORE_NAME "asus_oled" +#define ASUS_OLED_ERROR "Asus OLED Display Error: " + #define ASUS_OLED_STATIC 's' #define ASUS_OLED_ROLL 'r' #define ASUS_OLED_FLASH 'f' @@ -55,9 +57,8 @@ #define USB_DEVICE_ID_ASUS_LCM2 0x175b MODULE_AUTHOR("Jakub Schmidtke, sjakub@gmail.com"); -MODULE_DESCRIPTION("Asus OLED Driver"); +MODULE_DESCRIPTION("Asus OLED Driver v" ASUS_OLED_VERSION); MODULE_LICENSE("GPL"); -MODULE_VERSION(ASUS_OLED_VERSION); static struct class *oled_class; static int oled_num; @@ -382,13 +383,13 @@ static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count) default: i = 0; - dev_err(odev->dev, "Unknown OLED Pack Mode: %d!\n", + printk(ASUS_OLED_ERROR "Unknown OLED Pack Mode: %d!\n", odev->pack_mode); break; } if (i >= odev->buf_size) { - dev_err(odev->dev, "Buffer overflow! Report a bug:" + printk(ASUS_OLED_ERROR "Buffer overflow! Report a bug:" "offs: %d >= %d i: %d (x: %d y: %d)\n", (int) odev->buf_offs, (int) odev->buf_size, (int) i, (int) x, (int) y); @@ -434,7 +435,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, odev->buf = kmalloc(odev->buf_size, GFP_KERNEL); if (odev->buf == NULL) { odev->buf_size = 0; - dev_err(odev->dev, "Out of memory!\n"); + printk(ASUS_OLED_ERROR "Out of memory!\n"); return -ENOMEM; } @@ -472,7 +473,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, odev->pic_mode = buf[1]; break; default: - dev_err(odev->dev, "Wrong picture mode: '%c'.\n", + printk(ASUS_OLED_ERROR "Wrong picture mode: '%c'.\n", buf[1]); return -EIO; break; @@ -532,7 +533,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, if (odev->buf == NULL) { odev->buf_size = 0; - dev_err(odev->dev, "Out of memory!\n"); + printk(ASUS_OLED_ERROR "Out of memory!\n"); return -ENOMEM; } @@ -592,15 +593,15 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, return count; error_width: - dev_err(odev->dev, "Wrong picture width specified.\n"); + printk(ASUS_OLED_ERROR "Wrong picture width specified.\n"); return -EIO; error_height: - dev_err(odev->dev, "Wrong picture height specified.\n"); + printk(ASUS_OLED_ERROR "Wrong picture height specified.\n"); return -EIO; error_header: - dev_err(odev->dev, "Wrong picture header.\n"); + printk(ASUS_OLED_ERROR "Wrong picture header.\n"); return -EIO; } diff --git a/trunk/drivers/staging/comedi/comedi_fops.c b/trunk/drivers/staging/comedi/comedi_fops.c index 7a76f9c07afd..e82126407e95 100644 --- a/trunk/drivers/staging/comedi/comedi_fops.c +++ b/trunk/drivers/staging/comedi/comedi_fops.c @@ -882,12 +882,14 @@ static int check_insn_config_length(struct comedi_insn *insn, /* by default we allow the insn since we don't have checks for * all possible cases yet */ default: - pr_warn("comedi: No check for data length of config insn id %i is implemented.\n", - data[0]); - pr_warn("comedi: Add a check to %s in %s.\n", - __func__, __FILE__); - pr_warn("comedi: Assuming n=%i is correct.\n", insn->n); + printk(KERN_WARNING + "comedi: no check for data length of config insn id " + "%i is implemented.\n" + " Add a check to %s in %s.\n" + " Assuming n=%i is correct.\n", data[0], __func__, + __FILE__, insn->n); return 0; + break; } return -EINVAL; } @@ -2032,8 +2034,8 @@ void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s) comedi_reset_async_buf(async); async->inttrig = NULL; } else { - dev_err(dev->class_dev, - "BUG: (?) do_become_nonbusy called with async=NULL\n"); + printk(KERN_ERR + "BUG: (?) do_become_nonbusy called with async=0\n"); } s->busy = NULL; @@ -2209,12 +2211,14 @@ static int __init comedi_init(void) int i; int retval; - pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n"); + printk(KERN_INFO "comedi: version " COMEDI_RELEASE + " - http://www.comedi.org\n"); if (comedi_num_legacy_minors < 0 || comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) { - pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\". Valid values are 0 through %i.\n", - COMEDI_NUM_BOARD_MINORS); + printk(KERN_ERR "comedi: error: invalid value for module " + "parameter \"comedi_num_legacy_minors\". Valid values " + "are 0 through %i.\n", COMEDI_NUM_BOARD_MINORS); return -EINVAL; } @@ -2243,7 +2247,7 @@ static int __init comedi_init(void) } comedi_class = class_create(THIS_MODULE, "comedi"); if (IS_ERR(comedi_class)) { - pr_err("comedi: failed to create class\n"); + printk(KERN_ERR "comedi: failed to create class"); cdev_del(&comedi_cdev); unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); @@ -2291,7 +2295,8 @@ module_exit(comedi_cleanup); void comedi_error(const struct comedi_device *dev, const char *s) { - dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s); + printk(KERN_ERR "comedi%d: %s: %s\n", dev->minor, + dev->driver->driver_name, s); } EXPORT_SYMBOL(comedi_error); @@ -2415,7 +2420,9 @@ int comedi_alloc_board_minor(struct device *hardware_device) comedi_device_cleanup(info->device); kfree(info->device); kfree(info); - pr_err("comedi: error: ran out of minor numbers for board device files.\n"); + printk(KERN_ERR + "comedi: error: " + "ran out of minor numbers for board device files.\n"); return -EBUSY; } info->device->minor = i; @@ -2492,7 +2499,9 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, spin_unlock(&comedi_file_info_table_lock); if (i == COMEDI_NUM_MINORS) { kfree(info); - pr_err("comedi: error: ran out of minor numbers for board device files.\n"); + printk(KERN_ERR + "comedi: error: " + "ran out of minor numbers for board device files.\n"); return -EBUSY; } s->minor = i; diff --git a/trunk/drivers/staging/comedi/comedidev.h b/trunk/drivers/staging/comedi/comedidev.h index cb67a5cb9c82..f713783ef624 100644 --- a/trunk/drivers/staging/comedi/comedidev.h +++ b/trunk/drivers/staging/comedi/comedidev.h @@ -46,7 +46,7 @@ #define DPRINTK(format, args...) do { \ if (comedi_debug) \ - pr_debug("comedi: " format, ## args); \ + printk(KERN_DEBUG "comedi: " format , ## args); \ } while (0) #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/trunk/drivers/staging/comedi/drivers.c b/trunk/drivers/staging/comedi/drivers.c index c9f5c1f7a9e9..c0fdb00783ed 100644 --- a/trunk/drivers/staging/comedi/drivers.c +++ b/trunk/drivers/staging/comedi/drivers.c @@ -119,8 +119,8 @@ static void __comedi_device_detach(struct comedi_device *dev) if (dev->driver) dev->driver->detach(dev); else - dev_warn(dev->class_dev, - "BUG: dev->driver=NULL in comedi_device_detach()\n"); + printk(KERN_WARNING + "BUG: dev->driver=NULL in comedi_device_detach()\n"); cleanup_device(dev); } @@ -142,7 +142,8 @@ static int comedi_device_postconfig(struct comedi_device *dev) return ret; } if (!dev->board_name) { - dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n"); + printk(KERN_WARNING "BUG: dev->board_name=<%p>\n", + dev->board_name); dev->board_name = "BUG"; } smp_wmb(); @@ -160,6 +161,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) for (driv = comedi_drivers; driv; driv = driv->next) { if (!try_module_get(driv->module)) { + printk(KERN_INFO "comedi: failed to increment module count, skipping\n"); continue; } if (driv->num_names) { @@ -175,6 +177,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* report valid board names before returning error */ for (driv = comedi_drivers; driv; driv = driv->next) { if (!try_module_get(driv->module)) { + printk(KERN_INFO + "comedi: failed to increment module count\n"); continue; } comedi_report_boards(driv); @@ -182,14 +186,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) } return -EIO; } - if (driv->attach == NULL) { - /* driver does not support manual configuration */ - dev_warn(dev->class_dev, - "driver '%s' does not support attach using comedi_config\n", - driv->driver_name); - module_put(driv->module); - return -ENOSYS; - } /* initialize dev->driver here so * comedi_error() can be called from attach */ dev->driver = driv; @@ -229,9 +225,8 @@ int comedi_driver_unregister(struct comedi_driver *driver) mutex_lock(&dev->mutex); if (dev->attached && dev->driver == driver) { if (dev->use_count) - dev_warn(dev->class_dev, - "BUG! detaching device with use_count=%d\n", - dev->use_count); + printk(KERN_WARNING "BUG! detaching device with use_count=%d\n", + dev->use_count); comedi_device_detach(dev); } mutex_unlock(&dev->mutex); @@ -278,8 +273,8 @@ static int postconfig(struct comedi_device *dev) async = kzalloc(sizeof(struct comedi_async), GFP_KERNEL); if (async == NULL) { - dev_warn(dev->class_dev, - "failed to allocate async struct\n"); + printk(KERN_INFO + "failed to allocate async struct\n"); return -ENOMEM; } init_waitqueue_head(&async->wait_head); @@ -295,8 +290,7 @@ static int postconfig(struct comedi_device *dev) async->prealloc_buf = NULL; async->prealloc_bufsz = 0; if (comedi_buf_alloc(dev, s, buf_size) < 0) { - dev_warn(dev->class_dev, - "Buffer allocation failed\n"); + printk(KERN_INFO "Buffer allocation failed\n"); return -ENOMEM; } if (s->buf_change) { @@ -376,17 +370,17 @@ static void comedi_report_boards(struct comedi_driver *driv) unsigned int i; const char *const *name_ptr; - pr_info("comedi: valid board names for %s driver are:\n", - driv->driver_name); + printk(KERN_INFO "comedi: valid board names for %s driver are:\n", + driv->driver_name); name_ptr = driv->board_name; for (i = 0; i < driv->num_names; i++) { - pr_info(" %s\n", *name_ptr); + printk(KERN_INFO " %s\n", *name_ptr); name_ptr = (const char **)((char *)name_ptr + driv->offset); } if (driv->num_names == 0) - pr_info(" %s\n", driv->driver_name); + printk(KERN_INFO " %s\n", driv->driver_name); } static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) @@ -590,9 +584,9 @@ static unsigned int comedi_buf_munge(struct comedi_async *async, block_size = num_bytes - count; if (block_size < 0) { - dev_warn(s->device->class_dev, - "%s: %s: bug! block_size is negative\n", - __FILE__, __func__); + printk(KERN_WARNING + "%s: %s: bug! block_size is negative\n", + __FILE__, __func__); break; } if ((int)(async->munge_ptr + block_size - @@ -673,8 +667,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes) { if ((int)(async->buf_write_count + nbytes - async->buf_write_alloc_count) > 0) { - dev_info(async->subdevice->device->class_dev, - "attempted to write-free more bytes than have been write-allocated.\n"); + printk(KERN_INFO "comedi: attempted to write-free more bytes than have been write-allocated.\n"); nbytes = async->buf_write_alloc_count - async->buf_write_count; } async->buf_write_count += nbytes; @@ -710,8 +703,8 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) smp_mb(); if ((int)(async->buf_read_count + nbytes - async->buf_read_alloc_count) > 0) { - dev_info(async->subdevice->device->class_dev, - "attempted to read-free more bytes than have been read-allocated.\n"); + printk(KERN_INFO + "comedi: attempted to read-free more bytes than have been read-allocated.\n"); nbytes = async->buf_read_alloc_count - async->buf_read_count; } async->buf_read_count += nbytes; @@ -860,9 +853,10 @@ comedi_auto_config_helper(struct device *hardware_device, mutex_lock(&comedi_dev->mutex); if (comedi_dev->attached) ret = -EBUSY; - else if (!try_module_get(driver->module)) + else if (!try_module_get(driver->module)) { + printk(KERN_INFO "comedi: failed to increment module count\n"); ret = -EIO; - else { + } else { /* set comedi_dev->driver here for attach wrapper */ comedi_dev->driver = driver; ret = (*attach_wrapper)(comedi_dev, context); @@ -890,19 +884,14 @@ static int comedi_auto_config_wrapper(struct comedi_device *dev, void *context) * has already been copied to it->board_name */ dev->board_ptr = comedi_recognize(driv, it->board_name); if (dev->board_ptr == NULL) { - dev_warn(dev->class_dev, - "auto config failed to find board entry '%s' for driver '%s'\n", - it->board_name, driv->driver_name); + printk(KERN_WARNING + "comedi: auto config failed to find board entry" + " '%s' for driver '%s'\n", it->board_name, + driv->driver_name); comedi_report_boards(driv); return -EINVAL; } } - if (!driv->attach) { - dev_warn(dev->class_dev, - "BUG! driver '%s' using old-style auto config but has no attach handler\n", - driv->driver_name); - return -EINVAL; - } return driv->attach(dev, it); } diff --git a/trunk/drivers/staging/comedi/drivers/adl_pci7x3x.c b/trunk/drivers/staging/comedi/drivers/adl_pci7x3x.c index 41963fba4fc2..990670a3c5b1 100644 --- a/trunk/drivers/staging/comedi/drivers/adl_pci7x3x.c +++ b/trunk/drivers/staging/comedi/drivers/adl_pci7x3x.c @@ -121,7 +121,7 @@ static int adl_pci7x3x_do_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned long reg = (unsigned long)s->private; + unsigned int reg = (unsigned int)s->private; unsigned int mask = data[0]; unsigned int bits = data[1]; @@ -147,7 +147,7 @@ static int adl_pci7x3x_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned long reg = (unsigned long)s->private; + unsigned int reg = (unsigned int)s->private; data[1] = inl(dev->iobase + reg); diff --git a/trunk/drivers/staging/comedi/drivers/amplc_dio200.c b/trunk/drivers/staging/comedi/drivers/amplc_dio200.c index 9c8fbf1b15f0..6c81e377262c 100644 --- a/trunk/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/trunk/drivers/staging/comedi/drivers/amplc_dio200.c @@ -215,9 +215,6 @@ order they appear in the channel list. #define DIO200_DRIVER_NAME "amplc_dio200" -#define DO_ISA IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) -#define DO_PCI IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) - /* PCI IDs */ #define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_DEVICE_ID_AMPLICON_PCI272 0x000a @@ -275,12 +272,12 @@ enum dio200_model { }; enum dio200_layout { -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) pc212_layout, pc214_layout, #endif pc215_layout, -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) pc218_layout, #endif pc272_layout @@ -295,7 +292,7 @@ struct dio200_board { }; static const struct dio200_board dio200_boards[] = { -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) { .name = "pc212e", .bustype = isa_bustype, @@ -327,7 +324,7 @@ static const struct dio200_board dio200_boards[] = { .layout = pc272_layout, }, #endif -#if DO_PCI +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) { .name = "pci215", .devid = PCI_DEVICE_ID_AMPLICON_PCI215, @@ -370,7 +367,7 @@ struct dio200_layout_struct { }; static const struct dio200_layout_struct dio200_layouts[] = { -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) [pc212_layout] = { .n_subdevs = 6, .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254, @@ -399,7 +396,7 @@ static const struct dio200_layout_struct dio200_layouts[] = { .has_int_sce = 1, .has_clk_gat_sce = 1, }, -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) [pc218_layout] = { .n_subdevs = 7, .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254, @@ -452,16 +449,6 @@ struct dio200_subdev_intr { int continuous; }; -static inline bool is_pci_board(const struct dio200_board *board) -{ - return DO_PCI && board->bustype == pci_bustype; -} - -static inline bool is_isa_board(const struct dio200_board *board) -{ - return DO_ISA && board->bustype == isa_bustype; -} - /* * This function looks for a board matching the supplied PCI device. */ @@ -471,7 +458,7 @@ dio200_find_pci_board(struct pci_dev *pci_dev) unsigned int i; for (i = 0; i < ARRAY_SIZE(dio200_boards); i++) - if (is_pci_board(&dio200_boards[i]) && + if (dio200_boards[i].bustype == pci_bustype && pci_dev->device == dio200_boards[i].devid) return &dio200_boards[i]; return NULL; @@ -1241,10 +1228,12 @@ static void dio200_report_attach(struct comedi_device *dev, unsigned int irq) char tmpbuf[60]; int tmplen; - if (is_isa_board(thisboard)) + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) && + thisboard->bustype == isa_bustype) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase); - else if (is_pci_board(thisboard)) + else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) && + thisboard->bustype == pci_bustype) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ", pci_name(pcidev)); else @@ -1372,7 +1361,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) } /* Process options and reserve resources according to bus type. */ - if (is_isa_board(thisboard)) { + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) && + thisboard->bustype == isa_bustype) { unsigned long iobase; unsigned int irq; @@ -1382,7 +1372,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret < 0) return ret; return dio200_common_attach(dev, iobase, irq, 0); - } else if (is_pci_board(thisboard)) { + } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) && + thisboard->bustype == pci_bustype) { struct pci_dev *pci_dev; pci_dev = dio200_find_pci_dev(dev, it); @@ -1406,7 +1397,7 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev, { int ret; - if (!DO_PCI) + if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI)) return -EINVAL; dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach pci %s\n", @@ -1427,6 +1418,7 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev, static void dio200_detach(struct comedi_device *dev) { const struct dio200_board *thisboard = comedi_board(dev); + struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct dio200_layout_struct *layout; unsigned n; @@ -1451,16 +1443,13 @@ static void dio200_detach(struct comedi_device *dev) } } } - if (is_isa_board(thisboard)) { + if (pcidev) { + if (dev->iobase) + comedi_pci_disable(pcidev); + pci_dev_put(pcidev); + } else { if (dev->iobase) release_region(dev->iobase, DIO200_IO_SIZE); - } else if (is_pci_board(thisboard)) { - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - if (pcidev) { - if (dev->iobase) - comedi_pci_disable(pcidev); - pci_dev_put(pcidev); - } } } @@ -1481,7 +1470,7 @@ static struct comedi_driver amplc_dio200_driver = { .num_names = ARRAY_SIZE(dio200_boards), }; -#if DO_PCI +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215) }, { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272) }, diff --git a/trunk/drivers/staging/comedi/drivers/amplc_pc236.c b/trunk/drivers/staging/comedi/drivers/amplc_pc236.c index c64438580b21..aabba9886b7d 100644 --- a/trunk/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/trunk/drivers/staging/comedi/drivers/amplc_pc236.c @@ -61,9 +61,6 @@ unused. #define PC236_DRIVER_NAME "amplc_pc236" -#define DO_ISA IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) -#define DO_PCI IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) - /* PCI236 PCI configuration register information */ #define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_DEVICE_ID_AMPLICON_PCI236 0x0009 @@ -106,14 +103,14 @@ struct pc236_board { enum pc236_model model; }; static const struct pc236_board pc236_boards[] = { -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) { .name = "pc36at", .bustype = isa_bustype, .model = pc36at_model, }, #endif -#if DO_PCI +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) { .name = "pci236", .devid = PCI_DEVICE_ID_AMPLICON_PCI236, @@ -138,18 +135,6 @@ struct pc236_private { int enable_irq; }; -/* test if ISA supported and this is an ISA board */ -static inline bool is_isa_board(const struct pc236_board *board) -{ - return DO_ISA && board->bustype == isa_bustype; -} - -/* test if PCI supported and this is a PCI board */ -static inline bool is_pci_board(const struct pc236_board *board) -{ - return DO_PCI && board->bustype == pci_bustype; -} - /* * This function looks for a board matching the supplied PCI device. */ @@ -158,7 +143,7 @@ static const struct pc236_board *pc236_find_pci_board(struct pci_dev *pci_dev) unsigned int i; for (i = 0; i < ARRAY_SIZE(pc236_boards); i++) - if (is_pci_board(&pc236_boards[i]) && + if (pc236_boards[i].bustype == pci_bustype && pci_dev->device == pc236_boards[i].devid) return &pc236_boards[i]; return NULL; @@ -229,13 +214,12 @@ static int pc236_request_region(struct comedi_device *dev, unsigned long from, */ static void pc236_intr_disable(struct comedi_device *dev) { - const struct pc236_board *thisboard = comedi_board(dev); struct pc236_private *devpriv = dev->private; unsigned long flags; spin_lock_irqsave(&dev->spinlock, flags); devpriv->enable_irq = 0; - if (is_pci_board(thisboard)) + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase) outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -247,13 +231,12 @@ static void pc236_intr_disable(struct comedi_device *dev) */ static void pc236_intr_enable(struct comedi_device *dev) { - const struct pc236_board *thisboard = comedi_board(dev); struct pc236_private *devpriv = dev->private; unsigned long flags; spin_lock_irqsave(&dev->spinlock, flags); devpriv->enable_irq = 1; - if (is_pci_board(thisboard)) + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase) outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -267,7 +250,6 @@ static void pc236_intr_enable(struct comedi_device *dev) */ static int pc236_intr_check(struct comedi_device *dev) { - const struct pc236_board *thisboard = comedi_board(dev); struct pc236_private *devpriv = dev->private; int retval = 0; unsigned long flags; @@ -275,7 +257,8 @@ static int pc236_intr_check(struct comedi_device *dev) spin_lock_irqsave(&dev->spinlock, flags); if (devpriv->enable_irq) { retval = 1; - if (is_pci_board(thisboard)) { + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && + devpriv->lcr_iobase) { if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR) & PLX9052_INTCSR_LI1STAT_MASK) == PLX9052_INTCSR_LI1STAT_INACTIVE) { @@ -431,13 +414,15 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq) char tmpbuf[60]; int tmplen; - if (is_isa_board(thisboard)) + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) && + thisboard->bustype == isa_bustype) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase); - else if (is_pci_board(thisboard)) + else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && + thisboard->bustype == pci_bustype) { tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ", pci_name(pcidev)); - else + } else tmplen = 0; if (irq) tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen, @@ -532,14 +517,16 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it) return ret; } /* Process options according to bus type. */ - if (is_isa_board(thisboard)) { + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) && + thisboard->bustype == isa_bustype) { unsigned long iobase = it->options[0]; unsigned int irq = it->options[1]; ret = pc236_request_region(dev, iobase, PC236_IO_SIZE); if (ret < 0) return ret; return pc236_common_attach(dev, iobase, irq, 0); - } else if (is_pci_board(thisboard)) { + } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && + thisboard->bustype == pci_bustype) { struct pci_dev *pci_dev; pci_dev = pc236_find_pci_dev(dev, it); @@ -563,7 +550,7 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev, { int ret; - if (!DO_PCI) + if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)) return -EINVAL; dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n", @@ -583,8 +570,8 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev, static void pc236_detach(struct comedi_device *dev) { - const struct pc236_board *thisboard = comedi_board(dev); struct pc236_private *devpriv = dev->private; + struct pci_dev *pcidev = comedi_to_pci_dev(dev); if (devpriv) pc236_intr_disable(dev); @@ -592,16 +579,13 @@ static void pc236_detach(struct comedi_device *dev) free_irq(dev->irq, dev); if (dev->subdevices) subdev_8255_cleanup(dev, dev->subdevices + 0); - if (is_isa_board(thisboard)) { + if (pcidev) { + if (dev->iobase) + comedi_pci_disable(pcidev); + pci_dev_put(pcidev); + } else { if (dev->iobase) release_region(dev->iobase, PC236_IO_SIZE); - } else if (is_pci_board(thisboard)) { - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - if (pcidev) { - if (dev->iobase) - comedi_pci_disable(pcidev); - pci_dev_put(pcidev); - } } } @@ -622,7 +606,7 @@ static struct comedi_driver amplc_pc236_driver = { .num_names = ARRAY_SIZE(pc236_boards), }; -#if DO_PCI +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236) }, {0} diff --git a/trunk/drivers/staging/comedi/drivers/amplc_pc263.c b/trunk/drivers/staging/comedi/drivers/amplc_pc263.c index 148c9d3acf64..40ec1ffebba6 100644 --- a/trunk/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/trunk/drivers/staging/comedi/drivers/amplc_pc263.c @@ -48,9 +48,6 @@ The state of the outputs can be read. #define PC263_DRIVER_NAME "amplc_pc263" -#define DO_ISA IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) -#define DO_PCI IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) - /* PCI263 PCI configuration register information */ #define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_DEVICE_ID_AMPLICON_PCI263 0x000c @@ -73,14 +70,14 @@ struct pc263_board { enum pc263_model model; }; static const struct pc263_board pc263_boards[] = { -#if DO_ISA +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) { .name = "pc263", .bustype = isa_bustype, .model = pc263_model, }, #endif -#if DO_PCI +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) { .name = "pci263", .devid = PCI_DEVICE_ID_AMPLICON_PCI263, @@ -96,18 +93,6 @@ static const struct pc263_board pc263_boards[] = { #endif }; -/* test if ISA supported and this is an ISA board */ -static inline bool is_isa_board(const struct pc263_board *board) -{ - return DO_ISA && board->bustype == isa_bustype; -} - -/* test if PCI supported and this is a PCI board */ -static inline bool is_pci_board(const struct pc263_board *board) -{ - return DO_PCI && board->bustype == pci_bustype; -} - /* * This function looks for a board matching the supplied PCI device. */ @@ -116,7 +101,7 @@ static const struct pc263_board *pc263_find_pci_board(struct pci_dev *pci_dev) unsigned int i; for (i = 0; i < ARRAY_SIZE(pc263_boards); i++) - if (is_pci_board(&pc263_boards[i]) && + if (pc263_boards[i].bustype == pci_bustype && pci_dev->device == pc263_boards[i].devid) return &pc263_boards[i]; return NULL; @@ -202,9 +187,11 @@ static void pc263_report_attach(struct comedi_device *dev) struct pci_dev *pcidev = comedi_to_pci_dev(dev); char tmpbuf[40]; - if (is_isa_board(thisboard)) + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) && + thisboard->bustype == isa_bustype) snprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase); - else if (is_pci_board(thisboard)) + else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) && + thisboard->bustype == pci_bustype) snprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ", pci_name(pcidev)); else @@ -272,13 +259,15 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach\n"); /* Process options and reserve resources according to bus type. */ - if (is_isa_board(thisboard)) { + if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) && + thisboard->bustype == isa_bustype) { unsigned long iobase = it->options[0]; ret = pc263_request_region(dev, iobase, PC263_IO_SIZE); if (ret < 0) return ret; return pc263_common_attach(dev, iobase); - } else if (is_pci_board(thisboard)) { + } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) && + thisboard->bustype == pci_bustype) { struct pci_dev *pci_dev; pci_dev = pc263_find_pci_dev(dev, it); @@ -299,7 +288,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int __devinit pc263_attach_pci(struct comedi_device *dev, struct pci_dev *pci_dev) { - if (!DO_PCI) + if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI)) return -EINVAL; dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach pci %s\n", @@ -314,18 +303,15 @@ static int __devinit pc263_attach_pci(struct comedi_device *dev, static void pc263_detach(struct comedi_device *dev) { - const struct pc263_board *thisboard = comedi_board(dev); + struct pci_dev *pcidev = comedi_to_pci_dev(dev); - if (is_isa_board(thisboard)) { + if (pcidev) { + if (dev->iobase) + comedi_pci_disable(pcidev); + pci_dev_put(pcidev); + } else { if (dev->iobase) release_region(dev->iobase, PC263_IO_SIZE); - } else if (is_pci_board(thisboard)) { - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - if (pcidev) { - if (dev->iobase) - comedi_pci_disable(pcidev); - pci_dev_put(pcidev); - } } } @@ -346,7 +332,7 @@ static struct comedi_driver amplc_pc263_driver = { .num_names = ARRAY_SIZE(pc263_boards), }; -#if DO_PCI +#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) }, {0} diff --git a/trunk/drivers/staging/comedi/drivers/contec_pci_dio.c b/trunk/drivers/staging/comedi/drivers/contec_pci_dio.c index 12ad9fa32f56..944cfeeb2b2d 100644 --- a/trunk/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/trunk/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -27,35 +27,51 @@ Author: Stefano Rivoir Updated: Wed, 27 Jun 2007 13:00:06 +0100 Status: works -Configuration Options: not applicable, uses comedi PCI auto config +Configuration Options: + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. */ #include "../comedidev.h" +enum contec_model { + PIO1616L = 0, +}; + +struct contec_board { + const char *name; + int model; + int in_ports; + int out_ports; + int in_offs; + int out_offs; + int out_boffs; +}; +static const struct contec_board contec_boards[] = { + {"PIO1616L", PIO1616L, 16, 16, 0, 2, 10}, +}; + #define PCI_DEVICE_ID_PIO1616L 0x8172 -/* - * Register map - */ -#define PIO1616L_DI_REG 0x00 -#define PIO1616L_DO_REG 0x02 +#define thisboard ((const struct contec_board *)dev->board_ptr) static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - unsigned int mask = data[0]; - unsigned int bits = data[1]; - if (mask) { - s->state &= ~mask; - s->state |= (bits & mask); + dev_dbg(dev->class_dev, "contec_do_insn_bits called\n"); + dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]); - outw(s->state, dev->iobase + PIO1616L_DO_REG); + if (data[0]) { + s->state &= ~data[0]; + s->state |= data[0] & data[1]; + dev_dbg(dev->class_dev, "out: %d on %lx\n", s->state, + dev->iobase + thisboard->out_offs); + outw(s->state, dev->iobase + thisboard->out_offs); } - - data[1] = s->state; - return insn->n; } @@ -63,58 +79,87 @@ static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - data[1] = inw(dev->iobase + PIO1616L_DI_REG); + + dev_dbg(dev->class_dev, "contec_di_insn_bits called\n"); + dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]); + + data[1] = inw(dev->iobase + thisboard->in_offs); return insn->n; } -static int contec_attach_pci(struct comedi_device *dev, - struct pci_dev *pcidev) +static struct pci_dev *contec_find_pci_dev(struct comedi_device *dev, + struct comedi_devconfig *it) { + struct pci_dev *pcidev = NULL; + int bus = it->options[0]; + int slot = it->options[1]; + + for_each_pci_dev(pcidev) { + if (bus || slot) { + if (bus != pcidev->bus->number || + slot != PCI_SLOT(pcidev->devfn)) + continue; + } + if (pcidev->vendor != PCI_VENDOR_ID_CONTEC || + pcidev->device != PCI_DEVICE_ID_PIO1616L) + continue; + + dev->board_ptr = contec_boards + 0; + return pcidev; + } + dev_err(dev->class_dev, + "No supported board found! (req. bus %d, slot %d)\n", + bus, slot); + return NULL; +} + +static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it) +{ + struct pci_dev *pcidev; struct comedi_subdevice *s; int ret; - comedi_set_hw_dev(dev, &pcidev->dev); + printk("comedi%d: contec: ", dev->minor); - dev->board_name = dev->driver->driver_name; - - ret = comedi_pci_enable(pcidev, dev->board_name); - if (ret) - return ret; - dev->iobase = pci_resource_start(pcidev, 0); + dev->board_name = thisboard->name; ret = comedi_alloc_subdevices(dev, 2); if (ret) return ret; - s = dev->subdevices + 0; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 16; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = contec_di_insn_bits; + pcidev = contec_find_pci_dev(dev, it); + if (!pcidev) + return -EIO; + comedi_set_hw_dev(dev, &pcidev->dev); - s = dev->subdevices + 1; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 16; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = contec_do_insn_bits; + if (comedi_pci_enable(pcidev, "contec_pci_dio")) { + printk("error enabling PCI device and request regions!\n"); + return -EIO; + } + dev->iobase = pci_resource_start(pcidev, 0); + printk(" base addr %lx ", dev->iobase); - dev_info(dev->class_dev, "%s attached\n", dev->board_name); + s = dev->subdevices + 0; - return 0; -} + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = contec_di_insn_bits; -static int contec_attach(struct comedi_device *dev, - struct comedi_devconfig *it) -{ - dev_warn(dev->class_dev, - "This driver does not support attach using comedi_config\n"); + s = dev->subdevices + 1; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = contec_do_insn_bits; + + printk("attached\n"); - return -ENOSYS; + return 1; } static void contec_detach(struct comedi_device *dev) @@ -124,6 +169,7 @@ static void contec_detach(struct comedi_device *dev) if (pcidev) { if (dev->iobase) comedi_pci_disable(pcidev); + pci_dev_put(pcidev); } } @@ -131,7 +177,6 @@ static struct comedi_driver contec_pci_dio_driver = { .driver_name = "contec_pci_dio", .module = THIS_MODULE, .attach = contec_attach, - .attach_pci = contec_attach_pci, .detach = contec_detach, }; @@ -147,7 +192,8 @@ static void __devexit contec_pci_dio_pci_remove(struct pci_dev *dev) } static DEFINE_PCI_DEVICE_TABLE(contec_pci_dio_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L) }, + { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L), + .driver_data = PIO1616L }, { 0 } }; MODULE_DEVICE_TABLE(pci, contec_pci_dio_pci_table); diff --git a/trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c b/trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c index e852808c6314..064be9aae3aa 100644 --- a/trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -41,6 +41,7 @@ #include #define PCI_VENDOR_ID_DYNALOG 0x10b5 +#define DRV_NAME "dyna_pci10xx" #define READ_TIMEOUT 50 @@ -53,11 +54,59 @@ static const struct comedi_lrange range_pci1050_ai = { 3, { static const char range_codes_pci1050_ai[] = { 0x00, 0x10, 0x30 }; +static const struct comedi_lrange range_pci1050_ao = { 1, { + UNI_RANGE(10) + } +}; + +static const char range_codes_pci1050_ao[] = { 0x00 }; + +struct boardtype { + const char *name; + int device_id; + int ai_chans; + int ai_bits; + int ao_chans; + int ao_bits; + int di_chans; + int di_bits; + int do_chans; + int do_bits; + const struct comedi_lrange *range_ai; + const char *range_codes_ai; + const struct comedi_lrange *range_ao; + const char *range_codes_ao; +}; + +static const struct boardtype boardtypes[] = { + { + .name = "dyna_pci1050", + .device_id = 0x1050, + .ai_chans = 16, + .ai_bits = 12, + .ao_chans = 16, + .ao_bits = 12, + .di_chans = 16, + .di_bits = 16, + .do_chans = 16, + .do_bits = 16, + .range_ai = &range_pci1050_ai, + .range_codes_ai = range_codes_pci1050_ai, + .range_ao = &range_pci1050_ao, + .range_codes_ao = range_codes_pci1050_ao, + }, + /* dummy entry corresponding to driver name */ + {.name = DRV_NAME}, +}; + struct dyna_pci10xx_private { struct mutex mutex; unsigned long BADR3; }; +#define thisboard ((const struct boardtype *)dev->board_ptr) +#define devpriv ((struct dyna_pci10xx_private *)dev->private) + /******************************************************************************/ /************************** READ WRITE FUNCTIONS ******************************/ /******************************************************************************/ @@ -67,14 +116,13 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct dyna_pci10xx_private *devpriv = dev->private; int n, counter; u16 d = 0; unsigned int chan, range; /* get the channel number and range */ chan = CR_CHAN(insn->chanspec); - range = range_codes_pci1050_ai[CR_RANGE((insn->chanspec))]; + range = thisboard->range_codes_ai[CR_RANGE((insn->chanspec))]; mutex_lock(&devpriv->mutex); /* convert n samples */ @@ -111,12 +159,11 @@ static int dyna_pci10xx_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct dyna_pci10xx_private *devpriv = dev->private; int n; unsigned int chan, range; chan = CR_CHAN(insn->chanspec); - range = range_codes_pci1050_ai[CR_RANGE((insn->chanspec))]; + range = thisboard->range_codes_ai[CR_RANGE((insn->chanspec))]; mutex_lock(&devpriv->mutex); for (n = 0; n < insn->n; n++) { @@ -134,7 +181,6 @@ static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct dyna_pci10xx_private *devpriv = dev->private; u16 d = 0; mutex_lock(&devpriv->mutex); @@ -154,8 +200,6 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct dyna_pci10xx_private *devpriv = dev->private; - /* The insn data is a mask in data[0] and the new data * in data[1], each channel cooresponding to a bit. * s->state contains the previous write data @@ -179,30 +223,71 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev, return insn->n; } -static int dyna_pci10xx_attach_pci(struct comedi_device *dev, - struct pci_dev *pcidev) +static struct pci_dev *dyna_pci10xx_find_pci_dev(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + struct pci_dev *pcidev = NULL; + int bus = it->options[0]; + int slot = it->options[1]; + int i; + + for_each_pci_dev(pcidev) { + if (bus || slot) { + if (bus != pcidev->bus->number || + slot != PCI_SLOT(pcidev->devfn)) + continue; + } + if (pcidev->vendor != PCI_VENDOR_ID_DYNALOG) + continue; + + for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) { + if (pcidev->device != boardtypes[i].device_id) + continue; + + dev->board_ptr = &boardtypes[i]; + return pcidev; + } + } + dev_err(dev->class_dev, + "No supported board found! (req. bus %d, slot %d)\n", + bus, slot); + return NULL; +} + +static int dyna_pci10xx_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { - struct dyna_pci10xx_private *devpriv; + struct pci_dev *pcidev; struct comedi_subdevice *s; int ret; + if (alloc_private(dev, sizeof(struct dyna_pci10xx_private)) < 0) { + printk(KERN_ERR "comedi: dyna_pci10xx: " + "failed to allocate memory!\n"); + return -ENOMEM; + } + + pcidev = dyna_pci10xx_find_pci_dev(dev, it); + if (!pcidev) + return -EIO; comedi_set_hw_dev(dev, &pcidev->dev); - dev->board_name = dev->driver->driver_name; + dev->board_name = thisboard->name; + dev->irq = 0; - ret = alloc_private(dev, sizeof(*devpriv)); - if (ret) - return ret; - devpriv = dev->private; + if (comedi_pci_enable(pcidev, DRV_NAME)) { + printk(KERN_ERR "comedi: dyna_pci10xx: " + "failed to enable PCI device and request regions!"); + return -EIO; + } + + mutex_init(&devpriv->mutex); + + printk(KERN_INFO "comedi: dyna_pci10xx: device found!\n"); - ret = comedi_pci_enable(pcidev, dev->board_name); - if (ret) - return ret; dev->iobase = pci_resource_start(pcidev, 2); devpriv->BADR3 = pci_resource_start(pcidev, 3); - mutex_init(&devpriv->mutex); - ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; @@ -211,9 +296,9 @@ static int dyna_pci10xx_attach_pci(struct comedi_device *dev, s = dev->subdevices + 0; s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF; - s->n_chan = 16; + s->n_chan = thisboard->ai_chans; s->maxdata = 0x0FFF; - s->range_table = &range_pci1050_ai; + s->range_table = thisboard->range_ai; s->len_chanlist = 16; s->insn_read = dyna_pci10xx_insn_read_ai; @@ -221,9 +306,9 @@ static int dyna_pci10xx_attach_pci(struct comedi_device *dev, s = dev->subdevices + 1; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = 16; + s->n_chan = thisboard->ao_chans; s->maxdata = 0x0FFF; - s->range_table = &range_unipolar10; + s->range_table = thisboard->range_ao; s->len_chanlist = 16; s->insn_write = dyna_pci10xx_insn_write_ao; @@ -231,47 +316,39 @@ static int dyna_pci10xx_attach_pci(struct comedi_device *dev, s = dev->subdevices + 2; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE | SDF_GROUND; - s->n_chan = 16; + s->n_chan = thisboard->di_chans; s->maxdata = 1; s->range_table = &range_digital; - s->len_chanlist = 16; + s->len_chanlist = thisboard->di_chans; s->insn_bits = dyna_pci10xx_di_insn_bits; /* digital output */ s = dev->subdevices + 3; s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND; - s->n_chan = 16; + s->n_chan = thisboard->do_chans; s->maxdata = 1; s->range_table = &range_digital; - s->len_chanlist = 16; + s->len_chanlist = thisboard->do_chans; s->state = 0; s->insn_bits = dyna_pci10xx_do_insn_bits; - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - - return 0; -} - -static int dyna_pci10xx_attach(struct comedi_device *dev, - struct comedi_devconfig *it) -{ - dev_warn(dev->class_dev, - "This driver does not support attach using comedi_config\n"); + printk(KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n", + thisboard->name); - return -ENOSYS; + return 1; } static void dyna_pci10xx_detach(struct comedi_device *dev) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct dyna_pci10xx_private *devpriv = dev->private; if (devpriv) mutex_destroy(&devpriv->mutex); if (pcidev) { if (dev->iobase) comedi_pci_disable(pcidev); + pci_dev_put(pcidev); } } @@ -279,8 +356,10 @@ static struct comedi_driver dyna_pci10xx_driver = { .driver_name = "dyna_pci10xx", .module = THIS_MODULE, .attach = dyna_pci10xx_attach, - .attach_pci = dyna_pci10xx_attach_pci, .detach = dyna_pci10xx_detach, + .board_name = &boardtypes[0].name, + .offset = sizeof(struct boardtype), + .num_names = ARRAY_SIZE(boardtypes), }; static int __devinit dyna_pci10xx_pci_probe(struct pci_dev *dev, diff --git a/trunk/drivers/staging/comedi/range.c b/trunk/drivers/staging/comedi/range.c index 5a6b6df07513..41f95237789d 100644 --- a/trunk/drivers/staging/comedi/range.c +++ b/trunk/drivers/staging/comedi/range.c @@ -131,7 +131,6 @@ static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec) int comedi_check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) { - struct comedi_device *dev = s->device; int i; int chan; @@ -140,10 +139,10 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, if (CR_CHAN(chanlist[i]) >= s->n_chan || CR_RANGE(chanlist[i]) >= s->range_table->length || aref_invalid(s, chanlist[i])) { - dev_warn(dev->class_dev, - "bad chanlist[%d]=0x%08x in_chan=%d range length=%d\n", - i, chanlist[i], s->n_chan, - s->range_table->length); + printk(KERN_ERR "bad chanlist[%d]=0x%08x " + "in_chan=%d range length=%d\n", i, + chanlist[i], s->n_chan, + s->range_table->length); return -EINVAL; } } else if (s->range_table_list) { @@ -153,14 +152,13 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, CR_RANGE(chanlist[i]) >= s->range_table_list[chan]->length || aref_invalid(s, chanlist[i])) { - dev_warn(dev->class_dev, - "bad chanlist[%d]=0x%08x\n", - i, chanlist[i]); + printk(KERN_ERR "bad chanlist[%d]=0x%08x\n", + i, chanlist[i]); return -EINVAL; } } } else { - dev_err(dev->class_dev, "(bug) no range type list!\n"); + printk(KERN_ERR "comedi: (bug) no range type list!\n"); return -EINVAL; } return 0; diff --git a/trunk/drivers/staging/csr/Makefile b/trunk/drivers/staging/csr/Makefile index ab626edc5ba4..afda44b0a925 100644 --- a/trunk/drivers/staging/csr/Makefile +++ b/trunk/drivers/staging/csr/Makefile @@ -25,6 +25,7 @@ csr_wifi-y := bh.o \ unifi_event.o \ unifi_pdu_processing.o \ unifi_sme.o \ + csr_formatted_io.o \ csr_wifi_hip_card_sdio.o \ csr_wifi_hip_card_sdio_intr.o \ csr_wifi_hip_card_sdio_mem.o \ diff --git a/trunk/drivers/staging/csr/csr_formatted_io.c b/trunk/drivers/staging/csr/csr_formatted_io.c new file mode 100644 index 000000000000..7213cc8fb577 --- /dev/null +++ b/trunk/drivers/staging/csr/csr_formatted_io.c @@ -0,0 +1,27 @@ +/***************************************************************************** + + (c) Cambridge Silicon Radio Limited 2010 + All rights reserved and confidential information of CSR + + Refer to LICENSE.txt included with this source for details + on the license terms. + +*****************************************************************************/ +#include +#include "csr_formatted_io.h" + +s32 CsrSnprintf(char *dest, size_t n, const char *fmt, ...) +{ + s32 r; + va_list args; + va_start(args, fmt); + r = vsnprintf(dest, n, fmt, args); + va_end(args); + + if (dest && (n > 0)) + { + dest[n - 1] = '\0'; + } + + return r; +} diff --git a/trunk/drivers/staging/csr/csr_formatted_io.h b/trunk/drivers/staging/csr/csr_formatted_io.h new file mode 100644 index 000000000000..2e238cb98d51 --- /dev/null +++ b/trunk/drivers/staging/csr/csr_formatted_io.h @@ -0,0 +1,25 @@ +#ifndef CSR_FORMATTED_IO_H__ +#define CSR_FORMATTED_IO_H__ +/***************************************************************************** + + (c) Cambridge Silicon Radio Limited 2010 + All rights reserved and confidential information of CSR + + Refer to LICENSE.txt included with this source for details + on the license terms. + +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +s32 CsrSnprintf(char *dest, size_t n, const char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/trunk/drivers/staging/csr/csr_wifi_hip_card_sdio.c b/trunk/drivers/staging/csr/csr_wifi_hip_card_sdio.c index cf148a0fec6a..44ab00c53fec 100644 --- a/trunk/drivers/staging/csr/csr_wifi_hip_card_sdio.c +++ b/trunk/drivers/staging/csr/csr_wifi_hip_card_sdio.c @@ -1612,13 +1612,13 @@ static CsrResult card_allocate_memory_resources(card_t *card) /* Reset any state carried forward from a previous life */ card->fh_command_queue.q_rd_ptr = 0; card->fh_command_queue.q_wr_ptr = 0; - (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, + (void)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_cmd_q"); for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) { card->fh_traffic_queue[i].q_rd_ptr = 0; card->fh_traffic_queue[i].q_wr_ptr = 0; - (void)scnprintf(card->fh_traffic_queue[i].name, + (void)CsrSnprintf(card->fh_traffic_queue[i].name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i); } #ifndef CSR_WIFI_HIP_TA_DISABLE @@ -1826,13 +1826,13 @@ static void card_init_soft_queues(card_t *card) /* Reset any state carried forward from a previous life */ card->fh_command_queue.q_rd_ptr = 0; card->fh_command_queue.q_wr_ptr = 0; - (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, + (void)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_cmd_q"); for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) { card->fh_traffic_queue[i].q_rd_ptr = 0; card->fh_traffic_queue[i].q_wr_ptr = 0; - (void)scnprintf(card->fh_traffic_queue[i].name, + (void)CsrSnprintf(card->fh_traffic_queue[i].name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i); } #ifndef CSR_WIFI_HIP_TA_DISABLE diff --git a/trunk/drivers/staging/csr/csr_wifi_hip_udi.c b/trunk/drivers/staging/csr/csr_wifi_hip_udi.c index 31a27cc60995..07cfd36c4971 100644 --- a/trunk/drivers/staging/csr/csr_wifi_hip_udi.c +++ b/trunk/drivers/staging/csr/csr_wifi_hip_udi.c @@ -64,104 +64,104 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) } i = n = 0; - written = scnprintf(p, remaining, "Chip ID %u\n", + written = CsrSnprintf(p, remaining, "Chip ID %u\n", (u16)card->chip_id); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Chip Version %04X\n", + written = CsrSnprintf(p, remaining, "Chip Version %04X\n", card->chip_version); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "HIP v%u.%u\n", + written = CsrSnprintf(p, remaining, "HIP v%u.%u\n", (card->config_data.version >> 8) & 0xFF, card->config_data.version & 0xFF); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Build %u: %s\n", + written = CsrSnprintf(p, remaining, "Build %lu: %s\n", card->build_id, card->build_id_string); UNIFI_SNPRINTF_RET(p, remaining, written); cfg = &card->config_data; - written = scnprintf(p, remaining, "sdio ctrl offset %u\n", + written = CsrSnprintf(p, remaining, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "fromhost sigbuf handle %u\n", + written = CsrSnprintf(p, remaining, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "tohost_sigbuf_handle %u\n", + written = CsrSnprintf(p, remaining, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_fromhost_sig_frags %u\n", + written = CsrSnprintf(p, remaining, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_tohost_sig_frags %u\n", + written = CsrSnprintf(p, remaining, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_fromhost_data_slots %u\n", + written = CsrSnprintf(p, remaining, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_tohost_data_slots %u\n", + written = CsrSnprintf(p, remaining, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "data_slot_size %u\n", + written = CsrSnprintf(p, remaining, "data_slot_size %u\n", cfg->data_slot_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0001 */ - written = scnprintf(p, remaining, "overlay_size %u\n", + written = CsrSnprintf(p, remaining, "overlay_size %u\n", (u16)cfg->overlay_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0300 */ - written = scnprintf(p, remaining, "data_slot_round %u\n", + written = CsrSnprintf(p, remaining, "data_slot_round %u\n", cfg->data_slot_round); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "sig_frag_size %u\n", + written = CsrSnprintf(p, remaining, "sig_frag_size %u\n", cfg->sig_frag_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0300 */ - written = scnprintf(p, remaining, "tohost_sig_pad %u\n", + written = CsrSnprintf(p, remaining, "tohost_sig_pad %u\n", cfg->tohost_signal_padding); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "\nInternal state:\n"); + written = CsrSnprintf(p, remaining, "\nInternal state:\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", + written = CsrSnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", card->last_phy_panic_code, card->last_phy_panic_arg); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", + written = CsrSnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", card->last_mac_panic_code, card->last_mac_panic_arg); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "fhsr: %u\n", + written = CsrSnprintf(p, remaining, "fhsr: %u\n", (u16)card->from_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "fhsw: %u\n", + written = CsrSnprintf(p, remaining, "fhsw: %u\n", (u16)card->from_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "thsr: %u\n", + written = CsrSnprintf(p, remaining, "thsr: %u\n", (u16)card->to_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "thsw: %u\n", + written = CsrSnprintf(p, remaining, "thsw: %u\n", (u16)card->to_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, - "fh buffer contains: %d signals, %ld bytes\n", + written = CsrSnprintf(p, remaining, + "fh buffer contains: %u signals, %u bytes\n", card->fh_buffer.count, card->fh_buffer.ptr - card->fh_buffer.buf); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "paused: "); + written = CsrSnprintf(p, remaining, "paused: "); UNIFI_SNPRINTF_RET(p, remaining, written); for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++) { - written = scnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); + written = CsrSnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = scnprintf(p, remaining, "\n"); + written = CsrSnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, + written = CsrSnprintf(p, remaining, "fh command q: %u waiting, %u free of %u:\n", CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue), CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue), @@ -169,7 +169,7 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) UNIFI_SNPRINTF_RET(p, remaining, written); for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) { - written = scnprintf(p, remaining, + written = CsrSnprintf(p, remaining, "fh traffic q[%u]: %u waiting, %u free of %u:\n", i, CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]), @@ -178,58 +178,58 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) UNIFI_SNPRINTF_RET(p, remaining, written); } - written = scnprintf(p, remaining, "fh data slots free: %u\n", + written = CsrSnprintf(p, remaining, "fh data slots free: %u\n", card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "From host data slots:"); + written = CsrSnprintf(p, remaining, "From host data slots:"); UNIFI_SNPRINTF_RET(p, remaining, written); n = card->config_data.num_fromhost_data_slots; for (i = 0; i < n && card->from_host_data; i++) { - written = scnprintf(p, remaining, " %u", + written = CsrSnprintf(p, remaining, " %u", (u16)card->from_host_data[i].bd.data_length); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = scnprintf(p, remaining, "\n"); + written = CsrSnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "To host data slots:"); + written = CsrSnprintf(p, remaining, "To host data slots:"); UNIFI_SNPRINTF_RET(p, remaining, written); n = card->config_data.num_tohost_data_slots; for (i = 0; i < n && card->to_host_data; i++) { - written = scnprintf(p, remaining, " %u", + written = CsrSnprintf(p, remaining, " %u", (u16)card->to_host_data[i].data_length); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = scnprintf(p, remaining, "\n"); + written = CsrSnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); #ifdef CSR_UNSAFE_SDIO_ACCESS - written = scnprintf(p, remaining, "Host State: %s\n", states[card->host_state]); + written = CsrSnprintf(p, remaining, "Host State: %s\n", states[card->host_state]); UNIFI_SNPRINTF_RET(p, remaining, written); r = unifi_check_io_status(card, &iostate); if (iostate == 1) { - written = scnprintf(p, remaining, "I/O Check: F1 disabled\n"); + written = CsrSnprintf(p, remaining, "I/O Check: F1 disabled\n"); UNIFI_SNPRINTF_RET(p, remaining, written); } else { if (iostate == 1) { - written = scnprintf(p, remaining, "I/O Check: pending interrupt\n"); + written = CsrSnprintf(p, remaining, "I/O Check: pending interrupt\n"); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = scnprintf(p, remaining, "BH reason interrupt = %d\n", + written = CsrSnprintf(p, remaining, "BH reason interrupt = %d\n", card->bh_reason_unifi); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "BH reason host = %d\n", + written = CsrSnprintf(p, remaining, "BH reason host = %d\n", card->bh_reason_host); UNIFI_SNPRINTF_RET(p, remaining, written); @@ -238,26 +238,26 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b); if ((r == CSR_RESULT_SUCCESS) && (!(b & 0x80))) { - written = scnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n", + written = CsrSnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n", b, card->from_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); break; } } iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); - written = scnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", + written = CsrSnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", iostate, card->to_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); } #endif - written = scnprintf(p, remaining, "\nStats:\n"); + written = CsrSnprintf(p, remaining, "\nStats:\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Total SDIO bytes: R=%u W=%u\n", + written = CsrSnprintf(p, remaining, "Total SDIO bytes: R=%lu W=%lu\n", card->sdio_bytes_read, card->sdio_bytes_written); UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Interrupts generated on card: %u\n", + written = CsrSnprintf(p, remaining, "Interrupts generated on card: %lu\n", card->unifi_interrupt_seq); UNIFI_SNPRINTF_RET(p, remaining, written); diff --git a/trunk/drivers/staging/csr/csr_wifi_hip_unifi.h b/trunk/drivers/staging/csr/csr_wifi_hip_unifi.h index 2923e2ef12f2..dc3c60b49702 100644 --- a/trunk/drivers/staging/csr/csr_wifi_hip_unifi.h +++ b/trunk/drivers/staging/csr/csr_wifi_hip_unifi.h @@ -98,6 +98,7 @@ extern "C" { #include "csr_framework_ext.h" /* from the synergy porting folder */ #include "csr_sdio.h" /* from the synergy porting folder */ #include "csr_macro.h" /* from the synergy porting folder */ +#include "csr_formatted_io.h" /* from the synergy gsp folder */ #include "csr_wifi_result.h" /* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */ diff --git a/trunk/drivers/staging/csr/io.c b/trunk/drivers/staging/csr/io.c index 4774dc852816..deaff252eec3 100644 --- a/trunk/drivers/staging/csr/io.c +++ b/trunk/drivers/staging/csr/io.c @@ -347,7 +347,7 @@ register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev) /* * We use the slot number as unifi device index. */ - scnprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance); + snprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance); /* * The following complex casting is in place in order to eliminate 64-bit compilation warning * "cast to/from pointer from/to integer of different size" @@ -904,54 +904,54 @@ uf_read_proc(char *page, char **start, off_t offset, int count, orig_p = p; - written = scnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n", + written = CsrSnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n", CSR_WIFI_VERSION, __DATE__, __TIME__); UNIFI_SNPRINTF_RET(p, remain, written); #ifdef CSR_SME_USERSPACE - written = scnprintf(p, remain, "SME: CSR userspace "); + written = CsrSnprintf(p, remain, "SME: CSR userspace "); UNIFI_SNPRINTF_RET(p, remain, written); #ifdef CSR_SUPPORT_WEXT - written = scnprintf(p, remain, "with WEXT support\n"); + written = CsrSnprintf(p, remain, "with WEXT support\n"); #else - written = scnprintf(p, remain, "\n"); + written = CsrSnprintf(p, remain, "\n"); #endif /* CSR_SUPPORT_WEXT */ UNIFI_SNPRINTF_RET(p, remain, written); #endif /* CSR_SME_USERSPACE */ #ifdef CSR_NATIVE_LINUX - written = scnprintf(p, remain, "SME: native\n"); + written = CsrSnprintf(p, remain, "SME: native\n"); UNIFI_SNPRINTF_RET(p, remain, written); #endif #ifdef CSR_SUPPORT_SME - written = scnprintf(p, remain, - "Firmware (ROM) build:%u, Patch:%u\n", + written = CsrSnprintf(p, remain, + "Firmware (ROM) build:%lu, Patch:%lu\n", priv->card_info.fw_build, priv->sme_versions.firmwarePatch); UNIFI_SNPRINTF_RET(p, remain, written); #endif p += unifi_print_status(priv->card, p, &remain); - written = scnprintf(p, remain, "Last dbg str: %s\n", + written = CsrSnprintf(p, remain, "Last dbg str: %s\n", priv->last_debug_string); UNIFI_SNPRINTF_RET(p, remain, written); - written = scnprintf(p, remain, "Last dbg16:"); + written = CsrSnprintf(p, remain, "Last dbg16:"); UNIFI_SNPRINTF_RET(p, remain, written); for (i = 0; i < 8; i++) { - written = scnprintf(p, remain, " %04X", + written = CsrSnprintf(p, remain, " %04X", priv->last_debug_word16[i]); UNIFI_SNPRINTF_RET(p, remain, written); } - written = scnprintf(p, remain, "\n"); + written = CsrSnprintf(p, remain, "\n"); UNIFI_SNPRINTF_RET(p, remain, written); - written = scnprintf(p, remain, " "); + written = CsrSnprintf(p, remain, " "); UNIFI_SNPRINTF_RET(p, remain, written); for (; i < 16; i++) { - written = scnprintf(p, remain, " %04X", + written = CsrSnprintf(p, remain, " %04X", priv->last_debug_word16[i]); UNIFI_SNPRINTF_RET(p, remain, written); } - written = scnprintf(p, remain, "\n"); + written = CsrSnprintf(p, remain, "\n"); UNIFI_SNPRINTF_RET(p, remain, written); *start = page; diff --git a/trunk/drivers/staging/iio/accel/adis16220_core.c b/trunk/drivers/staging/iio/accel/adis16220_core.c index 575f1af25d5d..c31e1ec2e66a 100644 --- a/trunk/drivers/staging/iio/accel/adis16220_core.c +++ b/trunk/drivers/staging/iio/accel/adis16220_core.c @@ -372,8 +372,7 @@ static ssize_t adis16220_accel_bin_read(struct file *filp, struct kobject *kobj, loff_t off, size_t count) { - struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj)); return adis16220_capture_buffer_read(indio_dev, buf, off, count, @@ -394,8 +393,7 @@ static ssize_t adis16220_adc1_bin_read(struct file *filp, struct kobject *kobj, char *buf, loff_t off, size_t count) { - struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj)); return adis16220_capture_buffer_read(indio_dev, buf, off, count, @@ -416,8 +414,7 @@ static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj, char *buf, loff_t off, size_t count) { - struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj)); return adis16220_capture_buffer_read(indio_dev, buf, off, count, diff --git a/trunk/drivers/staging/line6/variax.c b/trunk/drivers/staging/line6/variax.c index f97416b1de54..bb99ee4919e7 100644 --- a/trunk/drivers/staging/line6/variax.c +++ b/trunk/drivers/staging/line6/variax.c @@ -353,10 +353,10 @@ static ssize_t variax_set_model(struct device *dev, { struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); - u8 value; + unsigned long value; int ret; - ret = kstrtou8(buf, 10, &value); + ret = strict_strtoul(buf, 10, &value); if (ret) return ret; @@ -387,10 +387,10 @@ static ssize_t variax_set_active(struct device *dev, { struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); - u8 value; + unsigned long value; int ret; - ret = kstrtou8(buf, 10, &value); + ret = strict_strtoul(buf, 10, &value); if (ret) return ret; diff --git a/trunk/drivers/staging/omapdrm/omap_crtc.c b/trunk/drivers/staging/omapdrm/omap_crtc.c index 98a10bcba0d3..62e0022561bc 100644 --- a/trunk/drivers/staging/omapdrm/omap_crtc.c +++ b/trunk/drivers/staging/omapdrm/omap_crtc.c @@ -191,18 +191,10 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc, return 0; } -static int omap_crtc_set_property(struct drm_crtc *crtc, - struct drm_property *property, uint64_t val) -{ - struct omap_crtc *omap_crtc = to_omap_crtc(crtc); - return omap_plane_set_property(omap_crtc->plane, property, val); -} - static const struct drm_crtc_funcs omap_crtc_funcs = { .set_config = drm_crtc_helper_set_config, .destroy = omap_crtc_destroy, .page_flip = omap_crtc_page_flip_locked, - .set_property = omap_crtc_set_property, }; static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = { @@ -239,8 +231,6 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, drm_crtc_init(dev, crtc, &omap_crtc_funcs); drm_crtc_helper_add(crtc, &omap_crtc_helper_funcs); - omap_plane_install_properties(omap_crtc->plane, &crtc->base); - return crtc; fail: diff --git a/trunk/drivers/staging/omapdrm/omap_dmm_tiler.c b/trunk/drivers/staging/omapdrm/omap_dmm_tiler.c index 3ae39554df18..ec7a5c8f5363 100644 --- a/trunk/drivers/staging/omapdrm/omap_dmm_tiler.c +++ b/trunk/drivers/staging/omapdrm/omap_dmm_tiler.c @@ -404,26 +404,8 @@ int tiler_release(struct tiler_block *block) * Utils */ -/* calculate the tiler space address of a pixel in a view orientation... - * below description copied from the display subsystem section of TRM: - * - * When the TILER is addressed, the bits: - * [28:27] = 0x0 for 8-bit tiled - * 0x1 for 16-bit tiled - * 0x2 for 32-bit tiled - * 0x3 for page mode - * [31:29] = 0x0 for 0-degree view - * 0x1 for 180-degree view + mirroring - * 0x2 for 0-degree view + mirroring - * 0x3 for 180-degree view - * 0x4 for 270-degree view + mirroring - * 0x5 for 270-degree view - * 0x6 for 90-degree view - * 0x7 for 90-degree view + mirroring - * Otherwise the bits indicated the corresponding bit address to access - * the SDRAM. - */ -static u32 tiler_get_address(enum tiler_fmt fmt, u32 orient, u32 x, u32 y) +/* calculate the tiler space address of a pixel in a view orientation */ +static u32 tiler_get_address(u32 orient, enum tiler_fmt fmt, u32 x, u32 y) { u32 x_bits, y_bits, tmp, x_mask, y_mask, alignment; @@ -435,11 +417,8 @@ static u32 tiler_get_address(enum tiler_fmt fmt, u32 orient, u32 x, u32 y) x_mask = MASK(x_bits); y_mask = MASK(y_bits); - if (x < 0 || x > x_mask || y < 0 || y > y_mask) { - DBG("invalid coords: %u < 0 || %u > %u || %u < 0 || %u > %u", - x, x, x_mask, y, y, y_mask); + if (x < 0 || x > x_mask || y < 0 || y > y_mask) return 0; - } /* account for mirroring */ if (orient & MASK_X_INVERT) @@ -460,22 +439,11 @@ dma_addr_t tiler_ssptr(struct tiler_block *block) { BUG_ON(!validfmt(block->fmt)); - return TILVIEW_8BIT + tiler_get_address(block->fmt, 0, + return TILVIEW_8BIT + tiler_get_address(0, block->fmt, block->area.p0.x * geom[block->fmt].slot_w, block->area.p0.y * geom[block->fmt].slot_h); } -dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient, - uint32_t x, uint32_t y) -{ - struct tcm_pt *p = &block->area.p0; - BUG_ON(!validfmt(block->fmt)); - - return tiler_get_address(block->fmt, orient, - (p->x * geom[block->fmt].slot_w) + x, - (p->y * geom[block->fmt].slot_h) + y); -} - void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h) { BUG_ON(!validfmt(fmt)); @@ -483,14 +451,11 @@ void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h) *h = round_up(*h, geom[fmt].slot_h); } -uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient) +uint32_t tiler_stride(enum tiler_fmt fmt) { BUG_ON(!validfmt(fmt)); - if (orient & MASK_XY_FLIP) - return 1 << (CONT_HEIGHT_BITS + geom[fmt].x_shft); - else - return 1 << (CONT_WIDTH_BITS + geom[fmt].y_shft); + return 1 << (CONT_WIDTH_BITS + geom[fmt].y_shft); } size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h) diff --git a/trunk/drivers/staging/omapdrm/omap_dmm_tiler.h b/trunk/drivers/staging/omapdrm/omap_dmm_tiler.h index 740911df5fc3..7b1052a329e4 100644 --- a/trunk/drivers/staging/omapdrm/omap_dmm_tiler.h +++ b/trunk/drivers/staging/omapdrm/omap_dmm_tiler.h @@ -54,18 +54,7 @@ struct tiler_block { #define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS)) #define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS)) -/* -Table 15-11. Coding and Description of TILER Orientations -S Y X Description Alternate description -0 0 0 0-degree view Natural view -0 0 1 0-degree view with vertical mirror 180-degree view with horizontal mirror -0 1 0 0-degree view with horizontal mirror 180-degree view with vertical mirror -0 1 1 180-degree view -1 0 0 90-degree view with vertical mirror 270-degree view with horizontal mirror -1 0 1 270-degree view -1 1 0 90-degree view -1 1 1 90-degree view with horizontal mirror 270-degree view with vertical mirror - */ +/* tiler space addressing bitfields */ #define MASK_XY_FLIP (1 << 31) #define MASK_Y_INVERT (1 << 30) #define MASK_X_INVERT (1 << 29) @@ -101,9 +90,7 @@ int tiler_release(struct tiler_block *block); /* utilities */ dma_addr_t tiler_ssptr(struct tiler_block *block); -dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient, - uint32_t x, uint32_t y); -uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient); +uint32_t tiler_stride(enum tiler_fmt fmt); size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h); size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h); void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h); diff --git a/trunk/drivers/staging/omapdrm/omap_drv.c b/trunk/drivers/staging/omapdrm/omap_drv.c index b8e79eb7cd5e..44149eeb97ae 100644 --- a/trunk/drivers/staging/omapdrm/omap_drv.c +++ b/trunk/drivers/staging/omapdrm/omap_drv.c @@ -649,8 +649,6 @@ static int dev_firstopen(struct drm_device *dev) */ static void dev_lastclose(struct drm_device *dev) { - int i; - /* we don't support vga-switcheroo.. so just make sure the fbdev * mode is active */ @@ -659,21 +657,6 @@ static void dev_lastclose(struct drm_device *dev) DBG("lastclose: dev=%p", dev); - /* need to restore default rotation state.. not sure if there is - * a cleaner way to restore properties to default state? Maybe - * a flag that properties should automatically be restored to - * default state on lastclose? - */ - for (i = 0; i < priv->num_crtcs; i++) { - drm_object_property_set_value(&priv->crtcs[i]->base, - priv->rotation_prop, 0); - } - - for (i = 0; i < priv->num_planes; i++) { - drm_object_property_set_value(&priv->planes[i]->base, - priv->rotation_prop, 0); - } - ret = drm_fb_helper_restore_fbdev_mode(priv->fbdev); if (ret) DBG("failed to restore crtc mode"); diff --git a/trunk/drivers/staging/omapdrm/omap_drv.h b/trunk/drivers/staging/omapdrm/omap_drv.h index 9dc72d143ff3..2092a9167d29 100644 --- a/trunk/drivers/staging/omapdrm/omap_drv.h +++ b/trunk/drivers/staging/omapdrm/omap_drv.h @@ -59,27 +59,6 @@ struct omap_drm_private { struct list_head obj_list; bool has_dmm; - - /* properties: */ - struct drm_property *rotation_prop; - struct drm_property *zorder_prop; -}; - -/* this should probably be in drm-core to standardize amongst drivers */ -#define DRM_ROTATE_0 0 -#define DRM_ROTATE_90 1 -#define DRM_ROTATE_180 2 -#define DRM_ROTATE_270 3 -#define DRM_REFLECT_X 4 -#define DRM_REFLECT_Y 5 - -/* parameters which describe (unrotated) coordinates of scanout within a fb: */ -struct omap_drm_window { - uint32_t rotation; - int32_t crtc_x, crtc_y; /* signed because can be offscreen */ - uint32_t crtc_w, crtc_h; - uint32_t src_x, src_y; - uint32_t src_w, src_h; }; #ifdef CONFIG_DEBUG_FS @@ -108,10 +87,6 @@ int omap_plane_mode_set(struct drm_plane *plane, uint32_t src_w, uint32_t src_h); void omap_plane_on_endwin(struct drm_plane *plane, void (*fxn)(void *), void *arg); -void omap_plane_install_properties(struct drm_plane *plane, - struct drm_mode_object *obj); -int omap_plane_set_property(struct drm_plane *plane, - struct drm_property *property, uint64_t val); struct drm_encoder *omap_encoder_init(struct drm_device *dev, struct omap_overlay_manager *mgr); @@ -139,8 +114,8 @@ struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p); int omap_framebuffer_replace(struct drm_framebuffer *a, struct drm_framebuffer *b, void *arg, void (*unpin)(void *arg, struct drm_gem_object *bo)); -void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, - struct omap_drm_window *win, struct omap_overlay_info *info); +void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, int x, int y, + struct omap_overlay_info *info); struct drm_connector *omap_framebuffer_get_next_connector( struct drm_framebuffer *fb, struct drm_connector *from); void omap_framebuffer_flush(struct drm_framebuffer *fb, @@ -182,12 +157,8 @@ int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, bool remap); int omap_gem_put_pages(struct drm_gem_object *obj); uint32_t omap_gem_flags(struct drm_gem_object *obj); -int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient, - int x, int y, dma_addr_t *paddr); uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj); size_t omap_gem_mmap_size(struct drm_gem_object *obj); -int omap_gem_tiled_size(struct drm_gem_object *obj, uint16_t *w, uint16_t *h); -int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient); struct dma_buf * omap_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags); diff --git a/trunk/drivers/staging/omapdrm/omap_fb.c b/trunk/drivers/staging/omapdrm/omap_fb.c index 446801d63007..74260f043ab1 100644 --- a/trunk/drivers/staging/omapdrm/omap_fb.c +++ b/trunk/drivers/staging/omapdrm/omap_fb.c @@ -18,7 +18,6 @@ */ #include "omap_drv.h" -#include "omap_dmm_tiler.h" #include "drm_crtc.h" #include "drm_crtc_helper.h" @@ -138,100 +137,30 @@ static const struct drm_framebuffer_funcs omap_framebuffer_funcs = { .dirty = omap_framebuffer_dirty, }; -static uint32_t get_linear_addr(struct plane *plane, - const struct format *format, int n, int x, int y) -{ - uint32_t offset; - - offset = plane->offset + - (x * format->planes[n].stride_bpp) + - (y * plane->pitch / format->planes[n].sub_y); - - return plane->paddr + offset; -} - /* update ovl info for scanout, handles cases of multi-planar fb's, etc. */ -void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, - struct omap_drm_window *win, struct omap_overlay_info *info) +void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, int x, int y, + struct omap_overlay_info *info) { struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb); const struct format *format = omap_fb->format; struct plane *plane = &omap_fb->planes[0]; - uint32_t x, y, orient = 0; - - info->color_mode = format->dss_format; - - info->pos_x = win->crtc_x; - info->pos_y = win->crtc_y; - info->out_width = win->crtc_w; - info->out_height = win->crtc_h; - info->width = win->src_w; - info->height = win->src_h; - - x = win->src_x; - y = win->src_y; - - if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) { - uint32_t w = win->src_w; - uint32_t h = win->src_h; - - switch (win->rotation & 0xf) { - default: - dev_err(fb->dev->dev, "invalid rotation: %02x", - (uint32_t)win->rotation); - /* fallthru to default to no rotation */ - case 0: - case BIT(DRM_ROTATE_0): - orient = 0; - break; - case BIT(DRM_ROTATE_90): - orient = MASK_XY_FLIP | MASK_X_INVERT; - break; - case BIT(DRM_ROTATE_180): - orient = MASK_X_INVERT | MASK_Y_INVERT; - break; - case BIT(DRM_ROTATE_270): - orient = MASK_XY_FLIP | MASK_Y_INVERT; - break; - } - - if (win->rotation & BIT(DRM_REFLECT_X)) - orient ^= MASK_X_INVERT; - - if (win->rotation & BIT(DRM_REFLECT_Y)) - orient ^= MASK_Y_INVERT; - - /* adjust x,y offset for flip/invert: */ - if (orient & MASK_XY_FLIP) - swap(w, h); - if (orient & MASK_Y_INVERT) - y += h - 1; - if (orient & MASK_X_INVERT) - x += w - 1; + unsigned int offset; - omap_gem_rotated_paddr(plane->bo, orient, x, y, &info->paddr); - info->rotation_type = OMAP_DSS_ROT_TILER; - info->screen_width = omap_gem_tiled_stride(plane->bo, orient); - } else { - info->paddr = get_linear_addr(plane, format, 0, x, y); - info->rotation_type = OMAP_DSS_ROT_DMA; - info->screen_width = plane->pitch; - } + offset = plane->offset + + (x * format->planes[0].stride_bpp) + + (y * plane->pitch / format->planes[0].sub_y); - /* convert to pixels: */ - info->screen_width /= format->planes[0].stride_bpp; + info->color_mode = format->dss_format; + info->paddr = plane->paddr + offset; + info->screen_width = plane->pitch / format->planes[0].stride_bpp; if (format->dss_format == OMAP_DSS_COLOR_NV12) { plane = &omap_fb->planes[1]; - - if (info->rotation_type == OMAP_DSS_ROT_TILER) { - WARN_ON(!(omap_gem_flags(plane->bo) & OMAP_BO_TILED)); - omap_gem_rotated_paddr(plane->bo, orient, - x/2, y/2, &info->p_uv_addr); - } else { - info->p_uv_addr = get_linear_addr(plane, format, 1, x, y); - } + offset = plane->offset + + (x * format->planes[1].stride_bpp) + + (y * plane->pitch / format->planes[1].sub_y); + info->p_uv_addr = plane->paddr + offset; } else { info->p_uv_addr = 0; } @@ -448,7 +377,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, size = pitch * mode_cmd->height / format->planes[i].sub_y; - if (size > (omap_gem_mmap_size(bos[i]) - mode_cmd->offsets[i])) { + if (size > (bos[i]->size - mode_cmd->offsets[i])) { dev_err(dev->dev, "provided buffer object is too small! %d < %d\n", bos[i]->size - mode_cmd->offsets[i], size); ret = -EINVAL; diff --git a/trunk/drivers/staging/omapdrm/omap_gem.c b/trunk/drivers/staging/omapdrm/omap_gem.c index 74082aa35589..3a0d035a9e03 100644 --- a/trunk/drivers/staging/omapdrm/omap_gem.c +++ b/trunk/drivers/staging/omapdrm/omap_gem.c @@ -339,17 +339,6 @@ size_t omap_gem_mmap_size(struct drm_gem_object *obj) return size; } -/* get tiled size, returns -EINVAL if not tiled buffer */ -int omap_gem_tiled_size(struct drm_gem_object *obj, uint16_t *w, uint16_t *h) -{ - struct omap_gem_object *omap_obj = to_omap_bo(obj); - if (omap_obj->flags & OMAP_BO_TILED) { - *w = omap_obj->width; - *h = omap_obj->height; - return 0; - } - return -EINVAL; -} /* Normal handling for the case of faulting in non-tiled buffers */ static int fault_1d(struct drm_gem_object *obj, @@ -843,36 +832,6 @@ int omap_gem_put_paddr(struct drm_gem_object *obj) return ret; } -/* Get rotated scanout address (only valid if already pinned), at the - * specified orientation and x,y offset from top-left corner of buffer - * (only valid for tiled 2d buffers) - */ -int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient, - int x, int y, dma_addr_t *paddr) -{ - struct omap_gem_object *omap_obj = to_omap_bo(obj); - int ret = -EINVAL; - - mutex_lock(&obj->dev->struct_mutex); - if ((omap_obj->paddr_cnt > 0) && omap_obj->block && - (omap_obj->flags & OMAP_BO_TILED)) { - *paddr = tiler_tsptr(omap_obj->block, orient, x, y); - ret = 0; - } - mutex_unlock(&obj->dev->struct_mutex); - return ret; -} - -/* Get tiler stride for the buffer (only valid for 2d tiled buffers) */ -int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient) -{ - struct omap_gem_object *omap_obj = to_omap_bo(obj); - int ret = -EINVAL; - if (omap_obj->flags & OMAP_BO_TILED) - ret = tiler_stride(gem2fmt(omap_obj->flags), orient); - return ret; -} - /* acquire pages when needed (for example, for DMA where physically * contiguous buffer is not required */ @@ -1443,7 +1402,7 @@ void omap_gem_init(struct drm_device *dev) */ usergart[i].height = h; usergart[i].height_shift = ilog2(h); - usergart[i].stride_pfn = tiler_stride(fmts[i], 0) >> PAGE_SHIFT; + usergart[i].stride_pfn = tiler_stride(fmts[i]) >> PAGE_SHIFT; usergart[i].slot_shift = ilog2((PAGE_SIZE / h) >> i); for (j = 0; j < NUM_USERGART_ENTRIES; j++) { struct usergart_entry *entry = &usergart[i].entry[j]; diff --git a/trunk/drivers/staging/omapdrm/omap_plane.c b/trunk/drivers/staging/omapdrm/omap_plane.c index 4bde639dd02c..7997be74010d 100644 --- a/trunk/drivers/staging/omapdrm/omap_plane.c +++ b/trunk/drivers/staging/omapdrm/omap_plane.c @@ -20,7 +20,6 @@ #include #include "omap_drv.h" -#include "omap_dmm_tiler.h" /* some hackery because omapdss has an 'enum omap_plane' (which would be * better named omap_plane_id).. and compiler seems unhappy about having @@ -44,9 +43,10 @@ struct omap_plane { struct omap_overlay *ovl; struct omap_overlay_info info; - /* position/orientation of scanout within the fb: */ - struct omap_drm_window win; - + /* Source values, converted to integers because we don't support + * fractional positions: + */ + unsigned int src_x, src_y; /* last fb that we pinned: */ struct drm_framebuffer *pinned_fb; @@ -289,7 +289,6 @@ static void update_scanout(struct drm_plane *plane) { struct omap_plane *omap_plane = to_omap_plane(plane); struct omap_overlay_info *info = &omap_plane->info; - struct omap_drm_window *win = &omap_plane->win; int ret; ret = update_pin(plane, plane->fb); @@ -300,10 +299,11 @@ static void update_scanout(struct drm_plane *plane) return; } - omap_framebuffer_update_scanout(plane->fb, win, info); + omap_framebuffer_update_scanout(plane->fb, + omap_plane->src_x, omap_plane->src_y, info); DBG("%s: %d,%d: %08x %08x (%d)", omap_plane->ovl->name, - win->src_x, win->src_y, + omap_plane->src_x, omap_plane->src_y, (u32)info->paddr, (u32)info->p_uv_addr, info->screen_width); } @@ -316,18 +316,21 @@ int omap_plane_mode_set(struct drm_plane *plane, uint32_t src_w, uint32_t src_h) { struct omap_plane *omap_plane = to_omap_plane(plane); - struct omap_drm_window *win = &omap_plane->win; - - win->crtc_x = crtc_x; - win->crtc_y = crtc_y; - win->crtc_w = crtc_w; - win->crtc_h = crtc_h; /* src values are in Q16 fixed point, convert to integer: */ - win->src_x = src_x >> 16; - win->src_y = src_y >> 16; - win->src_w = src_w >> 16; - win->src_h = src_h >> 16; + src_x = src_x >> 16; + src_y = src_y >> 16; + src_w = src_w >> 16; + src_h = src_h >> 16; + + omap_plane->info.pos_x = crtc_x; + omap_plane->info.pos_y = crtc_y; + omap_plane->info.out_width = crtc_w; + omap_plane->info.out_height = crtc_h; + omap_plane->info.width = src_w; + omap_plane->info.height = src_h; + omap_plane->src_x = src_x; + omap_plane->src_y = src_y; /* note: this is done after this fxn returns.. but if we need * to do a commit/update_scanout, etc before this returns we @@ -356,8 +359,6 @@ static int omap_plane_update(struct drm_plane *plane, static int omap_plane_disable(struct drm_plane *plane) { - struct omap_plane *omap_plane = to_omap_plane(plane); - omap_plane->win.rotation = BIT(DRM_ROTATE_0); return omap_plane_dpms(plane, DRM_MODE_DPMS_OFF); } @@ -408,79 +409,10 @@ void omap_plane_on_endwin(struct drm_plane *plane, install_irq(plane); } -/* helper to install properties which are common to planes and crtcs */ -void omap_plane_install_properties(struct drm_plane *plane, - struct drm_mode_object *obj) -{ - struct drm_device *dev = plane->dev; - struct omap_drm_private *priv = dev->dev_private; - struct drm_property *prop; - - prop = priv->rotation_prop; - if (!prop) { - const struct drm_prop_enum_list props[] = { - { DRM_ROTATE_0, "rotate-0" }, - { DRM_ROTATE_90, "rotate-90" }, - { DRM_ROTATE_180, "rotate-180" }, - { DRM_ROTATE_270, "rotate-270" }, - { DRM_REFLECT_X, "reflect-x" }, - { DRM_REFLECT_Y, "reflect-y" }, - }; - prop = drm_property_create_bitmask(dev, 0, "rotation", - props, ARRAY_SIZE(props)); - if (prop == NULL) - return; - priv->rotation_prop = prop; - } - drm_object_attach_property(obj, prop, 0); - - prop = priv->zorder_prop; - if (!prop) { - prop = drm_property_create_range(dev, 0, "zorder", 0, 3); - if (prop == NULL) - return; - priv->zorder_prop = prop; - } - drm_object_attach_property(obj, prop, 0); -} - -int omap_plane_set_property(struct drm_plane *plane, - struct drm_property *property, uint64_t val) -{ - struct omap_plane *omap_plane = to_omap_plane(plane); - struct omap_drm_private *priv = plane->dev->dev_private; - int ret = -EINVAL; - - if (property == priv->rotation_prop) { - struct omap_overlay *ovl = omap_plane->ovl; - - DBG("%s: rotation: %02x", ovl->name, (uint32_t)val); - omap_plane->win.rotation = val; - - if (ovl->is_enabled(ovl)) - ret = omap_plane_dpms(plane, DRM_MODE_DPMS_ON); - else - ret = 0; - } else if (property == priv->zorder_prop) { - struct omap_overlay *ovl = omap_plane->ovl; - - DBG("%s: zorder: %d", ovl->name, (uint32_t)val); - omap_plane->info.zorder = val; - - if (ovl->is_enabled(ovl)) - ret = omap_plane_dpms(plane, DRM_MODE_DPMS_ON); - else - ret = 0; - } - - return ret; -} - static const struct drm_plane_funcs omap_plane_funcs = { .update_plane = omap_plane_update, .disable_plane = omap_plane_disable, .destroy = omap_plane_destroy, - .set_property = omap_plane_set_property, }; /* initialize plane */ @@ -523,8 +455,6 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, drm_plane_init(dev, plane, possible_crtcs, &omap_plane_funcs, omap_plane->formats, omap_plane->nformats, priv); - omap_plane_install_properties(plane, &plane->base); - /* get our starting configuration, set defaults for parameters * we don't currently use, etc: */ @@ -533,6 +463,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, omap_plane->info.rotation = OMAP_DSS_ROT_0; omap_plane->info.global_alpha = 0xff; omap_plane->info.mirror = 0; + omap_plane->info.mirror = 0; /* Set defaults depending on whether we are a CRTC or overlay * layer. diff --git a/trunk/drivers/staging/serqt_usb2/serqt_usb2.c b/trunk/drivers/staging/serqt_usb2/serqt_usb2.c index 1b26023b7928..8a362f7af379 100644 --- a/trunk/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/trunk/drivers/staging/serqt_usb2/serqt_usb2.c @@ -247,6 +247,7 @@ static void ProcessLineStatus(struct quatech_port *qt_port, qt_port->shadowLSR = line_status & (SERIAL_LSR_OE | SERIAL_LSR_PE | SERIAL_LSR_FE | SERIAL_LSR_BI); + return; } static void ProcessModemStatus(struct quatech_port *qt_port, @@ -255,6 +256,7 @@ static void ProcessModemStatus(struct quatech_port *qt_port, qt_port->shadowMSR = modem_status; wake_up_interruptible(&qt_port->wait); + return; } static void ProcessRxChar(struct tty_struct *tty, struct usb_serial_port *port, @@ -1410,7 +1412,7 @@ static int qt_tiocmget(struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port = qt_get_port_private(port); - int retval; + int retval = -ENODEV; if (!serial) return -ENODEV; @@ -1428,7 +1430,7 @@ static int qt_tiocmset(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port = qt_get_port_private(port); - int retval; + int retval = -ENODEV; if (!serial) return -ENODEV; @@ -1456,6 +1458,7 @@ static void qt_throttle(struct tty_struct *tty) qt_port->RxHolding = 1; mutex_unlock(&qt_port->lock); + return; } static void qt_unthrottle(struct tty_struct *tty) @@ -1496,6 +1499,8 @@ static void qt_unthrottle(struct tty_struct *tty) } } mutex_unlock(&qt_port->lock); + return; + } static int qt_calc_num_ports(struct usb_serial *serial) diff --git a/trunk/drivers/staging/vme/devices/vme_user.c b/trunk/drivers/staging/vme/devices/vme_user.c index 0170788fcdee..e25645e226e3 100644 --- a/trunk/drivers/staging/vme/devices/vme_user.c +++ b/trunk/drivers/staging/vme/devices/vme_user.c @@ -64,13 +64,13 @@ static unsigned int bus_num; * * However the VME driver at http://www.vmelinux.org/ is rather old and doesn't * even support the tsi148 chipset (which has 8 master and 8 slave windows). - * We'll run with this for now as far as possible, however it probably makes + * We'll run with this or now as far as possible, however it probably makes * sense to get rid of the old mappings and just do everything dynamically. * * So for now, we'll restrict the driver to providing 4 masters and 4 slaves as * defined above and try to support at least some of the interface from - * http://www.vmelinux.org/ as an alternative the driver can be written - * providing a saner interface later. + * http://www.vmelinux.org/ as an alternative drive can be written providing a + * saner interface later. * * The vmelinux.org driver never supported slave images, the devices reserved * for slaves were repurposed to support all 8 master images on the UniverseII! @@ -242,7 +242,7 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count, } /* - * We are going to alloc a page during init per window for small transfers. + * We are going ot alloc a page during init per window for small transfers. * Small transfers will go user space -> buffer -> VME. Larger (more than a * page) transfers will lock the user space buffer into memory and then * transfer the data directly from the user space buffers out to VME. diff --git a/trunk/drivers/staging/xgifb/vb_init.c b/trunk/drivers/staging/xgifb/vb_init.c index fdb7d1a78b3b..80dba6a425ba 100644 --- a/trunk/drivers/staging/xgifb/vb_init.c +++ b/trunk/drivers/staging/xgifb/vb_init.c @@ -1269,7 +1269,7 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo) if (temp <= 2) temp &= 0x03; else - temp = ((temp & 0x04) >> 1) | ((~temp) & 0x01); + temp = ((temp & 0x04) >> 1) || ((~temp) & 0x01); xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);