public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [serial] Calling platform specific code on driver bind/unbind
@ 2015-12-04 21:37 Piotr Madalinski
  2015-12-12 23:58 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Piotr Madalinski @ 2015-12-04 21:37 UTC (permalink / raw)
  To: linux-kernel

Hi,
I'm hacking my openwrt router and look for a proper way to make a serial 
driver call a platform-specific function such as this:

static void ath79_enable_uart(void) {
     if (soc_is_ar933x())
         ath79_gpio_function_enable(AR933X_GPIO_FUNC_UART_EN);
}

and

static void ath79_disable_uart(void) {
     if (soc_is_ar933x())
         ath79_gpio_function_disable(AR933X_GPIO_FUNC_UART_EN);
}

on driver bind/unbind instead of in platform initialization code, in 
order to be able to
reuse the pins as gpio, without disabling uart entirely.

My current solution uses platform_data to pass function pointers,
and invokes them in driver's request_port and release_port functions 
respectively.

And, oddly enough, the one in release_port gets invoked on unbind but 
the other one
isn't called on bind (I had to add a call to it in probe to get it working).

So I wonder, if the request/release functions are a proper place for 
such a callback,
or is there some better, more 'canonical' solution.

Also, I could attach my patches but it is my first post here, and they 
are a bit openwrt specific,
and I don't want to be yelled upon ;-).

Regards,
Piotr Madalinski

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [serial] Calling platform specific code on driver bind/unbind
  2015-12-04 21:37 [serial] Calling platform specific code on driver bind/unbind Piotr Madalinski
@ 2015-12-12 23:58 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2015-12-12 23:58 UTC (permalink / raw)
  To: Piotr Madalinski; +Cc: linux-kernel@vger.kernel.org

On Fri, Dec 4, 2015 at 11:37 PM, Piotr Madalinski
<piotr.madalinski@yahoo.pl> wrote:
> Hi,
> I'm hacking my openwrt router and look for a proper way to make a serial
> driver call a platform-specific function such as this:
>
> static void ath79_enable_uart(void) {
>     if (soc_is_ar933x())
>         ath79_gpio_function_enable(AR933X_GPIO_FUNC_UART_EN);
> }
>
> and
>
> static void ath79_disable_uart(void) {
>     if (soc_is_ar933x())
>         ath79_gpio_function_disable(AR933X_GPIO_FUNC_UART_EN);
> }
>
> on driver bind/unbind instead of in platform initialization code, in order
> to be able to
> reuse the pins as gpio, without disabling uart entirely.
>
> My current solution uses platform_data to pass function pointers,
> and invokes them in driver's request_port and release_port functions
> respectively.
>
> And, oddly enough, the one in release_port gets invoked on unbind but the
> other one
> isn't called on bind (I had to add a call to it in probe to get it working).
>
> So I wonder, if the request/release functions are a proper place for such a
> callback,
> or is there some better, more 'canonical' solution.

pinctrl framework / API?

>
> Also, I could attach my patches but it is my first post here, and they are a
> bit openwrt specific,
> and I don't want to be yelled upon ;-).



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-12 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 21:37 [serial] Calling platform specific code on driver bind/unbind Piotr Madalinski
2015-12-12 23:58 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox