Skip to content

Commit

Permalink
[PATCH] pcmcia: export stored values in sysfs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Dominik Brodowski committed Jan 5, 2006
1 parent 1371d3b commit 002dbb2
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions drivers/pcmcia/socket_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,28 @@

static ssize_t pccard_show_type(struct class_device *dev, char *buf)
{
int val;
struct pcmcia_socket *s = to_socket(dev);

if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
s->ops->get_status(s, &val);
if (val & SS_CARDBUS)
if (s->state & SOCKET_CARDBUS)
return sprintf(buf, "32-bit\n");
if (val & SS_DETECT)
return sprintf(buf, "16-bit\n");
return sprintf(buf, "invalid\n");
return sprintf(buf, "16-bit\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)
{
int val;
struct pcmcia_socket *s = to_socket(dev);

if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
s->ops->get_status(s, &val);
if (val & SS_3VCARD)
return sprintf(buf, "3.3V\n");
if (val & SS_XVCARD)
return sprintf(buf, "X.XV\n");
return sprintf(buf, "5.0V\n");
if (s->socket.Vcc)
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10,
s->socket.Vcc % 10);
return sprintf(buf, "X.XV\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)
{
Expand All @@ -79,7 +72,7 @@ static ssize_t pccard_show_vpp(struct class_device *dev, char *buf)
return -ENODEV;
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)
{
Expand All @@ -88,7 +81,7 @@ static ssize_t pccard_show_vcc(struct class_device *dev, char *buf)
return -ENODEV;
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)
Expand Down

0 comments on commit 002dbb2

Please sign in to comment.