Re: [Linuxarm] Re: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-18 Thread Joe Perches
On Thu, 2021-03-18 at 17:33 +0800, liuqi (BA) wrote:
> On 2021/3/17 22:57, Joe Perches wrote:
> > On Wed, 2021-03-17 at 17:41 +0800, Qi Liu wrote:
> > > Use the generic sysfs_emit_at() function take place of scnprintf()
> > []
> > > diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c
> > []
> > > @@ -328,41 +328,37 @@ static ssize_t arm_ccn_pmu_event_show(struct device 
> > > *dev,
> > >   struct arm_ccn_pmu_event, attr);
> > >   ssize_t res;
> > >   
> > > 
> > > 
> > > - res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
> > > + res = sysfs_emit(buf, "type=0x%x", event->type);
> > >   if (event->event)
> > > - res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x",
> > > + res += sysfs_emit_at(buf + res, res, ",event=0x%x",
> > >   event->event);
> > 
> > sysfs_emit_at should always use buf, not buf + offset.
> > res should be int and is the offset from buf for the output
> > 
> > so the form should be similar to
> > 
> > int len;
> > 
> > len = sysfs_emit(buf, "type=0x%x", event->type);
> > if (event->event) {
> > len += sysfs_emit_at(buf, len, ",event=0x%x", event->event);
> > 
> > etc...
> > 
> Hi Joe,
> 
> I'll fix the use of sysfs_emit_at in next version, thanks.
> But I think it's better to keep the res as ssize_t, as the return value 
> of this function is ssize_t.

The 2nd arg of sysfs_emit_at is int.
On 64 bit platforms, ssize_t is 64 bit while int is 32.

If res (or len) is ssize_t, there could be a lot of -Wconversion warnings
like this produced when using make W=

warning: conversion from ‘ssize_t’ {aka ‘long int’} to ‘int’ may change value 
[-Wconversion]
  262 |  len += sysfs_emit_at(buf, len, "\n");




Re: [Linuxarm] Re: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-18 Thread liuqi (BA)




On 2021/3/17 22:57, Joe Perches wrote:

On Wed, 2021-03-17 at 17:41 +0800, Qi Liu wrote:

Use the generic sysfs_emit_at() function take place of scnprintf()

[]

diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c

[]

@@ -328,41 +328,37 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev,
    struct arm_ccn_pmu_event, attr);
    ssize_t res;
  


-   res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
+   res = sysfs_emit(buf, "type=0x%x", event->type);
    if (event->event)
-   res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x",
+   res += sysfs_emit_at(buf + res, res, ",event=0x%x",
    event->event);


sysfs_emit_at should always use buf, not buf + offset.
res should be int and is the offset from buf for the output

so the form should be similar to

int len;

len = sysfs_emit(buf, "type=0x%x", event->type);
if (event->event) {
len += sysfs_emit_at(buf, len, ",event=0x%x", event->event);

etc...


Hi Joe,

I'll fix the use of sysfs_emit_at in next version, thanks.
But I think it's better to keep the res as ssize_t, as the return value 
of this function is ssize_t.


Thanks,

Qi


___
Linuxarm mailing list -- linux...@openeuler.org
To unsubscribe send an email to linuxarm-le...@openeuler.org





Re: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-17 Thread Joe Perches
On Wed, 2021-03-17 at 17:41 +0800, Qi Liu wrote:
> Use the generic sysfs_emit_at() function take place of scnprintf()
[]
> diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c
[]
> @@ -328,41 +328,37 @@ static ssize_t arm_ccn_pmu_event_show(struct device 
> *dev,
>   struct arm_ccn_pmu_event, attr);
>   ssize_t res;
>  
> 
> - res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
> + res = sysfs_emit(buf, "type=0x%x", event->type);
>   if (event->event)
> - res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x",
> + res += sysfs_emit_at(buf + res, res, ",event=0x%x",
>   event->event);

sysfs_emit_at should always use buf, not buf + offset.
res should be int and is the offset from buf for the output

so the form should be similar to

int len;

len = sysfs_emit(buf, "type=0x%x", event->type);
if (event->event) {
len += sysfs_emit_at(buf, len, ",event=0x%x", event->event);

etc...




Re: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-17 Thread kernel test robot
Hi Qi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.12-rc3 next-20210317]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Qi-Liu/drivers-perf-convert-sysfs-sprintf-snprintf-scnprintf-to-sysfs_emit/20210317-174750
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
1df27313f50a57497c1faeb6a6ae4ca939c85a7d
config: arm-randconfig-r036-20210317 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
8ef111222a3dd12a9175f69c3bff598c46e8bdf7)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# 
https://github.com/0day-ci/linux/commit/81a69a2f7fa73d0c41d699d6c6993c2594001241
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Qi-Liu/drivers-perf-convert-sysfs-sprintf-snprintf-scnprintf-to-sysfs_emit/20210317-174750
git checkout 81a69a2f7fa73d0c41d699d6c6993c2594001241
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/perf/arm-ccn.c:345:32: warning: incompatible integer to pointer 
>> conversion passing 'ssize_t' (aka 'int') to parameter of type 'const char *' 
>> [-Wint-conversion]
   res += sysfs_emit(buf + res, res, ",xp=?,vc=?");
