forked from mirrors/linux
		
	pwm: Let pwm_get_state() return the last implemented state
When pwm_apply_state() is called the lowlevel driver usually has to apply some rounding because the hardware doesn't support nanosecond resolution. So let pwm_get_state() return the actually implemented state instead of the last applied one if possible. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
		
							parent
							
								
									fc3c5512e3
								
							
						
					
					
						commit
						01ccf903ed
					
				
					 1 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
					@ -474,7 +474,14 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
 | 
				
			||||||
		if (err)
 | 
							if (err)
 | 
				
			||||||
			return err;
 | 
								return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pwm->state = *state;
 | 
							/*
 | 
				
			||||||
 | 
							 * .apply might have to round some values in *state, if possible
 | 
				
			||||||
 | 
							 * read the actually implemented value back.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							if (chip->ops->get_state)
 | 
				
			||||||
 | 
								chip->ops->get_state(chip, pwm, &pwm->state);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								pwm->state = *state;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * FIXME: restore the initial state in case of error.
 | 
							 * FIXME: restore the initial state in case of error.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue