Skip to content

Commit

Permalink
staging: unisys: move timskmod.h functionality
Browse files Browse the repository at this point in the history
This patch removes all timksmod.h pound defines. It also removes
visorkmodutils.c since it no longer has any use by itself. Since
visorkmodutils.c is no longer needed the module_init for
visorchipset.c is modified to call visorutil_spar_detect directly
instead of the extern variable in timksmod.h.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Erik Arfvidson authored and Greg Kroah-Hartman committed May 8, 2015
1 parent 01f125c commit d5b3f1d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 195 deletions.
1 change: 1 addition & 0 deletions drivers/staging/unisys/include/periodic_work.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "timskmod.h"


/* PERIODIC_WORK an opaque structure to users.
* Fields are declared only in the implementation .c files.
*/
Expand Down
94 changes: 0 additions & 94 deletions drivers/staging/unisys/include/timskmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,98 +51,4 @@
#include <linux/seq_file.h>
#include <linux/mm.h>

/* #define DEBUG */
#if !defined SUCCESS
#define SUCCESS 0
#endif
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define STRUCTSEQUAL(x, y) (memcmp(&x, &y, sizeof(x)) == 0)
#ifndef HOSTADDRESS
#define HOSTADDRESS unsigned long long
#endif

#define sizeofmember(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
/** "Covered quotient" function */
#define COVQ(v, d) (((v) + (d) - 1) / (d))
#define SWAPPOINTERS(p1, p2) \
do { \
void *SWAPPOINTERS_TEMP = (void *)p1; \
(void *)(p1) = (void *)(p2); \
(void *)(p2) = SWAPPOINTERS_TEMP; \
} while (0)

#define WARNDRV(fmt, args...) LOGWRN(fmt, ## args)
#define SECUREDRV(fmt, args...) LOGWRN(fmt, ## args)

#define PRINTKDEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args)
#define TBDDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
#define HUHDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
#define ERRDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
#define ERRDEVX(devno, fmt, args...) LOGERRDEVX(devno, fmt, ## args)
#define WARNDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args)
#define SECUREDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args)
#define INFODEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args)
#define INFODEVX(devno, fmt, args...) LOGINFDEVX(devno, fmt, ## args)

/** Verifies the consistency of your PRIVATEDEVICEDATA structure using
* conventional "signature" fields:
* <p>
* - sig1 should contain the size of the structure
* - sig2 should contain a pointer to the beginning of the structure
*/
#define DDLOOKSVALID(dd) \
((dd != NULL) && \
((dd)->sig1 == sizeof(PRIVATEDEVICEDATA)) && \
((dd)->sig2 == dd))

/** Verifies the consistency of your PRIVATEFILEDATA structure using
* conventional "signature" fields:
* <p>
* - sig1 should contain the size of the structure
* - sig2 should contain a pointer to the beginning of the structure
*/
#define FDLOOKSVALID(fd) \
((fd != NULL) && \
((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \
((fd)->sig2 == fd))

/** Sleep for an indicated number of seconds (for use in kernel mode).
* x - the number of seconds to sleep.
*/
#define SLEEP(x) \
do { __set_current_state(TASK_INTERRUPTIBLE); \
schedule_timeout((x)*HZ); \
} while (0)

/** Sleep for an indicated number of jiffies (for use in kernel mode).
* x - the number of jiffies to sleep.
*/
#define SLEEPJIFFIES(x) \
do { __set_current_state(TASK_INTERRUPTIBLE); \
schedule_timeout(x); \
} while (0)

static inline struct cdev *cdev_alloc_init(struct module *owner,
const struct file_operations *fops)
{
struct cdev *cdev = NULL;

cdev = cdev_alloc();
if (!cdev)
return NULL;
cdev->ops = fops;
cdev->owner = owner;

/* Note that the memory allocated for cdev will be deallocated
* when the usage count drops to 0, because it is controlled
* by a kobject of type ktype_cdev_dynamic. (This
* deallocation could very well happen outside of our kernel
* module, like via the cdev_put in __fput() for example.)
*/
return cdev;
}

extern int unisys_spar_platform;

#endif
10 changes: 3 additions & 7 deletions drivers/staging/unisys/include/visorbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
#include "periodic_work.h"
#include "channel.h"

#ifndef HOSTADDRESS
#define HOSTADDRESS u64
#endif

struct visor_driver;
struct visor_device;

Expand Down Expand Up @@ -170,9 +166,9 @@ void visorbus_disable_channel_interrupts(struct visor_device *dev);
* <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
* In this case, the values can simply be read from the channel header.
*/
struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
struct visorchannel *visorchannel_create(u64 physaddr,
ulong channel_bytes, uuid_le guid);
struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
struct visorchannel *visorchannel_create_with_lock(u64 physaddr,
ulong channel_bytes,
uuid_le guid);
void visorchannel_destroy(struct visorchannel *channel);
Expand All @@ -189,7 +185,7 @@ bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
u32 queue);
int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
u64 visorchannel_get_physaddr(struct visorchannel *channel);
ulong visorchannel_get_nbytes(struct visorchannel *channel);
char *visorchannel_id(struct visorchannel *channel, char *s);
char *visorchannel_zoneid(struct visorchannel *channel, char *s);
Expand Down
9 changes: 5 additions & 4 deletions drivers/staging/unisys/visorbus/visorbus_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ remove_visor_device(struct visor_device *dev)
}

static struct visor_device *
find_visor_device_by_channel(HOSTADDRESS channel_physaddr)
find_visor_device_by_channel(u64 channel_physaddr)
{
struct list_head *listentry, *listtmp;

Expand Down Expand Up @@ -1607,8 +1607,9 @@ fix_vbus_dev_info(struct visor_device *visordev)
* type name
*/
for (i = 0; visordrv->channel_types[i].name; i++) {
if (STRUCTSEQUAL(visordrv->channel_types[i].guid,
visordev->channel_type_guid)) {
if (memcmp(&visordrv->channel_types[i].guid,
&visordev->channel_type_guid,
sizeof(visordrv->channel_types[i].guid)) == 0) {
chan_type_name = visordrv->channel_types[i].name;
break;
}
Expand Down Expand Up @@ -1667,7 +1668,7 @@ create_bus_instance(int id)
if ((visorchipset_get_bus_info(id, &bus_info)) &&
(bus_info.chan_info.channel_addr > 0) &&
(bus_info.chan_info.n_channel_bytes > 0)) {
HOSTADDRESS channel_addr = bus_info.chan_info.channel_addr;
u64 channel_addr = bus_info.chan_info.channel_addr;
unsigned long n_channel_bytes =
(unsigned long)
bus_info.chan_info.n_channel_bytes;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/unisys/visorbus/visorbus_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum visorchipset_addresstype {
*/
struct visorchipset_channel_info {
enum visorchipset_addresstype addr_type;
HOSTADDRESS channel_addr;
u64 channel_addr;
struct irq_info intr;
u64 n_channel_bytes;
uuid_le channel_type_uuid;
Expand Down
14 changes: 7 additions & 7 deletions drivers/staging/unisys/visorbus/visorchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define MYDRVNAME "visorchannel"

struct visorchannel {
HOSTADDRESS physaddr;
u64 physaddr;
ulong nbytes;
void __iomem *mapped;
struct channel_header chan_hdr;
Expand All @@ -50,7 +50,7 @@ struct visorchannel {
* but does NOT modify this data area.
*/
static struct visorchannel *
visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
visorchannel_create_guts(u64 physaddr, ulong channel_bytes,
ulong off, uuid_le guid, bool needs_lock)
{
struct visorchannel *channel;
Expand Down Expand Up @@ -112,15 +112,15 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
}

struct visorchannel *
visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid)
{
return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
false);
}
EXPORT_SYMBOL_GPL(visorchannel_create);

struct visorchannel *
visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes,
uuid_le guid)
{
return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
Expand All @@ -141,7 +141,7 @@ visorchannel_destroy(struct visorchannel *channel)
}
EXPORT_SYMBOL_GPL(visorchannel_destroy);

HOSTADDRESS
u64
visorchannel_get_physaddr(struct visorchannel *channel)
{
return channel->physaddr;
Expand Down Expand Up @@ -177,7 +177,7 @@ visorchannel_zoneid(struct visorchannel *channel, char *s)
}
EXPORT_SYMBOL_GPL(visorchannel_zoneid);

HOSTADDRESS
u64
visorchannel_get_clientpartition(struct visorchannel *channel)
{
return channel->chan_hdr.partition_handle;
Expand Down Expand Up @@ -498,7 +498,7 @@ void
visorchannel_debug(struct visorchannel *channel, int num_queues,
struct seq_file *seq, u32 off)
{
HOSTADDRESS addr = 0;
u64 addr = 0;
ulong nbytes = 0, nbytes_region = 0;
struct channel_header hdr;
struct channel_header *phdr = &hdr;
Expand Down
38 changes: 29 additions & 9 deletions drivers/staging/unisys/visorbus/visorchipset.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@

#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000


#define UNISYS_SPAR_LEAF_ID 0x40000000

/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
#define UNISYS_SPAR_ID_EBX 0x73696e55
#define UNISYS_SPAR_ID_ECX 0x70537379
#define UNISYS_SPAR_ID_EDX 0x34367261

/*
* Module parameters
*/
Expand Down Expand Up @@ -1675,7 +1683,7 @@ my_device_destroy(struct controlvm_message *inmsg)
* for failure.
*/
static int
initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
initialize_controlvm_payload_info(u64 phys_addr, u64 offset, u32 bytes,
struct visor_controlvm_payload_info *info)
{
u8 __iomem *payload = NULL;
Expand Down Expand Up @@ -1723,7 +1731,7 @@ destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info)
static void
initialize_controlvm_payload(void)
{
HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
u64 phys_addr = visorchannel_get_physaddr(controlvm_channel);
u64 payload_offset = 0;
u32 payload_bytes = 0;

Expand Down Expand Up @@ -2056,7 +2064,7 @@ parahotplug_process_message(struct controlvm_message *inmsg)
* either successfully or with an error.
*/
static bool
handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
handle_command(struct controlvm_message inmsg, u64 channel_addr)
{
struct controlvm_message_packet *cmd = &inmsg.cmd;
u64 parm_addr;
Expand Down Expand Up @@ -2152,7 +2160,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
return true;
}

static HOSTADDRESS controlvm_get_channel_address(void)
static u64 controlvm_get_channel_address(void)
{
u64 addr = 0;
u32 size = 0;
Expand Down Expand Up @@ -2589,7 +2597,7 @@ static long visorchipset_ioctl(struct file *file, unsigned int cmd,
sizeof(vrtc_offset))) {
return -EFAULT;
}
return SUCCESS;
return 0;
case VMCALL_UPDATE_PHYSICAL_TIME:
if (copy_from_user(&adjustment, (void __user *)arg,
sizeof(adjustment))) {
Expand Down Expand Up @@ -2642,7 +2650,7 @@ static int
visorchipset_init(struct acpi_device *acpi_device)
{
int rc = 0;
HOSTADDRESS addr;
u64 addr;

memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
Expand Down Expand Up @@ -2758,7 +2766,6 @@ static const struct acpi_device_id unisys_device_ids[] = {
{"PNP0A07", 0},
{"", 0},
};
MODULE_DEVICE_TABLE(acpi, unisys_device_ids);

static struct acpi_driver unisys_acpi_driver = {
.name = "unisys_acpi",
Expand All @@ -2770,12 +2777,25 @@ static struct acpi_driver unisys_acpi_driver = {
.remove = visorchipset_exit,
},
};
static __init uint32_t visorutil_spar_detect(void)
{
unsigned int eax, ebx, ecx, edx;

if (cpu_has_hypervisor) {
/* check the ID */
cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
return (ebx == UNISYS_SPAR_ID_EBX) &&
(ecx == UNISYS_SPAR_ID_ECX) &&
(edx == UNISYS_SPAR_ID_EDX);
} else {
return 0;
}
}

static int init_unisys(void)
{
int result;

if (!unisys_spar_platform)
if (!visorutil_spar_detect())
return -ENODEV;

result = acpi_bus_register_driver(&unisys_acpi_driver);
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/unisys/visorutil/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o

visorutil-y := charqueue.o periodic_work.o visorkmodutils.o
visorutil-y := charqueue.o periodic_work.o

ccflags-y += -Idrivers/staging/unisys/include
4 changes: 3 additions & 1 deletion drivers/staging/unisys/visorutil/periodic_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/*
* Helper functions to schedule periodic work in Linux kernel mode.
*/
#include <linux/sched.h>

#include "timskmod.h"
#include "periodic_work.h"
Expand Down Expand Up @@ -192,7 +193,8 @@ bool visor_periodic_work_stop(struct periodic_work *pw)
}
if (pw->is_scheduled) {
write_unlock(&pw->lock);
SLEEPJIFFIES(10);
__set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(10);
write_lock(&pw->lock);
} else {
pw->want_to_stop = false;
Expand Down
Loading

0 comments on commit d5b3f1d

Please sign in to comment.