Skip to contentSkip to conversation

drivers: iio: dummy: Unable to add channels to simple_dummy_channel

PATCH Bharath Vedartham 3 participants 3 messages Jan 23, 2019 – Jan 24, 2019 IIO

lore
Share & tools
lore
#0 lore raw

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(+)
drivers/iio/dummy/iio_simple_dummy.c +43 -0
index 6205247..306e0cd 100644
@@ -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
drivers/iio/dummy/iio_simple_dummy.h +3 -0
index f7005c3..be6eff0 100644
@@ -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
Signature · 7 lines
2.7.4


_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
#1 lore raw
Quoted 4 lines · Bharath Vedartham

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
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#2 lore raw
In reply to Bharath Vedartham
Quoted 104 lines · Bharath Vedartham

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(+)
drivers/iio/dummy/iio_simple_dummy.c +43 -0
index 6205247..306e0cd 100644
@@ -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
drivers/iio/dummy/iio_simple_dummy.h +0 -0
index f7005c3..be6eff0 100644

drivers/iio/dummy/iio_simple_dummy.h enum iio_simple_dummy_scan_elements { · line 116

Quoted 7 lines
drivers/iio/dummy/iio_simple_dummy.h +3 -0
@@ -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;

Signature · 9 lines
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies