pcmcia: use sysfs_emit{,_at} for sysfs output
Convert the PCMCIA core and yenta_socket.c to use sysfs_emit or sysfs_emit_at when providing output in sysfs. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
parent
fffbcee933
commit
78e0185c25
|
@ -998,7 +998,7 @@ static int runtime_resume(struct device *dev)
|
||||||
static ssize_t field##_show (struct device *dev, struct device_attribute *attr, char *buf) \
|
static ssize_t field##_show (struct device *dev, struct device_attribute *attr, char *buf) \
|
||||||
{ \
|
{ \
|
||||||
struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
|
struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
|
||||||
return p_dev->test ? sprintf(buf, format, p_dev->field) : -ENODEV; \
|
return p_dev->test ? sysfs_emit(buf, format, p_dev->field) : -ENODEV; \
|
||||||
} \
|
} \
|
||||||
static DEVICE_ATTR_RO(field);
|
static DEVICE_ATTR_RO(field);
|
||||||
|
|
||||||
|
@ -1006,7 +1006,7 @@ static DEVICE_ATTR_RO(field);
|
||||||
static ssize_t name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
|
static ssize_t name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
|
||||||
{ \
|
{ \
|
||||||
struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
|
struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
|
||||||
return p_dev->field ? sprintf(buf, "%s\n", p_dev->field) : -ENODEV; \
|
return p_dev->field ? sysfs_emit(buf, "%s\n", p_dev->field) : -ENODEV; \
|
||||||
} \
|
} \
|
||||||
static DEVICE_ATTR_RO(name);
|
static DEVICE_ATTR_RO(name);
|
||||||
|
|
||||||
|
@ -1022,7 +1022,7 @@ static ssize_t function_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
|
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
|
||||||
return p_dev->socket ? sprintf(buf, "0x%02x\n", p_dev->func) : -ENODEV;
|
return p_dev->socket ? sysfs_emit(buf, "0x%02x\n", p_dev->func) : -ENODEV;
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(function);
|
static DEVICE_ATTR_RO(function);
|
||||||
|
|
||||||
|
@ -1030,13 +1030,12 @@ static ssize_t resources_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
|
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
|
||||||
char *str = buf;
|
int i, at = 0;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < PCMCIA_NUM_RESOURCES; i++)
|
for (i = 0; i < PCMCIA_NUM_RESOURCES; i++)
|
||||||
str += sprintf(str, "%pr\n", p_dev->resource[i]);
|
at += sysfs_emit_at(buf, at, "%pr\n", p_dev->resource[i]);
|
||||||
|
|
||||||
return str - buf;
|
return at;
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(resources);
|
static DEVICE_ATTR_RO(resources);
|
||||||
|
|
||||||
|
@ -1045,9 +1044,9 @@ static ssize_t pm_state_show(struct device *dev, struct device_attribute *attr,
|
||||||
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
|
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
|
||||||
|
|
||||||
if (p_dev->suspended)
|
if (p_dev->suspended)
|
||||||
return sprintf(buf, "off\n");
|
return sysfs_emit(buf, "off\n");
|
||||||
else
|
else
|
||||||
return sprintf(buf, "on\n");
|
return sysfs_emit(buf, "on\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t pm_state_store(struct device *dev, struct device_attribute *attr,
|
static ssize_t pm_state_store(struct device *dev, struct device_attribute *attr,
|
||||||
|
@ -1081,8 +1080,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
|
||||||
hash[i] = crc32(0, p_dev->prod_id[i],
|
hash[i] = crc32(0, p_dev->prod_id[i],
|
||||||
strlen(p_dev->prod_id[i]));
|
strlen(p_dev->prod_id[i]));
|
||||||
}
|
}
|
||||||
return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
|
return sysfs_emit(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02Xpa%08Xpb%08Xpc%08Xpd%08X\n",
|
||||||
"pa%08Xpb%08Xpc%08Xpd%08X\n",
|
|
||||||
p_dev->has_manf_id ? p_dev->manf_id : 0,
|
p_dev->has_manf_id ? p_dev->manf_id : 0,
|
||||||
p_dev->has_card_id ? p_dev->card_id : 0,
|
p_dev->has_card_id ? p_dev->card_id : 0,
|
||||||
p_dev->has_func_id ? p_dev->func_id : 0,
|
p_dev->has_func_id ? p_dev->func_id : 0,
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ static ssize_t show_io_db(struct device *dev,
|
||||||
for (p = data->io_db.next; p != &data->io_db; p = p->next) {
|
for (p = data->io_db.next; p != &data->io_db; p = p->next) {
|
||||||
if (ret > (PAGE_SIZE - 10))
|
if (ret > (PAGE_SIZE - 10))
|
||||||
continue;
|
continue;
|
||||||
ret += scnprintf(&buf[ret], (PAGE_SIZE - ret - 1),
|
ret += sysfs_emit_at(buf, ret,
|
||||||
"0x%08lx - 0x%08lx\n",
|
"0x%08lx - 0x%08lx\n",
|
||||||
((unsigned long) p->base),
|
((unsigned long) p->base),
|
||||||
((unsigned long) p->base + p->num - 1));
|
((unsigned long) p->base + p->num - 1));
|
||||||
|
@ -1139,7 +1139,7 @@ static ssize_t show_mem_db(struct device *dev,
|
||||||
p = p->next) {
|
p = p->next) {
|
||||||
if (ret > (PAGE_SIZE - 10))
|
if (ret > (PAGE_SIZE - 10))
|
||||||
continue;
|
continue;
|
||||||
ret += scnprintf(&buf[ret], (PAGE_SIZE - ret - 1),
|
ret += sysfs_emit_at(buf, ret,
|
||||||
"0x%08lx - 0x%08lx\n",
|
"0x%08lx - 0x%08lx\n",
|
||||||
((unsigned long) p->base),
|
((unsigned long) p->base),
|
||||||
((unsigned long) p->base + p->num - 1));
|
((unsigned long) p->base + p->num - 1));
|
||||||
|
@ -1148,7 +1148,7 @@ static ssize_t show_mem_db(struct device *dev,
|
||||||
for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
|
for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
|
||||||
if (ret > (PAGE_SIZE - 10))
|
if (ret > (PAGE_SIZE - 10))
|
||||||
continue;
|
continue;
|
||||||
ret += scnprintf(&buf[ret], (PAGE_SIZE - ret - 1),
|
ret += sysfs_emit_at(buf, ret,
|
||||||
"0x%08lx - 0x%08lx\n",
|
"0x%08lx - 0x%08lx\n",
|
||||||
((unsigned long) p->base),
|
((unsigned long) p->base),
|
||||||
((unsigned long) p->base + p->num - 1));
|
((unsigned long) p->base + p->num - 1));
|
||||||
|
|
|
@ -38,8 +38,8 @@ static ssize_t pccard_show_type(struct device *dev, struct device_attribute *att
|
||||||
if (!(s->state & SOCKET_PRESENT))
|
if (!(s->state & SOCKET_PRESENT))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
if (s->state & SOCKET_CARDBUS)
|
if (s->state & SOCKET_CARDBUS)
|
||||||
return sprintf(buf, "32-bit\n");
|
return sysfs_emit(buf, "32-bit\n");
|
||||||
return sprintf(buf, "16-bit\n");
|
return sysfs_emit(buf, "16-bit\n");
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
|
static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ static ssize_t pccard_show_voltage(struct device *dev, struct device_attribute *
|
||||||
if (!(s->state & SOCKET_PRESENT))
|
if (!(s->state & SOCKET_PRESENT))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
if (s->socket.Vcc)
|
if (s->socket.Vcc)
|
||||||
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10,
|
return sysfs_emit(buf, "%d.%dV\n", s->socket.Vcc / 10,
|
||||||
s->socket.Vcc % 10);
|
s->socket.Vcc % 10);
|
||||||
return sprintf(buf, "X.XV\n");
|
return sysfs_emit(buf, "X.XV\n");
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
|
static DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ static ssize_t pccard_show_vpp(struct device *dev, struct device_attribute *attr
|
||||||
struct pcmcia_socket *s = to_socket(dev);
|
struct pcmcia_socket *s = to_socket(dev);
|
||||||
if (!(s->state & SOCKET_PRESENT))
|
if (!(s->state & SOCKET_PRESENT))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
|
return sysfs_emit(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
|
static DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ static ssize_t pccard_show_vcc(struct device *dev, struct device_attribute *attr
|
||||||
struct pcmcia_socket *s = to_socket(dev);
|
struct pcmcia_socket *s = to_socket(dev);
|
||||||
if (!(s->state & SOCKET_PRESENT))
|
if (!(s->state & SOCKET_PRESENT))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
|
return sysfs_emit(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
|
static DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ static ssize_t pccard_show_card_pm_state(struct device *dev,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct pcmcia_socket *s = to_socket(dev);
|
struct pcmcia_socket *s = to_socket(dev);
|
||||||
return sprintf(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on");
|
return sysfs_emit(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on");
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t pccard_store_card_pm_state(struct device *dev,
|
static ssize_t pccard_store_card_pm_state(struct device *dev,
|
||||||
|
@ -145,7 +145,7 @@ static ssize_t pccard_show_irq_mask(struct device *dev,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct pcmcia_socket *s = to_socket(dev);
|
struct pcmcia_socket *s = to_socket(dev);
|
||||||
return sprintf(buf, "0x%04x\n", s->irq_mask);
|
return sysfs_emit(buf, "0x%04x\n", s->irq_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t pccard_store_irq_mask(struct device *dev,
|
static ssize_t pccard_store_irq_mask(struct device *dev,
|
||||||
|
@ -177,7 +177,7 @@ static ssize_t pccard_show_resource(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct pcmcia_socket *s = to_socket(dev);
|
struct pcmcia_socket *s = to_socket(dev);
|
||||||
return sprintf(buf, "%s\n", s->resource_setup_done ? "yes" : "no");
|
return sysfs_emit(buf, "%s\n", s->resource_setup_done ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t pccard_store_resource(struct device *dev,
|
static ssize_t pccard_store_resource(struct device *dev,
|
||||||
|
|
|
@ -178,16 +178,16 @@ static ssize_t show_yenta_registers(struct device *yentadev, struct device_attri
|
||||||
struct yenta_socket *socket = dev_get_drvdata(yentadev);
|
struct yenta_socket *socket = dev_get_drvdata(yentadev);
|
||||||
int offset = 0, i;
|
int offset = 0, i;
|
||||||
|
|
||||||
offset = snprintf(buf, PAGE_SIZE, "CB registers:");
|
offset = sysfs_emit(buf, "CB registers:");
|
||||||
for (i = 0; i < 0x24; i += 4) {
|
for (i = 0; i < 0x24; i += 4) {
|
||||||
unsigned val;
|
unsigned val;
|
||||||
if (!(i & 15))
|
if (!(i & 15))
|
||||||
offset += scnprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i);
|
offset += sysfs_emit_at(buf, offset, "\n%02x:", i);
|
||||||
val = cb_readl(socket, i);
|
val = cb_readl(socket, i);
|
||||||
offset += scnprintf(buf + offset, PAGE_SIZE - offset, " %08x", val);
|
offset += sysfs_emit_at(buf, offset, " %08x", val);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += scnprintf(buf + offset, PAGE_SIZE - offset, "\n\nExCA registers:");
|
offset += sysfs_emit_at(buf, offset, "\n\nExCA registers:");
|
||||||
for (i = 0; i < 0x45; i++) {
|
for (i = 0; i < 0x45; i++) {
|
||||||
unsigned char val;
|
unsigned char val;
|
||||||
if (!(i & 7)) {
|
if (!(i & 7)) {
|
||||||
|
@ -195,12 +195,12 @@ static ssize_t show_yenta_registers(struct device *yentadev, struct device_attri
|
||||||
memcpy(buf + offset, " -", 2);
|
memcpy(buf + offset, " -", 2);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
} else
|
} else
|
||||||
offset += scnprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i);
|
offset += sysfs_emit_at(buf, offset, "\n%02x:", i);
|
||||||
}
|
}
|
||||||
val = exca_readb(socket, i);
|
val = exca_readb(socket, i);
|
||||||
offset += scnprintf(buf + offset, PAGE_SIZE - offset, " %02x", val);
|
offset += sysfs_emit_at(buf, offset, " %02x", val);
|
||||||
}
|
}
|
||||||
buf[offset++] = '\n';
|
sysfs_emit_at(buf, offset, "\n");
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue