From: Markus Pargmann <mpa@pengutronix•de>
To: kernel@pengutronix•de
Cc: Michael Grzeschik <m.grzeschik@pengutronix•de>,
mkl@pengutronix•de, wg@grandegger•com, netdev@vger•kernel.org,
linux-kernel@vger•kernel.org, linux-can@vger•kernel.org
Subject: Re: [PATCH v2] can: c_can: add xceiver enable/disable support
Date: Wed, 20 Jan 2016 15:01:18 +0100 [thread overview]
Message-ID: <2136394.8KvYBfKku7@adelgunde> (raw)
In-Reply-To: <1453297443-23279-1-git-send-email-m.grzeschik@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 2641 bytes --]
Hi,
On Wednesday 20 January 2016 14:44:03 Michael Grzeschik wrote:
> This patch adds support to enable and disable the xceiver
> in case it's switchable by the regulator framework.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix•de>
Reviewed-by: Markus Pargmann <mpa@pengutronix•de>
> ---
> v1 -> v2:
> - always returning PTR_ERR in case devm_regulator_get fails
> - removed inline wrapper functions with checks for xceiver == NULL
>
> drivers/net/can/c_can/c_can.c | 12 ++++++++++++
> drivers/net/can/c_can/c_can.h | 1 +
> 2 files changed, 13 insertions(+)
>
> diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
> index f91b094..0723aeb 100644
> --- a/drivers/net/can/c_can/c_can.c
> +++ b/drivers/net/can/c_can/c_can.c
> @@ -36,6 +36,7 @@
> #include <linux/io.h>
> #include <linux/pm_runtime.h>
> #include <linux/pinctrl/consumer.h>
> +#include <linux/regulator/consumer.h>
>
> #include <linux/can.h>
> #include <linux/can/dev.h>
> @@ -612,6 +613,10 @@ static int c_can_start(struct net_device *dev)
> else
> pinctrl_pm_select_default_state(priv->device);
>
> + err = regulator_enable(priv->reg_xceiver);
> + if (err)
> + return err;
> +
> return 0;
> }
>
> @@ -626,6 +631,9 @@ static void c_can_stop(struct net_device *dev)
>
> /* deactivate pins */
> pinctrl_pm_select_sleep_state(dev->dev.parent);
> +
> + regulator_disable(priv->reg_xceiver);
> +
> priv->can.state = CAN_STATE_STOPPED;
> }
>
> @@ -1263,6 +1271,10 @@ int register_c_can_dev(struct net_device *dev)
> */
> pinctrl_pm_select_sleep_state(dev->dev.parent);
>
> + priv->reg_xceiver = devm_regulator_get(priv->device, "xceiver");
> + if (IS_ERR(priv->reg_xceiver))
> + return PTR_ERR(priv->reg_xceiver);
> +
> c_can_pm_runtime_enable(priv);
>
> dev->flags |= IFF_ECHO; /* we support local echo */
> diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
> index 8acdc7f..59246e3 100644
> --- a/drivers/net/can/c_can/c_can.h
> +++ b/drivers/net/can/c_can/c_can.h
> @@ -213,6 +213,7 @@ struct c_can_priv {
> u32 comm_rcv_high;
> u32 rxmasked;
> u32 dlc[C_CAN_MSG_OBJ_TX_NUM];
> + struct regulator *reg_xceiver;
> };
>
> struct net_device *alloc_c_can_dev(void);
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-01-20 14:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-20 13:44 [PATCH v2] can: c_can: add xceiver enable/disable support Michael Grzeschik
2016-01-20 14:01 ` Markus Pargmann [this message]
2016-01-20 14:11 ` Kurt Van Dijck
2016-01-20 14:29 ` Marc Kleine-Budde
2016-01-20 14:29 ` Markus Pargmann
2016-01-20 16:19 ` Bjørn Mork
2016-01-20 16:46 ` Michael Grzeschik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2136394.8KvYBfKku7@adelgunde \
--to=mpa@pengutronix$(echo .)de \
--cc=kernel@pengutronix$(echo .)de \
--cc=linux-can@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=m.grzeschik@pengutronix$(echo .)de \
--cc=mkl@pengutronix$(echo .)de \
--cc=netdev@vger$(echo .)kernel.org \
--cc=wg@grandegger$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox