Re: [PATCH] staging:board: Macros with flow control statements
On Tue, May 03, 2016 at 06:01:56AM +0300, Nikita Eshkeev wrote: > This patch fixes the checkpatch.pl warning: > > WARNING: Macros with flow control statements should be avoided > +#define board_staging(str, fn) \ > +static int __init runtime_board_check(void) \ > +{\ > + if (of_machine_is_compatible(str)) \ > + fn(); \ > + \ > + return 0; \ > +}\ > + \ > +device_initcall(runtime_board_check) > + That's a dumb warning, the code is fine, as you can see. checkpatch isn't always correct. sorry, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging:board: Macros with flow control statements
This patch fixes the checkpatch.pl warning: WARNING: Macros with flow control statements should be avoided +#define board_staging(str, fn) \ +static int __init runtime_board_check(void)\ +{ \ + if (of_machine_is_compatible(str)) \ + fn(); \ + \ + return 0; \ +} \ + \ +device_initcall(runtime_board_check) + Signed-off-by: Nikita Eshkeev--- drivers/staging/board/armadillo800eva.c | 13 +++-- drivers/staging/board/board.h | 11 --- drivers/staging/board/kzm9d.c | 13 +++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c index 4de4fd0..f759d8f 100644 --- a/drivers/staging/board/armadillo800eva.c +++ b/drivers/staging/board/armadillo800eva.c @@ -94,11 +94,20 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = { }, }; -static void __init armadillo800eva_init(void) +static void armadillo800eva_setup(void) { board_staging_gic_setup_xlate("arm,pl390", 32); board_staging_register_devices(armadillo800eva_devices, ARRAY_SIZE(armadillo800eva_devices)); } -board_staging("renesas,armadillo800eva", armadillo800eva_init); +static int __init armadillo800eva_init(void) +{ + const char *compat = "renesas,armadillo800eva"; + + if (of_machine_is_compatible(compat)) + armadillo800eva_setup(); + return 0; +} + +device_initcall(armadillo800eva_init); diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h index 42ed125..0fa1197 100644 --- a/drivers/staging/board/board.h +++ b/drivers/staging/board/board.h @@ -31,15 +31,4 @@ int board_staging_register_device(const struct board_staging_dev *dev); void board_staging_register_devices(const struct board_staging_dev *devs, unsigned int ndevs); -#define board_staging(str, fn) \ -static int __init runtime_board_check(void)\ -{ \ - if (of_machine_is_compatible(str)) \ - fn(); \ - \ - return 0; \ -} \ - \ -device_initcall(runtime_board_check) - #endif /* __BOARD_H__ */ diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c index 05a6d43..2884823 100644 --- a/drivers/staging/board/kzm9d.c +++ b/drivers/staging/board/kzm9d.c @@ -9,7 +9,7 @@ static struct resource usbs1_res[] __initdata = { DEFINE_RES_IRQ(159), }; -static void __init kzm9d_init(void) +static void kzm9d_setup(void) { board_staging_gic_setup_xlate("arm,pl390", 32); @@ -22,4 +22,13 @@ static void __init kzm9d_init(void) } } -board_staging("renesas,kzm9d", kzm9d_init); +static int __init kzm9d_init(void) +{ + const char *compat = "renesas,kzm9d"; + + if (of_machine_is_compatible(compat)) + kzm9d_setup(); + return 0; +} + +device_initcall(kzm9d_init); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 06/12] staging/android: prepare sync_file for de-staging
Hi Pavel, 2016-05-02 Pavel Machek: > Hi! > > > > -} > > -EXPORT_SYMBOL(sync_file_merge); > > - > > static const char *android_fence_get_driver_name(struct fence *fence) > > { > > struct sync_timeline *parent = fence_parent(fence); > > if this is meant to be used outside android, should it select some > better prefix than android_fence_? Sure, This patchset doesn't touch this code, but my latest patchset changes them to timeline_*. Gustavo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/12] staging/android: remove redundant comments on sync_merge_data
2016-05-02 Pavel Machek: > On Wed 2016-04-27 13:27:08, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > struct sync_merge_data already have documentation on top of the > > struct definition. No need to duplicate it. > > > > Signed-off-by: Gustavo Padovan > > Reviewed-by: Maarten Lankhorst > > > @@ -33,8 +33,8 @@ struct sync_merge_data { > > /** > > * struct sync_fence_info - detailed fence information > > * @obj_name: name of parent sync_timeline > > - * @driver_name: name of driver implementing the parent > > - * @status:status of the fence 0:active 1:signaled <0:error > > +* @driver_name:name of driver implementing the parent > > +* @status: status of the fence 0:active 1:signaled <0:error > > The whitespace (or mail client configuration?) looks wrong here. this has been fixed in v2 already and Greg pulled everything into staging next already. Gustavo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 06/12] staging/android: prepare sync_file for de-staging
Hi! > -} > -EXPORT_SYMBOL(sync_file_merge); > - > static const char *android_fence_get_driver_name(struct fence *fence) > { > struct sync_timeline *parent = fence_parent(fence); if this is meant to be used outside android, should it select some better prefix than android_fence_? Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/12] staging/android: remove redundant comments on sync_merge_data
On Wed 2016-04-27 13:27:08, Gustavo Padovan wrote: > From: Gustavo Padovan> > struct sync_merge_data already have documentation on top of the > struct definition. No need to duplicate it. > > Signed-off-by: Gustavo Padovan > Reviewed-by: Maarten Lankhorst > @@ -33,8 +33,8 @@ struct sync_merge_data { > /** > * struct sync_fence_info - detailed fence information > * @obj_name:name of parent sync_timeline > - * @driver_name: name of driver implementing the parent > - * @status: status of the fence 0:active 1:signaled <0:error > +* @driver_name: name of driver implementing the parent > +* @status: status of the fence 0:active 1:signaled <0:error The whitespace (or mail client configuration?) looks wrong here. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] PCI: hv: report resources release after stopping the bus
On Fri, Apr 29, 2016 at 11:39:10AM +0200, Vitaly Kuznetsov wrote: > Kernel hang is observed when pci-hyperv module is release with device > drivers still attached. E.g. when I do 'rmmod pci_hyperv' with BCM5720 > device pass-through-ed (tg3 module) I see the following: > > NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [rmmod:2104] > ... > Call Trace: > [] tg3_read_mem+0x87/0x100 [tg3] > [] ? 0xa063f000 > [] tg3_poll_fw+0x85/0x150 [tg3] > [] tg3_chip_reset+0x357/0x8c0 [tg3] > [] tg3_halt+0x3b/0x190 [tg3] > [] tg3_stop+0x171/0x230 [tg3] > ... > [] tg3_remove_one+0x90/0x140 [tg3] > [] pci_device_remove+0x39/0xc0 > [] __device_release_driver+0xa1/0x160 > [] device_release_driver+0x23/0x30 > [] pci_stop_bus_device+0x8a/0xa0 > [] pci_stop_root_bus+0x36/0x60 > [] hv_pci_remove+0x238/0x260 [pci_hyperv] > > The problem seems to be that we report local resources release before > stopping the bus and removing devices from it and device drivers may > try to perform some operations with these resources on shutdown. Move > resources release report after we do pci_stop_root_bus(). > > Signed-off-by: Vitaly KuznetsovApplied with Jake's ack to pci/host-hv for v4.7, thanks, Vitaly! > --- > drivers/pci/host/pci-hyperv.c | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c > index f2559b6..c17e792 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -2268,11 +2268,6 @@ static int hv_pci_remove(struct hv_device *hdev) > > hbus = hv_get_drvdata(hdev); > > - ret = hv_send_resources_released(hdev); > - if (ret) > - dev_err(>device, > - "Couldn't send resources released packet(s)\n"); > - > memset(_packet, 0, sizeof(pkt.teardown_packet)); > init_completion(_pkt.host_event); > pkt.teardown_packet.completion_func = hv_pci_generic_compl; > @@ -2295,6 +2290,11 @@ static int hv_pci_remove(struct hv_device *hdev) > pci_unlock_rescan_remove(); > } > > + ret = hv_send_resources_released(hdev); > + if (ret) > + dev_err(>device, > + "Couldn't send resources released packet(s)\n"); > + > vmbus_close(hdev->channel); > > /* Delete any children which might still exist. */ > -- > 2.5.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pci" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 12/19] staging: comedi: mite: do mite_steup() as part of mite_attach()
Currently all the drivers that use the mite driver have to call mite_setup() after allocating and initializing the mite device with mite_attach(). Move the mite_setup() call into mite_attach() to simplify the drivers a bit and remove the need for the additional inline and exported functions. For aesthetics, move mite_setup2(), and rename it to mite_setup(), so it's near mite_attach(). Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 183 +++-- drivers/staging/comedi/drivers/mite.h | 10 +- drivers/staging/comedi/drivers/ni_660x.c | 6 +- drivers/staging/comedi/drivers/ni_pcidio.c | 6 +- drivers/staging/comedi/drivers/ni_pcimio.c | 6 +- 5 files changed, 101 insertions(+), 110 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index f64c5df..08e9c8b 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -245,82 +245,6 @@ static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) return empty_count + full_count; } -int mite_setup2(struct comedi_device *dev, - struct mite *mite, bool use_win1) -{ - resource_size_t daq_phys_addr; - unsigned long length; - int i; - u32 csigr_bits; - unsigned int unknown_dma_burst_bits; - - pci_set_master(mite->pcidev); - - mite->mmio = pci_ioremap_bar(mite->pcidev, 0); - if (!mite->mmio) { - dev_err(dev->class_dev, - "Failed to remap mite io memory address\n"); - return -ENOMEM; - } - - dev->mmio = pci_ioremap_bar(mite->pcidev, 1); - if (!dev->mmio) { - dev_err(dev->class_dev, - "Failed to remap daq io memory address\n"); - return -ENOMEM; - } - daq_phys_addr = pci_resource_start(mite->pcidev, 1); - length = pci_resource_len(mite->pcidev, 1); - - if (use_win1) { - writel(0, mite->mmio + MITE_IODWBSR); - dev_info(dev->class_dev, -"using I/O Window Base Size register 1\n"); - writel(daq_phys_addr | WENAB | - MITE_IODWBSR_1_WSIZE_bits(length), - mite->mmio + MITE_IODWBSR_1); - writel(0, mite->mmio + MITE_IODWCR_1); - } else { - writel(daq_phys_addr | WENAB, mite->mmio + MITE_IODWBSR); - } - /* -* Make sure dma bursts work. I got this from running a bus analyzer -* on a pxi-6281 and a pxi-6713. 6713 powered up with register value -* of 0x61f and bursts worked. 6281 powered up with register value of -* 0x1f and bursts didn't work. The NI windows driver reads the -* register, then does a bitwise-or of 0x600 with it and writes it back. - * -* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be -* written and read back. The bits 0x1f always read as 1. -* The rest always read as zero. -*/ - unknown_dma_burst_bits = readl(mite->mmio + MITE_UNKNOWN_DMA_BURST_REG); - unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS; - writel(unknown_dma_burst_bits, mite->mmio + MITE_UNKNOWN_DMA_BURST_REG); - - csigr_bits = readl(mite->mmio + MITE_CSIGR); - mite->num_channels = CSIGR_TO_DMAC(csigr_bits); - if (mite->num_channels > MAX_MITE_DMA_CHANNELS) { - dev_warn(dev->class_dev, -"mite: bug? chip claims to have %i dma channels. Setting to %i.\n", -mite->num_channels, MAX_MITE_DMA_CHANNELS); - mite->num_channels = MAX_MITE_DMA_CHANNELS; - } - dump_chip_signature(csigr_bits); - for (i = 0; i < mite->num_channels; i++) { - writel(CHOR_DMARESET, mite->mmio + MITE_CHOR(i)); - /* disable interrupts */ - writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE | - CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | - CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE, - mite->mmio + MITE_CHCR(i)); - } - mite->fifo_size = mite_fifo_size(mite, 0); - dev_info(dev->class_dev, "fifo size is %i.\n", mite->fifo_size); - return 0; -} -EXPORT_SYMBOL_GPL(mite_setup2); - struct mite_ring *mite_alloc_ring(struct mite *mite) { struct mite_ring *ring; @@ -807,31 +731,118 @@ int mite_done(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_done); +static int mite_setup(struct comedi_device *dev, struct mite *mite, + bool use_win1) +{ + resource_size_t daq_phys_addr; + unsigned long length; + int i; + u32 csigr_bits; + unsigned int
[PATCH 02/19] staging: comedi: mite: rename 'struct mite_dma_descriptor'
Rename this struct to 'mite_dma_desc' to help shorten the long lines. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 8 drivers/staging/comedi/drivers/mite.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 4bfdbf0..127a86e 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -380,7 +380,7 @@ void mite_free_ring(struct mite_dma_descriptor_ring *ring) if (ring->descriptors) { dma_free_coherent(ring->hw_dev, ring->n_links * - sizeof(struct mite_dma_descriptor), + sizeof(struct mite_dma_desc), ring->descriptors, ring->descriptors_dma_addr); } @@ -477,7 +477,7 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, if (ring->descriptors) { dma_free_coherent(ring->hw_dev, ring->n_links * - sizeof(struct mite_dma_descriptor), + sizeof(struct mite_dma_desc), ring->descriptors, ring->descriptors_dma_addr); } @@ -492,7 +492,7 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, ring->descriptors = dma_alloc_coherent(ring->hw_dev, - n_links * sizeof(struct mite_dma_descriptor), + n_links * sizeof(struct mite_dma_desc), >descriptors_dma_addr, GFP_KERNEL); if (!ring->descriptors) { dev_err(s->device->class_dev, @@ -537,7 +537,7 @@ int mite_init_ring_descriptors(struct mite_dma_descriptor_ring *ring, cpu_to_le32(async->buf_map->page_list[i].dma_addr); ring->descriptors[i].next = cpu_to_le32(ring->descriptors_dma_addr + - (i + 1) * sizeof(struct mite_dma_descriptor)); + (i + 1) * sizeof(struct mite_dma_desc)); } /* the last link is either a remainder or was a full link. */ diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 93d6a32..c42438f 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -28,7 +28,7 @@ struct comedi_subdevice; struct device; struct pci_dev; -struct mite_dma_descriptor { +struct mite_dma_desc { __le32 count; __le32 addr; __le32 next; @@ -38,7 +38,7 @@ struct mite_dma_descriptor { struct mite_dma_descriptor_ring { struct device *hw_dev; unsigned int n_links; - struct mite_dma_descriptor *descriptors; + struct mite_dma_desc *descriptors; dma_addr_t descriptors_dma_addr; }; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 17/19] staging: comedi: mite: move the mite dma arm/disarm/reset functions
For aesthetics, move these functions to a more logical spot in the code and add docbook comments for the exported functions. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 76 +++ drivers/staging/comedi/drivers/mite.h | 5 ++- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 82f4fda..ce479ad 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -213,12 +213,6 @@ static unsigned int mite_drq_reqs(unsigned int drq_line) return CR_REQS((drq_line & 0x3) | 0x4); } -static void mite_dma_reset(struct mite_channel *mite_chan) -{ - writel(CHOR_DMARESET | CHOR_FRESET, - mite_chan->mite->mmio + MITE_CHOR(mite_chan->channel)); -} - static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) { unsigned int fcr_bits = readl(mite->mmio + MITE_FCR(channel)); @@ -228,25 +222,6 @@ static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) return empty_count + full_count; } -void mite_dma_arm(struct mite_channel *mite_chan) -{ - struct mite *mite = mite_chan->mite; - unsigned long flags; - - /* -* memory barrier is intended to insure any twiddling with the buffer -* is done before writing to the mite to arm dma transfer -*/ - smp_mb(); - spin_lock_irqsave(>lock, flags); - mite_chan->done = 0; - /* arm */ - writel(CHOR_START, mite->mmio + MITE_CHOR(mite_chan->channel)); - mmiowb(); - spin_unlock_irqrestore(>lock, flags); -} -EXPORT_SYMBOL_GPL(mite_dma_arm); - static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan) { struct mite *mite = mite_chan->mite; @@ -298,15 +273,6 @@ static u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) return mite_device_bytes_transferred(mite_chan) + in_transit_count; } -void mite_dma_disarm(struct mite_channel *mite_chan) -{ - struct mite *mite = mite_chan->mite; - - /* disarm */ - writel(CHOR_ABORT, mite->mmio + MITE_CHOR(mite_chan->channel)); -} -EXPORT_SYMBOL_GPL(mite_dma_disarm); - static void mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s) { @@ -447,6 +413,48 @@ int mite_done(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_done); +static void mite_dma_reset(struct mite_channel *mite_chan) +{ + writel(CHOR_DMARESET | CHOR_FRESET, + mite_chan->mite->mmio + MITE_CHOR(mite_chan->channel)); +} + +/** + * mite_dma_arm() - Start a MITE dma transfer. + * @mite_chan: MITE dma channel. + */ +void mite_dma_arm(struct mite_channel *mite_chan) +{ + struct mite *mite = mite_chan->mite; + unsigned long flags; + + /* +* memory barrier is intended to insure any twiddling with the buffer +* is done before writing to the mite to arm dma transfer +*/ + smp_mb(); + spin_lock_irqsave(>lock, flags); + mite_chan->done = 0; + /* arm */ + writel(CHOR_START, mite->mmio + MITE_CHOR(mite_chan->channel)); + mmiowb(); + spin_unlock_irqrestore(>lock, flags); +} +EXPORT_SYMBOL_GPL(mite_dma_arm); + +/** + * mite_dma_disarm() - Stop a MITE dma transfer. + * @mite_chan: MITE dma channel. + */ +void mite_dma_disarm(struct mite_channel *mite_chan) +{ + struct mite *mite = mite_chan->mite; + + /* disarm */ + writel(CHOR_ABORT, mite->mmio + MITE_CHOR(mite_chan->channel)); +} +EXPORT_SYMBOL_GPL(mite_dma_disarm); + /** * mite_prep_dma() - Prepare a MITE dma channel for transfers. * @mite_chan: MITE dma channel. diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 4017ddb..c7ae3db 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -60,14 +60,15 @@ struct mite { spinlock_t lock; }; -void mite_dma_arm(struct mite_channel *mite_chan); -void mite_dma_disarm(struct mite_channel *mite_chan); void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s); u32 mite_bytes_in_transit(struct mite_channel *mite_chan); void mite_ack_linkc(struct mite_channel *, struct comedi_subdevice *, bool sync); int mite_done(struct mite_channel *mite_chan); +void mite_dma_arm(struct mite_channel *); +void mite_dma_disarm(struct mite_channel *); + void mite_prep_dma(struct mite_channel *, unsigned int num_device_bits, unsigned int num_memory_bits); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 03/19] staging: comedi: mite: rename 'struct mite_dma_descriptor_ring'
Rename this name to 'mite_ring' to help shorten the long lines. In the ni_660x driver, also shorten the private data member 'mite_rings' to simply 'ring'. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 21 +-- drivers/staging/comedi/drivers/mite.h | 29 -- drivers/staging/comedi/drivers/ni_660x.c | 18 +++- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h| 8 +++ 6 files changed, 37 insertions(+), 43 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 127a86e..c616587 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -355,11 +355,11 @@ void mite_detach(struct mite *mite) } EXPORT_SYMBOL_GPL(mite_detach); -struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite *mite) +struct mite_ring *mite_alloc_ring(struct mite *mite) { - struct mite_dma_descriptor_ring *ring = - kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL); + struct mite_ring *ring; + ring = kmalloc(sizeof(*ring), GFP_KERNEL); if (!ring) return NULL; ring->hw_dev = get_device(>pcidev->dev); @@ -374,7 +374,7 @@ struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite *mite) }; EXPORT_SYMBOL_GPL(mite_alloc_ring); -void mite_free_ring(struct mite_dma_descriptor_ring *ring) +void mite_free_ring(struct mite_ring *ring) { if (ring) { if (ring->descriptors) { @@ -390,11 +390,10 @@ void mite_free_ring(struct mite_dma_descriptor_ring *ring) }; EXPORT_SYMBOL_GPL(mite_free_ring); -struct mite_channel * -mite_request_channel_in_range(struct mite *mite, - struct mite_dma_descriptor_ring *ring, - unsigned int min_channel, - unsigned int max_channel) +struct mite_channel *mite_request_channel_in_range(struct mite *mite, + struct mite_ring *ring, + unsigned int min_channel, + unsigned int max_channel) { int i; unsigned long flags; @@ -468,7 +467,7 @@ EXPORT_SYMBOL_GPL(mite_dma_arm); /**/ -int mite_buf_change(struct mite_dma_descriptor_ring *ring, +int mite_buf_change(struct mite_ring *ring, struct comedi_subdevice *s) { struct comedi_async *async = s->async; @@ -512,7 +511,7 @@ EXPORT_SYMBOL_GPL(mite_buf_change); * DMA data buffer. A command may call this function later to re-initialize and * shorten the amount of memory that will be transferred. */ -int mite_init_ring_descriptors(struct mite_dma_descriptor_ring *ring, +int mite_init_ring_descriptors(struct mite_ring *ring, struct comedi_subdevice *s, unsigned int nbytes) { diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index c42438f..5317d15 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -35,7 +35,7 @@ struct mite_dma_desc { u32 dar; }; -struct mite_dma_descriptor_ring { +struct mite_ring { struct device *hw_dev; unsigned int n_links; struct mite_dma_desc *descriptors; @@ -47,7 +47,7 @@ struct mite_channel { unsigned int channel; int dir; int done; - struct mite_dma_descriptor_ring *ring; + struct mite_ring *ring; }; struct mite { @@ -72,16 +72,15 @@ static inline int mite_setup(struct comedi_device *dev, } void mite_detach(struct mite *); -struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite *); -void mite_free_ring(struct mite_dma_descriptor_ring *ring); -struct mite_channel * -mite_request_channel_in_range(struct mite *, - struct mite_dma_descriptor_ring *ring, - unsigned int min_channel, - unsigned int max_channel); -static inline struct mite_channel * -mite_request_channel(struct mite *mite, -struct mite_dma_descriptor_ring *ring) +struct mite_ring *mite_alloc_ring(struct mite *); +void mite_free_ring(struct mite_ring *ring); +struct mite_channel *mite_request_channel_in_range(struct mite *, + struct mite_ring *, + unsigned int min_channel, + unsigned int max_channel); + +static inline struct mite_channel *mite_request_channel(struct mite
[PATCH 13/19] staging: comedi: mite: tidy up kernel messages in mite_steup()
The dev_err() messages with pci_ioremap_bar() fails are just noise. Remove them. The 'use_win1' and 'fifo_size' dev_info() messages are also noise but they may be useful when debugging. Change them to dev_dbg(). Absorb dump_chip_signnature() and change the pr_info() messages to dev_dbg(). These also might be useful when debugging. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 50 +++ 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 08e9c8b..d51a29b 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -219,23 +219,6 @@ static void mite_dma_reset(struct mite_channel *mite_chan) mite_chan->mite->mmio + MITE_CHOR(mite_chan->channel)); } -static void dump_chip_signature(u32 csigr_bits) -{ - unsigned int wpdep; - - /* get the wpdep bits and convert it to the write port fifo depth */ - wpdep = CSIGR_TO_WPDEP(csigr_bits); - if (wpdep) - wpdep = BIT(wpdep); - - pr_info("version = %i, type = %i, mite mode = %i, interface mode = %i\n", - CSIGR_TO_VER(csigr_bits), CSIGR_TO_TYPE(csigr_bits), - CSIGR_TO_MMODE(csigr_bits), CSIGR_TO_IMODE(csigr_bits)); - pr_info("num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n", - CSIGR_TO_DMAC(csigr_bits), wpdep, - CSIGR_TO_WINS(csigr_bits), CSIGR_TO_IOWINS(csigr_bits)); -} - static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) { unsigned int fcr_bits = readl(mite->mmio + MITE_FCR(channel)); @@ -739,29 +722,24 @@ static int mite_setup(struct comedi_device *dev, struct mite *mite, int i; u32 csigr_bits; unsigned int unknown_dma_burst_bits; + unsigned int wpdep; pci_set_master(mite->pcidev); mite->mmio = pci_ioremap_bar(mite->pcidev, 0); - if (!mite->mmio) { - dev_err(dev->class_dev, - "Failed to remap mite io memory address\n"); + if (!mite->mmio) return -ENOMEM; - } dev->mmio = pci_ioremap_bar(mite->pcidev, 1); - if (!dev->mmio) { - dev_err(dev->class_dev, - "Failed to remap daq io memory address\n"); + if (!dev->mmio) return -ENOMEM; - } daq_phys_addr = pci_resource_start(mite->pcidev, 1); length = pci_resource_len(mite->pcidev, 1); if (use_win1) { writel(0, mite->mmio + MITE_IODWBSR); - dev_info(dev->class_dev, -"using I/O Window Base Size register 1\n"); + dev_dbg(dev->class_dev, + "mite: using I/O Window Base Size register 1\n"); writel(daq_phys_addr | WENAB | MITE_IODWBSR_1_WSIZE_bits(length), mite->mmio + MITE_IODWBSR_1); @@ -792,7 +770,21 @@ static int mite_setup(struct comedi_device *dev, struct mite *mite, mite->num_channels, MAX_MITE_DMA_CHANNELS); mite->num_channels = MAX_MITE_DMA_CHANNELS; } - dump_chip_signature(csigr_bits); + + /* get the wpdep bits and convert it to the write port fifo depth */ + wpdep = CSIGR_TO_WPDEP(csigr_bits); + if (wpdep) + wpdep = BIT(wpdep); + + dev_dbg(dev->class_dev, + "mite: version = %i, type = %i, mite mode = %i, interface mode = %i\n", + CSIGR_TO_VER(csigr_bits), CSIGR_TO_TYPE(csigr_bits), + CSIGR_TO_MMODE(csigr_bits), CSIGR_TO_IMODE(csigr_bits)); + dev_dbg(dev->class_dev, + "mite: num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n", + CSIGR_TO_DMAC(csigr_bits), wpdep, + CSIGR_TO_WINS(csigr_bits), CSIGR_TO_IOWINS(csigr_bits)); + for (i = 0; i < mite->num_channels; i++) { writel(CHOR_DMARESET, mite->mmio + MITE_CHOR(i)); /* disable interrupts */ @@ -802,7 +794,7 @@ static int mite_setup(struct comedi_device *dev, struct mite *mite, mite->mmio + MITE_CHCR(i)); } mite->fifo_size = mite_fifo_size(mite, 0); - dev_info(dev->class_dev, "fifo size is %i.\n", mite->fifo_size); + dev_dbg(dev->class_dev, "mite: fifo size is %i.\n", mite->fifo_size); return 0; } -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 15/19] staging: comedi: mite: tidy up mite dma channel request/release
For aesthetics, make the actual "request" function static and change mite_request_channel_in_range() into a wrapper that calls the internal function. Change the inline function that requests any free channel into an export that also calls the internal function. Move the functions to a more logical spot in the code and add docbook comments for the exported functions. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 137 +- drivers/staging/comedi/drivers/mite.h | 21 ++ 2 files changed, 91 insertions(+), 67 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 308ceb60..b1231ed 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -228,59 +228,6 @@ static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) return empty_count + full_count; } -struct mite_channel *mite_request_channel_in_range(struct mite *mite, - struct mite_ring *ring, - unsigned int min_channel, - unsigned int max_channel) -{ - struct mite_channel *mite_chan = NULL; - unsigned long flags; - int i; - - /* -* spin lock so mite_release_channel can be called safely -* from interrupts -*/ - spin_lock_irqsave(>lock, flags); - for (i = min_channel; i <= max_channel; ++i) { - mite_chan = >channels[i]; - if (!mite_chan->ring) { - mite_chan->ring = ring; - break; - } - mite_chan = NULL; - } - spin_unlock_irqrestore(>lock, flags); - return mite_chan; -} -EXPORT_SYMBOL_GPL(mite_request_channel_in_range); - -void mite_release_channel(struct mite_channel *mite_chan) -{ - struct mite *mite = mite_chan->mite; - unsigned long flags; - - /* spin lock to prevent races with mite_request_channel */ - spin_lock_irqsave(>lock, flags); - if (mite_chan->ring) { - mite_dma_disarm(mite_chan); - mite_dma_reset(mite_chan); - /* -* disable all channel's interrupts (do it after disarm/reset so -* MITE_CHCR reg isn't changed while dma is still active!) -*/ - writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | - CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE | - CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | - CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE, - mite->mmio + MITE_CHCR(mite_chan->channel)); - mite_chan->ring = NULL; - mmiowb(); - } - spin_unlock_irqrestore(>lock, flags); -} -EXPORT_SYMBOL_GPL(mite_release_channel); - void mite_dma_arm(struct mite_channel *mite_chan) { struct mite *mite = mite_chan->mite; @@ -585,6 +532,90 @@ int mite_done(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_done); +static struct mite_channel *__mite_request_channel(struct mite *mite, + struct mite_ring *ring, + unsigned int min_channel, + unsigned int max_channel) +{ + struct mite_channel *mite_chan = NULL; + unsigned long flags; + int i; + + /* +* spin lock so mite_release_channel can be called safely +* from interrupts +*/ + spin_lock_irqsave(>lock, flags); + for (i = min_channel; i <= max_channel; ++i) { + mite_chan = >channels[i]; + if (!mite_chan->ring) { + mite_chan->ring = ring; + break; + } + mite_chan = NULL; + } + spin_unlock_irqrestore(>lock, flags); + return mite_chan; +} + +/** + * mite_request_channel_in_range() - Request a MITE dma channel. + * @mite: MITE device. + * @ring: MITE dma ring. + * @min_channel: minimum channel index to use. + * @max_channel: maximum channel index to use. + */ +struct mite_channel *mite_request_channel_in_range(struct mite *mite, + struct mite_ring *ring, + unsigned int min_channel, + unsigned int max_channel) +{ + return __mite_request_channel(mite, ring, min_channel, max_channel); +} +EXPORT_SYMBOL_GPL(mite_request_channel_in_range); + +/** + * mite_request_channel() - Request a MITE dma channel. + * @mite: MITE device. + * @ring: MITE dma ring. + */ +struct mite_channel *mite_request_channel(struct
[PATCH 09/19] staging: comedi: mite: introduce mite_free_dma_descs()
Introduce a helper function to handle the dma_free_coherent() of the mite dma descriptors. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 33 - 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 14b5345..8b0f875 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -371,16 +371,24 @@ struct mite_ring *mite_alloc_ring(struct mite *mite) }; EXPORT_SYMBOL_GPL(mite_alloc_ring); +static void mite_free_dma_descs(struct mite_ring *ring) +{ + struct mite_dma_desc *descs = ring->descs; + + if (descs) { + dma_free_coherent(ring->hw_dev, + ring->n_links * sizeof(*descs), + descs, ring->dma_addr); + ring->descs = NULL; + ring->dma_addr = 0; + ring->n_links = 0; + } +} + void mite_free_ring(struct mite_ring *ring) { if (ring) { - if (ring->descs) { - dma_free_coherent(ring->hw_dev, - ring->n_links * - sizeof(struct mite_dma_desc), - ring->descs, - ring->dma_addr); - } + mite_free_dma_descs(ring); put_device(ring->hw_dev); kfree(ring); } @@ -467,16 +475,7 @@ int mite_buf_change(struct mite_ring *ring, struct comedi_async *async = s->async; unsigned int n_links; - if (ring->descs) { - dma_free_coherent(ring->hw_dev, - ring->n_links * - sizeof(struct mite_dma_desc), - ring->descs, - ring->dma_addr); - } - ring->descs = NULL; - ring->dma_addr = 0; - ring->n_links = 0; + mite_free_dma_descs(ring); if (async->prealloc_bufsz == 0) return 0; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 01/19] staging: comedi: mite: rename 'struct mite_struct'
Rename this struct to simply 'mite'. The current name is a bit redundant. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 33 +++--- drivers/staging/comedi/drivers/mite.h | 18 drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h| 2 +- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 1f54cd0..4bfdbf0 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -219,9 +219,9 @@ static void mite_dma_reset(struct mite_channel *mite_chan) mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); } -struct mite_struct *mite_alloc(struct pci_dev *pcidev) +struct mite *mite_alloc(struct pci_dev *pcidev) { - struct mite_struct *mite; + struct mite *mite; unsigned int i; mite = kzalloc(sizeof(*mite), GFP_KERNEL); @@ -255,8 +255,7 @@ static void dump_chip_signature(u32 csigr_bits) CSIGR_TO_WINS(csigr_bits), CSIGR_TO_IOWINS(csigr_bits)); } -static unsigned int mite_fifo_size(struct mite_struct *mite, - unsigned int channel) +static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) { unsigned int fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel)); unsigned int empty_count = (fcr_bits >> 16) & 0xff; @@ -266,7 +265,7 @@ static unsigned int mite_fifo_size(struct mite_struct *mite, } int mite_setup2(struct comedi_device *dev, - struct mite_struct *mite, bool use_win1) + struct mite *mite, bool use_win1) { resource_size_t daq_phys_addr; unsigned long length; @@ -344,7 +343,7 @@ int mite_setup2(struct comedi_device *dev, } EXPORT_SYMBOL_GPL(mite_setup2); -void mite_detach(struct mite_struct *mite) +void mite_detach(struct mite *mite) { if (!mite) return; @@ -356,7 +355,7 @@ void mite_detach(struct mite_struct *mite) } EXPORT_SYMBOL_GPL(mite_detach); -struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite) +struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite *mite) { struct mite_dma_descriptor_ring *ring = kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL); @@ -392,7 +391,7 @@ void mite_free_ring(struct mite_dma_descriptor_ring *ring) EXPORT_SYMBOL_GPL(mite_free_ring); struct mite_channel * -mite_request_channel_in_range(struct mite_struct *mite, +mite_request_channel_in_range(struct mite *mite, struct mite_dma_descriptor_ring *ring, unsigned int min_channel, unsigned int max_channel) @@ -421,7 +420,7 @@ EXPORT_SYMBOL_GPL(mite_request_channel_in_range); void mite_release_channel(struct mite_channel *mite_chan) { - struct mite_struct *mite = mite_chan->mite; + struct mite *mite = mite_chan->mite; unsigned long flags; /* spin lock to prevent races with mite_request_channel */ @@ -448,7 +447,7 @@ EXPORT_SYMBOL_GPL(mite_release_channel); void mite_dma_arm(struct mite_channel *mite_chan) { - struct mite_struct *mite = mite_chan->mite; + struct mite *mite = mite_chan->mite; int chor; unsigned long flags; @@ -566,8 +565,8 @@ EXPORT_SYMBOL_GPL(mite_init_ring_descriptors); void mite_prep_dma(struct mite_channel *mite_chan, unsigned int num_device_bits, unsigned int num_memory_bits) { + struct mite *mite = mite_chan->mite; unsigned int chcr, mcr, dcr, lkcr; - struct mite_struct *mite = mite_chan->mite; mite_dma_reset(mite_chan); @@ -650,14 +649,14 @@ EXPORT_SYMBOL_GPL(mite_prep_dma); static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan) { - struct mite_struct *mite = mite_chan->mite; + struct mite *mite = mite_chan->mite; return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel)); } u32 mite_bytes_in_transit(struct mite_channel *mite_chan) { - struct mite_struct *mite = mite_chan->mite; + struct mite *mite = mite_chan->mite; return readl(mite->mite_io_addr + MITE_FCR(mite_chan->channel)) & 0x00FF; @@ -702,7 +701,7 @@ static u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) void mite_dma_disarm(struct mite_channel *mite_chan) { - struct mite_struct *mite = mite_chan->mite; + struct mite *mite = mite_chan->mite; unsigned int chor; /* disarm */ @@ -798,7 +797,7 @@ EXPORT_SYMBOL_GPL(mite_sync_dma); static unsigned int mite_get_status(struct mite_channel
[PATCH 19/19] staging: comedi: mite: tidy up module init/exit
Move the module_init()/module_exit() so they are in the prefered spot on the line after the function. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 440090e..b1c0860 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -945,12 +945,11 @@ static int __init mite_module_init(void) { return 0; } +module_init(mite_module_init); static void __exit mite_module_exit(void) { } - -module_init(mite_module_init); module_exit(mite_module_exit); MODULE_AUTHOR("Comedi http://www.comedi.org;); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 10/19] staging: comedi: mite: use prefered form for passing a struct size
Add a local variable to mite_buf_change() so that the prefered form of passing a struct size, sizeof(*p), can be used. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 8b0f875..650c603 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -473,6 +473,7 @@ int mite_buf_change(struct mite_ring *ring, struct comedi_subdevice *s) { struct comedi_async *async = s->async; + struct mite_dma_desc *descs; unsigned int n_links; mite_free_dma_descs(ring); @@ -482,15 +483,15 @@ int mite_buf_change(struct mite_ring *ring, n_links = async->prealloc_bufsz >> PAGE_SHIFT; - ring->descs = - dma_alloc_coherent(ring->hw_dev, - n_links * sizeof(struct mite_dma_desc), - >dma_addr, GFP_KERNEL); - if (!ring->descs) { + descs = dma_alloc_coherent(ring->hw_dev, + n_links * sizeof(*descs), + >dma_addr, GFP_KERNEL); + if (!descs) { dev_err(s->device->class_dev, "mite: ring buffer allocation failed\n"); return -ENOMEM; } + ring->descs = descs; ring->n_links = n_links; return mite_init_ring_descriptors(ring, s, n_links << PAGE_SHIFT); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 14/19] staging: comedi: mite: move the mite ring functions
For aesthetics, move the functions that allocate/free and initialize the mite dma ring. They are currently kind of scattered around the code. Add docbook comments for the exported functions. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 274 ++ drivers/staging/comedi/drivers/mite.h | 8 +- 2 files changed, 150 insertions(+), 132 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index d51a29b..308ceb60 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -228,49 +228,6 @@ static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) return empty_count + full_count; } -struct mite_ring *mite_alloc_ring(struct mite *mite) -{ - struct mite_ring *ring; - - ring = kmalloc(sizeof(*ring), GFP_KERNEL); - if (!ring) - return NULL; - ring->hw_dev = get_device(>pcidev->dev); - if (!ring->hw_dev) { - kfree(ring); - return NULL; - } - ring->n_links = 0; - ring->descs = NULL; - ring->dma_addr = 0; - return ring; -}; -EXPORT_SYMBOL_GPL(mite_alloc_ring); - -static void mite_free_dma_descs(struct mite_ring *ring) -{ - struct mite_dma_desc *descs = ring->descs; - - if (descs) { - dma_free_coherent(ring->hw_dev, - ring->n_links * sizeof(*descs), - descs, ring->dma_addr); - ring->descs = NULL; - ring->dma_addr = 0; - ring->n_links = 0; - } -} - -void mite_free_ring(struct mite_ring *ring) -{ - if (ring) { - mite_free_dma_descs(ring); - put_device(ring->hw_dev); - kfree(ring); - } -}; -EXPORT_SYMBOL_GPL(mite_free_ring); - struct mite_channel *mite_request_channel_in_range(struct mite *mite, struct mite_ring *ring, unsigned int min_channel, @@ -343,92 +300,6 @@ void mite_dma_arm(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_dma_arm); -/**/ - -int mite_buf_change(struct mite_ring *ring, - struct comedi_subdevice *s) -{ - struct comedi_async *async = s->async; - struct mite_dma_desc *descs; - unsigned int n_links; - - mite_free_dma_descs(ring); - - if (async->prealloc_bufsz == 0) - return 0; - - n_links = async->prealloc_bufsz >> PAGE_SHIFT; - - descs = dma_alloc_coherent(ring->hw_dev, - n_links * sizeof(*descs), - >dma_addr, GFP_KERNEL); - if (!descs) { - dev_err(s->device->class_dev, - "mite: ring buffer allocation failed\n"); - return -ENOMEM; - } - ring->descs = descs; - ring->n_links = n_links; - - return mite_init_ring_descriptors(ring, s, n_links << PAGE_SHIFT); -} -EXPORT_SYMBOL_GPL(mite_buf_change); - -/* - * initializes the ring buffer descriptors to provide correct DMA transfer links - * to the exact amount of memory required. When the ring buffer is allocated in - * mite_buf_change, the default is to initialize the ring to refer to the entire - * DMA data buffer. A command may call this function later to re-initialize and - * shorten the amount of memory that will be transferred. - */ -int mite_init_ring_descriptors(struct mite_ring *ring, - struct comedi_subdevice *s, - unsigned int nbytes) -{ - struct comedi_async *async = s->async; - struct mite_dma_desc *desc = NULL; - unsigned int n_full_links = nbytes >> PAGE_SHIFT; - unsigned int remainder = nbytes % PAGE_SIZE; - int i; - - dev_dbg(s->device->class_dev, - "mite: init ring buffer to %u bytes\n", nbytes); - - if ((n_full_links + (remainder > 0 ? 1 : 0)) > ring->n_links) { - dev_err(s->device->class_dev, - "mite: ring buffer too small for requested init\n"); - return -ENOMEM; - } - - /* We set the descriptors for all full links. */ - for (i = 0; i < n_full_links; ++i) { - desc = >descs[i]; - desc->count = cpu_to_le32(PAGE_SIZE); - desc->addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); - desc->next = cpu_to_le32(ring->dma_addr + -(i + 1) * sizeof(*desc)); - } - - /* the last link is either a remainder or was a full link. */ - if (remainder > 0) { - desc = >descs[i]; -
[PATCH 16/19] staging: comedi: mite: move mite_prep_dma()
For aesthetics, move this functions to a more logical spot in the code and add a docbook comment for the exported function. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 176 ++ drivers/staging/comedi/drivers/mite.h | 2 +- 2 files changed, 92 insertions(+), 86 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index b1231ed..82f4fda 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -247,91 +247,6 @@ void mite_dma_arm(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_dma_arm); -void mite_prep_dma(struct mite_channel *mite_chan, - unsigned int num_device_bits, unsigned int num_memory_bits) -{ - struct mite *mite = mite_chan->mite; - unsigned int chcr, mcr, dcr, lkcr; - - mite_dma_reset(mite_chan); - - /* short link chaining mode */ - chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE | - CHCR_BURSTEN; - /* -* Link Complete Interrupt: interrupt every time a link -* in MITE_RING is completed. This can generate a lot of -* extra interrupts, but right now we update the values -* of buf_int_ptr and buf_int_count at each interrupt. A -* better method is to poll the MITE before each user -* "read()" to calculate the number of bytes available. -*/ - chcr |= CHCR_SET_LC_IE; - if (num_memory_bits == 32 && num_device_bits == 16) { - /* -* Doing a combined 32 and 16 bit byteswap gets the 16 bit -* samples into the fifo in the right order. Tested doing 32 bit -* memory to 16 bit device transfers to the analog out of a -* pxi-6281, which has mite version = 1, type = 4. This also -* works for dma reads from the counters on e-series boards. -*/ - chcr |= CHCR_BYTE_SWAP_DEVICE | CHCR_BYTE_SWAP_MEMORY; - } - if (mite_chan->dir == COMEDI_INPUT) - chcr |= CHCR_DEV_TO_MEM; - - writel(chcr, mite->mmio + MITE_CHCR(mite_chan->channel)); - - /* to/from memory */ - mcr = mite_retry_limit(64) | CR_ASEQUP; - switch (num_memory_bits) { - case 8: - mcr |= CR_PSIZE8; - break; - case 16: - mcr |= CR_PSIZE16; - break; - case 32: - mcr |= CR_PSIZE32; - break; - default: - pr_warn("bug! invalid mem bit width for dma transfer\n"); - break; - } - writel(mcr, mite->mmio + MITE_MCR(mite_chan->channel)); - - /* from/to device */ - dcr = mite_retry_limit(64) | CR_ASEQUP; - dcr |= CR_PORTIO | CR_AMDEVICE | mite_drq_reqs(mite_chan->channel); - switch (num_device_bits) { - case 8: - dcr |= CR_PSIZE8; - break; - case 16: - dcr |= CR_PSIZE16; - break; - case 32: - dcr |= CR_PSIZE32; - break; - default: - pr_warn("bug! invalid dev bit width for dma transfer\n"); - break; - } - writel(dcr, mite->mmio + MITE_DCR(mite_chan->channel)); - - /* reset the DAR */ - writel(0, mite->mmio + MITE_DAR(mite_chan->channel)); - - /* the link is 32bits */ - lkcr = mite_retry_limit(64) | CR_ASEQUP | CR_PSIZE32; - writel(lkcr, mite->mmio + MITE_LKCR(mite_chan->channel)); - - /* starting address for link chaining */ - writel(mite_chan->ring->dma_addr, - mite->mmio + MITE_LKAR(mite_chan->channel)); -} -EXPORT_SYMBOL_GPL(mite_prep_dma); - static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan) { struct mite *mite = mite_chan->mite; @@ -532,6 +447,97 @@ int mite_done(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_done); +/** + * mite_prep_dma() - Prepare a MITE dma channel for transfers. + * @mite_chan: MITE dma channel. + * @num_device_bits: device transfer size (8, 16, or 32-bits). + * @num_memory_bits: memory transfer size (8, 16, or 32-bits). + */ +void mite_prep_dma(struct mite_channel *mite_chan, + unsigned int num_device_bits, unsigned int num_memory_bits) +{ + struct mite *mite = mite_chan->mite; + unsigned int chcr, mcr, dcr, lkcr; + + mite_dma_reset(mite_chan); + + /* short link chaining mode */ + chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE | + CHCR_BURSTEN; + /* +* Link Complete Interrupt: interrupt every time a link +* in MITE_RING is completed. This can generate a lot of +* extra interrupts, but right now we update the values +* of buf_int_ptr
[PATCH 07/19] staging: comedi: mite: rename mite member 'mite_io_addr'
Rename this member of struct mite to 'mmio' to help shorten the long lines. Add a local variable for the mite pointer in the ni_pcimio driver to clarify and shorten the long lines. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 69 +- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_pcimio.c | 26 +-- 3 files changed, 44 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 058ea5e..9a74e37 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -216,7 +216,7 @@ static unsigned int mite_drq_reqs(unsigned int drq_line) static void mite_dma_reset(struct mite_channel *mite_chan) { writel(CHOR_DMARESET | CHOR_FRESET, - mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); + mite_chan->mite->mmio + MITE_CHOR(mite_chan->channel)); } struct mite *mite_alloc(struct pci_dev *pcidev) @@ -257,7 +257,7 @@ static void dump_chip_signature(u32 csigr_bits) static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel) { - unsigned int fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel)); + unsigned int fcr_bits = readl(mite->mmio + MITE_FCR(channel)); unsigned int empty_count = (fcr_bits >> 16) & 0xff; unsigned int full_count = fcr_bits & 0xff; @@ -275,8 +275,8 @@ int mite_setup2(struct comedi_device *dev, pci_set_master(mite->pcidev); - mite->mite_io_addr = pci_ioremap_bar(mite->pcidev, 0); - if (!mite->mite_io_addr) { + mite->mmio = pci_ioremap_bar(mite->pcidev, 0); + if (!mite->mmio) { dev_err(dev->class_dev, "Failed to remap mite io memory address\n"); return -ENOMEM; @@ -292,16 +292,15 @@ int mite_setup2(struct comedi_device *dev, length = pci_resource_len(mite->pcidev, 1); if (use_win1) { - writel(0, mite->mite_io_addr + MITE_IODWBSR); + writel(0, mite->mmio + MITE_IODWBSR); dev_info(dev->class_dev, "using I/O Window Base Size register 1\n"); writel(daq_phys_addr | WENAB | MITE_IODWBSR_1_WSIZE_bits(length), - mite->mite_io_addr + MITE_IODWBSR_1); - writel(0, mite->mite_io_addr + MITE_IODWCR_1); + mite->mmio + MITE_IODWBSR_1); + writel(0, mite->mmio + MITE_IODWCR_1); } else { - writel(daq_phys_addr | WENAB, - mite->mite_io_addr + MITE_IODWBSR); + writel(daq_phys_addr | WENAB, mite->mmio + MITE_IODWBSR); } /* * Make sure dma bursts work. I got this from running a bus analyzer @@ -314,13 +313,11 @@ int mite_setup2(struct comedi_device *dev, * written and read back. The bits 0x1f always read as 1. * The rest always read as zero. */ - unknown_dma_burst_bits = - readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG); + unknown_dma_burst_bits = readl(mite->mmio + MITE_UNKNOWN_DMA_BURST_REG); unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS; - writel(unknown_dma_burst_bits, - mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG); + writel(unknown_dma_burst_bits, mite->mmio + MITE_UNKNOWN_DMA_BURST_REG); - csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR); + csigr_bits = readl(mite->mmio + MITE_CSIGR); mite->num_channels = CSIGR_TO_DMAC(csigr_bits); if (mite->num_channels > MAX_MITE_DMA_CHANNELS) { dev_warn(dev->class_dev, @@ -330,12 +327,12 @@ int mite_setup2(struct comedi_device *dev, } dump_chip_signature(csigr_bits); for (i = 0; i < mite->num_channels; i++) { - writel(CHOR_DMARESET, mite->mite_io_addr + MITE_CHOR(i)); + writel(CHOR_DMARESET, mite->mmio + MITE_CHOR(i)); /* disable interrupts */ writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE, - mite->mite_io_addr + MITE_CHCR(i)); + mite->mmio + MITE_CHCR(i)); } mite->fifo_size = mite_fifo_size(mite, 0); dev_info(dev->class_dev, "fifo size is %i.\n", mite->fifo_size); @@ -348,8 +345,8 @@ void mite_detach(struct mite *mite) if (!mite) return; - if (mite->mite_io_addr) - iounmap(mite->mite_io_addr); + if (mite->mmio) + iounmap(mite->mmio); kfree(mite); } @@ -435,7
[PATCH 04/19] staging: comedi: mite: rename mite_ring member 'descriptors_dma_addr'
Rename this member of struct mite_ring to 'dma_addr' to help shorten the long lines. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 16 drivers/staging/comedi/drivers/mite.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index c616587..cf1157e 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -369,7 +369,7 @@ struct mite_ring *mite_alloc_ring(struct mite *mite) } ring->n_links = 0; ring->descriptors = NULL; - ring->descriptors_dma_addr = 0; + ring->dma_addr = 0; return ring; }; EXPORT_SYMBOL_GPL(mite_alloc_ring); @@ -382,7 +382,7 @@ void mite_free_ring(struct mite_ring *ring) ring->n_links * sizeof(struct mite_dma_desc), ring->descriptors, - ring->descriptors_dma_addr); + ring->dma_addr); } put_device(ring->hw_dev); kfree(ring); @@ -478,10 +478,10 @@ int mite_buf_change(struct mite_ring *ring, ring->n_links * sizeof(struct mite_dma_desc), ring->descriptors, - ring->descriptors_dma_addr); + ring->dma_addr); } ring->descriptors = NULL; - ring->descriptors_dma_addr = 0; + ring->dma_addr = 0; ring->n_links = 0; if (async->prealloc_bufsz == 0) @@ -492,7 +492,7 @@ int mite_buf_change(struct mite_ring *ring, ring->descriptors = dma_alloc_coherent(ring->hw_dev, n_links * sizeof(struct mite_dma_desc), - >descriptors_dma_addr, GFP_KERNEL); + >dma_addr, GFP_KERNEL); if (!ring->descriptors) { dev_err(s->device->class_dev, "mite: ring buffer allocation failed\n"); @@ -535,7 +535,7 @@ int mite_init_ring_descriptors(struct mite_ring *ring, ring->descriptors[i].addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); ring->descriptors[i].next = - cpu_to_le32(ring->descriptors_dma_addr + + cpu_to_le32(ring->dma_addr + (i + 1) * sizeof(struct mite_dma_desc)); } @@ -550,7 +550,7 @@ int mite_init_ring_descriptors(struct mite_ring *ring, } /* Assign the last link->next to point back to the head of the list. */ - ring->descriptors[i - 1].next = cpu_to_le32(ring->descriptors_dma_addr); + ring->descriptors[i - 1].next = cpu_to_le32(ring->dma_addr); /* * barrier is meant to insure that all the writes to the dma descriptors @@ -641,7 +641,7 @@ void mite_prep_dma(struct mite_channel *mite_chan, writel(lkcr, mite->mite_io_addr + MITE_LKCR(mite_chan->channel)); /* starting address for link chaining */ - writel(mite_chan->ring->descriptors_dma_addr, + writel(mite_chan->ring->dma_addr, mite->mite_io_addr + MITE_LKAR(mite_chan->channel)); } EXPORT_SYMBOL_GPL(mite_prep_dma); diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 5317d15..cd0883c 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -39,7 +39,7 @@ struct mite_ring { struct device *hw_dev; unsigned int n_links; struct mite_dma_desc *descriptors; - dma_addr_t descriptors_dma_addr; + dma_addr_t dma_addr; }; struct mite_channel { -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 06/19] staging: comedi: mite: tidy up mite_init_ring_descriptors()
Use a local variable for the mite_dma_desc pointer to help clarify this function. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index c21d9fa..058ea5e 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -516,6 +516,7 @@ int mite_init_ring_descriptors(struct mite_ring *ring, unsigned int nbytes) { struct comedi_async *async = s->async; + struct mite_dma_desc *desc = NULL; unsigned int n_full_links = nbytes >> PAGE_SHIFT; unsigned int remainder = nbytes % PAGE_SIZE; int i; @@ -531,26 +532,23 @@ int mite_init_ring_descriptors(struct mite_ring *ring, /* We set the descriptors for all full links. */ for (i = 0; i < n_full_links; ++i) { - ring->descs[i].count = cpu_to_le32(PAGE_SIZE); - ring->descs[i].addr = - cpu_to_le32(async->buf_map->page_list[i].dma_addr); - ring->descs[i].next = - cpu_to_le32(ring->dma_addr + - (i + 1) * sizeof(struct mite_dma_desc)); + desc = >descs[i]; + desc->count = cpu_to_le32(PAGE_SIZE); + desc->addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); + desc->next = cpu_to_le32(ring->dma_addr + +(i + 1) * sizeof(*desc)); } /* the last link is either a remainder or was a full link. */ if (remainder > 0) { + desc = >descs[i]; /* set the lesser count for the remainder link */ - ring->descs[i].count = cpu_to_le32(remainder); - ring->descs[i].addr = - cpu_to_le32(async->buf_map->page_list[i].dma_addr); - /* increment i so that assignment below refs last link */ - ++i; + desc->count = cpu_to_le32(remainder); + desc->addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); } /* Assign the last link->next to point back to the head of the list. */ - ring->descs[i - 1].next = cpu_to_le32(ring->dma_addr); + desc->next = cpu_to_le32(ring->dma_addr); /* * barrier is meant to insure that all the writes to the dma descriptors -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 08/19] staging: comedi: mite: remove mite member 'channel_allocated'
An allocated mite_channel will have its 'ring' member initialized to point to the mite_ring that will be used for DMA. A non-allocated mite_channel will have a 'ring' member set to NULL, either by a channel release or due to the initial kzalloc of the 'mite' struct. Refactor the code to use the mite_chan->ring to detect in a channel is allocated and remove the unnecessary member. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 17 - drivers/staging/comedi/drivers/mite.h | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 9a74e37..14b5345 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -392,9 +392,9 @@ struct mite_channel *mite_request_channel_in_range(struct mite *mite, unsigned int min_channel, unsigned int max_channel) { - int i; + struct mite_channel *mite_chan = NULL; unsigned long flags; - struct mite_channel *channel = NULL; + int i; /* * spin lock so mite_release_channel can be called safely @@ -402,15 +402,15 @@ struct mite_channel *mite_request_channel_in_range(struct mite *mite, */ spin_lock_irqsave(>lock, flags); for (i = min_channel; i <= max_channel; ++i) { - if (mite->channel_allocated[i] == 0) { - mite->channel_allocated[i] = 1; - channel = >channels[i]; - channel->ring = ring; + mite_chan = >channels[i]; + if (!mite_chan->ring) { + mite_chan->ring = ring; break; } + mite_chan = NULL; } spin_unlock_irqrestore(>lock, flags); - return channel; + return mite_chan; } EXPORT_SYMBOL_GPL(mite_request_channel_in_range); @@ -421,7 +421,7 @@ void mite_release_channel(struct mite_channel *mite_chan) /* spin lock to prevent races with mite_request_channel */ spin_lock_irqsave(>lock, flags); - if (mite->channel_allocated[mite_chan->channel]) { + if (mite_chan->ring) { mite_dma_disarm(mite_chan); mite_dma_reset(mite_chan); /* @@ -433,7 +433,6 @@ void mite_release_channel(struct mite_channel *mite_chan) CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE, mite->mmio + MITE_CHCR(mite_chan->channel)); - mite->channel_allocated[mite_chan->channel] = 0; mite_chan->ring = NULL; mmiowb(); } diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index d1d97ec..2d97ad4 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -54,7 +54,6 @@ struct mite { struct pci_dev *pcidev; void __iomem *mmio; struct mite_channel channels[MAX_MITE_DMA_CHANNELS]; - short channel_allocated[MAX_MITE_DMA_CHANNELS]; int num_channels; unsigned int fifo_size; /* protects mite_channel from being released by the driver */ -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 05/19] staging: comedi: mite: rename mite_ring member 'descriptors'
Rename this member of struct mite_ring to 'descs' to help shorten the long lines. Signed-off-by: H Hartley SweetenCc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 28 ++-- drivers/staging/comedi/drivers/mite.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index cf1157e..c21d9fa 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -368,7 +368,7 @@ struct mite_ring *mite_alloc_ring(struct mite *mite) return NULL; } ring->n_links = 0; - ring->descriptors = NULL; + ring->descs = NULL; ring->dma_addr = 0; return ring; }; @@ -377,11 +377,11 @@ EXPORT_SYMBOL_GPL(mite_alloc_ring); void mite_free_ring(struct mite_ring *ring) { if (ring) { - if (ring->descriptors) { + if (ring->descs) { dma_free_coherent(ring->hw_dev, ring->n_links * sizeof(struct mite_dma_desc), - ring->descriptors, + ring->descs, ring->dma_addr); } put_device(ring->hw_dev); @@ -473,14 +473,14 @@ int mite_buf_change(struct mite_ring *ring, struct comedi_async *async = s->async; unsigned int n_links; - if (ring->descriptors) { + if (ring->descs) { dma_free_coherent(ring->hw_dev, ring->n_links * sizeof(struct mite_dma_desc), - ring->descriptors, + ring->descs, ring->dma_addr); } - ring->descriptors = NULL; + ring->descs = NULL; ring->dma_addr = 0; ring->n_links = 0; @@ -489,11 +489,11 @@ int mite_buf_change(struct mite_ring *ring, n_links = async->prealloc_bufsz >> PAGE_SHIFT; - ring->descriptors = + ring->descs = dma_alloc_coherent(ring->hw_dev, n_links * sizeof(struct mite_dma_desc), >dma_addr, GFP_KERNEL); - if (!ring->descriptors) { + if (!ring->descs) { dev_err(s->device->class_dev, "mite: ring buffer allocation failed\n"); return -ENOMEM; @@ -531,10 +531,10 @@ int mite_init_ring_descriptors(struct mite_ring *ring, /* We set the descriptors for all full links. */ for (i = 0; i < n_full_links; ++i) { - ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE); - ring->descriptors[i].addr = + ring->descs[i].count = cpu_to_le32(PAGE_SIZE); + ring->descs[i].addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); - ring->descriptors[i].next = + ring->descs[i].next = cpu_to_le32(ring->dma_addr + (i + 1) * sizeof(struct mite_dma_desc)); } @@ -542,15 +542,15 @@ int mite_init_ring_descriptors(struct mite_ring *ring, /* the last link is either a remainder or was a full link. */ if (remainder > 0) { /* set the lesser count for the remainder link */ - ring->descriptors[i].count = cpu_to_le32(remainder); - ring->descriptors[i].addr = + ring->descs[i].count = cpu_to_le32(remainder); + ring->descs[i].addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); /* increment i so that assignment below refs last link */ ++i; } /* Assign the last link->next to point back to the head of the list. */ - ring->descriptors[i - 1].next = cpu_to_le32(ring->dma_addr); + ring->descs[i - 1].next = cpu_to_le32(ring->dma_addr); /* * barrier is meant to insure that all the writes to the dma descriptors diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index cd0883c..991e6b63 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -38,7 +38,7 @@ struct mite_dma_desc { struct mite_ring { struct device *hw_dev; unsigned int n_links; - struct mite_dma_desc *descriptors; + struct mite_dma_desc *descs; dma_addr_t dma_addr; }; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: Time for a code audit?
> -Original Message- > From: Dan Carpenter [mailto:dan.carpen...@oracle.com] > Sent: Monday, May 02, 2016 8:55 AM > To: Kershner, David A > Cc: gre...@linuxfoundation.org; driverdev-devel@linuxdriverproject.org; > Sell, Timothy C; *S-Par-Maintainer; Binder, David Anthony > Subject: Re: Time for a code audit? > > Reviewing drivers/staging/unisys/visornic/visornic_main.c > >212 static int >213 visor_copy_fragsinfo_from_skb(struct sk_buff *skb, unsigned int > firstfraglen, >214unsigned int frags_max, >215struct phys_info frags[]) >216 { >217 unsigned int count = 0, ii, size, offset = 0, numfrags; > ^^ > > The second "i" character indicates that it is an integer. Which is ugly > and, of course, misleading. > >296 static ssize_t enable_ints_write(struct file *file, >297 const char __user *buffer, >298 size_t count, loff_t *ppos) >299 { >300 /* >301 * Don't want to break ABI here by having a debugfs >302 * file that no longer exists or is writable, so >303 * lets just make this a vestigual function >304 */ >305 return count; >306 } > > We don't care about ABI so much as we do about applications or scripts. > This was added by Neil Horman because the original code was useless and > dangerous. It was the right patch for him, because he doesn't know > about the userspace so he can't say if anything will break. But > presumably you guys know. Does anything break if we remove this debugfs > file? > > Also if so then shame shame shame. User space is not supposed to depend > on debugfs being writable. Just delete this... > > 1019 */ > 1020 static void > 1021 visornic_set_multi(struct net_device *netdev) > 1022 { > 1023 struct uiscmdrsp *cmdrsp; > 1024 struct visornic_devdata *devdata = netdev_priv(netdev); > 1025 > 1026 /* any filtering changes */ > 1027 if (devdata->old_flags != netdev->flags) { > 1028 if ((netdev->flags & IFF_PROMISC) != > 1029 (devdata->old_flags & IFF_PROMISC)) { > > Reverse these if statements and pull the code in two indent levels. > > 1154 /** > 1155 * visornic_rx - Handle receive packets coming back from IO Part > 1156 * @cmdrsp: Receive packet returned from IO Part > 1157 * > 1158 * Got a receive packet back from the IO Part, handle it and send > 1159 * it up the stack. > 1160 * Returns void > > Actually it returns either zero or one but in a convoluted way. Update > it to use literals and update the comment. > > 1361 /** > 1362 * devdata_initialize - Initialize devdata structure > 1363 * @devdata: visornic_devdata structure to initialize > 1364 * #dev: visorbus_deviced it belongs to > 1365 * > 1366 * Setup initial values for the visornic based on channel and > default > 1367 * values. > 1368 * Returns a pointer to the devdata if successful, else NULL > 1369 */ > 1370 static struct visornic_devdata * > 1371 devdata_initialize(struct visornic_devdata *devdata, struct > visor_device *dev) > 1372 { > 1373 if (!devdata) > 1374 return NULL; > > This check doesn't make sense and the error handling is kind of odd. > Just remove it, remove the error handling and update the comment. > > 1817 err = visorbus_read_channel(dev, channel_offset, > 1818 >num_rcv_bufs, 4); > 1819 if (err) { > 1820 dev_err(>device, > 1821 "%s failed to get #rcv bufs from chan (%d)\n", > 1822 __func__, err); > 1823 goto cleanup_netdev; > 1824 } > 1825 > 1826 devdata->rcvbuf = kcalloc(devdata->num_rcv_bufs, > 1827sizeof(struct sk_buff *), > GFP_KERNEL); > 1828 if (!devdata->rcvbuf) { > 1829 err = -ENOMEM; > 1830 goto cleanup_rcvbuf; > > We never allocated rcvbuf. It should still be goto cleanup_netdev; The > other gotos after this in this function are slightly off as well. But > thanks for the nice label names because it makes reviewing this much > easier. :) > > 1831 } > > In visornic_init(): > 2126 err = visorbus_register_visor_driver(_driver); > 2127 if (!err) > 2128 return 0; > > Flip this around. > > if (err) > goto cleanup_debugfs; > > return 0; > > > These things should be reviewed by people on netdev and the scsi thing > should get a review by the scsi
Re: [PATCH 0/6] Intel Secure Guard Extensions
On 2016-04-29 16:17, Jarkko Sakkinen wrote: On Tue, Apr 26, 2016 at 09:00:10PM +0200, Pavel Machek wrote: On Mon 2016-04-25 20:34:07, Jarkko Sakkinen wrote: Intel(R) SGX is a set of CPU instructions that can be used by applications to set aside private regions of code and data. The code outside the enclave is disallowed to access the memory inside the enclave by the CPU access control. The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package. What are non-evil use cases for this? I'm not sure what you mean by non-evil. I would think that this should be pretty straightforward. Pretty much every security technology integrated in every computer in existence has the potential to be used by malware for various purposes. Based on a cursory look at SGX, it is pretty easy to figure out how to use this to hide arbitrary code from virus scanners and the OS itself unless you have some way to force everything to be a debug enclave, which entirely defeats the stated purpose of the extensions. I can see this being useful for tight embedded systems. On a desktop which I have full control of physical access to though, it's something I'd immediately turn off, because the risk of misuse is so significant (I've done so on my new Thinkpad L560 too, although that's mostly because Linux doesn't support it yet). ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 08/13] staging/android: remove size arg of sync_timeline_create()
From: Gustavo PadovanAfter we removed sw_sync_timeline this arg has not been really used by anyone, all its users pass the size of struct sync_timeline there. So simplify this function but not requiring the size anymore. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sync.c | 7 ++- drivers/staging/android/sync.h | 7 ++- drivers/staging/android/sync_debug.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 442d808..c83a599 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -30,15 +30,12 @@ static const struct fence_ops timeline_fence_ops; -struct sync_timeline *sync_timeline_create(int size, const char *drv_name, +struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name) { struct sync_timeline *obj; - if (size < sizeof(struct sync_timeline)) - return NULL; - - obj = kzalloc(size, GFP_KERNEL); + obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (!obj) return NULL; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index f003e97..f2fbf98 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -66,16 +66,13 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) /** * sync_timeline_create() - creates a sync object - * @size: size to allocate for this obj * @drv_name: sync_timeline driver name * @name: sync_timeline name * - * Creates a new sync_timeline. @size bytes will be allocated allowing - * for implementation specific data to be kept after the generic - * sync_timeline struct. Returns the sync_timeline object or NULL in + * Creates a new sync_timeline. Returns the sync_timeline object or NULL in * case of error. */ -struct sync_timeline *sync_timeline_create(int size, const char *drv_name, +struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name); /** diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 6282046..cb0f888 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -218,7 +218,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) get_task_comm(task_comm, current); - obj = sync_timeline_create(sizeof(*obj), "sw_sync", task_comm); + obj = sync_timeline_create("sw_sync", task_comm); if (!obj) return -ENOMEM; -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 10/13] staging/android: move sw_sync related code to sw_sync.c
From: Gustavo PadovanSplit sync_debug and sw_sync in two different files. Signed-off-by: Gustavo Padovan --- drivers/staging/android/Makefile | 1 + drivers/staging/android/sw_sync.c| 136 +++ drivers/staging/android/sync.h | 2 + drivers/staging/android/sync_debug.c | 115 - 4 files changed, 139 insertions(+), 115 deletions(-) create mode 100644 drivers/staging/android/sw_sync.c diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index bf45967..980d6dc 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -5,3 +5,4 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)+= lowmemorykiller.o obj-$(CONFIG_SYNC) += sync.o sync_debug.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c new file mode 100644 index 000..90e3ee5 --- /dev/null +++ b/drivers/staging/android/sw_sync.c @@ -0,0 +1,136 @@ +/* + * drivers/dma-buf/sw_sync.c + * + * Copyright (C) 2012 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include + +#include "uapi/sw_sync.h" +#include "sync.h" + +/* + * *WARNING* + * + * improper use of this can result in deadlocking kernel drivers from userspace. + */ + +/* opening sw_sync create a new sync obj */ +static int sw_sync_debugfs_open(struct inode *inode, struct file *file) +{ + struct sync_timeline *obj; + char task_comm[TASK_COMM_LEN]; + + get_task_comm(task_comm, current); + + obj = sync_timeline_create("sw_sync", task_comm); + if (!obj) + return -ENOMEM; + + file->private_data = obj; + + return 0; +} + +static int sw_sync_debugfs_release(struct inode *inode, struct file *file) +{ + struct sync_timeline *obj = file->private_data; + + sync_timeline_destroy(obj); + return 0; +} + +static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, + unsigned long arg) +{ + int fd = get_unused_fd_flags(O_CLOEXEC); + int err; + struct sync_pt *pt; + struct sync_file *sync_file; + struct sw_sync_create_fence_data data; + + if (fd < 0) + return fd; + + if (copy_from_user(, (void __user *)arg, sizeof(data))) { + err = -EFAULT; + goto err; + } + + pt = sync_pt_create(obj, sizeof(*pt), data.value); + if (!pt) { + err = -ENOMEM; + goto err; + } + + sync_file = sync_file_create(>base); + if (!sync_file) { + fence_put(>base); + err = -ENOMEM; + goto err; + } + + data.fence = fd; + if (copy_to_user((void __user *)arg, , sizeof(data))) { + fput(sync_file->file); + err = -EFAULT; + goto err; + } + + fd_install(fd, sync_file->file); + + return 0; + +err: + put_unused_fd(fd); + return err; +} + +static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) +{ + u32 value; + + if (copy_from_user(, (void __user *)arg, sizeof(value))) + return -EFAULT; + + sync_timeline_signal(obj, value); + + return 0; +} + +static long sw_sync_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct sync_timeline *obj = file->private_data; + + switch (cmd) { + case SW_SYNC_IOC_CREATE_FENCE: + return sw_sync_ioctl_create_fence(obj, arg); + + case SW_SYNC_IOC_INC: + return sw_sync_ioctl_inc(obj, arg); + + default: + return -ENOTTY; + } +} + +const struct file_operations sw_sync_debugfs_fops = { + .open = sw_sync_debugfs_open, + .release= sw_sync_debugfs_release, + .unlocked_ioctl = sw_sync_ioctl, + .compat_ioctl = sw_sync_ioctl, +}; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 14b61cb..02ecf44 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -132,6 +132,8 @@ struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size, #ifdef CONFIG_DEBUG_FS +extern const struct
[PATCH 04/13] staging/android: remove sw_sync_timeline and sw_sync_pt
From: Gustavo PadovanAs we moved value storage to sync_timeline and fence those two structs became useless and can be removed now. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c| 24 +++- drivers/staging/android/sw_sync.h| 24 ++-- drivers/staging/android/sync_debug.c | 12 ++-- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index c5e92c6..461dbd9 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -25,31 +25,21 @@ #include "sw_sync.h" -struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) +struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) { - struct sw_sync_pt *pt; - - pt = (struct sw_sync_pt *) - sync_pt_create(>obj, sizeof(struct sw_sync_pt), value); - - pt->value = value; - - return (struct fence *)pt; + return sync_pt_create(obj, sizeof(struct fence), value); } EXPORT_SYMBOL(sw_sync_pt_create); -struct sw_sync_timeline *sw_sync_timeline_create(const char *name) +struct sync_timeline *sw_sync_timeline_create(const char *name) { - struct sw_sync_timeline *obj = (struct sw_sync_timeline *) - sync_timeline_create(sizeof(struct sw_sync_timeline), -"sw_sync", name); - - return obj; + return sync_timeline_create(sizeof(struct sync_timeline), + "sw_sync", name); } EXPORT_SYMBOL(sw_sync_timeline_create); -void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) +void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) { - sync_timeline_signal(>obj, inc); + sync_timeline_signal(obj, inc); } EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h index e18667b..9f26c62 100644 --- a/drivers/staging/android/sw_sync.h +++ b/drivers/staging/android/sw_sync.h @@ -22,34 +22,22 @@ #include "sync.h" #include "uapi/sw_sync.h" -struct sw_sync_timeline { - struct sync_timeline obj; - - u32 value; -}; - -struct sw_sync_pt { - struct fencept; - - u32 value; -}; - #if IS_ENABLED(CONFIG_SW_SYNC) -struct sw_sync_timeline *sw_sync_timeline_create(const char *name); -void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc); +struct sync_timeline *sw_sync_timeline_create(const char *name); +void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc); -struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value); +struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value); #else -static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name) +static inline struct sync_timeline *sw_sync_timeline_create(const char *name) { return NULL; } -static inline void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) +static inline void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) { } -static inline struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, +static inline struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) { return NULL; diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index e5634f2..e207a4d 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -209,7 +209,7 @@ static const struct file_operations sync_info_debugfs_fops = { /* opening sw_sync create a new sync obj */ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) { - struct sw_sync_timeline *obj; + struct sync_timeline *obj; char task_comm[TASK_COMM_LEN]; get_task_comm(task_comm, current); @@ -225,13 +225,13 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) static int sw_sync_debugfs_release(struct inode *inode, struct file *file) { - struct sw_sync_timeline *obj = file->private_data; + struct sync_timeline *obj = file->private_data; - sync_timeline_destroy(>obj); + sync_timeline_destroy(obj); return 0; } -static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, +static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, unsigned long arg) { int fd = get_unused_fd_flags(O_CLOEXEC); @@ -277,7 +277,7 @@ err: return err; } -static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned long arg) +static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) { u32 value; @@ -292,7 +292,7 @@ static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned
[PATCH 02/13] staging/android: remove .{fence, timeline}_value_str() from timeline_ops
From: Gustavo PadovanNow that the value of fence and the timeline are not stored by sw_sync anymore we can remove this extra abstraction to retrieve this data. This patch changes both fence_ops (.fence_value_str and .timeline_value_str) to return the str directly. It also clean up struct sync_timeline_ops by removing both ops from there. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c| 17 - drivers/staging/android/sync.c | 16 ++-- drivers/staging/android/sync.h | 9 - drivers/staging/android/sync_debug.c | 12 ++-- drivers/staging/android/trace/sync.h | 12 +++- 5 files changed, 7 insertions(+), 59 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 428e22c..4200b12 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -38,25 +38,8 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create); -static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, - char *str, int size) -{ - struct sw_sync_timeline *timeline = - (struct sw_sync_timeline *)sync_timeline; - snprintf(str, size, "%d", timeline->value); -} - -static void sw_sync_fence_value_str(struct fence *fence, char *str, int size) -{ - struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; - - snprintf(str, size, "%d", pt->value); -} - static struct sync_timeline_ops sw_sync_timeline_ops = { .driver_name = "sw_sync", - .timeline_value_str = sw_sync_timeline_value_str, - .fence_value_str = sw_sync_fence_value_str, }; struct sw_sync_timeline *sw_sync_timeline_create(const char *name) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 8dd2181..c75d1e6 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -185,14 +185,7 @@ static bool android_fence_enable_signaling(struct fence *fence) static void android_fence_value_str(struct fence *fence, char *str, int size) { - struct sync_timeline *parent = fence_parent(fence); - - if (!parent->ops->fence_value_str) { - if (size) - *str = 0; - return; - } - parent->ops->fence_value_str(fence, str, size); + snprintf(str, size, "%d", fence->seqno); } static void android_fence_timeline_value_str(struct fence *fence, @@ -200,12 +193,7 @@ static void android_fence_timeline_value_str(struct fence *fence, { struct sync_timeline *parent = fence_parent(fence); - if (!parent->ops->timeline_value_str) { - if (size) - *str = 0; - return; - } - parent->ops->timeline_value_str(parent, str, size); + snprintf(str, size, "%d", parent->value); } static const struct fence_ops android_fence_ops = { diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 627525c..29f8c19 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -28,18 +28,9 @@ struct sync_timeline; /** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation - * @timeline_value_str: fill str with the value of the sync_timeline's counter - * @fence_value_str: fill str with the value of the fence */ struct sync_timeline_ops { const char *driver_name; - - /* optional */ - void (*timeline_value_str)(struct sync_timeline *timeline, char *str, - int size); - - /* optional */ - void (*fence_value_str)(struct fence *fence, char *str, int size); }; /** diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 5f57499..c532457 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -133,16 +133,8 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) struct list_head *pos; unsigned long flags; - seq_printf(s, "%s %s", obj->name, obj->ops->driver_name); - - if (obj->ops->timeline_value_str) { - char value[64]; - - obj->ops->timeline_value_str(obj, value, sizeof(value)); - seq_printf(s, ": %s", value); - } - - seq_puts(s, "\n"); + seq_printf(s, "%s %s: %d\n", obj->name, obj->ops->driver_name, + obj->value); spin_lock_irqsave(>child_list_lock, flags); list_for_each(pos, >child_list_head) { diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h index a0f80f4..d7f6457f 100644 --- a/drivers/staging/android/trace/sync.h +++ b/drivers/staging/android/trace/sync.h @@
[PATCH 05/13] staging/android: remove sw_sync.[ch] files
From: Gustavo PadovanWe can glue the sw_sync file operations directly on the sync framework without the need to pass through sw_sync wrappers. It only builds sw_sync debugfs file support if CONFIG_SW_SYNC is enabled. Signed-off-by: Gustavo Padovan --- drivers/staging/android/Makefile | 1 - drivers/staging/android/sw_sync.c| 45 -- drivers/staging/android/sw_sync.h| 47 drivers/staging/android/sync_debug.c | 17 ++--- 4 files changed, 13 insertions(+), 97 deletions(-) delete mode 100644 drivers/staging/android/sw_sync.c delete mode 100644 drivers/staging/android/sw_sync.h diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 980d6dc..bf45967 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -5,4 +5,3 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)+= lowmemorykiller.o obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c deleted file mode 100644 index 461dbd9..000 --- a/drivers/staging/android/sw_sync.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * drivers/base/sw_sync.c - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sw_sync.h" - -struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) -{ - return sync_pt_create(obj, sizeof(struct fence), value); -} -EXPORT_SYMBOL(sw_sync_pt_create); - -struct sync_timeline *sw_sync_timeline_create(const char *name) -{ - return sync_timeline_create(sizeof(struct sync_timeline), - "sw_sync", name); -} -EXPORT_SYMBOL(sw_sync_timeline_create); - -void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) -{ - sync_timeline_signal(obj, inc); -} -EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h deleted file mode 100644 index 9f26c62..000 --- a/drivers/staging/android/sw_sync.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * include/linux/sw_sync.h - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef _LINUX_SW_SYNC_H -#define _LINUX_SW_SYNC_H - -#include -#include -#include "sync.h" -#include "uapi/sw_sync.h" - -#if IS_ENABLED(CONFIG_SW_SYNC) -struct sync_timeline *sw_sync_timeline_create(const char *name); -void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc); - -struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value); -#else -static inline struct sync_timeline *sw_sync_timeline_create(const char *name) -{ - return NULL; -} - -static inline void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) -{ -} - -static inline struct fence *sw_sync_pt_create(struct sync_timeline *obj, - u32 value) -{ - return NULL; -} -#endif /* IS_ENABLED(CONFIG_SW_SYNC) */ - -#endif /* _LINUX_SW_SYNC_H */ diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index e207a4d..dc85d5f 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -27,7 +27,11 @@ #include #include #include -#include "sw_sync.h" +#include +#include + +#include "uapi/sw_sync.h" +#include "sync.h" #ifdef CONFIG_DEBUG_FS @@ -200,6 +204,7 @@ static const struct file_operations sync_info_debugfs_fops = { .release= single_release, }; +#if IS_ENABLED(CONFIG_SW_SYNC) /* * *WARNING* * @@ -214,7 +219,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) get_task_comm(task_comm, current); - obj = sw_sync_timeline_create(task_comm); + obj =
[PATCH 01/13] staging/android: store last signaled value on sync timeline
From: Gustavo PadovanNow fence timeline is aware of the last signaled fence, as it receives the increment to the current value in sync_timeline_signal(). That allow us to remove .has_signaled() from timeline_ops as we can directly compare using timeline->value and fence->seqno in sync.c Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c | 16 ++-- drivers/staging/android/sync.c| 15 +++ drivers/staging/android/sync.h| 14 +- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index af39ff5..428e22c 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -30,7 +30,7 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) struct sw_sync_pt *pt; pt = (struct sw_sync_pt *) - sync_pt_create(>obj, sizeof(struct sw_sync_pt)); + sync_pt_create(>obj, sizeof(struct sw_sync_pt), value); pt->value = value; @@ -38,15 +38,6 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create); -static int sw_sync_fence_has_signaled(struct fence *fence) -{ - struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; - struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)fence_parent(fence); - - return (pt->value > obj->value) ? 0 : 1; -} - static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, char *str, int size) { @@ -64,7 +55,6 @@ static void sw_sync_fence_value_str(struct fence *fence, char *str, int size) static struct sync_timeline_ops sw_sync_timeline_ops = { .driver_name = "sw_sync", - .has_signaled = sw_sync_fence_has_signaled, .timeline_value_str = sw_sync_timeline_value_str, .fence_value_str = sw_sync_fence_value_str, }; @@ -82,8 +72,6 @@ EXPORT_SYMBOL(sw_sync_timeline_create); void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) { - obj->value += inc; - - sync_timeline_signal(>obj); + sync_timeline_signal(>obj, inc); } EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 1d14c83..8dd2181 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -90,7 +90,7 @@ void sync_timeline_destroy(struct sync_timeline *obj) } EXPORT_SYMBOL(sync_timeline_destroy); -void sync_timeline_signal(struct sync_timeline *obj) +void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) { unsigned long flags; struct fence *fence, *next; @@ -99,6 +99,8 @@ void sync_timeline_signal(struct sync_timeline *obj) spin_lock_irqsave(>child_list_lock, flags); + obj->value += inc; + list_for_each_entry_safe(fence, next, >active_list_head, active_list) { if (fence_is_signaled_locked(fence)) @@ -109,7 +111,8 @@ void sync_timeline_signal(struct sync_timeline *obj) } EXPORT_SYMBOL(sync_timeline_signal); -struct fence *sync_pt_create(struct sync_timeline *obj, int size) +struct fence *sync_pt_create(struct sync_timeline *obj, int size, +unsigned int value) { unsigned long flags; struct fence *fence; @@ -124,7 +127,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size) spin_lock_irqsave(>child_list_lock, flags); sync_timeline_get(obj); fence_init(fence, _fence_ops, >child_list_lock, - obj->context, ++obj->value); + obj->context, value); list_add_tail(>child_list, >child_list_head); INIT_LIST_HEAD(>active_list); spin_unlock_irqrestore(>child_list_lock, flags); @@ -164,12 +167,8 @@ static void android_fence_release(struct fence *fence) static bool android_fence_signaled(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - int ret; - ret = parent->ops->has_signaled(fence); - if (ret < 0) - fence->status = ret; - return ret; + return (fence->seqno > parent->value) ? false : true; } static bool android_fence_enable_signaling(struct fence *fence) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index b56885c..627525c 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -28,19 +28,12 @@ struct sync_timeline; /** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation - * @has_signaled: returns: - * 1 if pt has signaled - * 0 if pt has not signaled - * <0 on error * @timeline_value_str: fill str with the value of
[PATCH 06/13] staging/android: rename android_fence to timeline_fence
From: Gustavo PadovanWe are moving out of staging/android so rename it to a name that is not related to android anymore. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sync.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index b3efcaa..442d808 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -28,7 +28,7 @@ #define CREATE_TRACE_POINTS #include "trace/sync.h" -static const struct fence_ops android_fence_ops; +static const struct fence_ops timeline_fence_ops; struct sync_timeline *sync_timeline_create(int size, const char *drv_name, const char *name) @@ -126,7 +126,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size, spin_lock_irqsave(>child_list_lock, flags); sync_timeline_get(obj); - fence_init(fence, _fence_ops, >child_list_lock, + fence_init(fence, _fence_ops, >child_list_lock, obj->context, value); list_add_tail(>child_list, >child_list_head); INIT_LIST_HEAD(>active_list); @@ -135,21 +135,21 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size, } EXPORT_SYMBOL(sync_pt_create); -static const char *android_fence_get_driver_name(struct fence *fence) +static const char *timeline_fence_get_driver_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); return parent->drv_name; } -static const char *android_fence_get_timeline_name(struct fence *fence) +static const char *timeline_fence_get_timeline_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); return parent->name; } -static void android_fence_release(struct fence *fence) +static void timeline_fence_release(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); unsigned long flags; @@ -164,31 +164,31 @@ static void android_fence_release(struct fence *fence) fence_free(fence); } -static bool android_fence_signaled(struct fence *fence) +static bool timeline_fence_signaled(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); return (fence->seqno > parent->value) ? false : true; } -static bool android_fence_enable_signaling(struct fence *fence) +static bool timeline_fence_enable_signaling(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - if (android_fence_signaled(fence)) + if (timeline_fence_signaled(fence)) return false; list_add_tail(>active_list, >active_list_head); return true; } -static void android_fence_value_str(struct fence *fence, +static void timeline_fence_value_str(struct fence *fence, char *str, int size) { snprintf(str, size, "%d", fence->seqno); } -static void android_fence_timeline_value_str(struct fence *fence, +static void timeline_fence_timeline_value_str(struct fence *fence, char *str, int size) { struct sync_timeline *parent = fence_parent(fence); @@ -196,13 +196,13 @@ static void android_fence_timeline_value_str(struct fence *fence, snprintf(str, size, "%d", parent->value); } -static const struct fence_ops android_fence_ops = { - .get_driver_name = android_fence_get_driver_name, - .get_timeline_name = android_fence_get_timeline_name, - .enable_signaling = android_fence_enable_signaling, - .signaled = android_fence_signaled, +static const struct fence_ops timeline_fence_ops = { + .get_driver_name = timeline_fence_get_driver_name, + .get_timeline_name = timeline_fence_get_timeline_name, + .enable_signaling = timeline_fence_enable_signaling, + .signaled = timeline_fence_signaled, .wait = fence_default_wait, - .release = android_fence_release, - .fence_value_str = android_fence_value_str, - .timeline_value_str = android_fence_timeline_value_str, + .release = timeline_fence_release, + .fence_value_str = timeline_fence_value_str, + .timeline_value_str = timeline_fence_timeline_value_str, }; -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 12/13] staging/android: make sync_timeline internal to sw_sync
From: Gustavo PadovanThe only use sync_timeline will have in upstream kernel is for debugging through the SW_SYNC interface. So make it internal to SW_SYNC to avoid people use it in the future. Signed-off-by: Gustavo Padovan --- drivers/staging/android/Kconfig | 16 +-- drivers/staging/android/Makefile | 3 +- drivers/staging/android/sw_sync.c | 211 ++ drivers/staging/android/sync.c| 199 --- drivers/staging/android/sync.h| 49 - 5 files changed, 216 insertions(+), 262 deletions(-) delete mode 100644 drivers/staging/android/sync.c diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 6480f60..f52c682 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -24,26 +24,18 @@ config ANDROID_LOW_MEMORY_KILLER scripts (/init.rc), and it defines priority values with minimum free memory size for each priority. -config SYNC - bool "Synchronization framework" - default n - select ANON_INODES - select DMA_SHARED_BUFFER - ---help--- - This option enables the framework for synchronization between multiple - drivers. Sync implementations can take advantage of hardware - synchronization built into devices like GPUs. - config SW_SYNC - bool "Software synchronization objects" + bool "Software synchronization framework" default n - depends on SYNC depends on SYNC_FILE ---help--- A sync object driver that uses a 32bit counter to coordinate synchronization. Useful when there is no hardware primitive backing the synchronization. + WARNING: improper use of this can result in deadlocking kernel + drivers from userspace. Intended for test and debug only. + source "drivers/staging/android/ion/Kconfig" endif # if ANDROID diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 980d6dc..7ca61b7 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -4,5 +4,4 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)+= lowmemorykiller.o -obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 90e3ee5..4922233 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -17,11 +17,222 @@ #include #include #include +#include #include #include "uapi/sw_sync.h" #include "sync.h" +#define CREATE_TRACE_POINTS +#include "trace/sync.h" + +/** + * sync_timeline_create() - creates a sync object + * @drv_name: sync_timeline driver name + * @name: sync_timeline name + * + * Creates a new sync_timeline. Returns the sync_timeline object or NULL in + * case of error. + */ +struct sync_timeline *sync_timeline_create(const char *drv_name, + const char *name) +{ + struct sync_timeline *obj; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) + return NULL; + + kref_init(>kref); + obj->context = fence_context_alloc(1); + strlcpy(obj->name, name, sizeof(obj->name)); + strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); + + INIT_LIST_HEAD(>child_list_head); + INIT_LIST_HEAD(>active_list_head); + spin_lock_init(>child_list_lock); + + sync_timeline_debug_add(obj); + + return obj; +} + +static void sync_timeline_free(struct kref *kref) +{ + struct sync_timeline *obj = + container_of(kref, struct sync_timeline, kref); + + sync_timeline_debug_remove(obj); + + kfree(obj); +} + +static void sync_timeline_get(struct sync_timeline *obj) +{ + kref_get(>kref); +} + +static void sync_timeline_put(struct sync_timeline *obj) +{ + kref_put(>kref, sync_timeline_free); +} + +/** + * sync_timeline_destroy() - destroys a sync object + * @obj: sync_timeline to destroy + * + * A sync implementation should call this when the @obj is going away + * (i.e. module unload.) @obj won't actually be freed until all its children + * fences are freed. + */ +static void sync_timeline_destroy(struct sync_timeline *obj) +{ + obj->destroyed = true; + /* +* Ensure timeline is marked as destroyed before +* changing timeline's fences status. +*/ + smp_wmb(); + + sync_timeline_put(obj); +} + +/** + * sync_timeline_signal() - signal a status change on a sync_timeline + * @obj: sync_timeline to signal + * @inc: num to increment on
[PATCH 11/13] staging/android: clean up #includes in the sync framework
From: Gustavo PadovanMost of the includes there are not necessary anymore. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sync.c | 6 -- drivers/staging/android/sync.h | 3 --- drivers/staging/android/sync_debug.c | 16 3 files changed, 25 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index aab80ec..bb12d86 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -14,14 +14,8 @@ * */ -#include #include -#include -#include -#include #include -#include -#include #include "sync.h" diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 02ecf44..54c515b 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -13,9 +13,6 @@ #ifndef _LINUX_SYNC_H #define _LINUX_SYNC_H -#include -#include -#include #include #include #include diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 2733cc3..864ad01 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -15,22 +15,6 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uapi/sw_sync.h" #include "sync.h" #ifdef CONFIG_DEBUG_FS -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 07/13] staging/android: remove unnecessary check for fence
From: Gustavo PadovanWhen we call sync_print_fence() fence is always valid. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sync_debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index dc85d5f..6282046 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -109,7 +109,7 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); } - if ((!fence || fence->ops->timeline_value_str) && + if (fence->ops->timeline_value_str && fence->ops->fence_value_str) { char value[64]; bool success; @@ -117,10 +117,9 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) fence->ops->fence_value_str(fence, value, sizeof(value)); success = strlen(value); - if (success) + if (success) { seq_printf(s, ": %s", value); - if (success && fence) { fence->ops->timeline_value_str(fence, value, sizeof(value)); -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 13/13] staging/android: make sw_ioctl info internal to sw_sync.c
From: Gustavo PadovanWe don't want to export this from the kernel. This is interface is only for testing and debug. So testers shall copy the ioctl info in their own projects. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c | 13 - drivers/staging/android/uapi/sw_sync.h | 32 2 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 drivers/staging/android/uapi/sw_sync.h diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 4922233..7a7acc1 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -20,12 +20,23 @@ #include #include -#include "uapi/sw_sync.h" #include "sync.h" #define CREATE_TRACE_POINTS #include "trace/sync.h" +struct sw_sync_create_fence_data { + __u32 value; + charname[32]; + __s32 fence; /* fd of new fence */ +}; + +#define SW_SYNC_IOC_MAGIC 'W' + +#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ + struct sw_sync_create_fence_data) +#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, __u32) + /** * sync_timeline_create() - creates a sync object * @drv_name: sync_timeline driver name diff --git a/drivers/staging/android/uapi/sw_sync.h b/drivers/staging/android/uapi/sw_sync.h deleted file mode 100644 index 9b5d486..000 --- a/drivers/staging/android/uapi/sw_sync.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef _UAPI_LINUX_SW_SYNC_H -#define _UAPI_LINUX_SW_SYNC_H - -#include - -struct sw_sync_create_fence_data { - __u32 value; - charname[32]; - __s32 fence; /* fd of new fence */ -}; - -#define SW_SYNC_IOC_MAGIC 'W' - -#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ - struct sw_sync_create_fence_data) -#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, __u32) - -#endif /* _UAPI_LINUX_SW_SYNC_H */ -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 09/13] staging/android: bring struct sync_pt back
From: Gustavo PadovanMove the list_head members from sync_pt to struct fence was a mistake, they will not be used by struct fence as planned before, so here we create sync_pt again to bring the list heads back. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sync.c | 40 ++-- drivers/staging/android/sync.h | 29 ++ drivers/staging/android/sync_debug.c | 16 +++ include/linux/fence.h| 2 -- 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index c83a599..aab80ec 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -28,8 +28,6 @@ #define CREATE_TRACE_POINTS #include "trace/sync.h" -static const struct fence_ops timeline_fence_ops; - struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name) { @@ -90,7 +88,7 @@ EXPORT_SYMBOL(sync_timeline_destroy); void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) { unsigned long flags; - struct fence *fence, *next; + struct sync_pt *pt, *next; trace_sync_timeline(obj); @@ -98,37 +96,37 @@ void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) obj->value += inc; - list_for_each_entry_safe(fence, next, >active_list_head, + list_for_each_entry_safe(pt, next, >active_list_head, active_list) { - if (fence_is_signaled_locked(fence)) - list_del_init(>active_list); + if (fence_is_signaled_locked(>base)) + list_del_init(>active_list); } spin_unlock_irqrestore(>child_list_lock, flags); } EXPORT_SYMBOL(sync_timeline_signal); -struct fence *sync_pt_create(struct sync_timeline *obj, int size, +struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, unsigned int value) { unsigned long flags; - struct fence *fence; + struct sync_pt *pt; - if (size < sizeof(*fence)) + if (size < sizeof(*pt)) return NULL; - fence = kzalloc(size, GFP_KERNEL); - if (!fence) + pt = kzalloc(size, GFP_KERNEL); + if (!pt) return NULL; spin_lock_irqsave(>child_list_lock, flags); sync_timeline_get(obj); - fence_init(fence, _fence_ops, >child_list_lock, + fence_init(>base, _fence_ops, >child_list_lock, obj->context, value); - list_add_tail(>child_list, >child_list_head); - INIT_LIST_HEAD(>active_list); + list_add_tail(>child_list, >child_list_head); + INIT_LIST_HEAD(>active_list); spin_unlock_irqrestore(>child_list_lock, flags); - return fence; + return pt; } EXPORT_SYMBOL(sync_pt_create); @@ -148,13 +146,14 @@ static const char *timeline_fence_get_timeline_name(struct fence *fence) static void timeline_fence_release(struct fence *fence) { + struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_timeline *parent = fence_parent(fence); unsigned long flags; spin_lock_irqsave(fence->lock, flags); - list_del(>child_list); - if (WARN_ON_ONCE(!list_empty(>active_list))) - list_del(>active_list); + list_del(>child_list); + if (WARN_ON_ONCE(!list_empty(>active_list))) + list_del(>active_list); spin_unlock_irqrestore(fence->lock, flags); sync_timeline_put(parent); @@ -170,12 +169,13 @@ static bool timeline_fence_signaled(struct fence *fence) static bool timeline_fence_enable_signaling(struct fence *fence) { + struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_timeline *parent = fence_parent(fence); if (timeline_fence_signaled(fence)) return false; - list_add_tail(>active_list, >active_list_head); + list_add_tail(>active_list, >active_list_head); return true; } @@ -193,7 +193,7 @@ static void timeline_fence_timeline_value_str(struct fence *fence, snprintf(str, size, "%d", parent->value); } -static const struct fence_ops timeline_fence_ops = { +const struct fence_ops timeline_fence_ops = { .get_driver_name = timeline_fence_get_driver_name, .get_timeline_name = timeline_fence_get_timeline_name, .enable_signaling = timeline_fence_enable_signaling, diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index f2fbf98..14b61cb 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -60,6 +60,27 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) child_list_lock); } +/** + * struct sync_pt - sync_pt object + *
[PATCH 00/13] staging/android: clean up SW_SYNC
From: Gustavo PadovanHi, The following patches do a clean up on the sw_sync inteface. It starts by removing struct sync_timeline_ops, which was creating unecessary wrappers in the code and the start to organize the sync_timeline and sw_sync code better. sw_sync interface was moved to sw_sync.c along with sync_timeline - which is now internal to sw_sync. The next step after this work is the actual de-stage of SW_SYNC and the upstreaming of selftests for sw_sync and sync_file. Please review! Gustavo --- Gustavo Padovan (13): staging/android: store last signaled value on sync timeline staging/android: remove .{fence,timeline}_value_str() from timeline_ops staging/android: remove struct sync_timeline_ops staging/android: remove sw_sync_timeline and sw_sync_pt staging/android: remove sw_sync.[ch] files staging/android: rename android_fence to timeline_fence staging/android: remove unnecessary check for fence staging/android: remove size arg of sync_timeline_create() staging/android: bring struct sync_pt back staging/android: move sw_sync related code to sw_sync.c staging/android: clean up #includes in the sync framework staging/android: make sync_timeline internal to sw_sync staging/android: make sw_ioctl info internal to sw_sync.c drivers/staging/android/Kconfig| 16 +- drivers/staging/android/Makefile | 3 +- drivers/staging/android/sw_sync.c | 355 + drivers/staging/android/sw_sync.h | 59 -- drivers/staging/android/sync.c | 221 drivers/staging/android/sync.h | 95 ++--- drivers/staging/android/sync_debug.c | 152 +- drivers/staging/android/trace/sync.h | 12 +- drivers/staging/android/uapi/sw_sync.h | 32 --- include/linux/fence.h | 2 - 10 files changed, 350 insertions(+), 597 deletions(-) delete mode 100644 drivers/staging/android/sw_sync.h delete mode 100644 drivers/staging/android/sync.c delete mode 100644 drivers/staging/android/uapi/sw_sync.h -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 03/13] staging/android: remove struct sync_timeline_ops
From: Gustavo PadovanMove drv_name, the last field of sync_timeline_ops, to sync_timeline and remove sync_timeline_ops. struct sync_timeline_ops was just an extra abstraction on top of fence_ops, and in the last few commits we removed all it ops in favor of cleaner fence_ops. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c| 9 ++--- drivers/staging/android/sync.c | 8 drivers/staging/android/sync.h | 28 +--- drivers/staging/android/sync_debug.c | 3 +-- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 4200b12..c5e92c6 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -38,16 +38,11 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create); -static struct sync_timeline_ops sw_sync_timeline_ops = { - .driver_name = "sw_sync", -}; - struct sw_sync_timeline *sw_sync_timeline_create(const char *name) { struct sw_sync_timeline *obj = (struct sw_sync_timeline *) - sync_timeline_create(_sync_timeline_ops, -sizeof(struct sw_sync_timeline), -name); + sync_timeline_create(sizeof(struct sw_sync_timeline), +"sw_sync", name); return obj; } diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index c75d1e6..b3efcaa 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -30,8 +30,8 @@ static const struct fence_ops android_fence_ops; -struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, - int size, const char *name) +struct sync_timeline *sync_timeline_create(int size, const char *drv_name, + const char *name) { struct sync_timeline *obj; @@ -43,9 +43,9 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, return NULL; kref_init(>kref); - obj->ops = ops; obj->context = fence_context_alloc(1); strlcpy(obj->name, name, sizeof(obj->name)); + strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); INIT_LIST_HEAD(>child_list_head); INIT_LIST_HEAD(>active_list_head); @@ -139,7 +139,7 @@ static const char *android_fence_get_driver_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - return parent->ops->driver_name; + return parent->drv_name; } static const char *android_fence_get_timeline_name(struct fence *fence) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 29f8c19..f003e97 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -23,20 +23,10 @@ #include #include -struct sync_timeline; - -/** - * struct sync_timeline_ops - sync object implementation ops - * @driver_name: name of the implementation - */ -struct sync_timeline_ops { - const char *driver_name; -}; - /** * struct sync_timeline - sync object * @kref: reference count on fence. - * @ops: ops that define the implementation of the sync_timeline + * @drv_name: drv_name of the driver using the sync_timeline * @name: name of the sync_timeline. Useful for debugging * @destroyed: set when sync_timeline is destroyed * @child_list_head: list of children sync_pts for this sync_timeline @@ -47,7 +37,7 @@ struct sync_timeline_ops { */ struct sync_timeline { struct kref kref; - const struct sync_timeline_ops *ops; + chardrv_name[32]; charname[32]; /* protected by child_list_lock */ @@ -76,17 +66,17 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) /** * sync_timeline_create() - creates a sync object - * @ops: specifies the implementation ops for the object * @size: size to allocate for this obj + * @drv_name: sync_timeline driver name * @name: sync_timeline name * - * Creates a new sync_timeline which will use the implementation specified by - * @ops. @size bytes will be allocated allowing for implementation specific - * data to be kept after the generic sync_timeline struct. Returns the - * sync_timeline object or NULL in case of error. + * Creates a new sync_timeline. @size bytes will be allocated allowing + * for implementation specific data to be kept after the generic + * sync_timeline struct. Returns the sync_timeline object or NULL in + * case of error. */ -struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, -
Re: [PATCH v2] vme: change LM callback argument to void pointer
- Original Message - > From: "Dan Carpenter"> Sent: Saturday, April 30, 2016 5:16:19 AM > > On Fri, Apr 29, 2016 at 04:41:02PM -0500, Aaron Sierra wrote: > > There appear to be no in-kernel callers of vme_lm_attach (or > > vme_lme_request for that matter), so this change only affects the VME > > subsystem and bridge drivers. > > Are we planning to add in-kernel users soon? Dan, I don't have plans to submit any new VME device drivers. I use this interface in a trivial bridge self-test driver that I wrote to help test a new bridge driver supporting the ALTHEA 7910 PCIe-VME bridge from IOxOS Technologies. -Aaron S. > regards, > dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 00/14] staging: fsl-mc: misc updates
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Friday, April 29, 2016 8:01 PM > To: Stuart Yoder> Cc: Jose Rivera ; de...@driverdev.osuosl.org; > ag...@suse.de; a...@arndb.de; > linux-ker...@vger.kernel.org; Yang-Leo Li > Subject: Re: [PATCH 00/14] staging: fsl-mc: misc updates > > On Mon, Apr 11, 2016 at 11:48:25AM -0500, Stuart Yoder wrote: > > From: Stuart Yoder > > > > This patch series makes further progress towards completing the fsl-mc > > TODO list. > > I don't seem to have gotten patch 14/14, can you resend just that one? Done. This was the patch where a 2nd maintainer was added for the fsl-mc bus driver. Thanks, Stuart ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 14/14 RESEND] MAINTAINERS: fsl-mc: Add second maintainer
Add Stuart Yoder as additional maintainer of fsl-mc bus driver. Signed-off-by: Stuart Yoder--- MAINTAINERS |1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 03e00c7..62db04e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4670,6 +4670,7 @@ F:sound/soc/fsl/mpc8610_hpcd.c FREESCALE QORIQ MANAGEMENT COMPLEX DRIVER M: "J. German Rivera" +M: Stuart Yoder L: linux-ker...@vger.kernel.org S: Maintained F: drivers/staging/fsl-mc/ -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: Time for a code audit?
Reviewing drivers/staging/unisys/visorinput/visorinput.c 465 case KEY_NUMLOCK: 466 led = LED_NUML; 467 break; 468 default: 469 led = -1; Just make this a direct return. 470 break; 471 } 472 if (led >= 0) { Then you can remove this if condition. 473 int old_state = (test_bit(led, visorinput_dev->led)); Remove extra parens. 474 475 if (old_state != desired_state) { 476 input_report_key(visorinput_dev, keycode, 1); 477 input_sync(visorinput_dev); 478 input_report_key(visorinput_dev, keycode, 0); 479 input_sync(visorinput_dev); 480 __change_bit(led, visorinput_dev->led); 481 } 482 } 483 } regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: Time for a code audit?
Reviewing drivers/staging/unisys/visornic/visornic_main.c 212 static int 213 visor_copy_fragsinfo_from_skb(struct sk_buff *skb, unsigned int firstfraglen, 214unsigned int frags_max, 215struct phys_info frags[]) 216 { 217 unsigned int count = 0, ii, size, offset = 0, numfrags; ^^ The second "i" character indicates that it is an integer. Which is ugly and, of course, misleading. 296 static ssize_t enable_ints_write(struct file *file, 297 const char __user *buffer, 298 size_t count, loff_t *ppos) 299 { 300 /* 301 * Don't want to break ABI here by having a debugfs 302 * file that no longer exists or is writable, so 303 * lets just make this a vestigual function 304 */ 305 return count; 306 } We don't care about ABI so much as we do about applications or scripts. This was added by Neil Horman because the original code was useless and dangerous. It was the right patch for him, because he doesn't know about the userspace so he can't say if anything will break. But presumably you guys know. Does anything break if we remove this debugfs file? Also if so then shame shame shame. User space is not supposed to depend on debugfs being writable. Just delete this... 1019 */ 1020 static void 1021 visornic_set_multi(struct net_device *netdev) 1022 { 1023 struct uiscmdrsp *cmdrsp; 1024 struct visornic_devdata *devdata = netdev_priv(netdev); 1025 1026 /* any filtering changes */ 1027 if (devdata->old_flags != netdev->flags) { 1028 if ((netdev->flags & IFF_PROMISC) != 1029 (devdata->old_flags & IFF_PROMISC)) { Reverse these if statements and pull the code in two indent levels. 1154 /** 1155 * visornic_rx - Handle receive packets coming back from IO Part 1156 * @cmdrsp: Receive packet returned from IO Part 1157 * 1158 * Got a receive packet back from the IO Part, handle it and send 1159 * it up the stack. 1160 * Returns void Actually it returns either zero or one but in a convoluted way. Update it to use literals and update the comment. 1361 /** 1362 * devdata_initialize - Initialize devdata structure 1363 * @devdata: visornic_devdata structure to initialize 1364 * #dev: visorbus_deviced it belongs to 1365 * 1366 * Setup initial values for the visornic based on channel and default 1367 * values. 1368 * Returns a pointer to the devdata if successful, else NULL 1369 */ 1370 static struct visornic_devdata * 1371 devdata_initialize(struct visornic_devdata *devdata, struct visor_device *dev) 1372 { 1373 if (!devdata) 1374 return NULL; This check doesn't make sense and the error handling is kind of odd. Just remove it, remove the error handling and update the comment. 1817 err = visorbus_read_channel(dev, channel_offset, 1818 >num_rcv_bufs, 4); 1819 if (err) { 1820 dev_err(>device, 1821 "%s failed to get #rcv bufs from chan (%d)\n", 1822 __func__, err); 1823 goto cleanup_netdev; 1824 } 1825 1826 devdata->rcvbuf = kcalloc(devdata->num_rcv_bufs, 1827sizeof(struct sk_buff *), GFP_KERNEL); 1828 if (!devdata->rcvbuf) { 1829 err = -ENOMEM; 1830 goto cleanup_rcvbuf; We never allocated rcvbuf. It should still be goto cleanup_netdev; The other gotos after this in this function are slightly off as well. But thanks for the nice label names because it makes reviewing this much easier. :) 1831 } In visornic_init(): 2126 err = visorbus_register_visor_driver(_driver); 2127 if (!err) 2128 return 0; Flip this around. if (err) goto cleanup_debugfs; return 0; These things should be reviewed by people on netdev and the scsi thing should get a review by the scsi people. regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/7] staging: wilc1000: change handle_get_mac_address's return type to void
When handle_get_mac_address is called in hostIFthread that is a kernel thread, it is not checked return type of this function. This patch changes return type to void and removes braces if statement due to have a single statement. Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 8a269fd..23bbaa8 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -398,8 +398,8 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) netdev_err(vif->ndev, "Failed to get IP address\n"); } -static s32 handle_get_mac_address(struct wilc_vif *vif, - struct get_mac_addr *get_mac_addr) +static void handle_get_mac_address(struct wilc_vif *vif, + struct get_mac_addr *get_mac_addr) { s32 result = 0; struct wid wid; @@ -412,13 +412,9 @@ static s32 handle_get_mac_address(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, GET_CFG, , 1, wilc_get_vif_idx(vif)); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to get mac address\n"); - result = -EFAULT; - } complete(_wait_response); - - return result; } static s32 handle_cfg_param(struct wilc_vif *vif, -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/7] staging: wilc1000: rename result in handle_get_mac_address
This patch renames result to ret that is used to get return value from wilc_send_config_pkt. Some handle_*() functions are used as result, others are used as ret. It will be changed as ret in all handle_*() functions to match variable name. Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 71d6b66..9535842 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -401,7 +401,7 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) static void handle_get_mac_address(struct wilc_vif *vif, struct get_mac_addr *get_mac_addr) { - int result = 0; + int ret = 0; struct wid wid; wid.id = (u16)WID_MAC_ADDR; @@ -409,10 +409,10 @@ static void handle_get_mac_address(struct wilc_vif *vif, wid.val = get_mac_addr->mac_addr; wid.size = ETH_ALEN; - result = wilc_send_config_pkt(vif, GET_CFG, , 1, - wilc_get_vif_idx(vif)); + ret = wilc_send_config_pkt(vif, GET_CFG, , 1, + wilc_get_vif_idx(vif)); - if (result) + if (ret) netdev_err(vif->ndev, "Failed to get mac address\n"); complete(_wait_response); } -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/7] staging: wilc1000: change handle_get_ip_address's return type to void
When handle_get_ip_address is called in hostIFthread that is a kernel thread, it is not checked return type of this function. This patch changes return type to void and removes braces if statement due to have a single statement. Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 605cf8f..ce1cd68 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -374,7 +374,7 @@ static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) netdev_err(vif->ndev, "Failed to set IP address\n"); } -static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx) +static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) { s32 result = 0; struct wid wid; @@ -394,12 +394,8 @@ static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx) if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0) wilc_setup_ipaddress(vif, set_ip[idx], idx); - if (result != 0) { + if (result != 0) netdev_err(vif->ndev, "Failed to get IP address\n"); - return -EINVAL; - } - - return result; } static s32 handle_get_mac_address(struct wilc_vif *vif, -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/7] staging: wilc1000: change data type of result in handle_get_mac_address
This patch changes data type of result variable from s32 to int. result is used to get return value from wilc_send_config_pkt that has return type of int. Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 23bbaa8..71d6b66 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -401,7 +401,7 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) static void handle_get_mac_address(struct wilc_vif *vif, struct get_mac_addr *get_mac_addr) { - s32 result = 0; + int result = 0; struct wid wid; wid.id = (u16)WID_MAC_ADDR; -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/7] staging: wilc1000: fix comparison style of if statement in handle_get_ip_address
This patch changes conditional comparison of if statement as if (ret) instead of using if (ret != 0) Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 1d48214..8a269fd 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -394,7 +394,7 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0) wilc_setup_ipaddress(vif, set_ip[idx], idx); - if (ret != 0) + if (ret) netdev_err(vif->ndev, "Failed to get IP address\n"); } -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/7] staging: wilc1000: rename result in handle_get_ip_address
This patch renames result to ret that is used to get return value from wilc_send_config_pkt. Some handle_*() functions are used as result, others are used as ret. It will be changed as ret in all handle_*() functions to match variable name. Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index acefd3b..1d48214 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -376,7 +376,7 @@ static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) { - int result = 0; + int ret = 0; struct wid wid; wid.id = (u16)WID_IP_ADDRESS; @@ -384,8 +384,8 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) wid.val = kmalloc(IP_ALEN, GFP_KERNEL); wid.size = IP_ALEN; - result = wilc_send_config_pkt(vif, GET_CFG, , 1, - wilc_get_vif_idx(vif)); + ret = wilc_send_config_pkt(vif, GET_CFG, , 1, + wilc_get_vif_idx(vif)); memcpy(get_ip[idx], wid.val, IP_ALEN); @@ -394,7 +394,7 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0) wilc_setup_ipaddress(vif, set_ip[idx], idx); - if (result != 0) + if (ret != 0) netdev_err(vif->ndev, "Failed to get IP address\n"); } -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/7] staging: wilc1000: change data type of result in handle_get_ip_address
This patch changes data type of result variable from s32 to int. result is used to get return value from wilc_send_config_pkt that has return type of int. Signed-off-by: Chaehyun Lim--- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index ce1cd68..acefd3b 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -376,7 +376,7 @@ static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) { - s32 result = 0; + int result = 0; struct wid wid; wid.id = (u16)WID_IP_ADDRESS; -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: Time for a code audit?
Reviewing drivers/staging/unisys/visorhba/visorhba_main.c visor_thread_start() I'm nervous about the error handling here. Is setting ->id to zero really sufficient to prevent dereferencing ->task? Still a lot of return -1; grep "return -1;" drivers/staging/unisys/ -R del_scsipending_ent() flip the if condition around so it's error handling instead of success handling. Remove the "sent = NULL" initializer. drivers/staging/unisys/visorhba/visorhba_main.c 301 /* specify the event that has to be triggered when this */ 302 /* cmd is complete */ 303 cmdrsp->scsitaskmgmt.notify_handle = (u64) 304 cmdrsp->scsitaskmgmt.notifyresult_handle = (u64) This casting an int pointer to u64 pointer seems bad. I must be blind. How does queue_disk_add_remove() work? Where do we initialize dar_work_queue? process_disk_notify() switch success handling to error handling. visorhba_probe(). We really can only probe one device right? Because VISORHBA_OPEN_MAX is 1. So what happens if we try to probe two? I don't immediately see how that is handled. visorhba_init() return a literal zero on success. Looks pretty good generally to mee. regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: speakup: i18n: Fixed a CHECK coding style.
On Mon, May 02, 2016 at 10:35:54AM +0530, rohitsakala wrote: > NULL comparison has been changed to correct coding style. > > Signed-off-by: rohitsakalaNah. Write your name properly like you did last time and fix your from header... regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel