mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-14 14:34:28 +08:00
staging: unisys: Convert the device attributes to visor_device
Convert the device attribute files to properly use visor_device. This removes a whole bunch of checks and assumptions and simplifies the code. Everything is straightforward. No testing down as I can't mimic channel info correctl. Signed-off-by: Don Zickus <dzickus@redhat.com> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
24c5a74e7d
commit
5ecbd5d46d
@ -541,78 +541,54 @@ static const struct attribute_group *visorbus_dev_groups[] = {
|
|||||||
static ssize_t partition_handle_show(struct device *dev,
|
static ssize_t partition_handle_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
struct visorchipset_bus_info bus_info;
|
u64 handle = visorchannel_get_clientpartition(vdev->visorchannel);
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
|
return snprintf(buf, PAGE_SIZE, "0x%Lx\n", handle);
|
||||||
len = snprintf(buf, PAGE_SIZE,
|
|
||||||
"0x%Lx\n",
|
|
||||||
(unsigned long long)bus_info.partition_handle);
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t partition_guid_show(struct device *dev,
|
static ssize_t partition_guid_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
struct visorchipset_bus_info bus_info;
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
|
return snprintf(buf, PAGE_SIZE, "{%pUb}\n", &vdev->partition_uuid);
|
||||||
len = snprintf(buf, PAGE_SIZE, "{%pUb}\n",
|
|
||||||
&bus_info.partition_uuid);
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t partition_name_show(struct device *dev,
|
static ssize_t partition_name_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
struct visorchipset_bus_info bus_info;
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (businst &&
|
return snprintf(buf, PAGE_SIZE, "%s\n", vdev->name);
|
||||||
visorchipset_get_bus_info(businst->devno, &bus_info) &&
|
|
||||||
bus_info.name)
|
|
||||||
len = snprintf(buf, PAGE_SIZE, "%s\n", bus_info.name);
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t channel_addr_show(struct device *dev,
|
static ssize_t channel_addr_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
struct visorchipset_bus_info bus_info;
|
u64 addr = visorchannel_get_physaddr(vdev->visorchannel);
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
|
return snprintf(buf, PAGE_SIZE, "0x%Lx\n", addr);
|
||||||
len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long)
|
|
||||||
bus_info.chan_info.channel_addr);
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t channel_bytes_show(struct device *dev,
|
static ssize_t channel_bytes_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
struct visorchipset_bus_info bus_info;
|
u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel);
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
|
return snprintf(buf, PAGE_SIZE, "0x%Lx\n", nbytes);
|
||||||
len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long)
|
|
||||||
bus_info.chan_info.n_channel_bytes);
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t channel_id_show(struct device *dev,
|
static ssize_t channel_id_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
if (businst && businst->chan) {
|
if (vdev->visorchannel) {
|
||||||
visorchannel_id(businst->chan, buf);
|
visorchannel_id(vdev->visorchannel, buf);
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
buf[len++] = '\n';
|
buf[len++] = '\n';
|
||||||
}
|
}
|
||||||
@ -622,8 +598,9 @@ static ssize_t channel_id_show(struct device *dev,
|
|||||||
static ssize_t client_bus_info_show(struct device *dev,
|
static ssize_t client_bus_info_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf) {
|
char *buf) {
|
||||||
struct visorbus_devdata *businst = to_visorbus_devdata(dev);
|
struct visor_device *vdev = to_visor_device(dev);
|
||||||
struct visorchipset_bus_info bus_info;
|
struct visorchannel *channel = vdev->visorchannel;
|
||||||
|
|
||||||
int i, x, remain = PAGE_SIZE;
|
int i, x, remain = PAGE_SIZE;
|
||||||
unsigned long off;
|
unsigned long off;
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
@ -631,16 +608,15 @@ static ssize_t client_bus_info_show(struct device *dev,
|
|||||||
struct ultra_vbus_deviceinfo dev_info;
|
struct ultra_vbus_deviceinfo dev_info;
|
||||||
|
|
||||||
partition_name = "";
|
partition_name = "";
|
||||||
if (businst && businst->chan) {
|
if (channel) {
|
||||||
if (visorchipset_get_bus_info(businst->devno, &bus_info) &&
|
if (vdev->name)
|
||||||
bus_info.name)
|
partition_name = vdev->name;
|
||||||
partition_name = bus_info.name;
|
|
||||||
x = snprintf(p, remain,
|
x = snprintf(p, remain,
|
||||||
"Client device / client driver info for %s partition (vbus #%d):\n",
|
"Client device / client driver info for %s partition (vbus #%ld):\n",
|
||||||
partition_name, businst->devno);
|
partition_name, vdev->chipset_dev_no);
|
||||||
p += x;
|
p += x;
|
||||||
remain -= x;
|
remain -= x;
|
||||||
x = visorchannel_read(businst->chan,
|
x = visorchannel_read(channel,
|
||||||
offsetof(struct
|
offsetof(struct
|
||||||
spar_vbus_channel_protocol,
|
spar_vbus_channel_protocol,
|
||||||
chp_info),
|
chp_info),
|
||||||
@ -651,7 +627,7 @@ static ssize_t client_bus_info_show(struct device *dev,
|
|||||||
p += x;
|
p += x;
|
||||||
remain -= x;
|
remain -= x;
|
||||||
}
|
}
|
||||||
x = visorchannel_read(businst->chan,
|
x = visorchannel_read(channel,
|
||||||
offsetof(struct
|
offsetof(struct
|
||||||
spar_vbus_channel_protocol,
|
spar_vbus_channel_protocol,
|
||||||
bus_info),
|
bus_info),
|
||||||
@ -665,8 +641,8 @@ static ssize_t client_bus_info_show(struct device *dev,
|
|||||||
off = offsetof(struct spar_vbus_channel_protocol, dev_info);
|
off = offsetof(struct spar_vbus_channel_protocol, dev_info);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (off + sizeof(dev_info) <=
|
while (off + sizeof(dev_info) <=
|
||||||
visorchannel_get_nbytes(businst->chan)) {
|
visorchannel_get_nbytes(channel)) {
|
||||||
x = visorchannel_read(businst->chan,
|
x = visorchannel_read(channel,
|
||||||
off, &dev_info, sizeof(dev_info));
|
off, &dev_info, sizeof(dev_info));
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
x = vbuschannel_devinfo_to_string
|
x = vbuschannel_devinfo_to_string
|
||||||
|
Loading…
Reference in New Issue
Block a user