Commit 8066e9a8 authored by Patrick Mochel's avatar Patrick Mochel

sysfs: Fixup s390 sysfs files.

- Remove count and off parameters from show() methods.
- Remove off parameter from store() methods.

Note 1: These have not been tested, but should be obviously correct.

Note 2: snprintf() was replaced with sprintf() where the filled buffer 
would obviously be < PAGE_SIZE. (like when printing single integer values).
In places where strings were printed, PAGE_SIZE is used as the max string
size.
parent 3f47b64a
......@@ -1949,28 +1949,22 @@ dasd_generic_set_offline (struct ccw_device *cdev)
* readonly controls the readonly status of a dasd
*/
static ssize_t
dasd_ro_show(struct device *dev, char *buf, size_t count, loff_t off)
dasd_ro_show(struct device *dev, char *buf)
{
dasd_device_t *device;
if (off)
return 0;
device = dev->driver_data;
if (!device)
return snprintf(buf, count, "n/a\n");
return snprintf(buf, PAGE_SIZE, "n/a\n");
return snprintf(buf, count, device->ro_flag ? "1\n" : "0\n");
return snprintf(buf, PAGE_SIZE, device->ro_flag ? "1\n" : "0\n");
}
static ssize_t
dasd_ro_store(struct device *dev, const char *buf, size_t count, loff_t off)
dasd_ro_store(struct device *dev, const char *buf, size_t count)
{
dasd_device_t *device = dev->driver_data;
if (off)
return 0;
if (device)
device->ro_flag = (buf[0] == '1') ? 1 : 0;
return count;
......@@ -1984,29 +1978,22 @@ static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
*/
/* TODO: Implement */
static ssize_t
dasd_use_diag_show(struct device *dev, char *buf, size_t count, loff_t off)
dasd_use_diag_show(struct device *dev, char *buf)
{
dasd_device_t *device;
if (off)
return 0;
device = dev->driver_data;
if (!device)
return snprintf(buf, count, "n/a\n");
return sprintf(buf, "n/a\n");
return snprintf(buf, count, device->use_diag_flag ? "1\n" : "0\n");
return sprintf(buf, device->use_diag_flag ? "1\n" : "0\n");
}
static ssize_t
dasd_use_diag_store(struct device *dev, const char *buf,
size_t count, loff_t off)
dasd_use_diag_store(struct device *dev, const char *buf, size_t count)
{
dasd_device_t *device = dev->driver_data;
if (off)
return 0;
if (device)
device->use_diag_flag = (buf[0] == '1') ? 1 : 0;
return count;
......@@ -2020,43 +2007,38 @@ DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
* an inaccaptable interface */
/* TODO: Split this up into smaller files! */
static ssize_t
dasd_devices_show(struct device *dev, char *buf, size_t count, loff_t off)
dasd_devices_show(struct device *dev, char *buf)
{
dasd_device_t *device;
dasd_devmap_t *devmap;
if (off) /* ignore partial write */
return 0;
devmap = NULL;
device = dev->driver_data;
if (device)
devmap = dasd_devmap_from_devno(device->devno);
if (!devmap)
return snprintf(buf, count, "unused\n");
return sprintf(buf, "unused\n");
return min ((size_t) dasd_devices_print(devmap, buf), count);
return min ((size_t) dasd_devices_print(devmap, buf), PAGE_SIZE);
}
static DEVICE_ATTR(dasd, 0444, dasd_devices_show, 0);
#endif
static ssize_t
dasd_discipline_show(struct device *dev, char *buf, size_t count, loff_t off)
dasd_discipline_show(struct device *dev, char *buf)
{
dasd_device_t *device;
if (off)
return 0;
device = dev->driver_data;
if (!device || !device->discipline)
return snprintf(buf, count, "none\n");
return snprintf(buf, count, "%s\n", device->discipline->name);
return sprintf(buf, "none\n");
return snprintf(buf, PAGE_SIZE, "%s\n", device->discipline->name);
}
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, 0);
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
static int
dasd_add_sysfs_files(struct ccw_device *cdev)
......
......@@ -185,15 +185,11 @@ ccwgroup_set_offline(struct ccwgroup_device *gdev)
}
static ssize_t
ccwgroup_online_store (struct device *dev, const char *buf, size_t count,
loff_t off)
ccwgroup_online_store (struct device *dev, const char *buf, size_t count)
{
struct ccwgroup_device *gdev;
unsigned int value;
if (off)
return 0;
gdev = to_ccwgroupdev(dev);
if (!dev->driver)
return count;
......@@ -209,16 +205,13 @@ ccwgroup_online_store (struct device *dev, const char *buf, size_t count,
}
static ssize_t
ccwgroup_online_show (struct device *dev, char *buf, size_t count, loff_t off)
ccwgroup_online_show (struct device *dev, char *buf)
{
int online;
if (off)
return 0;
online = (to_ccwgroupdev(dev)->state == CCWGROUP_ONLINE);
return snprintf(buf, count, online ? "1\n" : "0\n");
return sprintf(buf, online ? "1\n" : "0\n");
}
static DEVICE_ATTR(online, 0644, ccwgroup_online_show, ccwgroup_online_store);
......
......@@ -606,30 +606,30 @@ s390_vary_chpid( __u8 chpid, int on)
* Files for the channel path entries.
*/
static ssize_t
chp_status_show(struct device *dev, char *buf, size_t count, loff_t off)
chp_status_show(struct device *dev, char *buf)
{
struct sys_device *sdev = container_of(dev, struct sys_device, dev);
struct channel_path *chp = container_of(sdev, struct channel_path, sdev);
if (!chp)
return off ? 0 : count;
return 0;
switch(chp->state) {
case CHP_OFFLINE:
return off ? 0 : snprintf(buf, count, "n/a\n");
return snprintf(buf, count, "n/a\n");
case CHP_LOGICALLY_OFFLINE:
return off ? 0 : snprintf(buf, count, "logically offline\n");
return snprintf(buf, count, "logically offline\n");
case CHP_STANDBY:
return off ? 0 : snprintf(buf, count, "n/a\n");
return snprintf(buf, count, "n/a\n");
case CHP_ONLINE:
return off ? 0 : snprintf(buf, count, "online\n");
return snprintf(buf, count, "online\n");
default:
return off ? 0 : count;
return 0;
}
}
static ssize_t
chp_status_write(struct device *dev, const char *buf, size_t count, loff_t off)
chp_status_write(struct device *dev, const char *buf, size_t count)
{
struct sys_device *sdev = container_of(dev, struct sys_device, dev);
struct channel_path *cp = container_of(sdev, struct channel_path, sdev);
......@@ -637,9 +637,6 @@ chp_status_write(struct device *dev, const char *buf, size_t count, loff_t off)
int num_args;
int error;
if (off)
return 0;
num_args = sscanf(buf, "%5s", cmd);
if (!num_args)
return count;
......
......@@ -157,7 +157,7 @@ module_exit(cleanup_ccw_bus_type);
* TODO: Split chpids and pimpampom up? Where is "in use" in the tree?
*/
static ssize_t
chpids_show (struct device * dev, char * buf, size_t count, loff_t off)
chpids_show (struct device * dev, char * buf)
{
struct subchannel *sch = to_subchannel(dev);
struct ssd_info *ssd = &sch->ssd_info;
......@@ -168,48 +168,48 @@ chpids_show (struct device * dev, char * buf, size_t count, loff_t off)
ret += sprintf (buf+ret, "%02x ", ssd->chpid[chp]);
ret += sprintf (buf+ret, "\n");
return off ? 0 : min((ssize_t)count, ret);
return min((ssize_t)PAGE_SIZE, ret);
}
static ssize_t
pimpampom_show (struct device * dev, char * buf, size_t count, loff_t off)
pimpampom_show (struct device * dev, char * buf)
{
struct subchannel *sch = to_subchannel(dev);
struct pmcw *pmcw = &sch->schib.pmcw;
return off ? 0 : snprintf (buf, count, "%02x %02x %02x\n",
pmcw->pim, pmcw->pam, pmcw->pom);
return sprintf (buf, "%02x %02x %02x\n",
pmcw->pim, pmcw->pam, pmcw->pom);
}
static ssize_t
devtype_show (struct device *dev, char *buf, size_t count, loff_t off)
devtype_show (struct device *dev, char *buf)
{
struct ccw_device *cdev = to_ccwdev(dev);
struct ccw_device_id *id = &(cdev->id);
if (id->dev_type != 0)
return off ? 0 : snprintf(buf, count, "%04x/%02x\n",
id->dev_type, id->dev_model);
return sprintf(buf, "%04x/%02x\n",
id->dev_type, id->dev_model);
else
return off ? 0 : snprintf(buf, count, "n/a\n");
return sprintf(buf, "n/a\n");
}
static ssize_t
cutype_show (struct device *dev, char *buf, size_t count, loff_t off)
cutype_show (struct device *dev, char *buf)
{
struct ccw_device *cdev = to_ccwdev(dev);
struct ccw_device_id *id = &(cdev->id);
return off ? 0 : snprintf(buf, count, "%04x/%02x\n",
id->cu_type, id->cu_model);
return sprintf(buf, "%04x/%02x\n",
id->cu_type, id->cu_model);
}
static ssize_t
online_show (struct device *dev, char *buf, size_t count, loff_t off)
online_show (struct device *dev, char *buf)
{
struct ccw_device *cdev = to_ccwdev(dev);
return off ? 0 : snprintf(buf, count, cdev->online ? "yes\n" : "no\n");
return sprintf(buf, cdev->online ? "yes\n" : "no\n");
}
void
......@@ -256,14 +256,11 @@ ccw_device_set_online(struct ccw_device *cdev)
}
static ssize_t
online_store (struct device *dev, const char *buf, size_t count, loff_t off)
online_store (struct device *dev, const char *buf, size_t count)
{
struct ccw_device *cdev = to_ccwdev(dev);
unsigned int value;
if (off)
return 0;
if (!cdev->drv)
return count;
......
......@@ -2512,27 +2512,24 @@ ctc_stats(struct net_device * dev)
#define CTRL_BUFSIZE 40
static ssize_t
buffer_show(struct device *dev, char *buf, size_t count, loff_t off)
buffer_show(struct device *dev, char *buf)
{
struct ctc_priv *priv;
priv = dev->driver_data;
if (!priv)
return -ENODEV;
return off ? 0 : snprintf(buf, count, "%d\n",
priv->channel[READ]->max_bufsize);
return sprintf(buf, "%d\n",
priv->channel[READ]->max_bufsize);
}
static ssize_t
buffer_write(struct device *dev, const char *buf, size_t count, loff_t off)
buffer_write(struct device *dev, const char *buf, size_t count)
{
struct ctc_priv *priv;
struct net_device *ndev;
int bs1;
if (off)
return 0;
priv = dev->driver_data;
if (!priv)
return -ENODEV;
......
......@@ -1637,32 +1637,30 @@ lcs_open_device(struct net_device *dev)
* show function for portno called by cat or similar things
*/
static ssize_t
lcs_portno_show (struct device *dev, char *buf, size_t count,
loff_t off)
lcs_portno_show (struct device *dev, char *buf)
{
struct lcs_card *card;
card = (struct lcs_card *)dev->driver_data;
if (off || !card)
if (!card)
return 0;
return snprintf(buf, count, "%d\n", card->portno);
return sprintf(buf, "%d\n", card->portno);
}
/**
* store the value which is piped to file portno
*/
static ssize_t
lcs_portno_store (struct device *dev, const char *buf, size_t count,
loff_t off)
lcs_portno_store (struct device *dev, const char *buf, size_t count)
{
struct lcs_card *card;
int value;
card = (struct lcs_card *)dev->driver_data;
if (off || !card)
if (!card)
return 0;
sscanf(buf, "%u", &value);
......
......@@ -1259,16 +1259,16 @@ netiucv_change_mtu (net_device * dev, int new_mtu)
#define CTRL_BUFSIZE 40
static ssize_t
user_show (struct device *dev, char *buf, size_t count, loff_t off)
user_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%s\n",
netiucv_printname(priv->conn->userid));
return snprintf(buf, PAGE_SIZE, "%s\n",
netiucv_printname(priv->conn->userid));
}
static ssize_t
user_write (struct device *dev, const char *buf, size_t count, loff_t off)
user_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
struct net_device *ndev = container_of((void *)priv, struct net_device, priv);
......@@ -1305,16 +1305,16 @@ user_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(user, 0644, user_show, user_write);
static ssize_t
buffer_show (struct device *dev, char *buf, size_t count, loff_t off)
buffer_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%d\n",
priv->conn->max_buffsize);
return sprintf(buf, "%d\n",
priv->conn->max_buffsize);
}
static ssize_t
buffer_write (struct device *dev, const char *buf, size_t count, loff_t off)
buffer_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
struct net_device *ndev = container_of((void *)priv, struct net_device, priv);
......@@ -1352,38 +1352,37 @@ buffer_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
static ssize_t
dev_fsm_show (struct device *dev, char *buf, size_t count, loff_t off)
dev_fsm_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%s\n",
fsm_getstate_str(priv->fsm));
return snprintf(buf, PAGE_SIZE, "%s\n",
fsm_getstate_str(priv->fsm));
}
static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL);
static ssize_t
conn_fsm_show (struct device *dev, char *buf, size_t count, loff_t off)
conn_fsm_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%s\n",
fsm_getstate_str(priv->conn->fsm));
return snprintf(buf, PAGE_SIZE, "%s\n",
fsm_getstate_str(priv->conn->fsm));
}
static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL);
static ssize_t
maxmulti_show (struct device *dev, char *buf, size_t count, loff_t off)
maxmulti_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%ld\n",
priv->conn->prof.maxmulti);
return sprintf(buf, "%ld\n", priv->conn->prof.maxmulti);
}
static ssize_t
maxmulti_write (struct device *dev, const char *buf, size_t count, loff_t off)
maxmulti_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
......@@ -1394,16 +1393,15 @@ maxmulti_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write);
static ssize_t
maxcq_show (struct device *dev, char *buf, size_t count, loff_t off)
maxcq_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%ld\n",
priv->conn->prof.maxcqueue);
return sprintf(buf, "%ld\n", priv->conn->prof.maxcqueue);
}
static ssize_t
maxcq_write (struct device *dev, const char *buf, size_t count, loff_t off)
maxcq_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
......@@ -1414,16 +1412,15 @@ maxcq_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write);
static ssize_t
sdoio_show (struct device *dev, char *buf, size_t count, loff_t off)
sdoio_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%ld\n",
priv->conn->prof.doios_single);
return sprintf(buf, "%ld\n", priv->conn->prof.doios_single);
}
static ssize_t
sdoio_write (struct device *dev, const char *buf, size_t count, loff_t off)
sdoio_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
......@@ -1434,16 +1431,15 @@ sdoio_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write);
static ssize_t
mdoio_show (struct device *dev, char *buf, size_t count, loff_t off)
mdoio_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%ld\n",
priv->conn->prof.doios_multi);
return sprintf(buf, "%ld\n", priv->conn->prof.doios_multi);
}
static ssize_t
mdoio_write (struct device *dev, const char *buf, size_t count, loff_t off)
mdoio_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
......@@ -1454,16 +1450,15 @@ mdoio_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write);
static ssize_t
txlen_show (struct device *dev, char *buf, size_t count, loff_t off)
txlen_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%ld\n",
priv->conn->prof.txlen);
return sprintf(buf, "%ld\n", priv->conn->prof.txlen);
}
static ssize_t
txlen_write (struct device *dev, const char *buf, size_t count, loff_t off)
txlen_write (struct device *dev, const char *buf, size_t count)
{
netiucv_priv *priv = dev->driver_data;
......@@ -1474,16 +1469,15 @@ txlen_write (struct device *dev, const char *buf, size_t count, loff_t off)
static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write);
static ssize_t
txtime_show (struct device *dev, char *buf, size_t count, loff_t off)
txtime_show (struct device *dev, char *buf)
{
netiucv_priv *priv = dev->driver_data;
return off ? 0 : snprintf(buf, count, "%ld\n",
priv->conn->prof.tx_time);
return snprintf(buf, count, "%ld\n", priv->conn->prof.tx_time);
}
static ssize_t
txtime_write (struct device *dev, const char *buf, size_t count, loff_t off)
txtime_write (struct device *dev, const char *buf)
{
netiucv_priv *priv = dev->driver_data;
......
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