From b4b7ff4b08e691656c9d77c758fc355833128ac0 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Wed, 20 Jan 2016 14:01:31 -0300 Subject: Linux-libre 4.4-gnu --- drivers/staging/most/hdm-dim2/Kconfig | 2 +- drivers/staging/most/hdm-dim2/dim2_hal.c | 62 +++++++---------------- drivers/staging/most/hdm-dim2/dim2_hal.h | 5 -- drivers/staging/most/hdm-dim2/dim2_hdm.c | 79 ++++++++++-------------------- drivers/staging/most/hdm-dim2/dim2_hdm.h | 3 +- drivers/staging/most/hdm-dim2/dim2_sysfs.c | 3 +- 6 files changed, 48 insertions(+), 106 deletions(-) (limited to 'drivers/staging/most/hdm-dim2') diff --git a/drivers/staging/most/hdm-dim2/Kconfig b/drivers/staging/most/hdm-dim2/Kconfig index fc5487694..28a0e1791 100644 --- a/drivers/staging/most/hdm-dim2/Kconfig +++ b/drivers/staging/most/hdm-dim2/Kconfig @@ -9,7 +9,7 @@ config HDM_DIM2 ---help--- Say Y here if you want to connect via MediaLB to network transceiver. - This device driver is platform dependent and needs an addtional + This device driver is platform dependent and needs an additional platform driver to be installed. For more information contact maintainer of this driver. diff --git a/drivers/staging/most/hdm-dim2/dim2_hal.c b/drivers/staging/most/hdm-dim2/dim2_hal.c index a54cf2ced..c915c44f0 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hal.c +++ b/drivers/staging/most/hdm-dim2/dim2_hal.c @@ -19,7 +19,6 @@ #include "dim2_reg.h" #include - /* * The number of frames per sub-buffer for synchronous channels. * Allowed values: 1, 2, 4, 8, 16, 32, 64. @@ -51,7 +50,6 @@ */ #define DBR_MAP_SIZE 2 - /* -------------------------------------------------------------------------- */ /* not configurable area */ @@ -60,10 +58,9 @@ #define MLB_CAT 0x80 #define AHB_CAT 0x88 -#define DBR_SIZE (16*1024) /* specified by IP */ +#define DBR_SIZE (16 * 1024) /* specified by IP */ #define DBR_BLOCK_SIZE (DBR_SIZE / 32 / DBR_MAP_SIZE) - /* -------------------------------------------------------------------------- */ /* generic helper functions and macros */ @@ -81,7 +78,6 @@ static inline bool dim_on_error(u8 error_id, const char *error_message) return false; } - /* -------------------------------------------------------------------------- */ /* types and local variables */ @@ -94,7 +90,6 @@ struct lld_global_vars_t { static struct lld_global_vars_t g = { false }; - /* -------------------------------------------------------------------------- */ static int dbr_get_mask_size(u16 size) @@ -134,7 +129,7 @@ static int alloc_dbr(u16 size) return block_idx * DBR_BLOCK_SIZE; } block_idx += mask_size; - /* do shift left with 2 steps for case mask_size == 32 */ + /* do shift left with 2 steps in case mask_size == 32 */ mask <<= mask_size - 1; } while ((mask <<= 1) != 0); } @@ -327,7 +322,6 @@ static void dim2_start_isoc_sync(u8 ch_addr, u8 idx, u32 buf_addr, dim2_write_ctr_mask(ADT + ch_addr, mask, adt); } - static void dim2_clear_ctram(void) { u32 ctr_addr; @@ -499,22 +493,6 @@ static void dim2_initialize(bool enable_6pin, u8 mlb_clock) DIMCB_IoWrite(&g.dim2->ACTL, ACTL_DMA_MODE_VAL_DMA_MODE_1 << ACTL_DMA_MODE_BIT | true << ACTL_SCE_BIT); - -#if 0 - DIMCB_IoWrite(&g.dim2->MIEN, - bit_mask(MIEN_CTX_BREAK_BIT) | - bit_mask(MIEN_CTX_PE_BIT) | - bit_mask(MIEN_CTX_DONE_BIT) | - bit_mask(MIEN_CRX_BREAK_BIT) | - bit_mask(MIEN_CRX_PE_BIT) | - bit_mask(MIEN_CRX_DONE_BIT) | - bit_mask(MIEN_ATX_BREAK_BIT) | - bit_mask(MIEN_ATX_PE_BIT) | - bit_mask(MIEN_ATX_DONE_BIT) | - bit_mask(MIEN_ARX_BREAK_BIT) | - bit_mask(MIEN_ARX_PE_BIT) | - bit_mask(MIEN_ARX_DONE_BIT)); -#endif } static bool dim2_is_mlb_locked(void) @@ -530,7 +508,6 @@ static bool dim2_is_mlb_locked(void) (DIMCB_IoRead(&g.dim2->MLBC0) & mask0) != 0; } - /* -------------------------------------------------------------------------- */ /* channel help routines */ @@ -559,7 +536,6 @@ static inline bool service_channel(u8 ch_addr, u8 idx) return true; } - /* -------------------------------------------------------------------------- */ /* channel init routines */ @@ -639,7 +615,8 @@ static bool channel_start(struct dim_channel *ch, u32 buf_addr, u16 buf_size) if (ch->packet_length || ch->bytes_per_frame) dim2_start_isoc_sync(ch->addr, state->idx1, buf_addr, buf_size); else - dim2_start_ctrl_async(ch->addr, state->idx1, buf_addr, buf_size); + dim2_start_ctrl_async(ch->addr, state->idx1, buf_addr, + buf_size); state->idx1 ^= 1; return true; @@ -670,7 +647,6 @@ static bool channel_detach_buffers(struct dim_channel *ch, u16 buffers_number) return true; } - /* -------------------------------------------------------------------------- */ /* API */ @@ -687,7 +663,8 @@ u8 DIM_Startup(void *dim_base_address, u32 mlb_clock) return DIM_INIT_ERR_MLB_CLOCK; g.dim2 = dim_base_address; - g.dbr_map[0] = g.dbr_map[1] = 0; + g.dbr_map[0] = 0; + g.dbr_map[1] = 0; dim2_initialize(mlb_clock >= 3, mlb_clock); @@ -766,14 +743,14 @@ u8 DIM_InitControl(struct dim_channel *ch, u8 is_tx, u16 ch_address, u16 max_buffer_size) { return init_ctrl_async(ch, CAT_CT_VAL_CONTROL, is_tx, ch_address, - max_buffer_size * 2); + max_buffer_size); } u8 DIM_InitAsync(struct dim_channel *ch, u8 is_tx, u16 ch_address, u16 max_buffer_size) { return init_ctrl_async(ch, CAT_CT_VAL_ASYNC, is_tx, ch_address, - max_buffer_size * 2); + max_buffer_size); } u8 DIM_InitIsoc(struct dim_channel *ch, u8 is_tx, u16 ch_address, @@ -855,11 +832,11 @@ void DIM_ServiceIrq(struct dim_channel *const *channels) } /* - * Use while-loop and a flag to make sure the age is changed back at least once, - * otherwise the interrupt may never come if CPU generates interrupt on changing age. - * - * This cycle runs not more than number of channels, because service_interrupts - * routine doesn't start the channel again. + * Use while-loop and a flag to make sure the age is changed back at + * least once, otherwise the interrupt may never come if CPU generates + * interrupt on changing age. + * This cycle runs not more than number of channels, because + * channel_service_interrupt() routine doesn't start the channel again. */ do { struct dim_channel *const *ch = channels; @@ -886,7 +863,7 @@ u8 DIM_ServiceChannel(struct dim_channel *ch) } struct dim_ch_state_t *DIM_GetChannelState(struct dim_channel *ch, - struct dim_ch_state_t *state_ptr) + struct dim_ch_state_t *state_ptr) { if (!ch || !state_ptr) return NULL; @@ -900,7 +877,8 @@ struct dim_ch_state_t *DIM_GetChannelState(struct dim_channel *ch, bool DIM_EnqueueBuffer(struct dim_channel *ch, u32 buffer_addr, u16 buffer_size) { if (!ch) - return dim_on_error(DIM_ERR_DRIVER_NOT_INITIALIZED, "Bad channel"); + return dim_on_error(DIM_ERR_DRIVER_NOT_INITIALIZED, + "Bad channel"); return channel_start(ch, buffer_addr, buffer_size); } @@ -908,12 +886,8 @@ bool DIM_EnqueueBuffer(struct dim_channel *ch, u32 buffer_addr, u16 buffer_size) bool DIM_DetachBuffers(struct dim_channel *ch, u16 buffers_number) { if (!ch) - return dim_on_error(DIM_ERR_DRIVER_NOT_INITIALIZED, "Bad channel"); + return dim_on_error(DIM_ERR_DRIVER_NOT_INITIALIZED, + "Bad channel"); return channel_detach_buffers(ch, buffers_number); } - -u32 DIM_ReadRegister(u8 register_index) -{ - return DIMCB_IoRead((u32 *)g.dim2 + register_index); -} diff --git a/drivers/staging/most/hdm-dim2/dim2_hal.h b/drivers/staging/most/hdm-dim2/dim2_hal.h index 8929af971..ebb7d87a4 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hal.h +++ b/drivers/staging/most/hdm-dim2/dim2_hal.h @@ -105,17 +105,12 @@ bool DIM_EnqueueBuffer(struct dim_channel *ch, u32 buffer_addr, bool DIM_DetachBuffers(struct dim_channel *ch, u16 buffers_number); -u32 DIM_ReadRegister(u8 register_index); - - u32 DIMCB_IoRead(u32 *ptr32); void DIMCB_IoWrite(u32 *ptr32, u32 value); void DIMCB_OnError(u8 error_id, const char *error_message); -void DIMCB_OnFail(const char *filename, int linenum); - #ifdef __cplusplus } diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.c b/drivers/staging/most/hdm-dim2/dim2_hdm.c index 6a5a3a277..b6fe346f7 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hdm.c +++ b/drivers/staging/most/hdm-dim2/dim2_hdm.c @@ -37,7 +37,7 @@ #define MAX_BUFFERS_PACKET 32 #define MAX_BUFFERS_STREAMING 32 #define MAX_BUF_SIZE_PACKET 2048 -#define MAX_BUF_SIZE_STREAMING (8*1024) +#define MAX_BUF_SIZE_STREAMING (8 * 1024) /* command line parameter to select clock speed */ static char *clock_speed; @@ -165,16 +165,6 @@ void DIMCB_OnError(u8 error_id, const char *error_message) error_message); } -/** - * DIMCB_OnFail - callback from HAL to report unrecoverable errors - * @filename: Source file where the error happened - * @linenum: Line number of the file where the error happened - */ -void DIMCB_OnFail(const char *filename, int linenum) -{ - pr_err("DIMCB_OnFail: file - %s, line no. - %d\n", filename, linenum); -} - /** * startup_dim - initialize the dim2 interface * @pdev: platform device @@ -210,12 +200,11 @@ static int startup_dim(struct platform_device *pdev) } if (dev->clk_speed == -1) { - pr_info("Bad or missing clock speed parameter," - " using default value: 3072fs\n"); + pr_info("Bad or missing clock speed parameter, using default value: 3072fs\n"); dev->clk_speed = CLK_3072FS; - } else + } else { pr_info("Selected clock speed: %s\n", clock_speed); - + } if (pdata && pdata->init) { int ret = pdata->init(pdata, dev->io_base, dev->clk_speed); @@ -248,7 +237,7 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch) unsigned long flags; struct dim_ch_state_t st; - BUG_ON(hdm_ch == 0); + BUG_ON(!hdm_ch); BUG_ON(!hdm_ch->is_initialized); spin_lock_irqsave(&dim_lock, flags); @@ -289,7 +278,7 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch) */ static int deliver_netinfo_thread(void *data) { - struct dim2_hdm *dev = (struct dim2_hdm *)data; + struct dim2_hdm *dev = data; while (!kthread_should_stop()) { wait_event_interruptible(dev->netinfo_waitq, @@ -346,7 +335,7 @@ static void service_done_flag(struct dim2_hdm *dev, int ch_idx) unsigned long flags; u8 *data; - BUG_ON(hdm_ch == 0); + BUG_ON(!hdm_ch); BUG_ON(!hdm_ch->is_initialized); spin_lock_irqsave(&dim_lock, flags); @@ -369,8 +358,7 @@ static void service_done_flag(struct dim2_hdm *dev, int ch_idx) spin_lock_irqsave(&dim_lock, flags); if (list_empty(head)) { spin_unlock_irqrestore(&dim_lock, flags); - pr_crit("hard error: started_mbo list is empty " - "whereas DIM2 has sent buffers\n"); + pr_crit("hard error: started_mbo list is empty whereas DIM2 has sent buffers\n"); break; } @@ -397,7 +385,8 @@ static void service_done_flag(struct dim2_hdm *dev, int ch_idx) (u32)data[0] * 256 + data[1] + 2; mbo->processed_length = - min(data_size, (u32)mbo->buffer_length); + min_t(u32, data_size, + mbo->buffer_length); } else { mbo->processed_length = mbo->buffer_length; } @@ -410,7 +399,7 @@ static void service_done_flag(struct dim2_hdm *dev, int ch_idx) } static struct dim_channel **get_active_channels(struct dim2_hdm *dev, - struct dim_channel **buffer) + struct dim_channel **buffer) { int idx = 0; int ch_idx; @@ -419,7 +408,7 @@ static struct dim_channel **get_active_channels(struct dim2_hdm *dev, if (dev->hch[ch_idx].is_initialized) buffer[idx++] = &dev->hch[ch_idx].ch; } - buffer[idx++] = 0; + buffer[idx++] = NULL; return buffer; } @@ -441,7 +430,7 @@ static void dim2_tasklet_fn(unsigned long data) continue; spin_lock_irqsave(&dim_lock, flags); - DIM_ServiceChannel(&(dev->hch[ch_idx].ch)); + DIM_ServiceChannel(&dev->hch[ch_idx].ch); spin_unlock_irqrestore(&dim_lock, flags); service_done_flag(dev, ch_idx); @@ -460,7 +449,7 @@ static void dim2_tasklet_fn(unsigned long data) */ static irqreturn_t dim2_ahb_isr(int irq, void *_dev) { - struct dim2_hdm *dev = (struct dim2_hdm *)_dev; + struct dim2_hdm *dev = _dev; struct dim_channel *buffer[DMA_CHANNELS + 1]; unsigned long flags; @@ -557,7 +546,8 @@ static int configure_channel(struct most_interface *most_iface, int ch_idx, pr_warn("%s: fixed buffer size (%d -> %d)\n", hdm_ch->name, buf_size, new_size); spin_lock_irqsave(&dim_lock, flags); - hal_ret = DIM_InitControl(&hdm_ch->ch, is_tx, ch_addr, buf_size); + hal_ret = DIM_InitControl(&hdm_ch->ch, is_tx, ch_addr, + buf_size); break; case MOST_CH_ASYNC: new_size = DIM_NormCtrlAsyncBufferSize(buf_size); @@ -575,8 +565,8 @@ static int configure_channel(struct most_interface *most_iface, int ch_idx, case MOST_CH_ISOC_AVP: new_size = DIM_NormIsocBufferSize(buf_size, sub_size); if (new_size == 0) { - pr_err("%s: invalid sub-buffer size or " - "too small buffer size\n", hdm_ch->name); + pr_err("%s: invalid sub-buffer size or too small buffer size\n", + hdm_ch->name); return -EINVAL; } ccfg->buffer_size = new_size; @@ -589,8 +579,8 @@ static int configure_channel(struct most_interface *most_iface, int ch_idx, case MOST_CH_SYNC: new_size = DIM_NormSyncBufferSize(buf_size, sub_size); if (new_size == 0) { - pr_err("%s: invalid sub-buffer size or " - "too small buffer size\n", hdm_ch->name); + pr_err("%s: invalid sub-buffer size or too small buffer size\n", + hdm_ch->name); return -EINVAL; } ccfg->buffer_size = new_size; @@ -679,7 +669,7 @@ static void request_netinfo(struct most_interface *most_iface, int ch_idx) return; } - mbo = most_get_mbo(&dev->most_iface, dev->atx_idx); + mbo = most_get_mbo(&dev->most_iface, dev->atx_idx, NULL); if (!mbo) return; @@ -787,7 +777,8 @@ static int dim2_probe(struct platform_device *pdev) ret = request_irq(dev->irq_ahb0, dim2_ahb_isr, 0, "mlb_ahb0", dev); if (ret) { - pr_err("failed to request IRQ: %d, err: %d\n", dev->irq_ahb0, ret); + pr_err("failed to request IRQ: %d, err: %d\n", + dev->irq_ahb0, ret); goto err_unmap_io; } #endif @@ -915,7 +906,7 @@ static int dim2_remove(struct platform_device *pdev) * break link to local platform_device_id struct * to prevent crash by unload platform device module */ - pdev->id_entry = 0; + pdev->id_entry = NULL; return 0; } @@ -933,30 +924,10 @@ static struct platform_driver dim2_driver = { .id_table = dim2_id, .driver = { .name = "hdm_dim2", - .owner = THIS_MODULE, }, }; -/** - * dim2_hdm_init - Driver Registration Routine - */ -static int __init dim2_hdm_init(void) -{ - pr_info("dim2_hdm_init()\n"); - return platform_driver_register(&dim2_driver); -} - -/** - * dim2_hdm_exit - Driver Cleanup Routine - **/ -static void __exit dim2_hdm_exit(void) -{ - pr_info("dim2_hdm_exit()\n"); - platform_driver_unregister(&dim2_driver); -} - -module_init(dim2_hdm_init); -module_exit(dim2_hdm_exit); +module_platform_driver(dim2_driver); MODULE_AUTHOR("Jain Roy Ambi "); MODULE_AUTHOR("Andrey Shvetsov "); diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.h b/drivers/staging/most/hdm-dim2/dim2_hdm.h index 6e6883232..1c94e3355 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hdm.h +++ b/drivers/staging/most/hdm-dim2/dim2_hdm.h @@ -18,7 +18,8 @@ struct device; /* platform dependent data for dim2 interface */ struct dim2_platform_data { - int (*init)(struct dim2_platform_data *pd, void *io_base, int clk_speed); + int (*init)(struct dim2_platform_data *pd, void *io_base, + int clk_speed); void (*destroy)(struct dim2_platform_data *pd); void *priv; }; diff --git a/drivers/staging/most/hdm-dim2/dim2_sysfs.c b/drivers/staging/most/hdm-dim2/dim2_sysfs.c index 8e331a286..c5b10c7d2 100644 --- a/drivers/staging/most/hdm-dim2/dim2_sysfs.c +++ b/drivers/staging/most/hdm-dim2/dim2_sysfs.c @@ -21,7 +21,8 @@ struct bus_attr { struct attribute attr; ssize_t (*show)(struct medialb_bus *bus, char *buf); - ssize_t (*store)(struct medialb_bus *bus, const char *buf, size_t count); + ssize_t (*store)(struct medialb_bus *bus, const char *buf, + size_t count); }; static ssize_t state_show(struct medialb_bus *bus, char *buf) -- cgit v1.2.3-54-g00ecf