SALEM – A Lynn man caught dealing cocaine twice in 2006 who pleaded guilty to avoid a trial received up to five years in state prison in Salem Superior Court Thursday.Barry Smith, 37, who last lived at 17 Acorn St., apt. #2, pleaded guilty to two counts of possession of cocaine with the intent to distribute.Judge David A. Lowy sentenced him to serve not less than three years and not more than five years in state prison.The judge agreed to adopt the recommendation by prosecutors and the defense.Because he now has two drug convictions on his record, Smith will be losing his driving privileges in Massachusetts for at least five years.Assistant District Attorney Michael A. Patten gave a summation concerning the two cases against Smith in 2006.Patten said it was shortly before 8 p.m., on Sept. 2 when Lynn police detectives Paul Holey and Geovanni R. Ruano were on patrol on Washington Street and observed a man in a green Ford Taurus in a parking lot near 110 Washington St. conducting what they believed to be a drug deal.As they approached the vehicle they found Smith behind the wheel clenching his left hand.A search revealed seven glassine twists of crack cocaine. Smith told police he sells drugs “part time,” and consented that they searched his home on Acorn Street where they found a small quantity of additional cocaine and $2,200 in cash.Then, while out on bail on Oct. 26 he was arrested in the area of 72 Washington St. with 25 twists of cocaine found in a deodorant container under the driver?s seat of the Ford sedan.Although Smith previously was convicted of dealing cocaine in 1996 out of Lynn District Court, the commonwealth agreed not to prosecute.Smith has been held in custody in lieu of bail since being arrested and will receive credit for the time he spent in jail awaiting trial on the two cases.