^~~
   include/linux/sysfs.h:335:39: note: passing argument to parameter 'fmt' here
   int sysfs_emit(char *buf, const char *fmt, ...);
 ^
   1 warning generated.


vim +345 drivers/perf/arm-ccn.c

   274  
   275  #define CCN_EVENT_ATTR(_name) \
   276  __ATTR(_name, S_IRUGO, arm_ccn_pmu_event_show, NULL)
   277  
   278  /*
   279   * Events defined in TRM for MN, HN-I and SBSX are actually watchpoints 
set on
   280   * their ports in XP they are connected to. For the sake of usability 
they are
   281   * explicitly defined here (and translated into a relevant watchpoint in
   282   * arm_ccn_pmu_event_init()) so the user can easily request them 
without deep
   283   * knowledge of the flit format.
   284   */
   285  
   286  #define CCN_EVENT_MN(_name, _def, _mask) { .attr = 
CCN_EVENT_ATTR(mn_##_name), \
   287  .type = CCN_TYPE_MN, .event = CCN_EVENT_WATCHPOINT, \
   288  .num_ports = CCN_NUM_XP_PORTS, .num_vcs = CCN_NUM_VCS, \
   289  .def = _def, .mask = _mask, }
   290  
   291  #define CCN_EVENT_HNI(_name, _def, _mask) { \
   292  .attr = CCN_EVENT_ATTR(hni_##_name), .type = 
CCN_TYPE_HNI, \
   293  .event = CCN_EVENT_WATCHPOINT, .num_ports = 
CCN_NUM_XP_PORTS, \
   294  .num_vcs = CCN_NUM_VCS, .def = _def, .mask = _mask, }
   295  
   296  #define CCN_EVENT_SBSX(_name, _def, _mask) { \
   297  .attr = CCN_EVENT_ATTR(sbsx_##_name), .type = 
CCN_TYPE_SBSX, \
   298  .event = CCN_EVENT_WATCHPOINT, .num_ports = 
CCN_NUM_XP_PORTS, \
   299  .num_vcs = CCN_NUM_VCS, .def = _def, .mask = _mask, }
   300  
   301  #define CCN_EVENT_HNF(_name, _event) { .attr = 
CCN_EVENT_ATTR(hnf_##_name), \
   302  .type = CCN_TYPE_HNF, .event = _event, }
   303  
   304  #define CCN_EVENT_XP(_name, _event) { .attr = 
CCN_EVENT_ATTR(xp_##_name), \
   305  .type = CCN_TYPE_XP, .event = _event, \
   306  .num_ports = CCN_NUM_XP_PORTS, .num_vcs = CCN_NUM_VCS, }
   307  
   308  /*
   309   * RN-I & RN-D (RN-D = RN-I + DVM) nodes have different type ID 
depending
   310   * on configuration. One of them is picked to represent the whole group,
   311   * as they all share the same event types.
   312   */
   313  #define CCN_EVENT_RNI(_name, _event) { .attr = 
CCN_EVENT_ATTR(rni_##_name), \
   314  .type = CCN_TYPE_RNI_3P, .event = _event, }
   315  
   316  #define CCN_EVENT_SBAS(_name, _event) { .attr = 
