Commit ce4065e9 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

debug cleanup

parent 8d9930c5
Loading
Loading
Loading
Loading
+15 −14
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@
 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 */


#define DEBUG /* should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)*/
#include <linux/i2c.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
@@ -3783,7 +3784,7 @@ static int set_ms_p123(struct i2c_client *client,u32 * p123, int chn) /* chn 0,1
		else p123[0]=256;
		else p123[0]=256;
		p123[1]=0;
		p123[1]=0;
		p123[2]=1;
		p123[2]=1;
		dev_info(&client->dev, "Using high speed divisor option on ms%d",chn);
		dev_dbg(&client->dev, "Using high speed divisor option on ms%d",chn);
	} else hs=0;
	} else hs=0;
	if (((rc=write_field(client, hs, awe_ms_hs[chn])))<0) return rc;
	if (((rc=write_field(client, hs, awe_ms_hs[chn])))<0) return rc;
	/* optionally disable spread spectrum before changing frequency */
	/* optionally disable spread spectrum before changing frequency */
@@ -4574,7 +4575,7 @@ static void si5338_init_of(struct i2c_client *client)
				return;
				return;
			} else if (i>0){
			} else if (i>0){
				init_type=0;
				init_type=0;
				dev_info(&client->dev,"Skipping conditional initialization (some driver variables will not be initialized)\n");
				dev_dbg(&client->dev,"Skipping conditional initialization (some driver variables will not be initialized)\n");
				return;
				return;
			}
			}
			init_type=1;
			init_type=1;
@@ -4588,7 +4589,7 @@ static void si5338_init_of(struct i2c_client *client)
		if (config_data){
		if (config_data){
			len /= sizeof(*config_data);
			len /= sizeof(*config_data);
			dev_dbg(&client->dev,"Read %d values\n",len);
			dev_dbg(&client->dev,"Read %d values\n",len);
			dev_info(&client->dev,"Found %d items in 'si5338,configuration_data' in the Device Tree\n",len);
			dev_dbg(&client->dev,"Found %d items in 'si5338,configuration_data' in the Device Tree\n",len);
			for (i=0;i<len;i++){
			for (i=0;i<len;i++){
				*setup_data_be32=config_data[i];
				*setup_data_be32=config_data[i];
				page_reg=setup_data.reg+(setup_data.page<<8);
				page_reg=setup_data.reg+(setup_data.page<<8);
@@ -4603,7 +4604,7 @@ static void si5338_init_of(struct i2c_client *client)
			sprintf(buf,"si5338,%s",in_freq_names[n]);
			sprintf(buf,"si5338,%s",in_freq_names[n]);
			config_data = of_get_property(client->dev.of_node, buf, &len);
			config_data = of_get_property(client->dev.of_node, buf, &len);
			if (config_data && (len>0)){
			if (config_data && (len>0)){
				dev_info(&client->dev,"Found '%s', value = %d (0x%x)\n",buf,(int)(be32_to_cpup(config_data)),(int)(be32_to_cpup(config_data)));
				dev_dbg(&client->dev,"Found '%s', value = %d (0x%x)\n",buf,(int)(be32_to_cpup(config_data)),(int)(be32_to_cpup(config_data)));
				if (set_in_frequency(client, be32_to_cpup(config_data),n)<0) return; /* 32 bits are sufficient here */
				if (set_in_frequency(client, be32_to_cpup(config_data),n)<0) return; /* 32 bits are sufficient here */
			}
			}
		}
		}
@@ -4621,7 +4622,7 @@ static void si5338_init_of(struct i2c_client *client)
					freq[1]=be32_to_cpup(&config_data[1]);
					freq[1]=be32_to_cpup(&config_data[1]);
					freq[2]=be32_to_cpup(&config_data[2]);
					freq[2]=be32_to_cpup(&config_data[2]);
				}
				}
				dev_info(&client->dev,"Found '%s', value = %lld+(%lld/%lld)\n",buf,freq[0],freq[1],freq[2]);
				dev_dbg(&client->dev,"Found '%s', value = %lld+(%lld/%lld)\n",buf,freq[0],freq[1],freq[2]);
				if (n & 2){ /* by output */
				if (n & 2){ /* by output */
					if (set_pll_freq_by_out(client, freq, n & 1)<0) return;
					if (set_pll_freq_by_out(client, freq, n & 1)<0) return;
				} else { /* directly set  PLL frequency */
				} else { /* directly set  PLL frequency */
@@ -4645,7 +4646,7 @@ static void si5338_init_of(struct i2c_client *client)
					freq[1]=be32_to_cpup(&config_data[1]);
					freq[1]=be32_to_cpup(&config_data[1]);
					freq[2]=be32_to_cpup(&config_data[2]);
					freq[2]=be32_to_cpup(&config_data[2]);
				}
				}
				dev_info(&client->dev,"Found '%s', value = %lld+(%lld/%lld)\n",buf,freq[0],freq[1],freq[2]);
				dev_dbg(&client->dev,"Found '%s', value = %lld+(%lld/%lld)\n",buf,freq[0],freq[1],freq[2]);
				if (set_out_frequency_and_route(client, freq, n&3, n>>2)<0) return;
				if (set_out_frequency_and_route(client, freq, n&3, n>>2)<0) return;
			}
			}
		}
		}
