From: Heikki Krogerus <heikki.krogerus@linux.intel.com> Date: 2015-08-05 13:39:14
The first patch adds a few helper macros for build-in property
creation and the second makes it possible to get the rfkill type
index based on name. The rest deal with rfkill-gpio.
Cheers,
Heikki Krogerus (5):
device property: helper macros for property entry creation
net: rfkill: add rfkill_find_type function
net: rfkill: gpio: get the name and type from device property
ARM: tegra: use build-in device properties with rfkill_gpio
net: rfkill: gpio: remove rfkill_gpio_platform_data
arch/arm/mach-tegra/board-paz00.c | 17 +++++++-----
include/linux/property.h | 35 ++++++++++++++++++++++++
include/linux/rfkill-gpio.h | 37 -------------------------
include/linux/rfkill.h | 15 +++++++++++
net/rfkill/Kconfig | 3 +--
net/rfkill/core.c | 57 ++++++++++++++++++++-------------------
net/rfkill/rfkill-gpio.c | 24 ++++++++---------
7 files changed, 101 insertions(+), 87 deletions(-)
delete mode 100644 include/linux/rfkill-gpio.h
--
2.4.6
From: Heikki Krogerus <heikki.krogerus@linux.intel.com> Date: 2015-08-05 13:39:27
This prepares the driver for removal of platform data.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
net/rfkill/rfkill-gpio.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
@@ -81,7 +81,6 @@ static int rfkill_gpio_acpi_probe(struct device *dev,if(!id)return-ENODEV;-rfkill->name=dev_name(dev);rfkill->type=(unsigned)id->driver_data;returnacpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
@@ -93,12 +92,21 @@ static int rfkill_gpio_probe(struct platform_device *pdev)structrfkill_gpio_platform_data*pdata=pdev->dev.platform_data;structrfkill_gpio_data*rfkill;structgpio_desc*gpio;+constchar*type_name;intret;rfkill=devm_kzalloc(&pdev->dev,sizeof(*rfkill),GFP_KERNEL);if(!rfkill)return-ENOMEM;+device_property_read_string(&pdev->dev,"name",&rfkill->name);+device_property_read_string(&pdev->dev,"type",&type_name);++if(!rfkill->name)+rfkill->name=dev_name(&pdev->dev);++rfkill->type=rfkill_find_type(type_name);+if(ACPI_HANDLE(&pdev->dev)){ret=rfkill_gpio_acpi_probe(&pdev->dev,rfkill);if(ret)
@@ -124,10 +132,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)rfkill->shutdown_gpio=gpio;-/* Make sure at-least one of the GPIO is defined and that-*anameisspecifiedforthisinstance-*/-if((!rfkill->reset_gpio&&!rfkill->shutdown_gpio)||!rfkill->name){+/* Make sure at-least one GPIO is defined for this instance */+if(!rfkill->reset_gpio&&!rfkill->shutdown_gpio){dev_err(&pdev->dev,"invalid platform data\n");return-EINVAL;}
From: Heikki Krogerus <heikki.krogerus@linux.intel.com> Date: 2015-08-05 13:39:29
Helper for finding the type based on name. Useful if the
type needs to be determined based on device property.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
include/linux/rfkill.h | 15 +++++++++++++
net/rfkill/core.c | 57 +++++++++++++++++++++++++-------------------------
2 files changed, 44 insertions(+), 28 deletions(-)
@@ -1,37 +0,0 @@-/*- * Copyright (c) 2011, NVIDIA Corporation.- *- * 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; either version 2 of the License, or- * (at your option) any later version.- *- * 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.- */---#ifndef __RFKILL_GPIO_H-#define __RFKILL_GPIO_H--#include <linux/types.h>-#include <linux/rfkill.h>--/**- * struct rfkill_gpio_platform_data - platform data for rfkill gpio device.- * for unused gpio's, the expected value is -1.- * @name: name for the gpio rf kill instance- */--struct rfkill_gpio_platform_data {- char *name;- enum rfkill_type type;-};--#endif /* __RFKILL_GPIO_H */
From: Heikki Krogerus <heikki.krogerus@linux.intel.com> Date: 2015-08-05 13:40:35
Pass the rfkill name and type to the device with properties
instead of driver specific platform data.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
CC: Alexandre Courbot <redacted>
CC: Thierry Reding <redacted>
CC: Stephen Warren <redacted>
---
arch/arm/mach-tegra/board-paz00.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2015-08-05 14:07:37
On Wed, 2015-08-05 at 16:39 +0300, Heikki Krogerus wrote:
quoted hunk
Helper for finding the type based on name. Useful if the
type needs to be determined based on device property.
Signed-off-by: Heikki Krogerus <heikki.krogerus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
include/linux/rfkill.h | 15 +++++++++++++
net/rfkill/core.c | 57 +++++++++++++++++++++++++---------------
----------
2 files changed, 44 insertions(+), 28 deletions(-)
Hmm… Besides 0 is implicitly casted to enum type the issue with enums
that you rather have to supply existing enum entry. I would suggest to
add RFKILL_TYPE_UNKNOWN if _ALL is reserved for some use cases.
On Wed, 2015-08-05 at 17:02 +0300, Andy Shevchenko wrote:
On Wed, 2015-08-05 at 16:39 +0300, Heikki Krogerus wrote:
[]
quoted
+#define PROP_ENTRY_STRING(_name_, _val_) { \
…_STRING_ARRAY I can notice.
s / can / can't /
quoted
+ .name = _name_, \
+ .type = DEV_PROP_STRING, \
+ .nval = 1, \
+ .value.str = (const char **)_val_, \
+}
+
/**
* struct property_set - Collection of "built-in" device
properties.
* @fwnode: Handle to be pointed to by the fwnode field of struct
device.
--
Andy Shevchenko [off-list ref]
Intel Finland Oy
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
@@ -1,37 +0,0 @@-/*- * Copyright (c) 2011, NVIDIA Corporation.- *- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- */
-
-
-#ifndef __RFKILL_GPIO_H
-#define __RFKILL_GPIO_H
-
-#include <linux/types.h>
-#include <linux/rfkill.h>
-
-/**
- * struct rfkill_gpio_platform_data - platform data for rfkill gpio
device.
- * for unused gpio's, the expected value is -1.
- * @name: name for the gpio rf kill instance
- */
-
-struct rfkill_gpio_platform_data {
- char *name;
- enum rfkill_type type;
-};
-
-#endif /* __RFKILL_GPIO_H */
RFKILL
- driver. The platform should fill in the appropriate fields
in the
- rfkill_gpio_platform_data structure and pass that to the
driver.
+ driver.
@@ -1,37 +0,0 @@-/*- * Copyright (c) 2011, NVIDIA Corporation.- *- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- */
-
-
-#ifndef __RFKILL_GPIO_H
-#define __RFKILL_GPIO_H
-
-#include <linux/types.h>
-#include <linux/rfkill.h>
-
-/**
- * struct rfkill_gpio_platform_data - platform data for rfkill gpio
device.
- * for unused gpio's, the expected value is -1.
- * @name: name for the gpio rf kill instance
- */
-
-struct rfkill_gpio_platform_data {
- char *name;
- enum rfkill_type type;
-};
-
-#endif /* __RFKILL_GPIO_H */
RFKILL
- driver. The platform should fill in the appropriate fields
in the
- rfkill_gpio_platform_data structure and pass that to the
driver.
+ driver.
Shouldn't we leave the error path and modify to check if we have device
property set set?
We already check them before this point. After this ACPI will be the
only "special" case where we know the needed information does not come
from device property and needs separate handling. Otherwise, if the
device properties are not set, we cracefully fail.
Thanks,
--
heikki
PROP_ prefix is too generic.
Maybe DEVPROP_ ? At least for the latter no records in the current
sources.
I disagree with that. IMO this kind of macros should ideally resemble
the structure name they are used to fill (struct property_entry in
this case). And there are already definitions for DEV_PROP_* to
describe the types, so using something like DEVPROP_* here is just
confusing.
If PROP_ENTRY_* is really not good enough, we can change them
PROPERTY_ENTRY_*. But is PROP_ENTRY_* really so bad?
Rafael, what is your opinion?
Thanks,
--
heikki
From: Heikki Krogerus <heikki.krogerus@linux.intel.com> Date: 2015-08-06 08:32:35
On Wed, Aug 05, 2015 at 05:07:29PM +0300, Andy Shevchenko wrote:
On Wed, 2015-08-05 at 16:39 +0300, Heikki Krogerus wrote:
quoted
Helper for finding the type based on name. Useful if the
type needs to be determined based on device property.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
include/linux/rfkill.h | 15 +++++++++++++
net/rfkill/core.c | 57 +++++++++++++++++++++++++---------------
----------
2 files changed, 44 insertions(+), 28 deletions(-)
Hmm… Besides 0 is implicitly casted to enum type the issue with enums
that you rather have to supply existing enum entry. I would suggest to
add RFKILL_TYPE_UNKNOWN if _ALL is reserved for some use cases.
Why would you add a new type just for this? You do realize it would
require adding specific handling all over the place? RFKILL_TYPE_ALL
(0) is already handled as an invalid type. Confused?
I'll change this and return RFKILL_TYPE_ALL instead of 0.
Thanks,
--
heikki
Hmm… Besides 0 is implicitly casted to enum type the issue with
enums
that you rather have to supply existing enum entry. I would suggest
to
add RFKILL_TYPE_UNKNOWN if _ALL is reserved for some use cases.
Why would you add a new type just for this? You do realize it would
require adding specific handling all over the place? RFKILL_TYPE_ALL
(0) is already handled as an invalid type.
It was my thought as well (see *if* in my previous comment).
Confused?
A bit, yes.
I'll change this and return RFKILL_TYPE_ALL instead of 0.
Excellent!
--
Andy Shevchenko [off-list ref]
Intel Finland Oy
PROP_ prefix is too generic.
Maybe DEVPROP_ ? At least for the latter no records in the current
sources.
I disagree with that. IMO this kind of macros should ideally resemble
the structure name they are used to fill (struct property_entry in
this case). And there are already definitions for DEV_PROP_* to
describe the types, so using something like DEVPROP_* here is just
confusing.
If PROP_ENTRY_* is really not good enough, we can change them
PROPERTY_ENTRY_*. But is PROP_ENTRY_* really so bad?
Rafael, what is your opinion?
I would prefer PROPERTY_ENTRY_ to be honest. It's not like we need to save
characters here.
Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
That BUILD_BUG_ON() is now less useful - previously it pointed to the
code that needed to change, now you're left wondering if you don't look
up since it isn't quite that obvious from the code what this does.
Something like
BUILD_BUG_ON(rfkill_types[NUM_RFKILL_TYPES - 1] == NULL);
would be better. As we only add here, that would be safe enough - I've
done something similar in the past that a bit more complicated.
With that and the static inline fixed (which maybe you could even
remove) I'm fine with all these rfkill patches, but I'm not sure how to
merge them since they affect all kinds of other trees. If desired, I
can apply them, but an ACK from the tegra maintainer would be good :)
johannes
That BUILD_BUG_ON() is now less useful - previously it pointed to the
code that needed to change, now you're left wondering if you don't look
up since it isn't quite that obvious from the code what this does.
Something like
BUILD_BUG_ON(rfkill_types[NUM_RFKILL_TYPES - 1] == NULL);
would be better. As we only add here, that would be safe enough - I've
done something similar in the past that a bit more complicated.
OK, I'll change it.
With that and the static inline fixed (which maybe you could even
remove) I'm fine with all these rfkill patches, but I'm not sure how to
merge them since they affect all kinds of other trees. If desired, I
can apply them, but an ACK from the tegra maintainer would be good :)
Andy and Mika are preparing some changes to the device property
handling. I'll wait for their proposal and prepare next version these
after that.
Thanks,
--
heikki