Skip to content

Commit e435dc3

Browse files
Janosch Frankborntraeger
authored andcommitted
s390: Make cpc_name accessible
sclp_ocf.c is the only way to get the cpc name, as it registers the sole event handler for the ocf event. By creating a new global function that copies that name, we make it accessible to the world which longs to retrieve it. Additionally we now also store the cpc name as EBCDIC, so we don't have to convert it to and from ASCII if it is requested in native encoding. Signed-off-by: Janosch Frank <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: Heiko Carstens <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
1 parent e65f30e commit e435dc3

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

arch/s390/include/asm/sclp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count);
101101
int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count);
102102
void sclp_early_detect(void);
103103
void _sclp_print_early(const char *);
104+
void sclp_ocf_cpc_name_copy(char *dst);
104105

105106
#endif /* _ASM_S390_SCLP_H */

drivers/s390/char/sclp_ocf.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define OCF_LENGTH_CPC_NAME 8UL
2727

2828
static char hmc_network[OCF_LENGTH_HMC_NETWORK + 1];
29-
static char cpc_name[OCF_LENGTH_CPC_NAME + 1];
29+
static char cpc_name[OCF_LENGTH_CPC_NAME]; /* in EBCDIC */
3030

3131
static DEFINE_SPINLOCK(sclp_ocf_lock);
3232
static struct work_struct sclp_ocf_change_work;
@@ -72,9 +72,8 @@ static void sclp_ocf_handler(struct evbuf_header *evbuf)
7272
}
7373
if (cpc) {
7474
size = min(OCF_LENGTH_CPC_NAME, (size_t) cpc->length);
75+
memset(cpc_name, 0, OCF_LENGTH_CPC_NAME);
7576
memcpy(cpc_name, cpc + 1, size);
76-
EBCASC(cpc_name, size);
77-
cpc_name[size] = 0;
7877
}
7978
spin_unlock(&sclp_ocf_lock);
8079
schedule_work(&sclp_ocf_change_work);
@@ -85,15 +84,23 @@ static struct sclp_register sclp_ocf_event = {
8584
.receiver_fn = sclp_ocf_handler,
8685
};
8786

87+
void sclp_ocf_cpc_name_copy(char *dst)
88+
{
89+
spin_lock_irq(&sclp_ocf_lock);
90+
memcpy(dst, cpc_name, OCF_LENGTH_CPC_NAME);
91+
spin_unlock_irq(&sclp_ocf_lock);
92+
}
93+
EXPORT_SYMBOL(sclp_ocf_cpc_name_copy);
94+
8895
static ssize_t cpc_name_show(struct kobject *kobj,
8996
struct kobj_attribute *attr, char *page)
9097
{
91-
int rc;
98+
char name[OCF_LENGTH_CPC_NAME + 1];
9299

93-
spin_lock_irq(&sclp_ocf_lock);
94-
rc = snprintf(page, PAGE_SIZE, "%s\n", cpc_name);
95-
spin_unlock_irq(&sclp_ocf_lock);
96-
return rc;
100+
sclp_ocf_cpc_name_copy(name);
101+
name[OCF_LENGTH_CPC_NAME] = 0;
102+
EBCASC(name, OCF_LENGTH_CPC_NAME);
103+
return snprintf(page, PAGE_SIZE, "%s\n", name);
97104
}
98105

99106
static struct kobj_attribute cpc_name_attr =

0 commit comments

Comments
 (0)