Commit 92b2ad31 authored by Federico Vaga's avatar Federico Vaga

style: checkpatch review

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent a8ed2205
This diff is collapsed.
......@@ -60,8 +60,8 @@ static int svec_reprogram(struct fmc_device *fmc, struct fmc_driver *drv,
return -ESRCH; /* the caller may accept this */
}
if(svec->verbose)
dev_info(fmc->hwdev, "reprogramming with %s\n", gw);
if (svec->verbose)
dev_info(fmc->hwdev, "reprogramming with %s\n", gw);
ret = request_firmware(&fw, gw, dev);
if (ret < 0) {
dev_warn(dev, "request firmware \"%s\": error %i\n", gw, ret);
......@@ -83,7 +83,7 @@ static int svec_reprogram(struct fmc_device *fmc, struct fmc_driver *drv,
fmc->flags |= FMC_DEVICE_HAS_CUSTOM;
out:
out:
release_firmware(fw);
if (ret < 0)
dev_err(dev, "svec reprogram failed while loading %s\n", gw);
......@@ -113,7 +113,7 @@ static int svec_write_ee(struct fmc_device *fmc, int pos,
{
if (!(fmc->flags & FMC_DEVICE_HAS_GOLDEN))
return -ENOTSUPP;
return svec_eeprom_write(fmc, pos, data, len);
}
......@@ -142,7 +142,8 @@ static int check_golden(struct fmc_device *fmc)
dev_err(svec->dev, "Bad SDB magic: 0x%08x\n", magic);
return -ENODEV;
}
if ((ret = fmc_scan_sdb_tree(fmc, 0x0)) < 0)
ret = fmc_scan_sdb_tree(fmc, 0x0);
if (ret < 0)
return -ENODEV;
vendor = fmc_readl(fmc, 0x5c);
......@@ -213,7 +214,7 @@ int svec_fmc_prepare(struct svec_dev *svec, unsigned int fmc_slot)
}
fmc->flags |= FMC_DEVICE_HAS_GOLDEN;
ret = svec_i2c_init(fmc);
if (ret) {
dev_err(svec->dev, "Error %d on svec i2c init", ret);
......@@ -222,10 +223,10 @@ int svec_fmc_prepare(struct svec_dev *svec, unsigned int fmc_slot)
}
svec->fmcs[fmc_slot] = fmc;
if(svec->verbose)
dev_info(svec->dev, "ready to create fmc device_id 0x%x\n",
fmc->device_id);
if (svec->verbose)
dev_info(svec->dev, "ready to create fmc device_id 0x%x\n",
fmc->device_id);
return ret;
}
......@@ -238,7 +239,6 @@ int svec_fmc_create(struct svec_dev *svec)
/* fmc structures filling */
for (i = 0; i < svec->fmcs_n; i++) {
error = svec_fmc_prepare(svec, i);
if (error)
goto failed;
}
......@@ -252,16 +252,14 @@ int svec_fmc_create(struct svec_dev *svec)
/* FIXME: how do we retrieve the actual number of registered
* devices?
*/
if(svec->verbose)
dev_info(svec->dev, "fmc devices registered\n");
if (svec->verbose)
dev_info(svec->dev, "fmc devices registered\n");
return 0;
failed:
failed:
for (i = 0; i < svec->fmcs_n; i++)
if (svec->fmcs[i])
kfree(svec->fmcs[i]);
kfree(svec->fmcs[i]);
/* FIXME: free fmc allocations. */
return error;
......@@ -280,7 +278,8 @@ void svec_fmc_destroy(struct svec_dev *svec)
svec->vic, svec->flags);
memset(svec->fmcs, 0, sizeof(struct fmc_devices *) * SVEC_N_SLOTS);
if(svec->verbose)
dev_info(svec->dev, "%d fmc devices unregistered\n", svec->fmcs_n);
if (svec->verbose)
dev_info(svec->dev, "%d fmc devices unregistered\n",
svec->fmcs_n);
}
......@@ -25,21 +25,30 @@ static int svec_irq_handler(void *data)
svec->irq_count++;
/* just in case we had an IRQ while messing around with the VIC registers/fmc_handlers */
/*
* just in case we had an IRQ while messing around with the
* VIC registers/fmc_handlers
*/
spin_lock_irqsave(&svec->irq_lock, flags);
if (svec->vic)
rv = svec_vic_irq_dispatch(svec);
else {
/* shared irq mode: call all handlers until one of them has dealt with the interrupt */
/*
* shared irq mode: call all handlers until one of them
* has dealt with the interrupt
*/
for (i = 0; i < SVEC_N_SLOTS; i++) {
irq_handler_t handler = svec->fmc_handlers[i];
/* Call all handlers even if the current one returned IRQ_HANDLED. The SVEC
VME Core IRQ is edge-sensitive, doing otherwise could result in missed irqs! */
if (handler)
/*
* Call all handlers even if the current one
* returned IRQ_HANDLED. The SVEC VME Core IRQ
* is edge-sensitive, doing otherwise could
* result in missed irqs!
*/
if (handler)
handler(i, svec->fmcs[i]);
}
}
......@@ -59,7 +68,10 @@ int svec_irq_request(struct fmc_device *fmc, irq_handler_t handler,
struct svec_dev *svec = (struct svec_dev *)fmc->carrier_data;
int rv = 0;
/* Depending on IRQF_SHARED flag, choose between a VIC and shared IRQ mode */
/*
* Depending on IRQF_SHARED flag, choose between a VIC and
* shared IRQ mode
*/
if (!flags)
rv = svec_vic_irq_request(svec, fmc, fmc->irq, handler);
else if (flags & IRQF_SHARED) {
......@@ -69,7 +81,10 @@ int svec_irq_request(struct fmc_device *fmc, irq_handler_t handler,
} else
return -EINVAL;
/* register the master VME handler the first time somebody requests an interrupt */
/*
* register the master VME handler the first time somebody
* requests an interrupt
*/
if (!rv && !test_bit(SVEC_FLAG_IRQS_REQUESTED, &svec->flags)) {
rv = vme_request_irq(svec->cfg_cur.interrupt_vector,
......@@ -87,6 +102,7 @@ int svec_irq_request(struct fmc_device *fmc, irq_handler_t handler,
void svec_irq_ack(struct fmc_device *fmc)
{
struct svec_dev *svec = (struct svec_dev *)fmc->carrier_data;
if (svec->vic)
svec_vic_irq_ack(svec, fmc->irq);
}
......@@ -108,7 +124,10 @@ int svec_irq_free(struct fmc_device *fmc)
spin_unlock(&svec->irq_lock);
}
/* shared IRQ mode: disable VME interrupt when freeing last FMC handler */
/*
* shared IRQ mode: disable VME interrupt when freeing last
* FMC handler
*/
if (!svec->vic && !svec->fmc_handlers[0] && !svec->fmc_handlers[1]) {
rv = vme_free_irq(svec->current_vector);
if (rv < 0)
......
......@@ -29,48 +29,49 @@
#define FW_CMD_RESET 0
#define FW_CMD_PROGRAM 1
static int svec_fw_cmd_reset (struct svec_dev * card)
static int svec_fw_cmd_reset(struct svec_dev *card)
{
int err = 0;
if (test_bit (SVEC_FLAG_FMCS_REGISTERED, &card->flags))
svec_fmc_destroy (card);
if (test_bit(SVEC_FLAG_FMCS_REGISTERED, &card->flags))
svec_fmc_destroy(card);
if (!card->map[MAP_CR_CSR])
err = svec_map_window (card, MAP_CR_CSR);
err = svec_map_window(card, MAP_CR_CSR);
if(err < 0)
if (err < 0)
return err;
svec_bootloader_unlock (card);
svec_bootloader_unlock(card);
if (!svec_is_bootloader_active (card))
if (!svec_is_bootloader_active(card))
return -ENODEV;
if (card->fw_buffer)
kfree (card->fw_buffer);
kfree(card->fw_buffer);
card->fw_buffer = vmalloc (SVEC_MAX_GATEWARE_SIZE);
card->fw_buffer = vmalloc(SVEC_MAX_GATEWARE_SIZE);
card->fw_length = 0;
card->fw_hash = 0xffffffff;
return 0;
}
static int svec_fw_cmd_program (struct svec_dev * card)
static int svec_fw_cmd_program(struct svec_dev *card)
{
int err;
if (!card->fw_buffer || !card->fw_length)
return -EINVAL;
return -EINVAL;
err = svec_load_fpga (card, card->fw_buffer, card->fw_length);
vfree (card->fw_buffer);
err = svec_load_fpga(card, card->fw_buffer, card->fw_length);
vfree(card->fw_buffer);
card->fw_buffer = NULL;
card->fw_length = 0;
if (err < 0)
return err;
svec_reconfigure (card);
svec_reconfigure(card);
return 0;
}
......@@ -110,19 +111,17 @@ ATTR_STORE_CALLBACK(firmware_name)
ATTR_STORE_CALLBACK(firmware_cmd)
{
int cmd;
struct svec_dev *card = dev_get_drvdata(pdev);
if (sscanf(buf, "%i", &cmd) != 1)
return -EINVAL;
switch(cmd)
{
case FW_CMD_RESET:
return svec_fw_cmd_reset (card);
case FW_CMD_PROGRAM:
return svec_fw_cmd_program (card);
default:
switch (cmd) {
case FW_CMD_RESET:
return svec_fw_cmd_reset(card);
case FW_CMD_PROGRAM:
return svec_fw_cmd_program(card);
default:
return -EINVAL;
}
......@@ -134,16 +133,15 @@ ATTR_STORE_CALLBACK(firmware_blob)
struct svec_dev *card = dev_get_drvdata(pdev);
if (!card->fw_buffer)
return -EAGAIN;
return -EAGAIN;
if (card->fw_length + count - 1 >= SVEC_MAX_GATEWARE_SIZE)
return -EINVAL;
return -EINVAL;
memcpy (card->fw_buffer + card->fw_length, buf, count);
memcpy(card->fw_buffer + card->fw_length, buf, count);
card->fw_length += count;
return count;
}
ATTR_SHOW_CALLBACK(dummy_attr)
......@@ -154,6 +152,7 @@ ATTR_SHOW_CALLBACK(dummy_attr)
ATTR_SHOW_CALLBACK(interrupt_vector)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "0x%x\n",
card->cfg_cur.interrupt_vector);
}
......@@ -161,13 +160,13 @@ ATTR_SHOW_CALLBACK(interrupt_vector)
ATTR_SHOW_CALLBACK(interrupt_level)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "%d\n", card->cfg_cur.interrupt_level);
}
ATTR_STORE_CALLBACK(interrupt_level)
{
int lvl;
struct svec_dev *card = dev_get_drvdata(pdev);
if (sscanf(buf, "%i", &lvl) != 1)
......@@ -182,7 +181,6 @@ ATTR_STORE_CALLBACK(interrupt_level)
ATTR_STORE_CALLBACK(interrupt_vector)
{
int vec;
struct svec_dev *card = dev_get_drvdata(pdev);
if (sscanf(buf, "%i", &vec) != 1)
......@@ -197,13 +195,13 @@ ATTR_STORE_CALLBACK(interrupt_vector)
ATTR_SHOW_CALLBACK(vme_am)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "0x%x\n", card->cfg_cur.vme_am);
}
ATTR_STORE_CALLBACK(vme_am)
{
int am;
struct svec_dev *card = dev_get_drvdata(pdev);
if (sscanf(buf, "%i", &am) != 1)
......@@ -216,6 +214,7 @@ ATTR_STORE_CALLBACK(vme_am)
ATTR_SHOW_CALLBACK(vme_base)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "0x%x\n", card->cfg_cur.vme_base);
}
......@@ -235,6 +234,7 @@ ATTR_STORE_CALLBACK(vme_base)
ATTR_SHOW_CALLBACK(vme_size)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "0x%x\n", card->cfg_cur.vme_size);
}
......@@ -254,6 +254,7 @@ ATTR_STORE_CALLBACK(vme_size)
ATTR_SHOW_CALLBACK(vme_addr)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "0x%x\n", card->vme_raw_addr);
}
......@@ -298,13 +299,13 @@ static int __next_token(char **str, char *buf, int buf_length)
char *p = *str, *tok;
int len;
while(isspace (*p))
while (isspace(*p))
p++;
if(*p == 0)
if (*p == 0)
return 0;
tok = p;
while(*p && !isspace(*p))
while (*p && !isspace(*p))
p++;
len = min(p - tok + 1, buf_length - 1);
......@@ -321,12 +322,11 @@ ATTR_STORE_CALLBACK(vme_data)
uint32_t data;
uint32_t addr = card->vme_raw_addr;
char *args = (char *) buf, token[16];
if (!card->cfg_cur.configured)
return -EAGAIN;
while (__next_token (&args, token, sizeof(token)))
{
while (__next_token(&args, token, sizeof(token))) {
if (sscanf(token, "%i", &data) != 1)
return -EINVAL;
......@@ -340,6 +340,7 @@ ATTR_STORE_CALLBACK(vme_data)
ATTR_SHOW_CALLBACK(use_vic)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "%d", card->cfg_cur.use_vic);
}
......@@ -363,13 +364,13 @@ ATTR_STORE_CALLBACK(use_vic)
ATTR_SHOW_CALLBACK(use_fmc)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "%d\n", card->cfg_cur.use_fmc);
}
ATTR_STORE_CALLBACK(use_fmc)
{
int enabled;
struct svec_dev *card = dev_get_drvdata(pdev);
if (sscanf(buf, "%i", &enabled) != 1)
......@@ -385,6 +386,7 @@ ATTR_STORE_CALLBACK(use_fmc)
ATTR_SHOW_CALLBACK(configured)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "%d\n", card->cfg_cur.configured);
}
......@@ -409,6 +411,7 @@ ATTR_STORE_CALLBACK(configured)
ATTR_SHOW_CALLBACK(slot)
{
struct svec_dev *card = dev_get_drvdata(pdev);
return snprintf(buf, PAGE_SIZE, "%d\n", card->slot);
}
......@@ -428,8 +431,8 @@ static DEVICE_ATTR(firmware_blob,
the userspace tools. */
static DEVICE_ATTR(slot, S_IRUGO, svec_show_slot, NULL);
/* Standard VME configuration attributes. Committed in atomic way by writing 1 to
1 to 'configured' attribute. */
/* Standard VME configuration attributes. Committed in atomic way by
writing 1 to 1 to 'configured' attribute. */
static DEVICE_ATTR(interrupt_vector,
S_IWUSR | S_IRUGO,
svec_show_interrupt_vector, svec_store_interrupt_vector);
......@@ -448,20 +451,22 @@ static DEVICE_ATTR(vme_am,
S_IWUSR | S_IRUGO, svec_show_vme_am, svec_store_vme_am);
/*
Enables support for the Vectored Interrupt Controller (VIC).
Enables support for the Vectored Interrupt Controller (VIC).
By default, the VIC is enabled and enumerated through SDB the first
time the FMC driver requests an interrupt. If no VIC is found, the driver
falls back to shared IRQ mode. This attribute is only to be used in exceptional
situations, where even attempting to look for the VIC may screw the card. */
falls back to shared IRQ mode. This attribute is only to be used in
exceptional situations, where even attempting to look for the VIC may
screw the card.
*/
static DEVICE_ATTR(use_vic,
S_IWUSR | S_IRUGO, svec_show_use_vic, svec_store_use_vic);
/*
Enables registration of the FMCs after checking their FRU information.
Enabled by default, you may want to disable it for debugging purposes (programming
EEPROMs and/or raw VME access)
*/
* Enables registration of the FMCs after checking their FRU information.
* Enabled by default, you may want to disable it for debugging purposes
* (programming EEPROMs and/or raw VME access)
*/
static DEVICE_ATTR(use_fmc,
S_IWUSR | S_IRUGO, svec_show_use_fmc, svec_store_use_fmc);
......
......@@ -5,7 +5,7 @@
* Released according to the GNU GPL, version 2 or any later version
*
* Driver for SVEC (Simple VME FMC carrier) board.
* VIC (Vectored Interrupt Controller) support code.
* VIC (Vectored Interrupt Controller) support code.
*/
#include <linux/interrupt.h>
......@@ -62,10 +62,10 @@ static int svec_vic_init(struct svec_dev *svec, struct fmc_device *fmc)
signed long vic_base;
struct vic_irq_controller *vic;
/* Try to look up the VIC in the SDB tree - note that IRQs shall be requested after the
FMC driver has scanned the SDB tree */
vic_base =
fmc_find_sdb_device(fmc->sdb, VIC_SDB_VENDOR, VIC_SDB_DEVICE, NULL);
/* Try to look up the VIC in the SDB tree - note that IRQs shall
be requested after the FMC driver has scanned the SDB tree */
vic_base = fmc_find_sdb_device(fmc->sdb, VIC_SDB_VENDOR,
VIC_SDB_DEVICE, NULL);
if (vic_base < 0) {
dev_err(svec->dev,
......@@ -73,8 +73,8 @@ static int svec_vic_init(struct svec_dev *svec, struct fmc_device *fmc)
return -ENODEV;
}
if(svec->verbose)
dev_info(svec->dev, "Found VIC @ 0x%lx\n", vic_base);
if (svec->verbose)
dev_info(svec->dev, "Found VIC @ 0x%lx\n", vic_base);
vic = kzalloc(sizeof(struct vic_irq_controller), GFP_KERNEL);
if (!vic)
......@@ -87,13 +87,15 @@ static int svec_vic_init(struct svec_dev *svec, struct fmc_device *fmc)
/* disable all IRQs, copy the vector table with pre-defined IRQ ids */
vic_writel(vic, 0xffffffff, VIC_REG_IDR);
for (i = 0; i < VIC_MAX_VECTORS; i++)
vic->vectors[i].saved_id =
vic_readl(vic, VIC_IVT_RAM_BASE + 4 * i);
vic->vectors[i].saved_id = vic_readl(vic,
VIC_IVT_RAM_BASE + 4 * i);
/* configure the VIC output: active high, edge sensitive, pulse width = 1 tick (16 ns) */
/* configure the VIC output:
active high, edge sensitive, pulse width = 1 tick (16 ns),
160 us IRQ retry timer */
vic_writel(vic,
VIC_CTL_ENABLE | VIC_CTL_POL | VIC_CTL_EMU_EDGE |
VIC_CTL_EMU_LEN_W(40000), VIC_REG_CTL); /* 160 us IRQ retry timer */
VIC_CTL_EMU_LEN_W(40000), VIC_REG_CTL);
vic->initialized = 1;
svec->vic = vic;
......@@ -112,15 +114,15 @@ void svec_vic_exit(struct vic_irq_controller *vic)
kfree(vic);
}
irqreturn_t svec_vic_irq_dispatch(struct svec_dev * svec)
irqreturn_t svec_vic_irq_dispatch(struct svec_dev *svec)
{
struct vic_irq_controller *vic = svec->vic;
int index, rv;
struct vector *vec;
do {
/* Our parent IRQ handler: read the index value from the Vector Address Register,
and find matching handler */
/* Our parent IRQ handler: read the index value from
the Vector Address Register, and find matching handler */
index = vic_readl(vic, VIC_REG_VAR) & 0xff;
if (index >= VIC_MAX_VECTORS)
......@@ -131,18 +133,18 @@ irqreturn_t svec_vic_irq_dispatch(struct svec_dev * svec)
goto fail;
rv = vec->handler(vec->saved_id, vec->requestor);
vic_writel(vic, 0, VIC_REG_EOIR); /* ack the irq */
if(rv < 0)
break;
if (rv < 0)
break;
/* check if any IRQ is still pending */
} while (vic_readl(vic, VIC_REG_RISR));
return rv;
fail:
fail:
return 0;
}
......@@ -162,7 +164,8 @@ int svec_vic_irq_request(struct svec_dev *svec, struct fmc_device *fmc,
vic = svec->vic;
for (i = 0; i < VIC_MAX_VECTORS; i++) {
/* find the vector in the stored table, assign handler and enable the line if exists */
/* find the vector in the stored table, assign handler
and enable the line if exists */
if (vic->vectors[i].saved_id == id) {
spin_lock(&svec->vic->vec_lock);
......@@ -173,7 +176,6 @@ int svec_vic_irq_request(struct svec_dev *svec, struct fmc_device *fmc,
spin_unlock(&svec->vic->vec_lock);
return 0;
}
}
......@@ -188,12 +190,12 @@ int svec_vic_irq_request(struct svec_dev *svec, struct fmc_device *fmc,
*/
static inline int vic_handler_count(struct vic_irq_controller *vic)
{
int i, count;
int i, count;
for (i = 0, count = 0; i < VIC_MAX_VECTORS; ++i)
if (vic->vectors[i].handler)
count++;
return count;
for (i = 0, count = 0; i < VIC_MAX_VECTORS; ++i)
if (vic->vectors[i].handler)
count++;
return count;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment