mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 22:51:37 +00:00
rfkill: use strict_strtoul (v2)
Switch sysfs parsing to something that actually works properly. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
5701ed843e
commit
849e0576a7
1 changed files with 12 additions and 2 deletions
|
@ -402,12 +402,16 @@ static ssize_t rfkill_state_store(struct device *dev,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct rfkill *rfkill = to_rfkill(dev);
|
struct rfkill *rfkill = to_rfkill(dev);
|
||||||
unsigned int state = simple_strtoul(buf, NULL, 0);
|
unsigned long state;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!capable(CAP_NET_ADMIN))
|
if (!capable(CAP_NET_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
|
error = strict_strtoul(buf, 0, &state);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
/* RFKILL_STATE_HARD_BLOCKED is illegal here... */
|
/* RFKILL_STATE_HARD_BLOCKED is illegal here... */
|
||||||
if (state != RFKILL_STATE_UNBLOCKED &&
|
if (state != RFKILL_STATE_UNBLOCKED &&
|
||||||
state != RFKILL_STATE_SOFT_BLOCKED)
|
state != RFKILL_STATE_SOFT_BLOCKED)
|
||||||
|
@ -435,7 +439,8 @@ static ssize_t rfkill_claim_store(struct device *dev,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct rfkill *rfkill = to_rfkill(dev);
|
struct rfkill *rfkill = to_rfkill(dev);
|
||||||
bool claim = !!simple_strtoul(buf, NULL, 0);
|
unsigned long claim_tmp;
|
||||||
|
bool claim;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!capable(CAP_NET_ADMIN))
|
if (!capable(CAP_NET_ADMIN))
|
||||||
|
@ -444,6 +449,11 @@ static ssize_t rfkill_claim_store(struct device *dev,
|
||||||
if (rfkill->user_claim_unsupported)
|
if (rfkill->user_claim_unsupported)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
error = strict_strtoul(buf, 0, &claim_tmp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
claim = !!claim_tmp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take the global lock to make sure the kernel is not in
|
* Take the global lock to make sure the kernel is not in
|
||||||
* the middle of rfkill_switch_all
|
* the middle of rfkill_switch_all
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue