From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756584AbbLDVn5 (ORCPT ); Fri, 4 Dec 2015 16:43:57 -0500 Received: from nm27-vm6.bullet.mail.ir2.yahoo.com ([212.82.97.57]:37293 "EHLO nm27-vm6.bullet.mail.ir2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754974AbbLDVn4 (ORCPT ); Fri, 4 Dec 2015 16:43:56 -0500 X-Greylist: delayed 376 seconds by postgrey-1.27 at vger.kernel.org; Fri, 04 Dec 2015 16:43:55 EST X-Yahoo-Newman-Id: 414150.89652.bm@smtp137.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 9AJsjW8VM1nPHPgmbLrPyPc_rxBDArNT2BNPhiMnp11xPp. E1GttgBnR6IDXKQjCm15yR_UimLI9lTANObnF5CqE6Adrm74tbTG041MnE.3 gePVZAhWnzBgfvIZoym0m3ezW91toBTs1nFvYuSjWSW5c0mKQgvQLBOoE4i6 qatgwhGWWR897k4cFGhye4nlGSGItTevtSNcvm.TY6V9SGsMh2NPMx431c4f JX311olNoxJYKlYS5Nf3v0U1E2.V_elKl0pUzGXzOqMyYlUDQ5ft70BHYWGR kTfzec69MMKLwckPgMk0Vslhu8DCpwWizeWjfo9XZozZy7jJGrotzJQTgNB4 6Jp.3PgmUtaT.OqYH53Xp3J2bciv2lcKWc36owaUGWNTVEahUU8k95GZWGsK UJDJBupBtQIuIJAu3_57LbvYg_xyPts9gTSLa.sUraOlq9N8HjsI4iNTKLft nMF0Z1oPBOZ.Jp7O.kgKx1iFNxqwrYXOyBQg4lgL2yYpUVcont5Sv.T9s_ek tYPDLFpW05w-- X-Yahoo-SMTP: T3BOYFSswBCrsioizEjzBCy_qPeFhnof_jQzY4w- From: Piotr Madalinski Subject: [serial] Calling platform specific code on driver bind/unbind To: linux-kernel@vger.kernel.org Message-ID: <566207A1.4020409@yahoo.pl> Date: Fri, 4 Dec 2015 22:37:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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