Commit 0808e84a authored by Alessandro Rubini's avatar Alessandro Rubini

HALF-WORKING: vcxo attribute: read works, write likely not

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent b8fb123f
......@@ -122,6 +122,38 @@ static struct fd_modlist mods[] = {
SUBSYS(zio),
};
/* We have an attribute specific to this card */
static ssize_t fd_show_vcxo(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct fmc_device *fmc = container_of(dev, struct fmc_device, dev);
struct fd_dev *fd = fmc->mezzanine_data;
/* FIXME: if WR-mode, return -1 as vcxo is driven by softpll */
return sprintf(buf, "%i\n", fd->current_vcxo_dac);
}
ssize_t fd_store_vcxo(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct fmc_device *fmc = container_of(dev, struct fmc_device, dev);
struct fd_dev *fd = fmc->mezzanine_data;
int vcxo;
char *rest;
/* checkpatck complains, but kstrtol only exists since 2.6.39 */
vcxo = simple_strtol(buf, &rest, 10);
if (rest && *rest)
return -EINVAL;
if (vcxo & ~0xffff)
return -EINVAL;
/* FIXME: if WR-mode, refuse writing the dac */
fd_spi_set_vcxo(fd, vcxo);
return count;
}
static DEVICE_ATTR(vcxo, 0644, fd_show_vcxo, fd_store_vcxo);
/* probe and remove are called by the FMC bus core */
int fd_probe(struct fmc_device *fmc)
{
......@@ -239,11 +271,14 @@ int fd_probe(struct fmc_device *fmc)
}
}
/* Finally, enable the input emgine */
/* Enable the input engine */
ret = fd_irq_init(fd);
if (ret < 0)
goto err;
/* Create our own attribute */
device_create_file(dev, &dev_attr_vcxo);
if (0) {
struct timespec ts1, ts2, ts3;
/* Temporarily, test the time stuff */
......@@ -280,6 +315,8 @@ int fd_remove(struct fmc_device *fmc)
if (!test_bit(FD_FLAG_INITED, &fd->flags)) /* FIXME: ditch this */
return 0; /* No init, no exit */
device_remove_file(&fmc->dev, &dev_attr_vcxo);
fd_irq_exit(fd);
while (--i >= 0) {
m = mods + i;
......
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