On Fri, Dec 12, 2014 at 12:09:55AM +0100, Xabier Oneca -- xOneca wrote: > Hello, > 2014-12-11 23:41 GMT+01:00 tito <farmat...@tiscali.it>: > > On Thursday 11 December 2014 21:50:56 walter harms wrote: > >> > >> Am 11.12.2014 16:36, schrieb Bartosz Golaszewski: > [...] > >> > +/* Opens the device file associated with given i2c bus. */ > >> > +static int i2c_dev_open(int i2cbus) > >> > +{ > >> > + char filename[32]; > >> > + int fd; > >> > + > >> > + snprintf(filename, sizeof(filename), "/dev/i2c-%d", i2cbus); > >> > + fd = open_or_warn(filename, O_RDWR); > >> > >> now user of "/dev/i2c/%d" get warning here even when the next open works. > >> I do not think that this was you intention. > >> > >> /* having one open is more easy :) */ > >> > >> just my 2 cents, > >> wh > > > > Hi, > > I think that this is better than having an error message like this: > > > > f (fd < 0) > > bb_perror_msg_and_die("Could not open file: /dev/i2c-%d or > > /dev/i2c/%d", i2cbus, i2cbus); > > > > and not knowing exactly which device you was not able to open. > > > > Ciao, > > Tito > > > >> > + if (fd < 0 && errno == ENOENT) { > >> > + snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); > >> > + fd = xopen(filename, O_RDWR); > >> > + } > [...] > > If you mistype 'i2cbus' parameter in the command line, you will have > both a warning and an error opening two devices, which can be > misleading. > > Why would you even try to open the old-style device in a new kernel, > or a new-style dev in an old one? I think this can be avoided with the > usual '#if LINUX_VERSION ...', be it with preprocessor instructions, > or with a plain 'if ... else' statement.
This is the wrong way, IMHO. It means that you *cannot* compile busybox with i2ctools that work on pre-2.6.14(?) kernels, unless you build it using 2.6.14 or older headers; and in that case, you must recompile busybox if you upgrade the kernel. It would be tolerable if it were right at the 2.4/2.6 cutoff, but it isn't. Also, someone could configure a newer kernel to use the same layout for /dev as an older kernel in at least two ways: -if they use a static /dev -if they configure the hotplug helper to use the old layout (for example, for backwards compatability). In mdev, that might look like this: i2c-([0-9]*) root:i2c 0660 =i2c/%1 I would support checking both paths. Thanks, Isaac Dunham _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox