kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* drivers: iio: dummy: Unable to add channels to simple_dummy_channel
@ 2019-01-23 17:55 Bharath Vedartham
  2019-01-23 18:57 ` valdis.kletnieks
  2019-01-24 11:05 ` Himanshu Jha
  0 siblings, 2 replies; 3+ messages in thread
From: Bharath Vedartham @ 2019-01-23 17:55 UTC (permalink / raw)
  To: himanshujha199640; +Cc: kernelnewbies

I am trying to add the 3-axis compass data channels to the
simple_dummy_channel. I have mounted configfs and am able to load the
modules correctly. Is this the right approach? printk is not printing
anything to syslogs.

This is part of the iio_tasks in (I have finished the first 2 tasks):

https://kernelnewbies.org/IIO_tasks

output of lsmod | grep dummy:

iio_dummy              20480  2
iio_dummy_evgen        16384  1 iio_dummy

output of ls /sys/bus/iio/devices/iio:device0/:

buffer                     in_sampling_frequency
in_voltage-voltage_scale
current_timestamp_clock    in_steps_calibheight      name
dev                        in_steps_en               out_voltage0_raw
events                     in_steps_input            power
in_accel_x_calibbias       in_voltage0_offset        scan_elements
in_accel_x_calibscale      in_voltage0_raw           subsystem
in_accel_x_raw             in_voltage0_scale         trigger
in_activity_running_input  in_voltage1-voltage2_raw  uevent
in_activity_walking_input  in_voltage3-voltage4_raw

I have also put the diff.Added channel to iio_dummy_channels and added
element to enum simple_dummy_scan_elements.

Thank you,
Bharath

---
 drivers/iio/dummy/iio_simple_dummy.c | 43 ++++++++++++++++++++++++++++++++++++
 drivers/iio/dummy/iio_simple_dummy.h |  3 +++
 2 files changed, 46 insertions(+)

diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c
index 6205247..306e0cd 100644
--- a/drivers/iio/dummy/iio_simple_dummy.c
+++ b/drivers/iio/dummy/iio_simple_dummy.c
@@ -268,6 +268,48 @@ static const struct iio_chan_spec iio_dummy_channels[] = {
 		.num_event_specs = 1,
 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
 	},
+	{
+		.type = IIO_MAGN,
+		.modified = 1,
+		.channel2 = IIO_MOD_X,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = DUMMY_INDEX_MAGNX,
+		.scan_type = {
+			.sign = 'u',
+			.realbits = 16,
+			.storagebits = 16,
+			.shift = 0,
+		},
+	},
+	{
+		.type = IIO_MAGN,
+		.modified = 1,
+		.channel2 = IIO_MOD_Y,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = DUMMY_INDEX_MAGNY,
+		.scan_type = {
+			.sign = 'u',
+			.realbits= 16,
+			.storagebits  = 16,
+			.shift = 0,
+		},
+	},
+	{
+		.type = IIO_MAGN,
+		.modified = 1,
+		.channel2 = IIO_MOD_Z,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = DUMMY_INDEX_MAGNZ,
+		.scan_type = {
+			.sign = 'u',
+			.realbits = 16,
+			.storagebits = 16,
+			.shift = 0,
+		},
+	},
 };
 
 /**
@@ -621,6 +663,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)
 	/* Provide description of available channels */
 	indio_dev->channels = iio_dummy_channels;
 	indio_dev->num_channels = ARRAY_SIZE(iio_dummy_channels);
