@@ -235,18 +235,8 @@ EXPORT_SYMBOL_GPL(pwm_get_chip_data);
235235
236236static  bool  pwm_ops_check (const  struct  pwm_chip  * chip )
237237{
238- 
239238	const  struct  pwm_ops  * ops  =  chip -> ops ;
240239
241- 	/* driver supports legacy, non-atomic operation */ 
242- 	if  (ops -> config  &&  ops -> enable  &&  ops -> disable ) {
243- 		if  (IS_ENABLED (CONFIG_PWM_DEBUG ))
244- 			dev_warn (chip -> dev ,
245- 				 "Driver needs updating to atomic API\n" );
246- 
247- 		return  true;
248- 	}
249- 
250240	if  (!ops -> apply )
251241		return  false;
252242
@@ -548,73 +538,6 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
548538	}
549539}
550540
551- static  int  pwm_apply_legacy (struct  pwm_chip  * chip , struct  pwm_device  * pwm ,
552- 			    const  struct  pwm_state  * state )
553- {
554- 	int  err ;
555- 	struct  pwm_state  initial_state  =  pwm -> state ;
556- 
557- 	if  (state -> polarity  !=  pwm -> state .polarity ) {
558- 		if  (!chip -> ops -> set_polarity )
559- 			return  - EINVAL ;
560- 
561- 		/* 
562- 		 * Changing the polarity of a running PWM is only allowed when 
563- 		 * the PWM driver implements ->apply(). 
564- 		 */ 
565- 		if  (pwm -> state .enabled ) {
566- 			chip -> ops -> disable (chip , pwm );
567- 
568- 			/* 
569- 			 * Update pwm->state already here in case 
570- 			 * .set_polarity() or another callback depend on that. 
571- 			 */ 
572- 			pwm -> state .enabled  =  false;
573- 		}
574- 
575- 		err  =  chip -> ops -> set_polarity (chip , pwm , state -> polarity );
576- 		if  (err )
577- 			goto rollback ;
578- 
579- 		pwm -> state .polarity  =  state -> polarity ;
580- 	}
581- 
582- 	if  (!state -> enabled ) {
583- 		if  (pwm -> state .enabled )
584- 			chip -> ops -> disable (chip , pwm );
585- 
586- 		return  0 ;
587- 	}
588- 
589- 	/* 
590- 	 * We cannot skip calling ->config even if state->period == 
591- 	 * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle 
592- 	 * because we might have exited early in the last call to 
593- 	 * pwm_apply_state because of !state->enabled and so the two values in 
594- 	 * pwm->state might not be configured in hardware. 
595- 	 */ 
596- 	err  =  chip -> ops -> config (pwm -> chip , pwm ,
597- 				state -> duty_cycle ,
598- 				state -> period );
599- 	if  (err )
600- 		goto rollback ;
601- 
602- 	pwm -> state .period  =  state -> period ;
603- 	pwm -> state .duty_cycle  =  state -> duty_cycle ;
604- 
605- 	if  (!pwm -> state .enabled ) {
606- 		err  =  chip -> ops -> enable (chip , pwm );
607- 		if  (err )
608- 			goto rollback ;
609- 	}
610- 
611- 	return  0 ;
612- 
613- rollback :
614- 	pwm -> state  =  initial_state ;
615- 	return  err ;
616- }
617- 
618541/** 
619542 * pwm_apply_state() - atomically apply a new state to a PWM device 
620543 * @pwm: PWM device 
@@ -647,10 +570,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
647570	    state -> usage_power  ==  pwm -> state .usage_power )
648571		return  0 ;
649572
650- 	if  (chip -> ops -> apply )
651- 		err  =  chip -> ops -> apply (chip , pwm , state );
652- 	else 
653- 		err  =  pwm_apply_legacy (chip , pwm , state );
573+ 	err  =  chip -> ops -> apply (chip , pwm , state );
654574	if  (err )
655575		return  err ;
656576
0 commit comments