diff mbox series

tty: st-asc: switch to using devm_fwnode_gpiod_get()

Message ID 20200103012053.GA1968@dtor-ws (mailing list archive)
State New, archived
Headers show
Series tty: st-asc: switch to using devm_fwnode_gpiod_get() | expand

Commit Message

Dmitry Torokhov Jan. 3, 2020, 1:20 a.m. UTC
devm_fwnode_get_gpiod_from_child() is going away as the name is too
unwieldy, let's switch to using the new devm_fwnode_gpiod_get().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/tty/serial/st-asc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Dmitry Torokhov Jan. 3, 2020, 6:23 p.m. UTC | #1
On Thu, Jan 02, 2020 at 05:20:53PM -0800, Dmitry Torokhov wrote:
> devm_fwnode_get_gpiod_from_child() is going away as the name is too
> unwieldy, let's switch to using the new devm_fwnode_gpiod_get().

Ugh, please ignore this, apparently I haven't compiled this branch...
Additionally, I think we can use standard devm_gpiod_get() here as node
is the same as the device in question.
kernel test robot Jan. 4, 2020, 4:52 a.m. UTC | #2
Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on tty/tty-testing]
[also build test ERROR on v5.5-rc4 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/tty-st-asc-switch-to-using-devm_fwnode_gpiod_get/20200104-090945
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: x86_64-randconfig-a002-20200102 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-3) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/tty/serial/st-asc.c: In function 'asc_set_termios':
>> drivers/tty/serial/st-asc.c:570:13: error: implicit declaration of function 'of_fwhandle_node'; did you mean 'of_match_node'? [-Werror=implicit-function-declaration]
                of_fwhandle_node(np),
                ^~~~~~~~~~~~~~~~
                of_match_node
   drivers/tty/serial/st-asc.c:570:13: warning: passing argument 2 of 'devm_fwnode_gpiod_get' makes pointer from integer without a cast [-Wint-conversion]
   In file included from drivers/tty/serial/st-asc.c:25:0:
   include/linux/gpio/consumer.h:560:19: note: expected 'struct fwnode_handle *' but argument is of type 'int'
    struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
                      ^~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +570 drivers/tty/serial/st-asc.c

   502	
   503	static void asc_set_termios(struct uart_port *port, struct ktermios *termios,
   504				    struct ktermios *old)
   505	{
   506		struct asc_port *ascport = to_asc_port(port);
   507		struct device_node *np = port->dev->of_node;
   508		struct gpio_desc *gpiod;
   509		unsigned int baud;
   510		u32 ctrl_val;
   511		tcflag_t cflag;
   512		unsigned long flags;
   513	
   514		/* Update termios to reflect hardware capabilities */
   515		termios->c_cflag &= ~(CMSPAR |
   516				 (ascport->hw_flow_control ? 0 : CRTSCTS));
   517	
   518		port->uartclk = clk_get_rate(ascport->clk);
   519	
   520		baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
   521		cflag = termios->c_cflag;
   522	
   523		spin_lock_irqsave(&port->lock, flags);
   524	
   525		/* read control register */
   526		ctrl_val = asc_in(port, ASC_CTL);
   527	
   528		/* stop serial port and reset value */
   529		asc_out(port, ASC_CTL, (ctrl_val & ~ASC_CTL_RUN));
   530		ctrl_val = ASC_CTL_RXENABLE | ASC_CTL_FIFOENABLE;
   531	
   532		/* reset fifo rx & tx */
   533		asc_out(port, ASC_TXRESET, 1);
   534		asc_out(port, ASC_RXRESET, 1);
   535	
   536		/* set character length */
   537		if ((cflag & CSIZE) == CS7) {
   538			ctrl_val |= ASC_CTL_MODE_7BIT_PAR;
   539		} else {
   540			ctrl_val |= (cflag & PARENB) ?  ASC_CTL_MODE_8BIT_PAR :
   541							ASC_CTL_MODE_8BIT;
   542		}
   543	
   544		/* set stop bit */
   545		ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT;
   546	
   547		/* odd parity */
   548		if (cflag & PARODD)
   549			ctrl_val |= ASC_CTL_PARITYODD;
   550	
   551		/* hardware flow control */
   552		if ((cflag & CRTSCTS)) {
   553			ctrl_val |= ASC_CTL_CTSENABLE;
   554	
   555			/* If flow-control selected, stop handling RTS manually */
   556			if (ascport->rts) {
   557				devm_gpiod_put(port->dev, ascport->rts);
   558				ascport->rts = NULL;
   559	
   560				pinctrl_select_state(ascport->pinctrl,
   561						     ascport->states[DEFAULT]);
   562			}
   563		} else {
   564			/* If flow-control disabled, it's safe to handle RTS manually */
   565			if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) {
   566				pinctrl_select_state(ascport->pinctrl,
   567						     ascport->states[NO_HW_FLOWCTRL]);
   568	
   569				gpiod = devm_fwnode_gpiod_get(port->dev,
 > 570							      of_fwhandle_node(np),
   571							      "rts",
   572							      GPIOD_OUT_LOW,
   573							      np->name);
   574				if (!IS_ERR(gpiod))
   575					ascport->rts = gpiod;
   576			}
   577		}
   578	
   579		if ((baud < 19200) && !ascport->force_m1) {
   580			asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud)));
   581		} else {
   582			/*
   583			 * MODE 1: recommended for high bit rates (above 19.2K)
   584			 *
   585			 *                   baudrate * 16 * 2^16
   586			 * ASCBaudRate =   ------------------------
   587			 *                          inputclock
   588			 *
   589			 * To keep maths inside 64bits, we divide inputclock by 16.
   590			 */
   591			u64 dividend = (u64)baud * (1 << 16);
   592	
   593			do_div(dividend, port->uartclk / 16);
   594			asc_out(port, ASC_BAUDRATE, dividend);
   595			ctrl_val |= ASC_CTL_BAUDMODE;
   596		}
   597	
   598		uart_update_timeout(port, cflag, baud);
   599	
   600		ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE;
   601		if (termios->c_iflag & INPCK)
   602			ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE;
   603		if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
   604			ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE;
   605	
   606		/*
   607		 * Characters to ignore
   608		 */
   609		ascport->port.ignore_status_mask = 0;
   610		if (termios->c_iflag & IGNPAR)
   611			ascport->port.ignore_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE;
   612		if (termios->c_iflag & IGNBRK) {
   613			ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_BE;
   614			/*
   615			 * If we're ignoring parity and break indicators,
   616			 * ignore overruns too (for real raw support).
   617			 */
   618			if (termios->c_iflag & IGNPAR)
   619				ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_OE;
   620		}
   621	
   622		/*
   623		 * Ignore all characters if CREAD is not set.
   624		 */
   625		if (!(termios->c_cflag & CREAD))
   626			ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_RX;
   627	
   628		/* Set the timeout */
   629		asc_out(port, ASC_TIMEOUT, 20);
   630	
   631		/* write final value and enable port */
   632		asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN));
   633	
   634		spin_unlock_irqrestore(&port->lock, flags);
   635	}
   636	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
diff mbox series

Patch

diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index fb6bbb5e22344..3a533a0f172bd 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -566,11 +566,11 @@  static void asc_set_termios(struct uart_port *port, struct ktermios *termios,
 			pinctrl_select_state(ascport->pinctrl,
 					     ascport->states[NO_HW_FLOWCTRL]);
 
-			gpiod = devm_fwnode_get_gpiod_from_child(port->dev,
-								 "rts",
-								 &np->fwnode,
-								 GPIOD_OUT_LOW,
-								 np->name);
+			gpiod = devm_fwnode_gpiod_get(port->dev,
+						      of_fwhandle_node(np),
+						      "rts",
+						      GPIOD_OUT_LOW,
+						      np->name);
 			if (!IS_ERR(gpiod))
 				ascport->rts = gpiod;
 		}