CCN_EVENT_ATTR(sbas_##_name), \
   317  .type = CCN_TYPE_SBAS, .event = _event, }
   318  
   319  #define CCN_EVENT_CYCLES(_name) { .attr = CCN_EVENT_ATTR(_name), \
   320  .type = CCN_TYPE_CYCLES }
   321  
   322  
   323  static ssize_t arm_ccn_pmu_event_show(struct device *dev,
   324  struct device_attribute *attr, char *buf)
   325  {
   326  struct arm_ccn *ccn 

Re: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-17 Thread kernel test robot
Hi Qi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.12-rc3 next-20210317]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Qi-Liu/drivers-perf-convert-sysfs-sprintf-snprintf-scnprintf-to-sysfs_emit/20210317-174750
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
1df27313f50a57497c1faeb6a6ae4ca939c85a7d
config: arm64-randconfig-s031-20210317 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-277-gc089cd2d-dirty
# 
https://github.com/0day-ci/linux/commit/81a69a2f7fa73d0c41d699d6c6993c2594001241
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Qi-Liu/drivers-perf-convert-sysfs-sprintf-snprintf-scnprintf-to-sysfs_emit/20210317-174750
git checkout 81a69a2f7fa73d0c41d699d6c6993c2594001241
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)
>> drivers/perf/arm-ccn.c:345:46: sparse: sparse: incorrect type in argument 2 
>> (different base types) @@ expected char const *fmt @@ got long 
>> [assigned] [usertype] res @@
   drivers/perf/arm-ccn.c:345:46: sparse: expected char const *fmt
   drivers/perf/arm-ccn.c:345:46: sparse: got long [assigned] [usertype] res

vim +345 drivers/perf/arm-ccn.c

   274  
   275  #define CCN_EVENT_ATTR(_name) \
   276  __ATTR(_name, S_IRUGO, arm_ccn_pmu_event_show, NULL)
   277  
   278  /*
   279   * Events defined in TRM for MN, HN-I and SBSX are actually watchpoints 
set on
   280   * their ports in XP they are connected to. For the sake of usability 
they are
   281   * explicitly defined here (and translated into a relevant watchpoint in
   282   * arm_ccn_pmu_event_init()) so the user can easily request them 
without deep
   283   * knowledge of the flit format.
   284   */
   285  
   286  #define CCN_EVENT_MN(_name, _def, _mask) { .attr = 
CCN_EVENT_ATTR(mn_##_name), \
   287  .type = CCN_TYPE_MN, .event = CCN_EVENT_WATCHPOINT, \
   288  .num_ports = CCN_NUM_XP_PORTS, .num_vcs = CCN_NUM_VCS, \
   289  .def = _def, .mask = _mask, }
   290  
   291  #define CCN_EVENT_HNI(_name, _def, _mask) { \
   292  .attr = CCN_EVENT_ATTR(hni_##_name), .type = 
CCN_TYPE_HNI, \
   293  .event = CCN_EVENT_WATCHPOINT, .num_ports = 
CCN_NUM_XP_PORTS, \
   294  .num_vcs = CCN_NUM_VCS, .def = _def, .mask = _mask, }
   295  
   296  #define CCN_EVENT_SBSX(_name, _def, _mask) { \
   297  .attr = CCN_EVENT_ATTR(sbsx_##_name), .type = 
CCN_TYPE_SBSX, \
   298  .event = CCN_EVENT_WATCHPOINT, .num_ports = 
CCN_NUM_XP_PORTS, \
   299  .num_vcs = CCN_NUM_VCS, .def = _def, .mask = _mask, }
   300  
   301  #define CCN_EVENT_HNF(_name, _event) { .attr = 
CCN_EVENT_ATTR(hnf_##_name), \
   302  .type = CCN_TYPE_HNF, .event = _event, }
   303  
   304  #define CCN_EVENT_XP(_name, _event) { .attr = 
CCN_EVENT_ATTR(xp_##_name), \
   305  .type = CCN_TYPE_XP, .event = _event, \
   306  .num_ports = CCN_NUM_XP_PORTS, .num_vcs = CCN_NUM_VCS, }
   307  
   308  /*
   309   * RN-I & RN-D (RN-D = RN-I + DVM) nodes have different type ID 
depending
   310   * on configuration. One of them is picked to represent the whole group,
   311   * as they all share the same event types.
   312   */
   313  #define CCN_EVENT_RNI(_name, _event) { .attr = 
CCN_EVENT_ATTR(rni_##_name), \
   314  .type = CCN_TYPE_RNI_3P, .event = _event, }
   315  
   316  #define CCN_EVENT_SBAS(_name, _event) { .attr = 
CCN_EVENT_ATTR(sbas_##_name), \
   317  .type = CCN_TYPE_SBAS, .event = _event, }
   318  
   319  #define CCN_EVENT_CYCLES(_name) { .attr = CCN_EVENT_ATTR(_name), \
   320  .type = CCN_TYPE_CYCLES }
   321  
   322  
   323  static ssize_t arm_ccn_pmu_event_show(struct device *dev,
   324  struct device_attribute *attr, char *buf)
   325  {
   326  struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev));
   327  struct arm_ccn_pmu_event *event = container_of(attr,
   328  struct arm_ccn_pmu_event, attr);
   329  ssize_t res;
   330  
   331  

Re: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-17 Thread kernel test robot
Hi Qi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.12-rc3 next-20210317]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Qi-Liu/drivers-perf-convert-sysfs-sprintf-snprintf-scnprintf-to-sysfs_emit/20210317-174750
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
1df27313f50a57497c1faeb6a6ae4ca939c85a7d
config: arm64-randconfig-r003-20210317 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/81a69a2f7fa73d0c41d699d6c6993c2594001241
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Qi-Liu/drivers-perf-convert-sysfs-sprintf-snprintf-scnprintf-to-sysfs_emit/20210317-174750
git checkout 81a69a2f7fa73d0c41d699d6c6993c2594001241
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

   drivers/perf/arm-ccn.c: In function 'arm_ccn_pmu_event_show':
>> drivers/perf/arm-ccn.c:345:32: warning: passing argument 2 of 'sysfs_emit' 
>> makes pointer from integer without a cast [-Wint-conversion]
 345 |   res += sysfs_emit(buf + res, res, ",xp=?,vc=?");
 |^~~
 ||
 |ssize_t {aka long int}
   In file included from include/linux/kobject.h:20,
from include/linux/irqdesc.h:6,
from include/linux/irq.h:584,
from include/asm-generic/hardirq.h:17,
from arch/arm64/include/asm/hardirq.h:17,
from include/linux/hardirq.h:10,
from include/linux/interrupt.h:11,
from drivers/perf/arm-ccn.c:10:
   include/linux/sysfs.h:335:39: note: expected 'const char *' but argument is 
of type 'ssize_t' {aka 'long int'}
 335 | int sysfs_emit(char *buf, const char *fmt, ...);
 |   ^~~


vim +/sysfs_emit +345 drivers/perf/arm-ccn.c

   274  
   275  #define CCN_EVENT_ATTR(_name) \
   276  __ATTR(_name, S_IRUGO, arm_ccn_pmu_event_show, NULL)
   277  
   278  /*
   279   * Events defined in TRM for MN, HN-I and SBSX are actually watchpoints 
set on
   280   * their ports in XP they are connected to. For the sake of usability 
they are
   281   * explicitly defined here (and translated into a relevant watchpoint in
   282   * arm_ccn_pmu_event_init()) so the user can easily request them 
without deep
   283   * knowledge of the flit format.
   284   */
   285  
   286  #define CCN_EVENT_MN(_name, _def, _mask) { .attr = 
