100 lines
2.3 KiB
C
100 lines
2.3 KiB
C
/*
|
|
* Copyright (c) 2012 NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <linux/cpuquiet.h>
|
|
|
|
ssize_t store_int_attribute(struct cpuquiet_attribute *cattr, const char *buf,
|
|
size_t count)
|
|
{
|
|
int err, val;
|
|
|
|
err = kstrtoint(buf, 0, &val);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
*((int *)(cattr->param)) = val;
|
|
|
|
return count;
|
|
}
|
|
|
|
ssize_t show_int_attribute(struct cpuquiet_attribute *cattr, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", *((int *)cattr->param));
|
|
}
|
|
|
|
ssize_t store_bool_attribute(struct cpuquiet_attribute *cattr, const char *buf,
|
|
size_t count)
|
|
{
|
|
int err, val;
|
|
|
|
err = kstrtoint(buf, 0, &val);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
if (val < 0 || val > 1)
|
|
return -EINVAL;
|
|
|
|
*((bool *)(cattr->param)) = val;
|
|
|
|
return count;
|
|
}
|
|
|
|
ssize_t show_bool_attribute(struct cpuquiet_attribute *cattr, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", *((bool *)cattr->param));
|
|
}
|
|
|
|
ssize_t store_uint_attribute(struct cpuquiet_attribute *cattr, const char *buf,
|
|
size_t count)
|
|
{
|
|
int err;
|
|
unsigned int val;
|
|
|
|
err = kstrtouint(buf, 0, &val);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
*((unsigned int *)(cattr->param)) = val;
|
|
|
|
return count;
|
|
}
|
|
|
|
ssize_t show_uint_attribute(struct cpuquiet_attribute *cattr, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", *((unsigned int *)cattr->param));
|
|
}
|
|
|
|
ssize_t store_ulong_attribute(struct cpuquiet_attribute *cattr, const char *buf,
|
|
size_t count)
|
|
{
|
|
int err;
|
|
unsigned long val;
|
|
|
|
err = kstrtoul(buf, 0, &val);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
*((unsigned long *)(cattr->param)) = val;
|
|
|
|
return count;
|
|
}
|
|
|
|
ssize_t show_ulong_attribute(struct cpuquiet_attribute *cattr, char *buf)
|
|
{
|
|
return sprintf(buf, "%lu\n", *((unsigned long *)cattr->param));
|
|
}
|