* [PATCH 3/3][v2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions
@ 2015-01-21 16:46 Rojhalat Ibrahim
2015-02-09 5:18 ` Alexandre Courbot
0 siblings, 1 reply; 4+ messages in thread
From: Rojhalat Ibrahim @ 2015-01-21 16:46 UTC (permalink / raw)
To: linux-gpio; +Cc: Alexandre Courbot, Linus Walleij, David Miller, netdev
Use the new gpiod_get_array and gpiod_put_array functions for obtaining and
disposing of GPIO descriptors.
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
---
This patch depends on my previous patch "gpiolib: add gpiod_get_array and
gpiod_put_array functions".
v2: use the new interface
Only compile-tested.
drivers/net/phy/mdio-mux-gpio.c | 61 +++++++++++-----------------------------
1 file changed, 18 insertions(+), 43 deletions(-)
diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c
index 320eb15..3f6929c 100644
--- a/drivers/net/phy/mdio-mux-gpio.c
+++ b/drivers/net/phy/mdio-mux-gpio.c
@@ -12,33 +12,31 @@
#include <linux/module.h>
#include <linux/phy.h>
#include <linux/mdio-mux.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#define DRV_VERSION "1.1"
#define DRV_DESCRIPTION "GPIO controlled MDIO bus multiplexer driver"
-#define MDIO_MUX_GPIO_MAX_BITS 8
-
struct mdio_mux_gpio_state {
- struct gpio_desc *gpio[MDIO_MUX_GPIO_MAX_BITS];
- unsigned int num_gpios;
+ struct gpio_descs *gpios;
void *mux_handle;
};
static int mdio_mux_gpio_switch_fn(int current_child, int desired_child,
void *data)
{
- int values[MDIO_MUX_GPIO_MAX_BITS];
- unsigned int n;
struct mdio_mux_gpio_state *s = data;
+ int values[s->gpios->array_size];
+ unsigned int n;
if (current_child == desired_child)
return 0;
- for (n = 0; n < s->num_gpios; n++) {
+ for (n = 0; n < s->gpios->array_size; n++)
values[n] = (desired_child >> n) & 1;
- }
- gpiod_set_array_cansleep(s->num_gpios, s->gpio, values);
+
+ gpiod_set_array_cansleep(s->gpios->array_size, s->gpios->desc_array,
+ values);
return 0;
}
@@ -46,56 +44,33 @@ static int mdio_mux_gpio_switch_fn(int current_child, int desired_child,
static int mdio_mux_gpio_probe(struct platform_device *pdev)
{
struct mdio_mux_gpio_state *s;
- int num_gpios;
- unsigned int n;
int r;
- if (!pdev->dev.of_node)
- return -ENODEV;
-
- num_gpios = of_gpio_count(pdev->dev.of_node);
- if (num_gpios <= 0 || num_gpios > MDIO_MUX_GPIO_MAX_BITS)
- return -ENODEV;
-
s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL);
if (!s)
return -ENOMEM;
- s->num_gpios = num_gpios;
-
- for (n = 0; n < num_gpios; ) {
- struct gpio_desc *gpio = gpiod_get_index(&pdev->dev, NULL, n,
- GPIOD_OUT_LOW);
- if (IS_ERR(gpio)) {
- r = PTR_ERR(gpio);
- goto err;
- }
- s->gpio[n] = gpio;
- n++;
- }
+ s->gpios = gpiod_get_array(&pdev->dev, NULL, GPIOD_OUT_LOW);
+ if (IS_ERR(s->gpios))
+ return PTR_ERR(s->gpios);
r = mdio_mux_init(&pdev->dev,
mdio_mux_gpio_switch_fn, &s->mux_handle, s);
- if (r == 0) {
- pdev->dev.platform_data = s;
- return 0;
- }
-err:
- while (n) {
- n--;
- gpiod_put(s->gpio[n]);
+ if (r != 0) {
+ gpiod_put_array(s->gpios);
+ return r;
}
- return r;
+
+ pdev->dev.platform_data = s;
+ return 0;
}
static int mdio_mux_gpio_remove(struct platform_device *pdev)
{
- unsigned int n;
struct mdio_mux_gpio_state *s = dev_get_platdata(&pdev->dev);
mdio_mux_uninit(s->mux_handle);
- for (n = 0; n < s->num_gpios; n++)
- gpiod_put(s->gpio[n]);
+ gpiod_put_array(s->gpios);
return 0;
}
--
2.0.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3][v2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions
2015-01-21 16:46 [PATCH 3/3][v2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions Rojhalat Ibrahim
@ 2015-02-09 5:18 ` Alexandre Courbot
2015-02-09 9:14 ` Rojhalat Ibrahim
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Courbot @ 2015-02-09 5:18 UTC (permalink / raw)
To: Rojhalat Ibrahim
Cc: linux-gpio, Alexandre Courbot, Linus Walleij, David Miller, netdev
On Thu, Jan 22, 2015 at 1:46 AM, Rojhalat Ibrahim <imr@rtschenk.de> wrote:
> Use the new gpiod_get_array and gpiod_put_array functions for obtaining and
> disposing of GPIO descriptors.
>
> Cc: David Miller <davem@davemloft.net>
> Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
> ---
> This patch depends on my previous patch "gpiolib: add gpiod_get_array and
> gpiod_put_array functions".
>
> v2: use the new interface
>
> Only compile-tested.
>
> drivers/net/phy/mdio-mux-gpio.c | 61 +++++++++++-----------------------------
> 1 file changed, 18 insertions(+), 43 deletions(-)
Oh yeah.
It would be great to have a tested-by for the next revision though.
Rojhalat, have you been able to test these new interfaces outside of
this driver?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3][v2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions
2015-02-09 5:18 ` Alexandre Courbot
@ 2015-02-09 9:14 ` Rojhalat Ibrahim
2015-02-09 13:53 ` Alexandre Courbot
0 siblings, 1 reply; 4+ messages in thread
From: Rojhalat Ibrahim @ 2015-02-09 9:14 UTC (permalink / raw)
To: Alexandre Courbot
Cc: linux-gpio, Alexandre Courbot, Linus Walleij, David Miller, netdev
On Monday 09 February 2015 14:18:14 Alexandre Courbot wrote:
> On Thu, Jan 22, 2015 at 1:46 AM, Rojhalat Ibrahim <imr@rtschenk.de> wrote:
> > Use the new gpiod_get_array and gpiod_put_array functions for obtaining and
> > disposing of GPIO descriptors.
> >
> > Cc: David Miller <davem@davemloft.net>
> > Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
> > ---
> > This patch depends on my previous patch "gpiolib: add gpiod_get_array and
> > gpiod_put_array functions".
> >
> > v2: use the new interface
> >
> > Only compile-tested.
> >
> > drivers/net/phy/mdio-mux-gpio.c | 61 +++++++++++-----------------------------
> > 1 file changed, 18 insertions(+), 43 deletions(-)
>
> Oh yeah.
>
> It would be great to have a tested-by for the next revision though.
>
> Rojhalat, have you been able to test these new interfaces outside of
> this driver?
>
I have tested the new interface with my FPGA configuration driver (which I
plan to submit eventually). I cannot test the mdio-mux-gpio driver because
I lack the necessary hardware.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3][v2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions
2015-02-09 9:14 ` Rojhalat Ibrahim
@ 2015-02-09 13:53 ` Alexandre Courbot
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Courbot @ 2015-02-09 13:53 UTC (permalink / raw)
To: Rojhalat Ibrahim
Cc: linux-gpio, Alexandre Courbot, Linus Walleij, David Miller, netdev
On Mon, Feb 9, 2015 at 6:14 PM, Rojhalat Ibrahim <imr@rtschenk.de> wrote:
> On Monday 09 February 2015 14:18:14 Alexandre Courbot wrote:
>> On Thu, Jan 22, 2015 at 1:46 AM, Rojhalat Ibrahim <imr@rtschenk.de> wrote:
>> > Use the new gpiod_get_array and gpiod_put_array functions for obtaining and
>> > disposing of GPIO descriptors.
>> >
>> > Cc: David Miller <davem@davemloft.net>
>> > Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
>> > ---
>> > This patch depends on my previous patch "gpiolib: add gpiod_get_array and
>> > gpiod_put_array functions".
>> >
>> > v2: use the new interface
>> >
>> > Only compile-tested.
>> >
>> > drivers/net/phy/mdio-mux-gpio.c | 61 +++++++++++-----------------------------
>> > 1 file changed, 18 insertions(+), 43 deletions(-)
>>
>> Oh yeah.
>>
>> It would be great to have a tested-by for the next revision though.
>>
>> Rojhalat, have you been able to test these new interfaces outside of
>> this driver?
>>
>
> I have tested the new interface with my FPGA configuration driver (which I
> plan to submit eventually). I cannot test the mdio-mux-gpio driver because
> I lack the necessary hardware.
That's good enough - I just want to make sure the interface has
undergone some testing. :P
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-09 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 16:46 [PATCH 3/3][v2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions Rojhalat Ibrahim
2015-02-09 5:18 ` Alexandre Courbot
2015-02-09 9:14 ` Rojhalat Ibrahim
2015-02-09 13:53 ` Alexandre Courbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).