diff mbox

[v3,2/3] ath9k: add a helper to get the string representation of ath_bus_type

Message ID 20160624123430.4097-3-martin.blumenstingl@googlemail.com (mailing list archive)
State RFC
Delegated to: Kalle Valo
Headers show

Commit Message

Martin Blumenstingl June 24, 2016, 12:34 p.m. UTC
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
this is a new patch which didn't exist in v2 yet, it prepares the new
function ath_bus_type_to_string which will be used in patch #3

 drivers/net/wireless/ath/ath.h  |  2 ++
 drivers/net/wireless/ath/main.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

Comments

Felix Fietkau June 27, 2016, 10:26 a.m. UTC | #1
On 2016-06-24 14:34, Martin Blumenstingl wrote:
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> this is a new patch which didn't exist in v2 yet, it prepares the new
> function ath_bus_type_to_string which will be used in patch #3
> 
>  drivers/net/wireless/ath/ath.h  |  2 ++
>  drivers/net/wireless/ath/main.c | 15 +++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
> index da7a7c8..be0d292 100644
> --- a/drivers/net/wireless/ath/ath.h
> +++ b/drivers/net/wireless/ath/ath.h
> @@ -327,4 +327,6 @@ static inline const char *ath_opmode_to_string(enum nl80211_iftype opmode)
>  }
>  #endif
>  
> +const char *ath_bus_type_to_string(enum ath_bus_type bustype);
> +
>  #endif /* ATH_H */
> diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c
> index 338d723..90427cb 100644
> --- a/drivers/net/wireless/ath/main.c
> +++ b/drivers/net/wireless/ath/main.c
> @@ -90,3 +90,18 @@ void ath_printk(const char *level, const struct ath_common* common,
>  	va_end(args);
>  }
>  EXPORT_SYMBOL(ath_printk);
> +
> +const char *ath_bus_type_to_string(enum ath_bus_type bustype)
> +{
> +	switch (bustype) {
> +	case ATH_PCI:
> +		return "pci";
> +	case ATH_AHB:
> +		return "ahb";
> +	case ATH_USB:
> +		return "usb";
> +	default:
> +		return "unknown";
> +	}
> +}
> +EXPORT_SYMBOL(ath_bus_type_to_string);
Why not simply add a const char* array with ath_bus_type as index?

- Felix
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin Blumenstingl June 29, 2016, 10:37 p.m. UTC | #2
On Mon, Jun 27, 2016 at 12:26 PM, Felix Fietkau <nbd@nbd.name> wrote:
> On 2016-06-24 14:34, Martin Blumenstingl wrote:
>> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>> ---
>> this is a new patch which didn't exist in v2 yet, it prepares the new
>> function ath_bus_type_to_string which will be used in patch #3
>>
>>  drivers/net/wireless/ath/ath.h  |  2 ++
>>  drivers/net/wireless/ath/main.c | 15 +++++++++++++++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
>> index da7a7c8..be0d292 100644
>> --- a/drivers/net/wireless/ath/ath.h
>> +++ b/drivers/net/wireless/ath/ath.h
>> @@ -327,4 +327,6 @@ static inline const char *ath_opmode_to_string(enum nl80211_iftype opmode)
>>  }
>>  #endif
>>
>> +const char *ath_bus_type_to_string(enum ath_bus_type bustype);
>> +
>>  #endif /* ATH_H */
>> diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c
>> index 338d723..90427cb 100644
>> --- a/drivers/net/wireless/ath/main.c
>> +++ b/drivers/net/wireless/ath/main.c
>> @@ -90,3 +90,18 @@ void ath_printk(const char *level, const struct ath_common* common,
>>       va_end(args);
>>  }
>>  EXPORT_SYMBOL(ath_printk);
>> +
>> +const char *ath_bus_type_to_string(enum ath_bus_type bustype)
>> +{
>> +     switch (bustype) {
>> +     case ATH_PCI:
>> +             return "pci";
>> +     case ATH_AHB:
>> +             return "ahb";
>> +     case ATH_USB:
>> +             return "usb";
>> +     default:
>> +             return "unknown";
>> +     }
>> +}
>> +EXPORT_SYMBOL(ath_bus_type_to_string);
> Why not simply add a const char* array with ath_bus_type as index?
Would you add this const char* array directly in ath.h or would you
define it as extern there and set it in main.c?
I would still provide the ath_bus_type_to_string function, but make it
static inline in that case.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index da7a7c8..be0d292 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -327,4 +327,6 @@  static inline const char *ath_opmode_to_string(enum nl80211_iftype opmode)
 }
 #endif
 
+const char *ath_bus_type_to_string(enum ath_bus_type bustype);
+
 #endif /* ATH_H */
diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c
index 338d723..90427cb 100644
--- a/drivers/net/wireless/ath/main.c
+++ b/drivers/net/wireless/ath/main.c
@@ -90,3 +90,18 @@  void ath_printk(const char *level, const struct ath_common* common,
 	va_end(args);
 }
 EXPORT_SYMBOL(ath_printk);
+
+const char *ath_bus_type_to_string(enum ath_bus_type bustype)
+{
+	switch (bustype) {
+	case ATH_PCI:
+		return "pci";
+	case ATH_AHB:
+		return "ahb";
+	case ATH_USB:
+		return "usb";
+	default:
+		return "unknown";
+	}
+}
+EXPORT_SYMBOL(ath_bus_type_to_string);