CCN_EVENT_ATTR(mn_##_name), \
   287  .type = CCN_TYPE_MN, .event = CCN_EVENT_WATCHPOINT, \
   288  .num_ports = CCN_NUM_XP_PORTS, .num_vcs = CCN_NUM_VCS, \
   289  .def = _def, .mask = _mask, }
   290  
   291  #define CCN_EVENT_HNI(_name, _def, _mask) { \
   292  .attr = CCN_EVENT_ATTR(hni_##_name), .type = 
CCN_TYPE_HNI, \
   293  .event = CCN_EVENT_WATCHPOINT, .num_ports = 
CCN_NUM_XP_PORTS, \
   294  .num_vcs = CCN_NUM_VCS, .def = _def, .mask = _mask, }
   295  
   296  #define CCN_EVENT_SBSX(_name, _def, _mask) { \
   297  .attr = CCN_EVENT_ATTR(sbsx_##_name), .type = 
CCN_TYPE_SBSX, \
   298  .event = CCN_EVENT_WATCHPOINT, .num_ports = 
CCN_NUM_XP_PORTS, \
   299  .num_vcs = CCN_NUM_VCS, .def = _def, .mask = _mask, }
   300  
   301  #define CCN_EVENT_HNF(_name, _event) { .attr = 
CCN_EVENT_ATTR(hnf_##_name), \
   302  .type = CCN_TYPE_HNF, .event = _event, }
   303  
   304  #define CCN_EVENT_XP(_name, _event) { .attr = 
CCN_EVENT_ATTR(xp_##_name), \
   305  .type = CCN_TYPE_XP, .event = _event, \
   306  .num_ports = CCN_NUM_XP_PORTS, .num_vcs = CCN_NUM_VCS, }
   307  
   308  /*
   309   * RN-I & RN-D (RN-D = RN-I + DVM) nodes have different type ID 
depending
   310   * on configuration. One of them is picked to represent the whole group,
   311   * as they all share the same event types.
   312   */
   313  #define CCN_EVENT_RNI(_name, _event) { .attr = 
CCN_EVENT_ATTR(rni_##_name), \
   314  .type = CCN_TYPE_RNI_3P, .event = _event, }
   315  
   316  #define CCN_EVENT_SBAS(_name, _event) { .attr = 

[PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at

2021-03-17 Thread Qi Liu
Use the generic sysfs_emit_at() function take place of scnprintf()

Signed-off-by: Qi Liu 
---
 drivers/perf/arm-ccn.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c
index 3a2ddc0..0588f29 100644
--- a/drivers/perf/arm-ccn.c
+++ b/drivers/perf/arm-ccn.c
@@ -328,41 +328,37 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev,
struct arm_ccn_pmu_event, attr);
ssize_t res;
 
-   res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
+   res = sysfs_emit(buf, "type=0x%x", event->type);
if (event->event)
-   res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x",
+   res += sysfs_emit_at(buf + res, res, ",event=0x%x",
event->event);
if (event->def)
-   res += scnprintf(buf + res, PAGE_SIZE - res, ",%s",
-   event->def);
+   res += sysfs_emit_at(buf + res, res, ",%s", event->def);
if (event->mask)
-   res += scnprintf(buf + res, PAGE_SIZE - res, ",mask=0x%x",
-   event->mask);
+   res += sysfs_emit_at(buf + res, res, ",mask=0x%x", event->mask);
 
/* Arguments required by an event */
switch (event->type) {
case CCN_TYPE_CYCLES:
break;
case CCN_TYPE_XP:
-   res += scnprintf(buf + res, PAGE_SIZE - res,
-   ",xp=?,vc=?");
+   res += sysfs_emit(buf + res, res, ",xp=?,vc=?");
if (event->event == CCN_EVENT_WATCHPOINT)
-   res += scnprintf(buf + res, PAGE_SIZE - res,
+   res += sysfs_emit_at(buf + res, res,
",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?");
else
-   res += scnprintf(buf + res, PAGE_SIZE - res,
-   ",bus=?");
+   res += sysfs_emit_at(buf + res, res, ",bus=?");
 
break;
case CCN_TYPE_MN:
-   res += scnprintf(buf + res, PAGE_SIZE - res, ",node=%d", 
ccn->mn_id);
+   res += sysfs_emit_at(buf + res, res, ",node=%d", ccn->mn_id);
break;
default:
-   res += scnprintf(buf + res, PAGE_SIZE - res, ",node=?");
+   res += sysfs_emit_at(buf + res, res, ",node=?");
break;
}
 
-   res += scnprintf(buf + res, PAGE_SIZE - res, "\n");
+   res += sysfs_emit_at(buf + res, res, "\n");
 
return res;
 }
-- 
2.8.1