Skip to content
Snippets Groups Projects
Commit 7f442491 authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

reprogram is complete and cast in stone

parent 86c0d5f7
Branches
Tags
No related merge requests found
......@@ -5,9 +5,6 @@
#include <linux/fmc.h>
#include "spec.h"
static char *t_filename;
module_param_named(file, t_filename, charp, 0444);
static struct fmc_driver t_drv; /* initialized later */
irqreturn_t t_handler(int irq, void *dev_id)
......@@ -32,8 +29,10 @@ int t_probe(struct fmc_device *fmc)
if (ret < 0)
return ret;
/* Reprogram, but only if specified in the arguments */
ret = fmc->op->reprogram(fmc, "");
/* Reprogram, if asked to. ESRCH == no filename specified */
ret = fmc->op->reprogram(fmc, &t_drv,"");
if (ret == -ESRCH)
ret = 0;
if (ret < 0)
fmc->op->irq_free(fmc);
......@@ -54,7 +53,9 @@ static struct fmc_driver t_drv = {
/* no table, as the current match just matches everything */
};
FMC_MODULE_PARAMS(t_drv); /* We accept the generic parameters */
/* We accept the generic parameters */
FMC_PARAM_BUSID(t_drv);
FMC_PARAM_GATEWARE(t_drv);
static int t_init(void)
{
......
......@@ -40,16 +40,17 @@ struct fmc_driver {
#define to_fmc_driver(x) container_of((x), struct fmc_driver, driver)
/* These are the generic parameters, that drivers may instantiate */
#define FMC_MODULE_PARAMS(_d) \
module_param_array_named(busid, _d.busid_val, int, &_d.busid_n, 0400); \
module_param_array_named(gateware, _d.gw_val, charp, &_d.gw_n, 0400)
#define FMC_PARAM_BUSID(_d) \
module_param_array_named(busid, _d.busid_val, int, &_d.busid_n, 0444)
#define FMC_PARAM_GATEWARE(_d) \
module_param_array_named(gateware, _d.gw_val, charp, &_d.gw_n, 0444)
/* To be carrier-independent, we need to abstract hardware access */
struct fmc_operations {
uint32_t (*readl)(struct fmc_device *fmc, int offset);
void (*writel)(struct fmc_device *fmc, uint32_t value, int offset);
int (*validate)(struct fmc_device *fmc, struct fmc_driver *drv);
int (*reprogram)(struct fmc_device *fmc, char *gateware);
int (*reprogram)(struct fmc_device *f, struct fmc_driver *d, char *gw);
int (*irq_request)(struct fmc_device *fmc, irq_handler_t h,
char *name, int flags);
void (*irq_ack)(struct fmc_device *fmc);
......
......@@ -34,7 +34,8 @@ static int spec_validate(struct fmc_device *fmc, struct fmc_driver *drv)
return -ENOENT;
}
static int spec_reprogram(struct fmc_device *fmc, char *gw)
static int spec_reprogram(struct fmc_device *fmc, struct fmc_driver *drv,
char *gw)
{
const struct firmware *fw;
struct spec_dev *spec = fmc->carrier_data;
......@@ -44,11 +45,17 @@ static int spec_reprogram(struct fmc_device *fmc, char *gw)
if (!gw)
gw = spec_fw_name;
if (!strlen(gw)) {
/* FIXME: use module parameters */
return 0;
if (!strlen(gw)) { /* use module parameters from the driver */
int index;
index = spec_validate(fmc, drv);
gw = drv->gw_val[index];
if (!gw)
return -ESRCH; /* the caller may accept this */
}
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);
......
......@@ -15,6 +15,8 @@
#include "wr-nic.h"
#include "spec.h"
static struct fmc_driver wrn_drv;
static char *wrn_filename = WRN_GATEWARE_DEFAULT_NAME;
module_param_named(file, wrn_filename, charp, 0444);
......@@ -40,7 +42,7 @@ int wrn_probe(struct fmc_device *fmc)
fmc_set_drvdata(fmc, dd);
/* We first write a new binary (and lm32) within the spec */
ret = fmc->op->reprogram(fmc, WRN_GATEWARE_DEFAULT_NAME);
ret = fmc->op->reprogram(fmc, &wrn_drv, WRN_GATEWARE_DEFAULT_NAME);
if (ret <0) {
dev_err(dev, "write firmware \"%s\": error %i\n",
wrn_filename, ret);
......
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