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

x86/platform/ts5500: Add a 'name' sysfs attribute

Add a new "name" attribute to the TS5500 sysfs group, to clarify
which supported board model it is.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Savoir-faire Linux Inc. <kernel@savoirfairelinux.com>
Link: http://lkml.kernel.org/r/1404860269-11837-3-git-send-email-vivien.didelot@savoirfairelinux.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Vivien Didelot and committed by
Ingo Molnar
84e288d4 1d240875

+25 -5
+7
Documentation/ABI/testing/sysfs-platform-ts5500
··· 30 30 the corresponding bit is set. For instance, 0x0e means jumpers 31 31 2, 3 and 4 are set. 32 32 33 + What: /sys/devices/platform/ts5500/name 34 + Date: July 2014 35 + KernelVersion: 3.16 36 + Contact: "Savoir-faire Linux Inc." <kernel@savoirfairelinux.com> 37 + Description: 38 + Model name of the TS board, e.g. "TS-5500". 39 + 33 40 What: /sys/devices/platform/ts5500/rs485 34 41 Date: January 2013 35 42 KernelVersion: 3.7
+18 -5
arch/x86/platform/ts5500/ts5500.c
··· 1 1 /* 2 2 * Technologic Systems TS-5500 Single Board Computer support 3 3 * 4 - * Copyright (C) 2013 Savoir-faire Linux Inc. 4 + * Copyright (C) 2013-2014 Savoir-faire Linux Inc. 5 5 * Vivien Didelot <vivien.didelot@savoirfairelinux.com> 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify it under ··· 66 66 67 67 /** 68 68 * struct ts5500_sbc - TS-5500 board description 69 + * @name: Board model name. 69 70 * @id: Board product ID. 70 71 * @sram: Flag for SRAM option. 71 72 * @rs485: Flag for RS-485 option. ··· 76 75 * @jumpers: Bitfield for jumpers' state. 77 76 */ 78 77 struct ts5500_sbc { 78 + const char *name; 79 79 int id; 80 80 bool sram; 81 81 bool rs485; ··· 124 122 if (!request_region(TS5500_PRODUCT_CODE_ADDR, 4, "ts5500")) 125 123 return -EBUSY; 126 124 127 - tmp = inb(TS5500_PRODUCT_CODE_ADDR); 128 - if (tmp != TS5500_PRODUCT_CODE) { 129 - pr_err("This platform is not a TS-5500 (found ID 0x%x)\n", tmp); 125 + sbc->id = inb(TS5500_PRODUCT_CODE_ADDR); 126 + if (sbc->id == TS5500_PRODUCT_CODE) { 127 + sbc->name = "TS-5500"; 128 + } else { 129 + pr_err("ts5500: unknown product code 0x%x\n", sbc->id); 130 130 ret = -ENODEV; 131 131 goto cleanup; 132 132 } 133 - sbc->id = tmp; 134 133 135 134 tmp = inb(TS5500_SRAM_RS485_ADC_ADDR); 136 135 sbc->sram = tmp & TS5500_SRAM; ··· 149 146 release_region(TS5500_PRODUCT_CODE_ADDR, 4); 150 147 return ret; 151 148 } 149 + 150 + static ssize_t name_show(struct device *dev, struct device_attribute *attr, 151 + char *buf) 152 + { 153 + struct ts5500_sbc *sbc = dev_get_drvdata(dev); 154 + 155 + return sprintf(buf, "%s\n", sbc->name); 156 + } 157 + static DEVICE_ATTR_RO(name); 152 158 153 159 static ssize_t id_show(struct device *dev, struct device_attribute *attr, 154 160 char *buf) ··· 195 183 196 184 static struct attribute *ts5500_attributes[] = { 197 185 &dev_attr_id.attr, 186 + &dev_attr_name.attr, 198 187 &dev_attr_jumpers.attr, 199 188 &dev_attr_sram.attr, 200 189 &dev_attr_rs485.attr,