}
if(period == -1) {
- int val = simple_strtoul(buf, NULL, 0);
+ int val = simple_strtoul(buf, NULL, 0);
-
- if(val >= (SPI_STATIC_PPR + 1)*4)
- period = val/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) { \
i->private_attrs[count].store = NULL; \
} \
i->attrs[count] = &i->private_attrs[count]; \
- count++
+ if(i->f->show_##field) \
+ count++
struct scsi_transport_template *
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;
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 */
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 *);