@@ -4657,7 +4658,7 @@ static void si5338_init_of(struct i2c_client *client)
				len /= sizeof(*config_data);
				len /= sizeof(*config_data);
				for (i=0;i<len;i++){
				for (i=0;i<len;i++){
					*setup_data_be32=config_data[i];
					*setup_data_be32=config_data[i];
					dev_info(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					dev_dbg(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					if (configure_output_driver(&client->dev, drv_configs[n].description, setup_data.mask)<0) return;
					if (configure_output_driver(&client->dev, drv_configs[n].description, setup_data.mask)<0) return;
				}
				}
			}
			}
@@ -4671,7 +4672,7 @@ static void si5338_init_of(struct i2c_client *client)
				len /= sizeof(*config_data);
				len /= sizeof(*config_data);
				for (i=0;i<len;i++){
				for (i=0;i<len;i++){
					*setup_data_be32=config_data[i];
					*setup_data_be32=config_data[i];
					dev_info(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					dev_dbg(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					if (set_drv_disable(client, n, setup_data.mask)<0) return;
					if (set_drv_disable(client, n, setup_data.mask)<0) return;
				}
				}
			}
			}
@@ -4685,7 +4686,7 @@ static void si5338_init_of(struct i2c_client *client)
				len /= sizeof(*config_data);
				len /= sizeof(*config_data);
				for (i=0;i<len;i++){
				for (i=0;i<len;i++){
					*setup_data_be32=config_data[i];
					*setup_data_be32=config_data[i];
					dev_info(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					dev_dbg(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					if (set_drv_powerdown(client, n, setup_data.mask)<0) return;
					if (set_drv_powerdown(client, n, setup_data.mask)<0) return;
				}
				}
			}
			}
@@ -4699,7 +4700,7 @@ static void si5338_init_of(struct i2c_client *client)
				len /= sizeof(*config_data);
				len /= sizeof(*config_data);
				for (i=0;i<len;i++){
				for (i=0;i<len;i++){
					*setup_data_be32=config_data[i];
					*setup_data_be32=config_data[i];
					dev_info(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					dev_dbg(&client->dev,"Setting '%s', channel %d",buf,setup_data.mask);
					if (set_drv_disable(client, n, setup_data.mask)<0) return;
					if (set_drv_disable(client, n, setup_data.mask)<0) return;
				}
				}
			}
			}
