From 40ef34b3dd72107a1a281c271d06c159cffc3b0f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 16 Aug 2012 14:06:39 -0700 Subject: [PATCH] --- yaml --- r: 324566 b: refs/heads/master c: 1021bb5c62a13b05242bbfdc8a5a241025dad883 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/staging/asus_oled/asus_oled.c | 21 ++- trunk/drivers/staging/comedi/comedi_fops.c | 37 ++-- trunk/drivers/staging/comedi/comedidev.h | 2 +- trunk/drivers/staging/comedi/drivers.c | 69 ++++---- .../staging/comedi/drivers/adl_pci7x3x.c | 4 +- .../staging/comedi/drivers/amplc_dio200.c | 57 ++++--- .../staging/comedi/drivers/amplc_pc236.c | 64 ++++--- .../staging/comedi/drivers/amplc_pc263.c | 52 +++--- .../staging/comedi/drivers/contec_pci_dio.c | 146 ++++++---------- .../staging/comedi/drivers/dyna_pci10xx.c | 161 +++++------------- trunk/drivers/staging/comedi/range.c | 16 +- trunk/drivers/staging/csr/Makefile | 1 - trunk/drivers/staging/csr/csr_formatted_io.c | 27 --- trunk/drivers/staging/csr/csr_formatted_io.h | 25 --- .../staging/csr/csr_wifi_hip_card_sdio.c | 8 +- trunk/drivers/staging/csr/csr_wifi_hip_udi.c | 94 +++++----- .../drivers/staging/csr/csr_wifi_hip_unifi.h | 1 - trunk/drivers/staging/csr/io.c | 30 ++-- trunk/drivers/staging/line6/variax.c | 8 +- trunk/drivers/staging/omapdrm/omap_crtc.c | 10 ++ .../drivers/staging/omapdrm/omap_dmm_tiler.c | 47 ++++- .../drivers/staging/omapdrm/omap_dmm_tiler.h | 17 +- trunk/drivers/staging/omapdrm/omap_drv.c | 17 ++ trunk/drivers/staging/omapdrm/omap_drv.h | 33 +++- trunk/drivers/staging/omapdrm/omap_fb.c | 99 +++++++++-- trunk/drivers/staging/omapdrm/omap_gem.c | 43 ++++- trunk/drivers/staging/omapdrm/omap_plane.c | 111 +++++++++--- trunk/drivers/staging/serqt_usb2/serqt_usb2.c | 9 +- trunk/drivers/staging/vme/devices/vme_user.c | 8 +- trunk/drivers/staging/xgifb/vb_init.c | 2 +- 31 files changed, 683 insertions(+), 538 deletions(-) delete mode 100644 trunk/drivers/staging/csr/csr_formatted_io.c delete mode 100644 trunk/drivers/staging/csr/csr_formatted_io.h diff --git a/[refs] b/[refs] index 50b0c7914fd1..ec17866842c6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bc2c90c974a0ed390327bbd94f49269e9f24e280 +refs/heads/master: 1021bb5c62a13b05242bbfdc8a5a241025dad883 diff --git a/trunk/drivers/staging/asus_oled/asus_oled.c b/trunk/drivers/staging/asus_oled/asus_oled.c index f63c1d3aeb64..42a5e7ab5122 100644 --- a/trunk/drivers/staging/asus_oled/asus_oled.c +++ b/trunk/drivers/staging/asus_oled/asus_oled.c @@ -42,8 +42,6 @@ #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' @@ -57,8 +55,9 @@ #define USB_DEVICE_ID_ASUS_LCM2 0x175b MODULE_AUTHOR("Jakub Schmidtke, sjakub@gmail.com"); -MODULE_DESCRIPTION("Asus OLED Driver v" ASUS_OLED_VERSION); +MODULE_DESCRIPTION("Asus OLED Driver"); MODULE_LICENSE("GPL"); +MODULE_VERSION(ASUS_OLED_VERSION); static struct class *oled_class; static int oled_num; @@ -383,13 +382,13 @@ static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count) default: i = 0; - printk(ASUS_OLED_ERROR "Unknown OLED Pack Mode: %d!\n", + dev_err(odev->dev, "Unknown OLED Pack Mode: %d!\n", odev->pack_mode); break; } if (i >= odev->buf_size) { - printk(ASUS_OLED_ERROR "Buffer overflow! Report a bug:" + dev_err(odev->dev, "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); @@ -435,7 +434,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; - printk(ASUS_OLED_ERROR "Out of memory!\n"); + dev_err(odev->dev, "Out of memory!\n"); return -ENOMEM; } @@ -473,7 +472,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, odev->pic_mode = buf[1]; break; default: - printk(ASUS_OLED_ERROR "Wrong picture mode: '%c'.\n", + dev_err(odev->dev, "Wrong picture mode: '%c'.\n", buf[1]); return -EIO; break; @@ -533,7 +532,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, if (odev->buf == NULL) { odev->buf_size = 0; - printk(ASUS_OLED_ERROR "Out of memory!\n"); + dev_err(odev->dev, "Out of memory!\n"); return -ENOMEM; } @@ -593,15 +592,15 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, return count; error_width: - printk(ASUS_OLED_ERROR "Wrong picture width specified.\n"); + dev_err(odev->dev, "Wrong picture width specified.\n"); return -EIO; error_height: - printk(ASUS_OLED_ERROR "Wrong picture height specified.\n"); + dev_err(odev->dev, "Wrong picture height specified.\n"); return -EIO; error_header: - printk(ASUS_OLED_ERROR "Wrong picture header.\n"); + dev_err(odev->dev, "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 e82126407e95..7a76f9c07afd 100644 --- a/trunk/drivers/staging/comedi/comedi_fops.c +++ b/trunk/drivers/staging/comedi/comedi_fops.c @@ -882,14 +882,12 @@ 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: - 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); + 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); return 0; - break; } return -EINVAL; } @@ -2034,8 +2032,8 @@ void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s) comedi_reset_async_buf(async); async->inttrig = NULL; } else { - printk(KERN_ERR - "BUG: (?) do_become_nonbusy called with async=0\n"); + dev_err(dev->class_dev, + "BUG: (?) do_become_nonbusy called with async=NULL\n"); } s->busy = NULL; @@ -2211,14 +2209,12 @@ static int __init comedi_init(void) int i; int retval; - printk(KERN_INFO "comedi: version " COMEDI_RELEASE - " - http://www.comedi.org\n"); + pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n"); if (comedi_num_legacy_minors < 0 || comedi_num_legacy_minors > 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); + pr_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; } @@ -2247,7 +2243,7 @@ static int __init comedi_init(void) } comedi_class = class_create(THIS_MODULE, "comedi"); if (IS_ERR(comedi_class)) { - printk(KERN_ERR "comedi: failed to create class"); + pr_err("comedi: failed to create class\n"); cdev_del(&comedi_cdev); unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); @@ -2295,8 +2291,7 @@ module_exit(comedi_cleanup); void comedi_error(const struct comedi_device *dev, const char *s) { - printk(KERN_ERR "comedi%d: %s: %s\n", dev->minor, - dev->driver->driver_name, s); + dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s); } EXPORT_SYMBOL(comedi_error); @@ -2420,9 +2415,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) comedi_device_cleanup(info->device); kfree(info->device); kfree(info); - printk(KERN_ERR - "comedi: error: " - "ran out of minor numbers for board device files.\n"); + pr_err("comedi: error: ran out of minor numbers for board device files.\n"); return -EBUSY; } info->device->minor = i; @@ -2499,9 +2492,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, spin_unlock(&comedi_file_info_table_lock); if (i == COMEDI_NUM_MINORS) { kfree(info); - printk(KERN_ERR - "comedi: error: " - "ran out of minor numbers for board device files.\n"); + pr_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 f713783ef624..cb67a5cb9c82 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) \ - printk(KERN_DEBUG "comedi: " format , ## args); \ + pr_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 c0fdb00783ed..c9f5c1f7a9e9 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 - printk(KERN_WARNING - "BUG: dev->driver=NULL in comedi_device_detach()\n"); + dev_warn(dev->class_dev, + "BUG: dev->driver=NULL in comedi_device_detach()\n"); cleanup_device(dev); } @@ -142,8 +142,7 @@ static int comedi_device_postconfig(struct comedi_device *dev) return ret; } if (!dev->board_name) { - printk(KERN_WARNING "BUG: dev->board_name=<%p>\n", - dev->board_name); + dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n"); dev->board_name = "BUG"; } smp_wmb(); @@ -161,7 +160,6 @@ 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) { @@ -177,8 +175,6 @@ 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); @@ -186,6 +182,14 @@ 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; @@ -225,8 +229,9 @@ int comedi_driver_unregister(struct comedi_driver *driver) mutex_lock(&dev->mutex); if (dev->attached && dev->driver == driver) { if (dev->use_count) - printk(KERN_WARNING "BUG! detaching device with use_count=%d\n", - dev->use_count); + dev_warn(dev->class_dev, + "BUG! detaching device with use_count=%d\n", + dev->use_count); comedi_device_detach(dev); } mutex_unlock(&dev->mutex); @@ -273,8 +278,8 @@ static int postconfig(struct comedi_device *dev) async = kzalloc(sizeof(struct comedi_async), GFP_KERNEL); if (async == NULL) { - printk(KERN_INFO - "failed to allocate async struct\n"); + dev_warn(dev->class_dev, + "failed to allocate async struct\n"); return -ENOMEM; } init_waitqueue_head(&async->wait_head); @@ -290,7 +295,8 @@ static int postconfig(struct comedi_device *dev) async->prealloc_buf = NULL; async->prealloc_bufsz = 0; if (comedi_buf_alloc(dev, s, buf_size) < 0) { - printk(KERN_INFO "Buffer allocation failed\n"); + dev_warn(dev->class_dev, + "Buffer allocation failed\n"); return -ENOMEM; } if (s->buf_change) { @@ -370,17 +376,17 @@ static void comedi_report_boards(struct comedi_driver *driv) unsigned int i; const char *const *name_ptr; - printk(KERN_INFO "comedi: valid board names for %s driver are:\n", - driv->driver_name); + pr_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++) { - printk(KERN_INFO " %s\n", *name_ptr); + pr_info(" %s\n", *name_ptr); name_ptr = (const char **)((char *)name_ptr + driv->offset); } if (driv->num_names == 0) - printk(KERN_INFO " %s\n", driv->driver_name); + pr_info(" %s\n", driv->driver_name); } static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) @@ -584,9 +590,9 @@ static unsigned int comedi_buf_munge(struct comedi_async *async, block_size = num_bytes - count; if (block_size < 0) { - printk(KERN_WARNING - "%s: %s: bug! block_size is negative\n", - __FILE__, __func__); + dev_warn(s->device->class_dev, + "%s: %s: bug! block_size is negative\n", + __FILE__, __func__); break; } if ((int)(async->munge_ptr + block_size - @@ -667,7 +673,8 @@ 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) { - printk(KERN_INFO "comedi: attempted to write-free more bytes than have been write-allocated.\n"); + dev_info(async->subdevice->device->class_dev, + "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; @@ -703,8 +710,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) { - printk(KERN_INFO - "comedi: attempted to read-free more bytes than have been read-allocated.\n"); + dev_info(async->subdevice->device->class_dev, + "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; @@ -853,10 +860,9 @@ 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)) { - printk(KERN_INFO "comedi: failed to increment module count\n"); + else if (!try_module_get(driver->module)) ret = -EIO; - } else { + else { /* set comedi_dev->driver here for attach wrapper */ comedi_dev->driver = driver; ret = (*attach_wrapper)(comedi_dev, context); @@ -884,14 +890,19 @@ 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) { - printk(KERN_WARNING - "comedi: auto config failed to find board entry" - " '%s' for driver '%s'\n", it->board_name, - driv->driver_name); + dev_warn(dev->class_dev, + "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 990670a3c5b1..41963fba4fc2 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 int reg = (unsigned int)s->private; + unsigned long reg = (unsigned long)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 int reg = (unsigned int)s->private; + unsigned long reg = (unsigned long)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 6c81e377262c..9c8fbf1b15f0 100644 --- a/trunk/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/trunk/drivers/staging/comedi/drivers/amplc_dio200.c @@ -215,6 +215,9 @@ 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 @@ -272,12 +275,12 @@ enum dio200_model { }; enum dio200_layout { -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) +#if DO_ISA pc212_layout, pc214_layout, #endif pc215_layout, -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) +#if DO_ISA pc218_layout, #endif pc272_layout @@ -292,7 +295,7 @@ struct dio200_board { }; static const struct dio200_board dio200_boards[] = { -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) +#if DO_ISA { .name = "pc212e", .bustype = isa_bustype, @@ -324,7 +327,7 @@ static const struct dio200_board dio200_boards[] = { .layout = pc272_layout, }, #endif -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) +#if DO_PCI { .name = "pci215", .devid = PCI_DEVICE_ID_AMPLICON_PCI215, @@ -367,7 +370,7 @@ struct dio200_layout_struct { }; static const struct dio200_layout_struct dio200_layouts[] = { -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) +#if DO_ISA [pc212_layout] = { .n_subdevs = 6, .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254, @@ -396,7 +399,7 @@ static const struct dio200_layout_struct dio200_layouts[] = { .has_int_sce = 1, .has_clk_gat_sce = 1, }, -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) +#if DO_ISA [pc218_layout] = { .n_subdevs = 7, .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254, @@ -449,6 +452,16 @@ 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. */ @@ -458,7 +471,7 @@ dio200_find_pci_board(struct pci_dev *pci_dev) unsigned int i; for (i = 0; i < ARRAY_SIZE(dio200_boards); i++) - if (dio200_boards[i].bustype == pci_bustype && + if (is_pci_board(&dio200_boards[i]) && pci_dev->device == dio200_boards[i].devid) return &dio200_boards[i]; return NULL; @@ -1228,12 +1241,10 @@ static void dio200_report_attach(struct comedi_device *dev, unsigned int irq) char tmpbuf[60]; int tmplen; - if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) && - thisboard->bustype == isa_bustype) + if (is_isa_board(thisboard)) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase); - else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) && - thisboard->bustype == pci_bustype) + else if (is_pci_board(thisboard)) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ", pci_name(pcidev)); else @@ -1361,8 +1372,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) } /* Process options and reserve resources according to bus type. */ - if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) && - thisboard->bustype == isa_bustype) { + if (is_isa_board(thisboard)) { unsigned long iobase; unsigned int irq; @@ -1372,8 +1382,7 @@ 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_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) && - thisboard->bustype == pci_bustype) { + } else if (is_pci_board(thisboard)) { struct pci_dev *pci_dev; pci_dev = dio200_find_pci_dev(dev, it); @@ -1397,7 +1406,7 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev, { int ret; - if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI)) + if (!DO_PCI) return -EINVAL; dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach pci %s\n", @@ -1418,7 +1427,6 @@ 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; @@ -1443,13 +1451,16 @@ static void dio200_detach(struct comedi_device *dev) } } } - if (pcidev) { - if (dev->iobase) - comedi_pci_disable(pcidev); - pci_dev_put(pcidev); - } else { + if (is_isa_board(thisboard)) { 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); + } } } @@ -1470,7 +1481,7 @@ static struct comedi_driver amplc_dio200_driver = { .num_names = ARRAY_SIZE(dio200_boards), }; -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) +#if DO_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 aabba9886b7d..c64438580b21 100644 --- a/trunk/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/trunk/drivers/staging/comedi/drivers/amplc_pc236.c @@ -61,6 +61,9 @@ 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 @@ -103,14 +106,14 @@ struct pc236_board { enum pc236_model model; }; static const struct pc236_board pc236_boards[] = { -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) +#if DO_ISA { .name = "pc36at", .bustype = isa_bustype, .model = pc36at_model, }, #endif -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) +#if DO_PCI { .name = "pci236", .devid = PCI_DEVICE_ID_AMPLICON_PCI236, @@ -135,6 +138,18 @@ 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. */ @@ -143,7 +158,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 (pc236_boards[i].bustype == pci_bustype && + if (is_pci_board(&pc236_boards[i]) && pci_dev->device == pc236_boards[i].devid) return &pc236_boards[i]; return NULL; @@ -214,12 +229,13 @@ 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_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase) + if (is_pci_board(thisboard)) outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -231,12 +247,13 @@ 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_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase) + if (is_pci_board(thisboard)) outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -250,6 +267,7 @@ 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; @@ -257,8 +275,7 @@ static int pc236_intr_check(struct comedi_device *dev) spin_lock_irqsave(&dev->spinlock, flags); if (devpriv->enable_irq) { retval = 1; - if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && - devpriv->lcr_iobase) { + if (is_pci_board(thisboard)) { if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR) & PLX9052_INTCSR_LI1STAT_MASK) == PLX9052_INTCSR_LI1STAT_INACTIVE) { @@ -414,15 +431,13 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq) char tmpbuf[60]; int tmplen; - if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) && - thisboard->bustype == isa_bustype) + if (is_isa_board(thisboard)) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase); - else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && - thisboard->bustype == pci_bustype) { + else if (is_pci_board(thisboard)) tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ", pci_name(pcidev)); - } else + else tmplen = 0; if (irq) tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen, @@ -517,16 +532,14 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it) return ret; } /* Process options according to bus type. */ - if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) && - thisboard->bustype == isa_bustype) { + if (is_isa_board(thisboard)) { 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_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && - thisboard->bustype == pci_bustype) { + } else if (is_pci_board(thisboard)) { struct pci_dev *pci_dev; pci_dev = pc236_find_pci_dev(dev, it); @@ -550,7 +563,7 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev, { int ret; - if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)) + if (!DO_PCI) return -EINVAL; dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n", @@ -570,8 +583,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); @@ -579,13 +592,16 @@ static void pc236_detach(struct comedi_device *dev) free_irq(dev->irq, dev); if (dev->subdevices) subdev_8255_cleanup(dev, dev->subdevices + 0); - if (pcidev) { - if (dev->iobase) - comedi_pci_disable(pcidev); - pci_dev_put(pcidev); - } else { + if (is_isa_board(thisboard)) { 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); + } } } @@ -606,7 +622,7 @@ static struct comedi_driver amplc_pc236_driver = { .num_names = ARRAY_SIZE(pc236_boards), }; -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) +#if DO_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 40ec1ffebba6..148c9d3acf64 100644 --- a/trunk/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/trunk/drivers/staging/comedi/drivers/amplc_pc263.c @@ -48,6 +48,9 @@ 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 @@ -70,14 +73,14 @@ struct pc263_board { enum pc263_model model; }; static const struct pc263_board pc263_boards[] = { -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) +#if DO_ISA { .name = "pc263", .bustype = isa_bustype, .model = pc263_model, }, #endif -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) +#if DO_PCI { .name = "pci263", .devid = PCI_DEVICE_ID_AMPLICON_PCI263, @@ -93,6 +96,18 @@ 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. */ @@ -101,7 +116,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 (pc263_boards[i].bustype == pci_bustype && + if (is_pci_board(&pc263_boards[i]) && pci_dev->device == pc263_boards[i].devid) return &pc263_boards[i]; return NULL; @@ -187,11 +202,9 @@ static void pc263_report_attach(struct comedi_device *dev) struct pci_dev *pcidev = comedi_to_pci_dev(dev); char tmpbuf[40]; - if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) && - thisboard->bustype == isa_bustype) + if (is_isa_board(thisboard)) snprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase); - else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) && - thisboard->bustype == pci_bustype) + else if (is_pci_board(thisboard)) snprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ", pci_name(pcidev)); else @@ -259,15 +272,13 @@ 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_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) && - thisboard->bustype == isa_bustype) { + if (is_isa_board(thisboard)) { 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_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) && - thisboard->bustype == pci_bustype) { + } else if (is_pci_board(thisboard)) { struct pci_dev *pci_dev; pci_dev = pc263_find_pci_dev(dev, it); @@ -288,7 +299,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 (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI)) + if (!DO_PCI) return -EINVAL; dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach pci %s\n", @@ -303,15 +314,18 @@ static int __devinit pc263_attach_pci(struct comedi_device *dev, static void pc263_detach(struct comedi_device *dev) { - struct pci_dev *pcidev = comedi_to_pci_dev(dev); + const struct pc263_board *thisboard = comedi_board(dev); - if (pcidev) { - if (dev->iobase) - comedi_pci_disable(pcidev); - pci_dev_put(pcidev); - } else { + if (is_isa_board(thisboard)) { 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); + } } } @@ -332,7 +346,7 @@ static struct comedi_driver amplc_pc263_driver = { .num_names = ARRAY_SIZE(pc263_boards), }; -#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) +#if DO_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 944cfeeb2b2d..12ad9fa32f56 100644 --- a/trunk/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/trunk/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -27,51 +27,35 @@ Author: Stefano Rivoir Updated: Wed, 27 Jun 2007 13:00:06 +0100 Status: works -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. +Configuration Options: not applicable, uses comedi PCI auto config */ #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 -#define thisboard ((const struct contec_board *)dev->board_ptr) +/* + * Register map + */ +#define PIO1616L_DI_REG 0x00 +#define PIO1616L_DO_REG 0x02 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]; - dev_dbg(dev->class_dev, "contec_do_insn_bits called\n"); - dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); - 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); + outw(s->state, dev->iobase + PIO1616L_DO_REG); } + + data[1] = s->state; + return insn->n; } @@ -79,87 +63,58 @@ static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - - 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); + data[1] = inw(dev->iobase + PIO1616L_DI_REG); return insn->n; } -static struct pci_dev *contec_find_pci_dev(struct comedi_device *dev, - struct comedi_devconfig *it) +static int contec_attach_pci(struct comedi_device *dev, + struct pci_dev *pcidev) { - 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; - printk("comedi%d: contec: ", dev->minor); + comedi_set_hw_dev(dev, &pcidev->dev); - dev->board_name = thisboard->name; + dev->board_name = dev->driver->driver_name; - ret = comedi_alloc_subdevices(dev, 2); + ret = comedi_pci_enable(pcidev, dev->board_name); if (ret) return ret; - - pcidev = contec_find_pci_dev(dev, it); - if (!pcidev) - return -EIO; - comedi_set_hw_dev(dev, &pcidev->dev); - - 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); - s = dev->subdevices + 0; + ret = comedi_alloc_subdevices(dev, 2); + if (ret) + return ret; - 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; + 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; 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; + 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; + + dev_info(dev->class_dev, "%s attached\n", dev->board_name); - printk("attached\n"); + return 0; +} + +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"); - return 1; + return -ENOSYS; } static void contec_detach(struct comedi_device *dev) @@ -169,7 +124,6 @@ static void contec_detach(struct comedi_device *dev) if (pcidev) { if (dev->iobase) comedi_pci_disable(pcidev); - pci_dev_put(pcidev); } } @@ -177,6 +131,7 @@ 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, }; @@ -192,8 +147,7 @@ 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), - .driver_data = PIO1616L }, + { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_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 064be9aae3aa..e852808c6314 100644 --- a/trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -41,7 +41,6 @@ #include #define PCI_VENDOR_ID_DYNALOG 0x10b5 -#define DRV_NAME "dyna_pci10xx" #define READ_TIMEOUT 50 @@ -54,59 +53,11 @@ 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 ******************************/ /******************************************************************************/ @@ -116,13 +67,14 @@ 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 = thisboard->range_codes_ai[CR_RANGE((insn->chanspec))]; + range = range_codes_pci1050_ai[CR_RANGE((insn->chanspec))]; mutex_lock(&devpriv->mutex); /* convert n samples */ @@ -159,11 +111,12 @@ 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 = thisboard->range_codes_ai[CR_RANGE((insn->chanspec))]; + range = range_codes_pci1050_ai[CR_RANGE((insn->chanspec))]; mutex_lock(&devpriv->mutex); for (n = 0; n < insn->n; n++) { @@ -181,6 +134,7 @@ 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); @@ -200,6 +154,8 @@ 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 @@ -223,71 +179,30 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev, return insn->n; } -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) +static int dyna_pci10xx_attach_pci(struct comedi_device *dev, + struct pci_dev *pcidev) { - struct pci_dev *pcidev; + struct dyna_pci10xx_private *devpriv; 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 = thisboard->name; - dev->irq = 0; - - 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); + dev->board_name = dev->driver->driver_name; - printk(KERN_INFO "comedi: dyna_pci10xx: device found!\n"); + ret = alloc_private(dev, sizeof(*devpriv)); + if (ret) + return ret; + devpriv = dev->private; + 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; @@ -296,9 +211,9 @@ static int dyna_pci10xx_attach(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 = thisboard->ai_chans; + s->n_chan = 16; s->maxdata = 0x0FFF; - s->range_table = thisboard->range_ai; + s->range_table = &range_pci1050_ai; s->len_chanlist = 16; s->insn_read = dyna_pci10xx_insn_read_ai; @@ -306,9 +221,9 @@ static int dyna_pci10xx_attach(struct comedi_device *dev, s = dev->subdevices + 1; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = thisboard->ao_chans; + s->n_chan = 16; s->maxdata = 0x0FFF; - s->range_table = thisboard->range_ao; + s->range_table = &range_unipolar10; s->len_chanlist = 16; s->insn_write = dyna_pci10xx_insn_write_ao; @@ -316,39 +231,47 @@ static int dyna_pci10xx_attach(struct comedi_device *dev, s = dev->subdevices + 2; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE | SDF_GROUND; - s->n_chan = thisboard->di_chans; + s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; - s->len_chanlist = thisboard->di_chans; + s->len_chanlist = 16; 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 = thisboard->do_chans; + s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; - s->len_chanlist = thisboard->do_chans; + s->len_chanlist = 16; s->state = 0; s->insn_bits = dyna_pci10xx_do_insn_bits; - printk(KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n", - thisboard->name); + 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"); - return 1; + return -ENOSYS; } 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); } } @@ -356,10 +279,8 @@ 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 41f95237789d..5a6b6df07513 100644 --- a/trunk/drivers/staging/comedi/range.c +++ b/trunk/drivers/staging/comedi/range.c @@ -131,6 +131,7 @@ 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; @@ -139,10 +140,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])) { - 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); + 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); return -EINVAL; } } else if (s->range_table_list) { @@ -152,13 +153,14 @@ 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])) { - printk(KERN_ERR "bad chanlist[%d]=0x%08x\n", - i, chanlist[i]); + dev_warn(dev->class_dev, + "bad chanlist[%d]=0x%08x\n", + i, chanlist[i]); return -EINVAL; } } } else { - printk(KERN_ERR "comedi: (bug) no range type list!\n"); + dev_err(dev->class_dev, "(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 afda44b0a925..ab626edc5ba4 100644 --- a/trunk/drivers/staging/csr/Makefile +++ b/trunk/drivers/staging/csr/Makefile @@ -25,7 +25,6 @@ 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 deleted file mode 100644 index 7213cc8fb577..000000000000 --- a/trunk/drivers/staging/csr/csr_formatted_io.c +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - - (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 deleted file mode 100644 index 2e238cb98d51..000000000000 --- a/trunk/drivers/staging/csr/csr_formatted_io.h +++ /dev/null @@ -1,25 +0,0 @@ -#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 44ab00c53fec..cf148a0fec6a 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)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, + (void)scnprintf(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)CsrSnprintf(card->fh_traffic_queue[i].name, + (void)scnprintf(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)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, + (void)scnprintf(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)CsrSnprintf(card->fh_traffic_queue[i].name, + (void)scnprintf(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 07cfd36c4971..31a27cc60995 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 = CsrSnprintf(p, remaining, "Chip ID %u\n", + written = scnprintf(p, remaining, "Chip ID %u\n", (u16)card->chip_id); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Chip Version %04X\n", + written = scnprintf(p, remaining, "Chip Version %04X\n", card->chip_version); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "HIP v%u.%u\n", + written = scnprintf(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 = CsrSnprintf(p, remaining, "Build %lu: %s\n", + written = scnprintf(p, remaining, "Build %u: %s\n", card->build_id, card->build_id_string); UNIFI_SNPRINTF_RET(p, remaining, written); cfg = &card->config_data; - written = CsrSnprintf(p, remaining, "sdio ctrl offset %u\n", + written = scnprintf(p, remaining, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "fromhost sigbuf handle %u\n", + written = scnprintf(p, remaining, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "tohost_sigbuf_handle %u\n", + written = scnprintf(p, remaining, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_fromhost_sig_frags %u\n", + written = scnprintf(p, remaining, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_tohost_sig_frags %u\n", + written = scnprintf(p, remaining, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_fromhost_data_slots %u\n", + written = scnprintf(p, remaining, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_tohost_data_slots %u\n", + written = scnprintf(p, remaining, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "data_slot_size %u\n", + written = scnprintf(p, remaining, "data_slot_size %u\n", cfg->data_slot_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0001 */ - written = CsrSnprintf(p, remaining, "overlay_size %u\n", + written = scnprintf(p, remaining, "overlay_size %u\n", (u16)cfg->overlay_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0300 */ - written = CsrSnprintf(p, remaining, "data_slot_round %u\n", + written = scnprintf(p, remaining, "data_slot_round %u\n", cfg->data_slot_round); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "sig_frag_size %u\n", + written = scnprintf(p, remaining, "sig_frag_size %u\n", cfg->sig_frag_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0300 */ - written = CsrSnprintf(p, remaining, "tohost_sig_pad %u\n", + written = scnprintf(p, remaining, "tohost_sig_pad %u\n", cfg->tohost_signal_padding); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "\nInternal state:\n"); + written = scnprintf(p, remaining, "\nInternal state:\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", + written = scnprintf(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 = CsrSnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", + written = scnprintf(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 = CsrSnprintf(p, remaining, "fhsr: %u\n", + written = scnprintf(p, remaining, "fhsr: %u\n", (u16)card->from_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "fhsw: %u\n", + written = scnprintf(p, remaining, "fhsw: %u\n", (u16)card->from_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "thsr: %u\n", + written = scnprintf(p, remaining, "thsr: %u\n", (u16)card->to_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "thsw: %u\n", + written = scnprintf(p, remaining, "thsw: %u\n", (u16)card->to_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, - "fh buffer contains: %u signals, %u bytes\n", + written = scnprintf(p, remaining, + "fh buffer contains: %d signals, %ld bytes\n", card->fh_buffer.count, card->fh_buffer.ptr - card->fh_buffer.buf); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "paused: "); + written = scnprintf(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 = CsrSnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); + written = scnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "\n"); + written = scnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, + written = scnprintf(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 = CsrSnprintf(p, remaining, + written = scnprintf(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 = CsrSnprintf(p, remaining, "fh data slots free: %u\n", + written = scnprintf(p, remaining, "fh data slots free: %u\n", card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "From host data slots:"); + written = scnprintf(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 = CsrSnprintf(p, remaining, " %u", + written = scnprintf(p, remaining, " %u", (u16)card->from_host_data[i].bd.data_length); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "\n"); + written = scnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "To host data slots:"); + written = scnprintf(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 = CsrSnprintf(p, remaining, " %u", + written = scnprintf(p, remaining, " %u", (u16)card->to_host_data[i].data_length); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "\n"); + written = scnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); #ifdef CSR_UNSAFE_SDIO_ACCESS - written = CsrSnprintf(p, remaining, "Host State: %s\n", states[card->host_state]); + written = scnprintf(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 = CsrSnprintf(p, remaining, "I/O Check: F1 disabled\n"); + written = scnprintf(p, remaining, "I/O Check: F1 disabled\n"); UNIFI_SNPRINTF_RET(p, remaining, written); } else { if (iostate == 1) { - written = CsrSnprintf(p, remaining, "I/O Check: pending interrupt\n"); + written = scnprintf(p, remaining, "I/O Check: pending interrupt\n"); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "BH reason interrupt = %d\n", + written = scnprintf(p, remaining, "BH reason interrupt = %d\n", card->bh_reason_unifi); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "BH reason host = %d\n", + written = scnprintf(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 = CsrSnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n", + written = scnprintf(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 = CsrSnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", + written = scnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", iostate, card->to_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); } #endif - written = CsrSnprintf(p, remaining, "\nStats:\n"); + written = scnprintf(p, remaining, "\nStats:\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Total SDIO bytes: R=%lu W=%lu\n", + written = scnprintf(p, remaining, "Total SDIO bytes: R=%u W=%u\n", card->sdio_bytes_read, card->sdio_bytes_written); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Interrupts generated on card: %lu\n", + written = scnprintf(p, remaining, "Interrupts generated on card: %u\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 dc3c60b49702..2923e2ef12f2 100644 --- a/trunk/drivers/staging/csr/csr_wifi_hip_unifi.h +++ b/trunk/drivers/staging/csr/csr_wifi_hip_unifi.h @@ -98,7 +98,6 @@ 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 deaff252eec3..4774dc852816 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. */ - snprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance); + scnprintf(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 = CsrSnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n", + written = scnprintf(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 = CsrSnprintf(p, remain, "SME: CSR userspace "); + written = scnprintf(p, remain, "SME: CSR userspace "); UNIFI_SNPRINTF_RET(p, remain, written); #ifdef CSR_SUPPORT_WEXT - written = CsrSnprintf(p, remain, "with WEXT support\n"); + written = scnprintf(p, remain, "with WEXT support\n"); #else - written = CsrSnprintf(p, remain, "\n"); + written = scnprintf(p, remain, "\n"); #endif /* CSR_SUPPORT_WEXT */ UNIFI_SNPRINTF_RET(p, remain, written); #endif /* CSR_SME_USERSPACE */ #ifdef CSR_NATIVE_LINUX - written = CsrSnprintf(p, remain, "SME: native\n"); + written = scnprintf(p, remain, "SME: native\n"); UNIFI_SNPRINTF_RET(p, remain, written); #endif #ifdef CSR_SUPPORT_SME - written = CsrSnprintf(p, remain, - "Firmware (ROM) build:%lu, Patch:%lu\n", + written = scnprintf(p, remain, + "Firmware (ROM) build:%u, Patch:%u\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 = CsrSnprintf(p, remain, "Last dbg str: %s\n", + written = scnprintf(p, remain, "Last dbg str: %s\n", priv->last_debug_string); UNIFI_SNPRINTF_RET(p, remain, written); - written = CsrSnprintf(p, remain, "Last dbg16:"); + written = scnprintf(p, remain, "Last dbg16:"); UNIFI_SNPRINTF_RET(p, remain, written); for (i = 0; i < 8; i++) { - written = CsrSnprintf(p, remain, " %04X", + written = scnprintf(p, remain, " %04X", priv->last_debug_word16[i]); UNIFI_SNPRINTF_RET(p, remain, written); } - written = CsrSnprintf(p, remain, "\n"); + written = scnprintf(p, remain, "\n"); UNIFI_SNPRINTF_RET(p, remain, written); - written = CsrSnprintf(p, remain, " "); + written = scnprintf(p, remain, " "); UNIFI_SNPRINTF_RET(p, remain, written); for (; i < 16; i++) { - written = CsrSnprintf(p, remain, " %04X", + written = scnprintf(p, remain, " %04X", priv->last_debug_word16[i]); UNIFI_SNPRINTF_RET(p, remain, written); } - written = CsrSnprintf(p, remain, "\n"); + written = scnprintf(p, remain, "\n"); UNIFI_SNPRINTF_RET(p, remain, written); *start = page; diff --git a/trunk/drivers/staging/line6/variax.c b/trunk/drivers/staging/line6/variax.c index bb99ee4919e7..f97416b1de54 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)); - unsigned long value; + u8 value; int ret; - ret = strict_strtoul(buf, 10, &value); + ret = kstrtou8(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)); - unsigned long value; + u8 value; int ret; - ret = strict_strtoul(buf, 10, &value); + ret = kstrtou8(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 62e0022561bc..98a10bcba0d3 100644 --- a/trunk/drivers/staging/omapdrm/omap_crtc.c +++ b/trunk/drivers/staging/omapdrm/omap_crtc.c @@ -191,10 +191,18 @@ 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 = { @@ -231,6 +239,8 @@ 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 ec7a5c8f5363..3ae39554df18 100644 --- a/trunk/drivers/staging/omapdrm/omap_dmm_tiler.c +++ b/trunk/drivers/staging/omapdrm/omap_dmm_tiler.c @@ -404,8 +404,26 @@ int tiler_release(struct tiler_block *block) * Utils */ -/* 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) +/* 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) { u32 x_bits, y_bits, tmp, x_mask, y_mask, alignment; @@ -417,8 +435,11 @@ static u32 tiler_get_address(u32 orient, enum tiler_fmt fmt, 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) + 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); return 0; + } /* account for mirroring */ if (orient & MASK_X_INVERT) @@ -439,11 +460,22 @@ dma_addr_t tiler_ssptr(struct tiler_block *block) { BUG_ON(!validfmt(block->fmt)); - return TILVIEW_8BIT + tiler_get_address(0, block->fmt, + return TILVIEW_8BIT + tiler_get_address(block->fmt, 0, 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)); @@ -451,11 +483,14 @@ 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 tiler_stride(enum tiler_fmt fmt, uint32_t orient) { BUG_ON(!validfmt(fmt)); - return 1 << (CONT_WIDTH_BITS + geom[fmt].y_shft); + if (orient & MASK_XY_FLIP) + return 1 << (CONT_HEIGHT_BITS + geom[fmt].x_shft); + else + 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 7b1052a329e4..740911df5fc3 100644 --- a/trunk/drivers/staging/omapdrm/omap_dmm_tiler.h +++ b/trunk/drivers/staging/omapdrm/omap_dmm_tiler.h @@ -54,7 +54,18 @@ struct tiler_block { #define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS)) #define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS)) -/* tiler space addressing bitfields */ +/* +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 + */ #define MASK_XY_FLIP (1 << 31) #define MASK_Y_INVERT (1 << 30) #define MASK_X_INVERT (1 << 29) @@ -90,7 +101,9 @@ int tiler_release(struct tiler_block *block); /* utilities */ dma_addr_t tiler_ssptr(struct tiler_block *block); -uint32_t tiler_stride(enum tiler_fmt fmt); +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); 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 44149eeb97ae..b8e79eb7cd5e 100644 --- a/trunk/drivers/staging/omapdrm/omap_drv.c +++ b/trunk/drivers/staging/omapdrm/omap_drv.c @@ -649,6 +649,8 @@ 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 */ @@ -657,6 +659,21 @@ 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 2092a9167d29..9dc72d143ff3 100644 --- a/trunk/drivers/staging/omapdrm/omap_drv.h +++ b/trunk/drivers/staging/omapdrm/omap_drv.h @@ -59,6 +59,27 @@ 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 @@ -87,6 +108,10 @@ 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); @@ -114,8 +139,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, int x, int y, - struct omap_overlay_info *info); +void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, + struct omap_drm_window *win, 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, @@ -157,8 +182,12 @@ 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 74260f043ab1..446801d63007 100644 --- a/trunk/drivers/staging/omapdrm/omap_fb.c +++ b/trunk/drivers/staging/omapdrm/omap_fb.c @@ -18,6 +18,7 @@ */ #include "omap_drv.h" +#include "omap_dmm_tiler.h" #include "drm_crtc.h" #include "drm_crtc_helper.h" @@ -137,30 +138,100 @@ 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, int x, int y, - struct omap_overlay_info *info) +void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, + struct omap_drm_window *win, 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]; - unsigned int offset; + 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; + } - offset = plane->offset + - (x * format->planes[0].stride_bpp) + - (y * plane->pitch / format->planes[0].sub_y); + 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; - info->color_mode = format->dss_format; - info->paddr = plane->paddr + offset; - info->screen_width = plane->pitch / format->planes[0].stride_bpp; + 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; + } + + /* convert to pixels: */ + info->screen_width /= format->planes[0].stride_bpp; if (format->dss_format == OMAP_DSS_COLOR_NV12) { plane = &omap_fb->planes[1]; - offset = plane->offset + - (x * format->planes[1].stride_bpp) + - (y * plane->pitch / format->planes[1].sub_y); - info->p_uv_addr = plane->paddr + offset; + + 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); + } } else { info->p_uv_addr = 0; } @@ -377,7 +448,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, size = pitch * mode_cmd->height / format->planes[i].sub_y; - if (size > (bos[i]->size - mode_cmd->offsets[i])) { + if (size > (omap_gem_mmap_size(bos[i]) - 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 3a0d035a9e03..74082aa35589 100644 --- a/trunk/drivers/staging/omapdrm/omap_gem.c +++ b/trunk/drivers/staging/omapdrm/omap_gem.c @@ -339,6 +339,17 @@ 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, @@ -832,6 +843,36 @@ 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 */ @@ -1402,7 +1443,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]) >> PAGE_SHIFT; + usergart[i].stride_pfn = tiler_stride(fmts[i], 0) >> 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 7997be74010d..4bde639dd02c 100644 --- a/trunk/drivers/staging/omapdrm/omap_plane.c +++ b/trunk/drivers/staging/omapdrm/omap_plane.c @@ -20,6 +20,7 @@ #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 @@ -43,10 +44,9 @@ struct omap_plane { struct omap_overlay *ovl; struct omap_overlay_info info; - /* Source values, converted to integers because we don't support - * fractional positions: - */ - unsigned int src_x, src_y; + /* position/orientation of scanout within the fb: */ + struct omap_drm_window win; + /* last fb that we pinned: */ struct drm_framebuffer *pinned_fb; @@ -289,6 +289,7 @@ 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); @@ -299,11 +300,10 @@ static void update_scanout(struct drm_plane *plane) return; } - omap_framebuffer_update_scanout(plane->fb, - omap_plane->src_x, omap_plane->src_y, info); + omap_framebuffer_update_scanout(plane->fb, win, info); DBG("%s: %d,%d: %08x %08x (%d)", omap_plane->ovl->name, - omap_plane->src_x, omap_plane->src_y, + win->src_x, win->src_y, (u32)info->paddr, (u32)info->p_uv_addr, info->screen_width); } @@ -316,21 +316,18 @@ 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: */ - 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; + win->src_x = src_x >> 16; + win->src_y = src_y >> 16; + win->src_w = src_w >> 16; + win->src_h = src_h >> 16; /* note: this is done after this fxn returns.. but if we need * to do a commit/update_scanout, etc before this returns we @@ -359,6 +356,8 @@ 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); } @@ -409,10 +408,79 @@ 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 */ @@ -455,6 +523,8 @@ 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: */ @@ -463,7 +533,6 @@ 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 8a362f7af379..1b26023b7928 100644 --- a/trunk/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/trunk/drivers/staging/serqt_usb2/serqt_usb2.c @@ -247,7 +247,6 @@ 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, @@ -256,7 +255,6 @@ 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, @@ -1412,7 +1410,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 = -ENODEV; + int retval; if (!serial) return -ENODEV; @@ -1430,7 +1428,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 = -ENODEV; + int retval; if (!serial) return -ENODEV; @@ -1458,7 +1456,6 @@ 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) @@ -1499,8 +1496,6 @@ 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 e25645e226e3..0170788fcdee 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 or now as far as possible, however it probably makes + * We'll run with this for 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 drive can be written providing a - * saner interface later. + * http://www.vmelinux.org/ as an alternative the driver 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 ot alloc a page during init per window for small transfers. + * We are going to 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 80dba6a425ba..fdb7d1a78b3b 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);