[PATCH] pcmcia: export stored values in sysfs
Export the stored values instead of re-reading everything in the socket information sysfs files, and make them accessible to all users, not only to root. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
parent
1371d3be04
commit
002dbb2d0d
1 changed files with 10 additions and 17 deletions
|
@ -42,35 +42,28 @@
|
||||||
|
|
||||||
static ssize_t pccard_show_type(struct class_device *dev, char *buf)
|
static ssize_t pccard_show_type(struct class_device *dev, char *buf)
|
||||||
{
|
{
|
||||||
int val;
|
|
||||||
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;
|
||||||
s->ops->get_status(s, &val);
|
if (s->state & SOCKET_CARDBUS)
|
||||||
if (val & SS_CARDBUS)
|
|
||||||
return sprintf(buf, "32-bit\n");
|
return sprintf(buf, "32-bit\n");
|
||||||
if (val & SS_DETECT)
|
|
||||||
return sprintf(buf, "16-bit\n");
|
return sprintf(buf, "16-bit\n");
|
||||||
return sprintf(buf, "invalid\n");
|
|
||||||
}
|
}
|
||||||
static CLASS_DEVICE_ATTR(card_type, 0400, pccard_show_type, NULL);
|
static CLASS_DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
|
||||||
|
|
||||||
static ssize_t pccard_show_voltage(struct class_device *dev, char *buf)
|
static ssize_t pccard_show_voltage(struct class_device *dev, char *buf)
|
||||||
{
|
{
|
||||||
int val;
|
|
||||||
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;
|
||||||
s->ops->get_status(s, &val);
|
if (s->socket.Vcc)
|
||||||
if (val & SS_3VCARD)
|
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10,
|
||||||
return sprintf(buf, "3.3V\n");
|
s->socket.Vcc % 10);
|
||||||
if (val & SS_XVCARD)
|
|
||||||
return sprintf(buf, "X.XV\n");
|
return sprintf(buf, "X.XV\n");
|
||||||
return sprintf(buf, "5.0V\n");
|
|
||||||
}
|
}
|
||||||
static CLASS_DEVICE_ATTR(card_voltage, 0400, pccard_show_voltage, NULL);
|
static CLASS_DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
|
||||||
|
|
||||||
static ssize_t pccard_show_vpp(struct class_device *dev, char *buf)
|
static ssize_t pccard_show_vpp(struct class_device *dev, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +72,7 @@ static ssize_t pccard_show_vpp(struct class_device *dev, char *buf)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
|
return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
|
||||||
}
|
}
|
||||||
static CLASS_DEVICE_ATTR(card_vpp, 0400, pccard_show_vpp, NULL);
|
static CLASS_DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
|
||||||
|
|
||||||
static ssize_t pccard_show_vcc(struct class_device *dev, char *buf)
|
static ssize_t pccard_show_vcc(struct class_device *dev, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +81,7 @@ static ssize_t pccard_show_vcc(struct class_device *dev, char *buf)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
|
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
|
||||||
}
|
}
|
||||||
static CLASS_DEVICE_ATTR(card_vcc, 0400, pccard_show_vcc, NULL);
|
static CLASS_DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
|
||||||
|
|
||||||
|
|
||||||
static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count)
|
static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count)
|
||||||
|
|
Loading…
Reference in a new issue