@@ -4715,7 +4716,7 @@ static void si5338_init_of(struct i2c_client *client)
				if (len>1) amp =  be32_to_cpup(&config_data[1]);
				if (len>1) amp =  be32_to_cpup(&config_data[1]);
				if (len>2) rate = be32_to_cpup(&config_data[2]);
				if (len>2) rate = be32_to_cpup(&config_data[2]);
				if (store_ss_down_parameters(client, rate, amp, n)==0){ 
				if (store_ss_down_parameters(client, rate, amp, n)==0){ 
					dev_info(&client->dev,"Set spread spectrum parameters for MS%d, amplitude=%d (*0.01%%), rate=%d Hz, %s\n",
					dev_dbg(&client->dev,"Set spread spectrum parameters for MS%d, amplitude=%d (*0.01%%), rate=%d Hz, %s\n",
							n,amp,rate,config_data[0]?"ON":"OFF");
							n,amp,rate,config_data[0]?"ON":"OFF");
				} else {
				} else {
					dev_err(&client->dev,"Failed to set spread spectrum parameters for MS%d, amplitude=%d (*0.01%%), rate=%d Hz, %s\n",
					dev_err(&client->dev,"Failed to set spread spectrum parameters for MS%d, amplitude=%d (*0.01%%), rate=%d Hz, %s\n",
@@ -4725,9 +4726,9 @@ static void si5338_init_of(struct i2c_client *client)
				if (config_data[0]){ /* enable SS */
				if (config_data[0]){ /* enable SS */
					if ((set_ss_down(client, n)==0) && /* calculate and set SS registers */
					if ((set_ss_down(client, n)==0) && /* calculate and set SS registers */
							(set_ss_state(client, 1, n)==0)){ // enable SS. Not using enable_spread_spectrum() as we'll reset MS later anyway
							(set_ss_state(client, 1, n)==0)){ // enable SS. Not using enable_spread_spectrum() as we'll reset MS later anyway
						dev_info(&client->dev,"Spread spectrum enabled for MS%d\n",n);
						dev_dbg(&client->dev,"Spread spectrum enabled for MS%d\n",n);
					} else {
					} else {
						dev_info(&client->dev,"Fail to enable spread spectrum for MS%d\n",n);
						dev_err(&client->dev,"Fail to enable spread spectrum for MS%d\n",n);
					}
					}
				}
				}
			}
			}
@@ -4764,7 +4765,7 @@ static int si5338_i2c_probe(struct i2c_client *client,
	if (((rc=_write_single_reg(client, REG5338_PAGE,0)))<0) return rc; // did not respond
	if (((rc=_write_single_reg(client, REG5338_PAGE,0)))<0) return rc; // did not respond
	if (((rc=read_reg(client, REG5338_DEV_CONFIG2)))<0) return rc; // did not respond
	if (((rc=read_reg(client, REG5338_DEV_CONFIG2)))<0) return rc; // did not respond
	if ((rc & REG5338_DEV_CONFIG2_MASK)!= REG5338_DEV_CONFIG2_VAL){
	if ((rc & REG5338_DEV_CONFIG2_MASK)!= REG5338_DEV_CONFIG2_VAL){
		dev_info(&client->dev,
		dev_err(&client->dev,
			 "Chip returned unexpected value from reg %d: %d, expected %d. It is not %s\n",
			 "Chip returned unexpected value from reg %d: %d, expected %d. It is not %s\n",
			 REG5338_DEV_CONFIG2,rc, REG5338_DEV_CONFIG2_VAL,id->name);
			 REG5338_DEV_CONFIG2,rc, REG5338_DEV_CONFIG2_VAL,id->name);
		return -EIO;
		return -EIO;
+3 −3
Original line number Original line Diff line number Diff line
@@ -296,8 +296,8 @@ static int make_group (struct device *dev, const char * name, int port_mask, mod
		ssize_t (*show)(struct device *dev, struct device_attribute *attr,
		ssize_t (*show)(struct device *dev, struct device_attribute *attr,
				char *buf),
				char *buf),
		ssize_t (*store)(struct device *dev, struct device_attribute *attr,
		ssize_t (*store)(struct device *dev, struct device_attribute *attr,
				 const char *buf, size_t count)
				 const char *buf, size_t count))
){
{
	int retval=-1;
	int retval=-1;
	int port,index=0,num_regs;
	int port,index=0,num_regs;
	struct attribute **pattrs; /* array of pointers to attibutes */
	struct attribute **pattrs; /* array of pointers to attibutes */
@@ -790,7 +790,7 @@ static void vsc330x_init_of(struct i2c_client *client)
			    dev_dbg(&client->dev,"page=0x%02x, reg=0x%02x, data=0x%02x, mask=0x%02x \n",
			    dev_dbg(&client->dev,"page=0x%02x, reg=0x%02x, data=0x%02x, mask=0x%02x \n",
			    		(int)setup_data.page, (int)setup_data.reg,(int)setup_data.data,(int)setup_data.mask);
			    		(int)setup_data.page, (int)setup_data.reg,(int)setup_data.data,(int)setup_data.mask);
			    if (((rc=write_page_with_mask(client, (setup_data.page==0xff)?-1:setup_data.page, setup_data.reg,
			    if (((rc=write_page_with_mask(client, (setup_data.page==0xff)?-1:setup_data.page, setup_data.reg,
			    		setup_data.data, setup_data.mask)))<0) return rc;
			    		setup_data.data, setup_data.mask)))<0) return;
			}
			}
		} else {
		} else {
			dev_info(&client->dev,"'vsc330x,configuration_data' not found\n");
			dev_info(&client->dev,"'vsc330x,configuration_data' not found\n");