Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/ps3: Add firmware version to sysfs

Add a new sysfs entry /sys/firmware/ps3/fw-version that exports
the PS3's firmware version.

The firmware version is available through an LV1 hypercall, and we've
been printing it to the boot log, but haven't provided an easy way for
user utilities to get it.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/41509b2da647cd34b1331cc4756c8774b1e284eb.1622822173.git.geoff@infradead.org

authored by

Geoff Levand and committed by
Michael Ellerman
07e2d6cf 015d9814

+40 -3
+40 -3
arch/powerpc/platforms/ps3/setup.c
··· 36 36 EXPORT_SYMBOL_GPL(ps3_gpu_mutex); 37 37 38 38 static union ps3_firmware_version ps3_firmware_version; 39 + static char ps3_firmware_version_str[16]; 39 40 40 41 void ps3_get_firmware_version(union ps3_firmware_version *v) 41 42 { ··· 183 182 return lv1_set_dabr(dabr, dabrx) ? -1 : 0; 184 183 } 185 184 185 + static ssize_t ps3_fw_version_show(struct kobject *kobj, 186 + struct kobj_attribute *attr, char *buf) 187 + { 188 + return sprintf(buf, "%s", ps3_firmware_version_str); 189 + } 190 + 191 + static int __init ps3_setup_sysfs(void) 192 + { 193 + static struct kobj_attribute attr = __ATTR(fw-version, S_IRUGO, 194 + ps3_fw_version_show, NULL); 195 + static struct kobject *kobj; 196 + int result; 197 + 198 + kobj = kobject_create_and_add("ps3", firmware_kobj); 199 + 200 + if (!kobj) { 201 + pr_warn("%s:%d: kobject_create_and_add failed.\n", __func__, 202 + __LINE__); 203 + return -ENOMEM; 204 + } 205 + 206 + result = sysfs_create_file(kobj, &attr.attr); 207 + 208 + if (result) { 209 + pr_warn("%s:%d: sysfs_create_file failed.\n", __func__, 210 + __LINE__); 211 + kobject_put(kobj); 212 + return -ENOMEM; 213 + } 214 + 215 + return 0; 216 + } 217 + core_initcall(ps3_setup_sysfs); 218 + 186 219 static void __init ps3_setup_arch(void) 187 220 { 188 221 u64 tmp; ··· 225 190 226 191 lv1_get_version_info(&ps3_firmware_version.raw, &tmp); 227 192 228 - printk(KERN_INFO "PS3 firmware version %u.%u.%u\n", 229 - ps3_firmware_version.major, ps3_firmware_version.minor, 230 - ps3_firmware_version.rev); 193 + snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str), 194 + "%u.%u.%u", ps3_firmware_version.major, 195 + ps3_firmware_version.minor, ps3_firmware_version.rev); 196 + 197 + printk(KERN_INFO "PS3 firmware version %s\n", ps3_firmware_version_str); 231 198 232 199 ps3_spu_set_platform(); 233 200