+	printk(KERN_DEBUG "No of channels are %d\n",indio_dev -> num_channels);
 
 	/*
 	 * Provide device type specific interface functions and
diff --git a/drivers/iio/dummy/iio_simple_dummy.h b/drivers/iio/dummy/iio_simple_dummy.h
index f7005c3..be6eff0 100644
--- a/drivers/iio/dummy/iio_simple_dummy.h
+++ b/drivers/iio/dummy/iio_simple_dummy.h
@@ -110,6 +110,9 @@ enum iio_simple_dummy_scan_elements {
 	DUMMY_INDEX_DIFFVOLTAGE_1M2,
 	DUMMY_INDEX_DIFFVOLTAGE_3M4,
 	DUMMY_INDEX_ACCELX,
+	DUMMY_INDEX_MAGNX,
+	DUMMY_INDEX_MAGNY,
+	DUMMY_INDEX_MAGNZ,
 };
 
 #ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
-- 
2.7.4


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: drivers: iio: dummy: Unable to add channels to simple_dummy_channel
  2019-01-23 17:55 drivers: iio: dummy: Unable to add channels to simple_dummy_channel Bharath Vedartham
@ 2019-01-23 18:57 ` valdis.kletnieks
  2019-01-24 11:05 ` Himanshu Jha
  1 sibling, 0 replies; 3+ messages in thread
From: valdis.kletnieks @ 2019-01-23 18:57 UTC (permalink / raw)
  To: Bharath Vedartham; +Cc: himanshujha199640, kernelnewbies

On Wed, 23 Jan 2019 23:25:59 +0530, Bharath Vedartham said:
> I am trying to add the 3-axis compass data channels to the
> simple_dummy_channel. I have mounted configfs and am able to load the
> modules correctly. Is this the right approach? printk is not printing
> anything to syslogs.

Do you have some printk's in your probing/open routines that show that you
in fact properly found and acquired the compass hardware? Remember that
the mere fact that a module will modprobe does not mean it's correct. Bonus
points if you have the stuff in place for udev or whatever to autoload your
driver, that's an additional indication you're on the right track.

If I wanted to, I could built the driver for a 622mbit/sec ATM connection, even
though I haven't seen one of those in a *long* time. They were only ever in
wide use in long-haul networking, as it was at the time the sort of thing that
major providers used for their core backbones, sold as an OC12, and evaporated
when gigabit interfaces became cheap enough for large corporations). I've seen
ATM cards for desktop PCs, but never for a laptop.

But if I built it, it would modprobe.

For the curious: (Prices were for the days when these things were still common)

T-1 - 1.544 megabits per second (24 DS0 lines) Ave. cost $250.-$500./mo.
T-3 - 43.232 megabits per second (28 T-1s) Ave. cost $4,000.-$16,000./mo.
OC-3 - 155 megabits per second (100 T-1s) Ave. cost $20,000.-$45,000./mo.
OC-12 - 622 megabits per second (4 OC3s) no estimated price available
OC-48 - 2.5 gigabits per seconds (4 OC12s) no estimated price available
OC-192 - 9.6 gigabits per second (4 OC48s)

(A DS0 was 64 kilobits per second, and the digitized form of 1 regular phone line. It's
no accident that in modem days, 56K was the highest download speed)

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: drivers: iio: dummy: Unable to add channels to simple_dummy_channel
  2019-01-23 17:55 drivers: iio: dummy: Unable to add channels to simple_dummy_channel Bharath Vedartham
  2019-01-23 18:57 ` valdis.kletnieks
@ 2019-01-24 11:05 ` Himanshu Jha
  1 sibling, 0 replies; 3+ messages in thread
From: Himanshu Jha @ 2019-01-24 11:05 UTC (permalink / raw)
  To: Bharath Vedartham; +Cc: kernelnewbies

On Wed, Jan 23, 2019 at 11:25:59PM +0530, Bharath Vedartham wrote:
> I am trying to add the 3-axis compass data channels to the
> simple_dummy_channel. I have mounted configfs and am able to load the
> modules correctly. Is this the right approach? printk is not printing
> anything to syslogs.
> 
> This is part of the iio_tasks in (I have finished the first 2 tasks):
> 
> https://kernelnewbies.org/IIO_tasks
> 
> output of lsmod | grep dummy:
> 
> iio_dummy              20480  2
> iio_dummy_evgen        16384  1 iio_dummy
> 
> output of ls /sys/bus/iio/devices/iio:device0/:
> 
> buffer                     in_sampling_frequency
> in_voltage-voltage_scale
> current_timestamp_clock    in_steps_calibheight      name
> dev                        in_steps_en               out_voltage0_raw
> events                     in_steps_input            power
> in_accel_x_calibbias       in_voltage0_offset        scan_elements
> in_accel_x_calibscale      in_voltage0_raw           subsystem
> in_accel_x_raw             in_voltage0_scale         trigger
> in_activity_running_input  in_voltage1-voltage2_raw  uevent
> in_activity_walking_input  in_voltage3-voltage4_raw
> 
> I have also put the diff.Added channel to iio_dummy_channels and added
> element to enum simple_dummy_scan_elements.
> 
> Thank you,
> Bharath
> 
> ---
>  drivers/iio/dummy/iio_simple_dummy.c | 43 ++++++++++++++++++++++++++++++++++++
>  drivers/iio/dummy/iio_simple_dummy.h |  3 +++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c
> index 6205247..306e0cd 100644
> --- a/drivers/iio/dummy/iio_simple_dummy.c
> +++ b/drivers/iio/dummy/iio_simple_dummy.c
> @@ -268,6 +268,48 @@ static const struct iio_chan_spec iio_dummy_channels[] = {
>  		.num_event_specs = 1,
>  #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
>  	},
> +	{
> +		.type = IIO_MAGN,
> +		.modified = 1,
> +		.channel2 = IIO_MOD_X,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = DUMMY_INDEX_MAGNX,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits = 16,
> +			.storagebits = 16,
> +			.shift = 0,
> +		},
> +	},
> +	{
> +		.type = IIO_MAGN,
> +		.modified = 1,
> +		.channel2 = IIO_MOD_Y,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = DUMMY_INDEX_MAGNY,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits= 16,
> +			.storagebits  = 16,
> +			.shift = 0,
> +		},
> +	},
> +	{
> +		.type = IIO_MAGN,
> +		.modified = 1,
> +		.channel2 = IIO_MOD_Z,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = DUMMY_INDEX_MAGNZ,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits = 16,
> +			.storagebits = 16,
> +			.shift = 0,
> +		},
> +	},
>  };
>  
>  /**
> @@ -621,6 +663,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)
>  	/* Provide description of available channels */
>  	indio_dev->channels = iio_dummy_channels;
>  	indio_dev->num_channels = ARRAY_SIZE(iio_dummy_channels);
> +	printk(KERN_DEBUG "No of channels are %d\n",indio_dev -> num_channels);
>  
>  	/*
>  	 * Provide device type specific interface functions and
> diff --git a/drivers/iio/dummy/iio_simple_dummy.h b/drivers/iio/dummy/iio_simple_dummy.h
> index f7005c3..be6eff0 100644
> --- a/drivers/iio/dummy/iio_simple_dummy.h
> +++ b/drivers/iio/dummy/iio_simple_dummy.h
> @@ -110,6 +110,9 @@ enum iio_simple_dummy_scan_elements {
>  	DUMMY_INDEX_DIFFVOLTAGE_1M2,
>  	DUMMY_INDEX_DIFFVOLTAGE_3M4,
>  	DUMMY_INDEX_ACCELX,
> +	DUMMY_INDEX_MAGNX,
> +	DUMMY_INDEX_MAGNY,
> +	DUMMY_INDEX_MAGNZ,
>  };

This looks good.

But think about what would happen if you read one of those attributes ?

Like if you do:

# cat in_accel_x_raw
34

(Looking at hardcoded value in the dummy source)
st->accel_val = 34;


-- 
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-24 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23 17:55 drivers: iio: dummy: Unable to add channels to simple_dummy_channel Bharath Vedartham
2019-01-23 18:57 ` valdis.kletnieks
2019-01-24 11:05 ` Himanshu Jha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).