#include <linux/of.h>
#include <linux/percpu.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <asm/cputhreads.h>
#include <asm/smp.h>
if (cache_size_kb(cache, &size_kb))
return -ENODEV;
- return sprintf(buf, "%uK\n", size_kb);
+ return sysfs_emit(buf, "%uK\n", size_kb);
}
static struct kobj_attribute cache_size_attr =
if (cache_get_line_size(cache, &line_size))
return -ENODEV;
- return sprintf(buf, "%u\n", line_size);
+ return sysfs_emit(buf, "%u\n", line_size);
}
static struct kobj_attribute cache_line_size_attr =
if (cache_nr_sets(cache, &nr_sets))
return -ENODEV;
- return sprintf(buf, "%u\n", nr_sets);
+ return sysfs_emit(buf, "%u\n", nr_sets);
}
static struct kobj_attribute cache_nr_sets_attr =
if (cache_associativity(cache, &associativity))
return -ENODEV;
- return sprintf(buf, "%u\n", associativity);
+ return sysfs_emit(buf, "%u\n", associativity);
}
static struct kobj_attribute cache_assoc_attr =
cache = index_kobj_to_cache(k);
- return sprintf(buf, "%s\n", cache_type_string(cache));
+ return sysfs_emit(buf, "%s\n", cache_type_string(cache));
}
static struct kobj_attribute cache_type_attr =
index = kobj_to_cache_index_dir(k);
cache = index->cache;
- return sprintf(buf, "%d\n", cache->level);
+ return sysfs_emit(buf, "%d\n", cache->level);
}
static struct kobj_attribute cache_level_attr =
#include <linux/of.h>
#include <linux/pci.h>
#include <linux/stat.h>
+#include <linux/sysfs.h>
#include <asm/ppc-pci.h>
#include <asm/pci-bridge.h>
if (!edev) \
return 0; \
\
- return sprintf(buf, _format "\n", edev->_memb); \
+ return sysfs_emit(buf, _format "\n", edev->_memb); \
} \
static DEVICE_ATTR(_name, 0444, eeh_show_##_name, NULL);
return -ENODEV;
state = eeh_ops->get_state(edev->pe, NULL);
- return sprintf(buf, "0x%08x 0x%08x\n",
- state, edev->pe->state);
+ return sysfs_emit(buf, "0x%08x 0x%08x\n", state, edev->pe->state);
}
static ssize_t eeh_pe_state_store(struct device *dev,
if (!edev || !edev->pe)
return -ENODEV;
- return sprintf(buf, "%d\n", pdn->last_allow_rc);
+ return sysfs_emit(buf, "%d\n", pdn->last_allow_rc);
}
static ssize_t eeh_notify_resume_store(struct device *dev,
struct kobj_attribute *attr,
char *buf)
{
- return sprintf(buf, "%d\n", fw_dump.fadump_enabled);
+ return sysfs_emit(buf, "%d\n", fw_dump.fadump_enabled);
}
/*
struct kobj_attribute *attr,
char *buf)
{
- return sprintf(buf, "%d\n", 1);
+ return sysfs_emit(buf, "%d\n", 1);
}
static ssize_t mem_reserved_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
{
- return sprintf(buf, "%ld\n", fw_dump.reserve_dump_area_size);
+ return sysfs_emit(buf, "%ld\n", fw_dump.reserve_dump_area_size);
}
static ssize_t registered_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
{
- return sprintf(buf, "%d\n", fw_dump.dump_registered);
+ return sysfs_emit(buf, "%d\n", fw_dump.dump_registered);
}
static ssize_t bootargs_append_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
{
- return sprintf(buf, "%s\n", (char *)__va(fw_dump.param_area));
+ return sysfs_emit(buf, "%s\n", (char *)__va(fw_dump.param_area));
}
static ssize_t bootargs_append_store(struct kobject *kobj,
#include <linux/init.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/mm.h>
#include <linux/spinlock.h>
#include <linux/string.h>
static ssize_t fail_iommu_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", dev->archdata.fail_iommu);
+ return sysfs_emit(buf, "%d\n", dev->archdata.fail_iommu);
}
static ssize_t fail_iommu_store(struct device *dev,
#include <linux/nospec.h>
#include <linux/prctl.h>
#include <linux/seq_buf.h>
+#include <linux/sysfs.h>
#include <linux/debugfs.h>
#include <asm/asm-prototypes.h>
}
if (thread_priv)
- return sprintf(buf, "Vulnerable: L1D private per thread\n");
+ return sysfs_emit(buf, "Vulnerable: L1D private per thread\n");
if (!security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV) &&
!security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR))
- return sprintf(buf, "Not affected\n");
+ return sysfs_emit(buf, "Not affected\n");
- return sprintf(buf, "Vulnerable\n");
+ return sysfs_emit(buf, "Vulnerable\n");
}
ssize_t cpu_show_l1tf(struct device *dev, struct device_attribute *attr, char *buf)
default:
type = "unknown";
}
- return sprintf(buf, "Mitigation: Kernel entry/exit barrier (%s)\n", type);
+ return sysfs_emit(buf, "Mitigation: Kernel entry/exit barrier (%s)\n", type);
}
if (!security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV) &&
!security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR))
- return sprintf(buf, "Not affected\n");
+ return sysfs_emit(buf, "Not affected\n");
- return sprintf(buf, "Vulnerable\n");
+ return sysfs_emit(buf, "Vulnerable\n");
}
static int ssb_prctl_get(struct task_struct *task)
#include <linux/percpu.h>
#include <linux/init.h>
#include <linux/sched.h>
+#include <linux/sysfs.h>
#include <linux/export.h>
#include <linux/nodemask.h>
#include <linux/cpumask.h>
{
pr_warn_once("%s (%d) read from unsupported smt_snooze_delay\n",
current->comm, current->pid);
- return sprintf(buf, "100\n");
+ return sysfs_emit(buf, "100\n");
}
static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
struct cpu *cpu = container_of(dev, struct cpu, dev); \
unsigned long val; \
smp_call_function_single(cpu->dev.id, read_##NAME, &val, 1); \
- return sprintf(buf, "%lx\n", val); \
+ return sysfs_emit(buf, "%lx\n", val); \
} \
static ssize_t __used \
store_##NAME(struct device *dev, struct device_attribute *attr, \
static ssize_t show_dscr_default(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%lx\n", dscr_default);
+ return sysfs_emit(buf, "%lx\n", dscr_default);
}
/**
value &= PWRMGTCR0_PW20_WAIT;
- return sprintf(buf, "%u\n", value ? 1 : 0);
+ return sysfs_emit(buf, "%u\n", value ? 1 : 0);
}
static void do_store_pw20_state(void *val)
time = pw20_wt;
}
- return sprintf(buf, "%llu\n", time > 0 ? time : 0);
+ return sysfs_emit(buf, "%llu\n", time > 0 ? time : 0);
}
static void set_pw20_wait_entry_bit(void *val)
value &= PWRMGTCR0_AV_IDLE_PD_EN;
- return sprintf(buf, "%u\n", value ? 1 : 0);
+ return sysfs_emit(buf, "%u\n", value ? 1 : 0);
}
static void do_store_altivec_idle(void *val)
time = altivec_idle_wt;
}
- return sprintf(buf, "%llu\n", time > 0 ? time : 0);
+ return sysfs_emit(buf, "%llu\n", time > 0 ? time : 0);
}
static void set_altivec_idle_wait_entry_bit(void *val)
#ifdef CONFIG_PPC_SVM
static ssize_t show_svm(struct device *dev, struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%u\n", is_secure_guest());
+ return sysfs_emit(buf, "%u\n", is_secure_guest());
}
static DEVICE_ATTR(svm, 0444, show_svm, NULL);
u64 val;
smp_call_function_single(cpu->dev.id, read_idle_purr, &val, 1);
- return sprintf(buf, "%llx\n", val);
+ return sysfs_emit(buf, "%llx\n", val);
}
static DEVICE_ATTR(idle_purr, 0400, idle_purr_show, NULL);
u64 val;
smp_call_function_single(cpu->dev.id, read_idle_spurr, &val, 1);
- return sprintf(buf, "%llx\n", val);
+ return sysfs_emit(buf, "%llx\n", val);
}
static DEVICE_ATTR(idle_spurr, 0400, idle_spurr_show, NULL);
{
struct cpu *cpu = container_of(dev, struct cpu, dev);
- return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id));
+ return sysfs_emit(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id));
}
static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL);
#include <linux/perf_event.h>
#include <linux/percpu.h>
#include <linux/hardirq.h>
+#include <linux/sysfs.h>
#include <linux/uaccess.h>
#include <asm/reg.h>
#include <asm/pmc.h>
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
- return sprintf(page, "event=0x%02llx\n", pmu_attr->id);
+ return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
}
static struct pmu power_pmu = {
#include <linux/rbtree.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/vmalloc.h>
#include <asm/cputhreads.h>
static ssize_t sockets_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", phys_sockets);
+ return sysfs_emit(buf, "%d\n", phys_sockets);
}
static ssize_t chipspersocket_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", phys_chipspersocket);
+ return sysfs_emit(buf, "%d\n", phys_chipspersocket);
}
static ssize_t coresperchip_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", phys_coresperchip);
+ return sysfs_emit(buf, "%d\n", phys_coresperchip);
}
static struct attribute *device_str_attr_create_(char *name, char *str)
static ssize_t domains_show(struct device *dev, struct device_attribute *attr,
char *page)
{
- int d, n, count = 0;
+ int d, count = 0;
const char *str;
for (d = 0; d < HV_PERF_DOMAIN_MAX; d++) {
if (!str)
continue;
- n = sprintf(page, "%d: %s\n", d, str);
- if (n < 0)
- break;
-
- count += n;
- page += n;
+ count += sysfs_emit_at(page, count, "%d: %s\n", d, str);
}
return count;
}
ret = -EIO; \
goto e_free; \
} \
- ret = sprintf(buf, _fmt, _expr); \
+ ret = sysfs_emit(buf, _fmt, _expr); \
e_free: \
kmem_cache_free(hv_page_cache, page); \
return ret; \
#include <linux/init.h>
#include <linux/perf_event.h>
+#include <linux/sysfs.h>
#include <asm/firmware.h>
#include <asm/hvcall.h>
#include <asm/io.h>
if (hret) \
return -EIO; \
\
- return sprintf(page, _format, caps._name); \
+ return sysfs_emit(page, _format, caps._name); \
} \
static struct device_attribute hv_caps_attr_##_name = __ATTR_RO(_name)
struct device_attribute *attr,
char *page)
{
- return sprintf(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT);
+ return sysfs_emit(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT);
}
static ssize_t cpumask_show(struct device *dev,
#include <linux/perf_event.h>
#include <linux/spinlock_types.h>
#include <linux/spinlock.h>
+#include <linux/sysfs.h>
#include <asm/types.h>
#include <asm/kvm_ppc.h>
struct perf_pmu_events_attr *pmu_attr;
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
- return sprintf(page, "event=0x%02llx\n", pmu_attr->id);
+ return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
}
/* Holds the hostwide stats */
#include <linux/module.h>
#include <linux/perf_event.h>
+#include <linux/sysfs.h>
#include <asm/kvm_ppc.h>
#include <asm/kvm_book3s_64.h>
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
- return sprintf(page, "event=0x%02llx\n", pmu_attr->id);
+ return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
}
#define VPA_PMU_EVENT_ATTR(_name, _id) \
#include <linux/i2c.h>
#include <linux/gpio/driver.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/kthread.h>
#include <linux/property.h>
#include <linux/reboot.h>
return -ENODEV;
mcu->reg_ctrl = ret;
- return sprintf(buf, "%02x\n", ret);
+ return sysfs_emit(buf, "%02x\n", ret);
}
static DEVICE_ATTR(status, 0444, show_status, NULL);
#include <linux/mutex.h>
#include <linux/linux_logo.h>
#include <linux/syscore_ops.h>
+#include <linux/sysfs.h>
#include <asm/spu.h>
#include <asm/spu_priv1.h>
#include <asm/spu_csa.h>
{
struct spu *spu = container_of(dev, struct spu, dev);
- return sprintf(buf, "%s %llu %llu %llu %llu "
- "%llu %llu %llu %llu %llu %llu %llu %llu\n",
+ return sysfs_emit(buf,
+ "%s %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
spu_state_names[spu->stats.util_state],
spu_acct_time(spu, SPU_UTIL_USER),
spu_acct_time(spu, SPU_UTIL_SYSTEM),
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/of.h>
#include <linux/device.h>
#include <linux/cpu.h>
static ssize_t show_fastsleep_workaround_applyonce(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%u\n", fastsleep_workaround_applyonce);
+ return sysfs_emit(buf, "%u\n", fastsleep_workaround_applyonce);
}
static ssize_t store_fastsleep_workaround_applyonce(struct device *dev,
#include <linux/kobject.h>
#include <linux/mm.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/vmalloc.h>
#include <linux/pagemap.h>
#include <linux/delay.h>
struct dump_attribute *attr,
char *buf)
{
- return sprintf(buf, "0x%x\n", dump_obj->id);
+ return sysfs_emit(buf, "0x%x\n", dump_obj->id);
}
static const char* dump_type_to_string(uint32_t type)
char *buf)
{
- return sprintf(buf, "0x%x %s\n", dump_obj->type,
- dump_type_to_string(dump_obj->type));
+ return sysfs_emit(buf, "0x%x %s\n", dump_obj->type,
+ dump_type_to_string(dump_obj->type));
}
static ssize_t dump_ack_show(struct dump_obj *dump_obj,
struct dump_attribute *attr,
char *buf)
{
- return sprintf(buf, "ack - acknowledge dump\n");
+ return sysfs_emit(buf, "ack - acknowledge dump\n");
}
/*
struct dump_attribute *attr,
char *buf)
{
- return sprintf(buf, "1 - initiate Service Processor(FSP) dump\n");
+ return sysfs_emit(buf, "1 - initiate Service Processor(FSP) dump\n");
}
static int64_t dump_fips_init(uint8_t type)
struct elog_attribute *attr,
char *buf)
{
- return sprintf(buf, "0x%llx\n", elog_obj->id);
+ return sysfs_emit(buf, "0x%llx\n", elog_obj->id);
}
static const char *elog_type_to_string(uint64_t type)
struct elog_attribute *attr,
char *buf)
{
- return sprintf(buf, "0x%llx %s\n",
- elog_obj->type,
- elog_type_to_string(elog_obj->type));
+ return sysfs_emit(buf, "0x%llx %s\n", elog_obj->type,
+ elog_type_to_string(elog_obj->type));
}
static ssize_t elog_ack_show(struct elog_obj *elog_obj,
struct elog_attribute *attr,
char *buf)
{
- return sprintf(buf, "ack - acknowledge log message\n");
+ return sysfs_emit(buf, "ack - acknowledge log message\n");
}
static ssize_t elog_ack_store(struct elog_obj *elog_obj,
struct manage_flash_t *const args_buf = &manage_flash_data;
int rc;
- rc = sprintf(buf, "%d\n", args_buf->status);
+ rc = sysfs_emit(buf, "%d\n", args_buf->status);
/* Set status to default*/
args_buf->status = FLASH_NO_OP;
return rc;
struct kobj_attribute *attr, char *buf)
{
struct update_flash_t *const args_buf = &update_flash_data;
- return sprintf(buf, "%d\n", args_buf->status);
+ return sysfs_emit(buf, "%d\n", args_buf->status);
}
/*
#include <linux/of.h>
#include <linux/kobject.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <asm/opal.h>
goto out;
}
ret = opal_error_code(opal_get_async_rc(msg));
- if (!ret) {
- ret = sprintf(buf, "%u\n", be32_to_cpu(pcap));
- if (ret < 0)
- ret = -EIO;
- }
+ if (!ret)
+ ret = sysfs_emit(buf, "%u\n", be32_to_cpu(pcap));
break;
case OPAL_SUCCESS:
- ret = sprintf(buf, "%u\n", be32_to_cpu(pcap));
- if (ret < 0)
- ret = -EIO;
+ ret = sysfs_emit(buf, "%u\n", be32_to_cpu(pcap));
break;
default:
ret = opal_error_code(ret);
#include <linux/of.h>
#include <linux/kobject.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <asm/opal.h>
goto out;
}
ret = opal_error_code(opal_get_async_rc(msg));
- if (!ret) {
- ret = sprintf(buf, "%u\n", be32_to_cpu(psr));
- if (ret < 0)
- ret = -EIO;
- }
+ if (!ret)
+ ret = sysfs_emit(buf, "%u\n", be32_to_cpu(psr));
break;
case OPAL_SUCCESS:
- ret = sprintf(buf, "%u\n", be32_to_cpu(psr));
- if (ret < 0)
- ret = -EIO;
+ ret = sysfs_emit(buf, "%u\n", be32_to_cpu(psr));
break;
default:
ret = opal_error_code(ret);
#include <linux/gfp.h>
#include <linux/smp.h>
#include <linux/stop_machine.h>
+#include <linux/sysfs.h>
#include <asm/cputhreads.h>
#include <asm/cpuidle.h>
static ssize_t show_subcores_per_core(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%x\n", subcores_per_core);
+ return sysfs_emit(buf, "%x\n", subcores_per_core);
}
static DEVICE_ATTR(subcores_per_core, 0644,
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/root_dev.h>
+#include <linux/sysfs.h>
#include <linux/console.h>
#include <linux/export.h>
#include <linux/memblock.h>
static ssize_t ps3_fw_version_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
- return sprintf(buf, "%s", ps3_firmware_version_str);
+ return sysfs_emit(buf, "%s\n", ps3_firmware_version_str);
}
static int __init ps3_setup_sysfs(void)
#include <linux/sched.h>
#include <linux/stringify.h>
#include <linux/swap.h>
+#include <linux/sysfs.h>
#include <linux/device.h>
#include <linux/balloon.h>
#include <asm/firmware.h>
struct device_attribute *attr, \
char *buf) \
{ \
- return sprintf(buf, format, ##args); \
+ return sysfs_emit(buf, format, ##args); \
} \
static DEVICE_ATTR(name, 0444, show_##name, NULL)
static ssize_t show_oom_pages(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%lu\n", PAGES2KB(oom_freed_pages));
+ return sysfs_emit(buf, "%lu\n", PAGES2KB(oom_freed_pages));
}
static ssize_t store_oom_pages(struct device *dev,
#include <linux/spinlock.h>
#include <linux/cpu.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/of.h>
#include "of_helpers.h"
static ssize_t dlpar_show(const struct class *class, const struct class_attribute *attr,
char *buf)
{
- return sprintf(buf, "%s\n", "memory,cpu,dt");
+ return sysfs_emit(buf, "%s\n", "memory,cpu,dt");
}
static CLASS_ATTR_RW(dlpar);
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/stat.h>
+#include <linux/sysfs.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <asm/ibmebus.h>
struct platform_device *ofdev;
ofdev = to_platform_device(dev);
- return sprintf(buf, "%pOF\n", ofdev->dev.of_node);
+ return sysfs_emit(buf, "%pOF\n", ofdev->dev.of_node);
}
static DEVICE_ATTR_RO(devspec);
struct platform_device *ofdev;
ofdev = to_platform_device(dev);
- return sprintf(buf, "%pOFn\n", ofdev->dev.of_node);
+ return sysfs_emit(buf, "%pOFn\n", ofdev->dev.of_node);
}
static DEVICE_ATTR_RO(name);
#include <linux/ioport.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/ndctl.h>
#include <linux/sched.h>
#include <linux/libnvdimm.h>
struct nvdimm *dimm = to_nvdimm(dev);
struct papr_scm_priv *p = nvdimm_provider_data(dimm);
- return sprintf(buf, "%#llx\n",
- READ_ONCE(p->health_bitmap_inject_mask));
+ return sysfs_emit(buf, "%#llx\n",
+ READ_ONCE(p->health_bitmap_inject_mask));
}
static DEVICE_ATTR_ADMIN_RO(health_bitmap_inject);
#include <linux/kobject.h>
#include <linux/string.h>
+#include <linux/sysfs.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <asm/machdep.h>
static ssize_t auto_poweron_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
- return sprintf(buf, "%lu\n", rtas_poweron_auto);
+ return sysfs_emit(buf, "%lu\n", rtas_poweron_auto);
}
static ssize_t auto_poweron_store(struct kobject *kobj,
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/seq_file.h>
+#include <linux/sysfs.h>
#include <linux/device.h>
#include <linux/cpu.h>
#include <linux/of.h>
if (rc != H_SUCCESS)
return -EINVAL;
- return sprintf(page, "%lu\n", retbuf[1] >> 32);
+ return sysfs_emit(page, "%lu\n", retbuf[1] >> 32);
}
/* Wrapper functions */
#include <linux/delay.h>
#include <linux/suspend.h>
#include <linux/stat.h>
+#include <linux/sysfs.h>
#include <asm/firmware.h>
#include <asm/hvcall.h>
#include <asm/machdep.h>
struct device_attribute *attr,
char *buf)
{
- return sprintf(buf, "%d\n", KERN_DT_UPDATE);
+ return sysfs_emit(buf, "%d\n", KERN_DT_UPDATE);
}
static DEVICE_ATTR(hibernate, 0644, show_hibernate, store_hibernate);
#include <linux/miscdevice.h>
#include <linux/kobject.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/mm.h>
#include "vas.h"
#define sysfs_caps_entry_read(_name) \
static ssize_t _name##_show(struct vas_cop_feat_caps *caps, char *buf) \
{ \
- return sprintf(buf, "%d\n", atomic_read(&caps->_name)); \
+ return sysfs_emit(buf, "%d\n", atomic_read(&caps->_name)); \
}
struct vas_sysfs_entry {
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/stat.h>
+#include <linux/sysfs.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/slab.h>
struct device_attribute *attr, \
char *buf) \
{ \
- return sprintf(buf, "%lu\n", to_vio_dev(dev)->cmo.name); \
+ return sysfs_emit(buf, "%lu\n", to_vio_dev(dev)->cmo.name); \
}
static ssize_t cmo_allocs_failed_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct vio_dev *viodev = to_vio_dev(dev);
- return sprintf(buf, "%d\n", atomic_read(&viodev->cmo.allocs_failed));
+ return sysfs_emit(buf, "%d\n", atomic_read(&viodev->cmo.allocs_failed));
}
static ssize_t cmo_allocs_failed_store(struct device *dev,
#define viobus_cmo_rd_attr(name) \
static ssize_t cmo_bus_##name##_show(const struct bus_type *bt, char *buf) \
{ \
- return sprintf(buf, "%lu\n", vio_cmo.name); \
+ return sysfs_emit(buf, "%lu\n", vio_cmo.name); \
} \
static struct bus_attribute bus_attr_cmo_bus_##name = \
__ATTR(cmo_##name, S_IRUGO, cmo_bus_##name##_show, NULL)
static ssize_t \
cmo_##name##_##var##_show(const struct bus_type *bt, char *buf) \
{ \
- return sprintf(buf, "%lu\n", vio_cmo.name.var); \
+ return sysfs_emit(buf, "%lu\n", vio_cmo.name.var); \
} \
static BUS_ATTR_RO(cmo_##name##_##var)
static ssize_t cmo_high_show(const struct bus_type *bt, char *buf)
{
- return sprintf(buf, "%lu\n", vio_cmo.high);
+ return sysfs_emit(buf, "%lu\n", vio_cmo.high);
}
static ssize_t cmo_high_store(const struct bus_type *bt, const char *buf,
static ssize_t name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
+ return sysfs_emit(buf, "%s\n", to_vio_dev(dev)->name);
}
static DEVICE_ATTR_RO(name);
{
struct device_node *of_node = dev->of_node;
- return sprintf(buf, "%pOF\n", of_node);
+ return sysfs_emit(buf, "%pOF\n", of_node);
}
static DEVICE_ATTR_RO(devspec);
const char *cp;
dn = dev->of_node;
- if (!dn) {
- strcpy(buf, "\n");
- return strlen(buf);
- }
+ if (!dn)
+ return sysfs_emit(buf, "\n");
cp = of_get_property(dn, "compatible", NULL);
- if (!cp) {
- strcpy(buf, "\n");
- return strlen(buf);
- }
+ if (!cp)
+ return sysfs_emit(buf, "\n");
- return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
+ return sysfs_emit(buf, "vio:T%sS%s\n", vio_dev->type, cp);
}
static DEVICE_ATTR_RO(modalias);
#include <linux/kernel.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/interrupt.h>
}
mutex_unlock(&sysfs_lock);
- return sprintf(buf, "%lld\n", interval);
+ return sysfs_emit(buf, "%lld\n", interval);
}
static ssize_t fsl_timer_wakeup_store(struct device *dev,