[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200805201209.02691.IvDoorn@gmail.com>
Date: Tue, 20 May 2008 12:09:02 +0200
From: Ivo van Doorn <ivdoorn@...il.com>
To: Henrique de Moraes Holschuh <hmh@....eng.br>
Cc: linux-kernel@...r.kernel.org, Thomas Renninger <trenn@...e.de>
Subject: Re: [PATCH 12/15] rfkill: add type string helper
On Sunday 18 May 2008, Henrique de Moraes Holschuh wrote:
> We will need access to the rfkill switch type in string format for more
> than just sysfs. Therefore, move it to a generic helper.
>
> Signed-off-by: Henrique de Moraes Holschuh <hmh@....eng.br>
Acked-by: Ivo van Doorn <IvDoorn@...il.com>
> Cc: Ivo van Doorn <IvDoorn@...il.com>
> ---
> net/rfkill/rfkill.c | 33 +++++++++++++++------------------
> 1 files changed, 15 insertions(+), 18 deletions(-)
>
> diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
> index 251defe..4ed8d19 100644
> --- a/net/rfkill/rfkill.c
> +++ b/net/rfkill/rfkill.c
> @@ -220,34 +220,31 @@ static ssize_t rfkill_name_show(struct device *dev,
> return sprintf(buf, "%s\n", rfkill->name);
> }
>
> -static ssize_t rfkill_type_show(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +static const char const *rfkill_get_type_str(enum rfkill_type type)
> {
> - struct rfkill *rfkill = to_rfkill(dev);
> - const char *type;
> -
> - switch (rfkill->type) {
> + switch (type) {
> case RFKILL_TYPE_WLAN:
> - type = "wlan";
> - break;
> + return "wlan";
> case RFKILL_TYPE_BLUETOOTH:
> - type = "bluetooth";
> - break;
> + return "bluetooth";
> case RFKILL_TYPE_UWB:
> - type = "ultrawideband";
> - break;
> + return "ultrawideband";
> case RFKILL_TYPE_WIMAX:
> - type = "wimax";
> - break;
> + return "wimax";
> case RFKILL_TYPE_WWAN:
> - type = "wwan";
> - break;
> + return "wwan";
> default:
> BUG();
> }
> +}
> +
> +static ssize_t rfkill_type_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct rfkill *rfkill = to_rfkill(dev);
>
> - return sprintf(buf, "%s\n", type);
> + return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type));
> }
>
> static ssize_t rfkill_state_show(struct device *dev,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists