Commit 678decfe authored by James Bottomley's avatar James Bottomley Committed by Linus Torvalds

[PATCH] more SPI transport attribute updates

This does three things

- Fix the signedness of the bit attributes (otherwise they show up as -1
when on, not 1)
- Make the period adjust to the closest value rather than ignoring
values it doesn't understand.
- Add a visibility field to attributes, so drivers can get rid of
attributes they're never going to care about
parent 47b243df
......@@ -207,36 +207,23 @@ store_spi_transport_period(struct class_device *cdev, const char *buf,
int val = simple_strtoul(buf, NULL, 0);
if(val >= (SPI_STATIC_PPR + 1)*4)
/* Should probably check limits here, but this
* gets reasonably close to OK for most things */
period = val/4;
}
if(period == -1 || period > 0xff)
return -EINVAL;
if(period > 0xff)
period = 0xff;
i->f->set_period(sdev, period);
return count;
}
static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR,
show_spi_transport_period,
store_spi_transport_period);
struct scsi_transport_template spi_transport_template = {
.class = &spi_transport_class,
.setup = &spi_setup_transport_attrs,
.cleanup = NULL,
.size = sizeof(struct spi_transport_attrs) - sizeof(unsigned long),
};
#define SETUP_ATTRIBUTE(field) \
i->private_attrs[count] = class_device_attr_##field; \
if(!i->f->set_##field) { \
......@@ -244,6 +231,7 @@ struct scsi_transport_template spi_transport_template = {
i->private_attrs[count].store = NULL; \
} \
i->attrs[count] = &i->private_attrs[count]; \
if(i->f->show_##field) \
count++
struct scsi_transport_template *
......@@ -277,7 +265,7 @@ spi_attach_transport(struct spi_function_template *ft)
/* if you add an attribute but forget to increase SPI_NUM_ATTRS
* this bug will trigger */
BUG_ON(count != SPI_NUM_ATTRS);
BUG_ON(count > SPI_NUM_ATTRS);
i->attrs[count] = NULL;
......
......@@ -27,14 +27,14 @@ struct scsi_transport_template;
struct spi_transport_attrs {
int period; /* value in the PPR/SDTR command */
int offset;
int width:1; /* 0 - narrow, 1 - wide */
int iu:1; /* Information Units enabled */
int dt:1; /* DT clocking enabled */
int qas:1; /* Quick Arbitration and Selection enabled */
int wr_flow:1; /* Write Flow control enabled */
int rd_strm:1; /* Read streaming enabled */
int rti:1; /* Retain Training Information */
int pcomp_en:1; /* Precompensation enabled */
unsigned int width:1; /* 0 - narrow, 1 - wide */
unsigned int iu:1; /* Information Units enabled */
unsigned int dt:1; /* DT clocking enabled */
unsigned int qas:1; /* Quick Arbitration and Selection enabled */
unsigned int wr_flow:1; /* Write Flow control enabled */
unsigned int rd_strm:1; /* Read streaming enabled */
unsigned int rti:1; /* Retain Training Information */
unsigned int pcomp_en:1;/* Precompensation enabled */
};
/* accessor functions */
......@@ -71,6 +71,20 @@ struct spi_function_template {
void (*set_rti)(struct scsi_device *, int);
void (*get_pcomp_en)(struct scsi_device *);
void (*set_pcomp_en)(struct scsi_device *, int);
/* The driver sets these to tell the transport class it
* wants the attributes displayed in sysfs. If the show_ flag
* is not set, the attribute will be private to the transport
* class */
unsigned long show_period:1;
unsigned long show_offset:1;
unsigned long show_width:1;
unsigned long show_iu:1;
unsigned long show_dt:1;
unsigned long show_qas:1;
unsigned long show_wr_flow:1;
unsigned long show_rd_strm:1;
unsigned long show_rti:1;
unsigned long show_pcomp_en:1;
};
struct scsi_transport_template *spi_attach_transport(struct spi_function_template *);
......
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